You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Issue is that sometimes, the firmware will go to sleep before the tb.loop() transaction is completed.
We did a 1second vTaskDelay() to fix the issue, however, I would like to find a cleaner wait to ensure transaction is fully completed.
There is a way if you use the Espressif_MQTT_Client mqttClient;, according to the docs the publish method used by sendTelemetryData should be blocking by default.
Non-blocking mode can be enabled with set_enqueue_messages(true) on the mqttClient. But for your case this is perfect.
Additionaly if you use tb.loop() with the EspressifMQTTClient and ESP-IDF, the method does nothing at all. So they call is not even required, because the EspressifMQTTClient uses a seperate FreeRTOS task in the background that actually sends the data so no looping is needed.
So atleast from what is written in the docu the data should actually always be sent from the device, as long as you call the publish method which the code does per default. So the vTaskDelay should not be needed.
If that is not the case than there is another way that is more difficult. You could use QoS Level 1, meaning you receive a response if the message was received by the broker.
This response is then received by the device in the mqtt_event_handler method. Therefore you could add the MQTT_EVENT_PUBLISHED case to the method. And if that case is hit you can go into deep sleep.
You would need to adjust a little bit more in the EspressifMQTTClient to enable QoS support tough, so if the aforementioned easier way works that would probably be preferable.
Hi,
Working with esp-idf + freeRTOS, our firmware is:
Issue is that sometimes, the firmware will go to sleep before the tb.loop() transaction is completed.
We did a 1second vTaskDelay() to fix the issue, however, I would like to find a cleaner wait to ensure transaction is fully completed.
The text was updated successfully, but these errors were encountered: