Skip to content

How to add your own module

yichone edited this page Nov 30, 2016 · 6 revisions

To add your own module is easy. Just follow the steps below:

  • Add the module source code to the path: LuaNode_Esp32/components/modules

  • If you add a module, say my_module, and your code named my_module.c, then you should register your module. Use the macro named LUANODE_MODULE to register your module.

    // The registration macro // The first parameter MY_MODULE is a string to be used for registration. Use your module name. // The second parameter is the module name to be required in lua, you invoke the methods in your module by using this name. // The third parameter is a key-value map for your module methods and their names. // The last parameter is a init function, which will be called when module initialize. Usually, you can set it for NULL. LUANODE_MODULE(MY_MODULE, "my_module", my_module_map, NULL);

Clone this wiki locally