-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature Request] Handle Light Sleep or Deep Sleep #75
Comments
Hi, could you explain the use case a bit more? If I understand correctly, the intent is to get the device to go into sleep between receiving MQTT messages? |
Actually, in my specific case is the device will have periods of activity where they're sending lots of sensor messages, and then variable periods of inactivity, where they're not taking any readings or sending anything. However the device needs to be able to wake up from an external gpio interrupt and resume taking readings and sending that data. If my device needs to receive any data I will schedule it to fetch it during periods of activity. I'm just looking for any guidance as to what tasks I should suspend and where would be the best place to call light sleep. In my case, deep sleep is probably out of the question as it would take too long to reboot, but light sleep with the modem off would be a reasonable compromise. |
For either sleep, you should not need to suspend any tasks. No tasks will run while the device is sleeping. |
For example, would MQTT keep alives be scheduled to be sent by the device if it enters light sleep? Or would I need to set up a wake timer? |
Hi @txf-, It depends on the definition of light sleep. As @archigup mentioned, if all tasks are suspended, no tasks will run. Referring to the example provided in this repository, a separate MQTT agent manager task handles all commands by calling MQTTAgent_CommandLoop. In that case, this task must be running to send the MQTT keep-alive ping message to the server when necessary. @archigup, Please correct me if I'm wrong. Thank you. |
Yes that is the kind of thing I'm mostly concerned about. Does automatic light sleep (the Freertos tickless idle) contemplate the scheduling necessary for the device to wake in time for the command loop to send these messages? |
The behavior may depend on the receive timeout setting, which is 1s by default. If the receive timeout is configured to be shorter than the keep-alive period, it could trigger the process to maintain the MQTT session active. |
Is your feature request related to an issue you've encountered? If so, please elaborate.
Given the fact that there are several tasks running in parallel it is hard to determine as to where one can put the device to sleep. Should each task be suspended one-by-one and then sleep should be handled in the MQTT process loop? presumably if one would like to opportunistically enter light sleep MQTT keep alives periods should be considered.
Describe the new feature request
In the example it would be nice to have a hint, or have special events to indicate when the best time would be to sleep, if desired. As there are a lot of abstractions away from a single loop, there could be a central way to trigger it, possibly in the agent?
The text was updated successfully, but these errors were encountered: