Query server to check if there are any messages waiting

Is there a synchronous device command to check if there are any messages waiting to be sent from agent to device?

My devices wakeup periodically for a short time, then go into deepsleep, and sometimes they're not processing messages from the server. I'm using WAIT_TIL_SENT. Running the deep sleep command inside imp.onidle() doesn't seem to do the trick. Is this because the device hasn't seen the server message in the short time it is connected, so the device thinks it is idle?

Comments

  • If your agent is poised to respond to a request from your device, you'll need to set up a timer on your device to wait for the response. Due to the vagaries of the Internet, this can sometimes take longer than normal, or not happen at all. If you don't get a response within the expected time, you have the choice of retrying immediately or going into deep sleep and trying later. No message is ever guaranteed to reach its destination.
  • We're looking into reports that onidle() doesn't appear be behaving correctly, but: messages are not buffered from agent to device. If the agent sends a message to the device and it is offline, the message is lost.

    A good way to do this is generally to send a message from device to agent when it comes online, then have the agent respond immediately with buffered messages, followed by an "ok to sleep" (or just "ok to sleep" if there are no messages to send).

    You can them implement a short timeout on the device side waiting for "ok to sleep" before giving up and sleeping anyway.
Sign In or Register to comment.