I've run into an issue using pybytes on my LoPy4 with Pysense shield.
I would like to get data from sensors, send them to Pybytes and go to deepsleep.
I do have sepadate funcions to get the data from sensors and to send the data.
Simplified code without any definitions and library imports:
sensorData = getSensorData() sendData(sensorData) py.setup_sleep(sleepTime) py.go_to_sleep()
The getSensorData() returns JSON dictionary with all the sensor data.
The sendData() looks like this:
def sendData(data): pybytes.send_signal(1, data['batt']) pybytes.send_signal(2, data['temp1']) pybytes.send_signal(3, data['press']) . .
(two dots represent more lines in the function, 9 values are being sent, wanted to save some space :) )
The problem is that calling sendData() jumps out immediately and the actual data sending process takes on later. From what I understand pybytes.send_signal() sets up a new thread with given arguments and is done.
So when I run the code, LoPy goes to deepsleep before it actually sends out any data to Pybytes.
Is there any flag or variable I could check to see if my Lopy board is still sending out the data and in that case wait before going to deepsleep??
sensorData = getSensorData() sendData(sensorData) while(True): if not "pybytes_still_sending_data": py.setup_sleep(sleepTime) py.go_to_sleep()
Possible workaround may be to put time.sleep() for like 20 sec before the deepsleep, but I would like to avoid this "solution".
Ill put this on the feature list!
I had like to know the answer to this too.
Would love to know this as well, or if there's any way to get confirmation that a message/signal was sent (with_ack)?