Interfacing Lua to Existing C/C++ Code
The following examples include C code that shows how to extend the Lua APIs provided by the server. The C code can be compiled from within this web page and is using the included TCC compiler on Windows and GCC on all other platforms.
A Lua binding is the interface between the Lua virtual machine and a native C function or a C++ method. It is the glue code that makes it possible to call C functions from within a Lua script. The idea is that you extend the Lua virtual machine to include your own (e.g.,device management) functions. Lua bindings can be designed manually or generated automatically. The following figure shows how Lua bindings can be generated automatically, where the generated Lua binding C code is compiled and linked with your firmware.
Install Required Modules
The Lua binding examples require the Mako Server module plugin and a compiler. Click the following button to install the required components.