As the title says... Chat on...

User avatar
By biobier
#10734
MikeV wrote:I've eventually got MQTT to work on this build, but it's taken a long time! To figure out why it wasn't working I created a state machine so I could monitor each step. The main issue seemed to be the m:publish function which can't be recalled until it's completed its work. I've now trimmed it back and the code to the minimum that works for me. It seems to survive temporarily stopping the broker and the wifi node. "init.lua" contains just dofile("MQTT.lc") after compiling with node.compile("MQTT.lua"). Remaining HEAP is 11912 - so not much left to play with!


Try to make some variables local it will speed things up as I learned.
User avatar
By m-cin
#10763
MikeV wrote:The main issue seemed to be the m:publish function which can't be recalled until it's completed its work.


Could anybody inlcude this info in NodeMCU API wiki? Every beginner stumbles over this little... peculiarity :)

There is even an open issue on this behaviour:

https://github.com/nodemcu/nodemcu-firmware/issues/146

None of the solutions proposed (lua_async and use of coroutine, as well as building all kind of queues) worked for me - not enough memory.

Next project - pure C :)

Regards
M.
User avatar
By biobier
#10773
m-cin wrote:
MikeV wrote:The main issue seemed to be the m:publish function which can't be recalled until it's completed its work.


Could anybody inlcude this info in NodeMCU API wiki? Every beginner stumbles over this little... peculiarity :)

There is even an open issue on this behaviour:

https://github.com/nodemcu/nodemcu-firmware/issues/146

None of the solutions proposed (lua_async and use of coroutine, as well as building all kind of queues) worked for me - not enough memory.

Next project - pure C :)

Regards
M.


Yes I had the same issue. Every effort to wait for complete the first sending ended in not enough memory.
compile the scripts helped a bit but not enough.

I'll go for C too now. Do you know a tutorial related to pure C coding with ESP8266? (Sorry for off topic)
User avatar
By m-cin
#10793
biobier wrote:I'll go for C too now. Do you know a tutorial related to pure C coding with ESP8266? (Sorry for off topic)


Not really. Reading others examples seems the only tutorial available :) There are some decent projects (Nokia display etc.) using MQTT library by Tuan. I'll start there.

(Same sorry for OT. It'll not happen again.)