Post your best Lua script examples here

User avatar
By Leo Villar
#11585 Hello thank you all for contributing without your help would not move so fast is controlling device and sorry for my english.

I have a problem no connectivity between the lua code MQTT and mosquitto running on ARM cpu such as RaspberryPI and BeagleBoard wit configuration default.
The same code has connection with my mosquitto linux running on Intel defaul setup or iot.eclipse.org.

I've tried everything , ports are open , for example I connect to the ARM Mosquitto from mqtt-spy and from mqtt.js perfectly.

Anyone have any idea why since Lua code MQTT not connected to Mosquitto running on ARM cpu ?
Thank You.
Leo.
User avatar
By Leo Villar
#11624
Leo Villar wrote:Hello thank you all for contributing without your help would not move so fast is controlling device and sorry for my english.

I have a problem no connectivity between the lua code MQTT and mosquitto running on ARM cpu such as RaspberryPI and BeagleBoard wit configuration default.
The same code has connection with my mosquitto linux running on Intel defaul setup or iot.eclipse.org.

I've tried everything , ports are open , for example I connect to the ARM Mosquitto from mqtt-spy and from mqtt.js perfectly.

Anyone have any idea why since Lua code MQTT not connected to Mosquitto running on ARM cpu ?
Thank You.
Leo.


Hello I could solve with this post http://www.esp8266.com/viewtopic.php?p=10845#p10845, had the ARM version of Mosquitto of date unsupported MQTT 3.1.1.
thx.
User avatar
By kefir135
#14852
sfinx wrote:
tuanpm wrote:
sfinx wrote:Any news on this publish queue? Or has anyone made a working queue implementation in lua?

Please try this: https://github.com/tuanpmt/lua-async ,
I've written this lib to make async process easier, now only waterfall function, you can publish another msg by callback after send msg.
Queue need a lot of RAM, not comfortable for LUA module

Thanks, I will have a look at that! I'm not sure however if this would solve the problem where 1 publish is triggered by a timer and another one by an interrupt..


Try a simple solution:
define a variable, make it true for the first time, then when you publish do it only IF variable is true.
Inside if, first set variable to false, then publish and make variable true in callback.
works like a charm.
it's not a queue, you drop messages when they are send at the same time, but you avoid LUA crashing...
Of course instead of dropping you can set a timer and check if variable is true, etc. You got the idea.
User avatar
By j0hncc
#15249
kefir135 wrote:Try a simple solution:
define a variable, make it true for the first time, then when you publish do it only IF variable is true.
Inside if, first set variable to false, then publish and make variable true in callback.
works like a charm.
it's not a queue, you drop messages when they are send at the same time, but you avoid LUA crashing...
Of course instead of dropping you can set a timer and check if variable is true, etc. You got the idea.


That wouldn't help would it-- for the case where the nodemcu received a message (from subscribed topic) while it was publishing another message? Or vice-versa??