umqtt/usocket questions

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
skimj
Posts: 3
Joined: Thu Mar 09, 2017 5:25 am

umqtt/usocket questions

Post by skimj » Thu Mar 09, 2017 5:49 am

I'm using version 1.8.7 on an ESP8266 board. I have a couple of questions about umqtt and usocket:

1. Would it be safe to use umqtt.simple.ping() in a timer callback? The umqtt ping function is simply `self.sock.write(b"\xc0\0")` so I think my root question is: does usocket.write allocate any memory?

2. Does umqtt.simple.check_msg() send any data over the network? The key bit of code is in the umqtt.simple.wait_msg() function: `msg = self.sock.read(sz)`. I have a very simple task loop that checks a sensor and checks for MQTT messages. I don't want to flood my wifi network with an infinite loop of "query" type messages, so I can put a sleep statement in the task loop if necessary but if `self.sock.read(sz)` is "read-only", I'll just let it go as fast as possible.

Post Reply