tango is a small, simple and customizable RPC (remote procedure call) module for Lua.
It now can be run on ESP MCU-based NodeMCU firmware (just server, no client). This opens opportunity to RPC from a PC to this MCU through the Wi-Fi networking.
- Prepare the NodeMCU
- Connect to Wi-Fi
- Launch server on the NodeMCU
- Test/run the client
Prepare the NodeMCU
First you need the Tango code on the MCU. The easiest way is to upload files to the SPIFFS, though options also available (the very good alternative would be to use LFS).
So first upload the essential files to SPIFFS, e.g using ESPlorer. The files are:
- (optional) test_server_nodemcu.lua
If files uploaded without path (config.lua, dispatcher.lua, ...) then rename them in-place:
- config.lua → tango/config.lua
- dispatcher.lua → tango/dispatcher.lua
- net.lua → tango/server/nodemcu/net.lua
- serialization.lua → tango/utils/serialization.lua
Connect to Wi-Fi
You can use whichever way you like. The goal is to have NodeMCU and your PC in one network so PC can connect to NodeMCU's TCP port.
Example script to run may be found here
Launch server on the NodeMCU
may be done with simple
The main core part of it is:
Test/run the client
If you have
busted framework you can run like this:
TANGO_SERVER=10.42.0.22 busted --tags=BasicTests --exclude-tags=io
Otherwise use the sample script:
TANGO_SERVER=10.42.0.22 lua5.1 test_client.lua copas_socket socket
The latter will fail on
io.popen because NodeMCU obviously missing that.
But before that you'll see several OK-s which is (generally) the success.