Imp in wake-up cycle seems to ignore device.send() from agent

How do I get the imp to handle events from the agent if it is in a shallow sleep (imp.wakeup) mode? It seems that the requests aren’t queued from the agent, so I might need to have some indication from the imp that it is awake and ready to receive “send” request. Am I missing something? Thanks.

There’s an onconnect() handler you can attach to on the agent, which will fire when the imp connects. You can then send your data.

Shallow sleep, or deep sleep? Imps should continue to receive messages during imp.wakeup (but not server.sleepfor/imp.deepsleepfor). Messages received during imp.sleep, if any, are queued.

Peter

Damn my late-night misreading. Peter is right. If the imp is in shallow sleep, and connected to the server, it’s ready to receive requests at any point.

There is still a slight timing issue right after the code is deployed. The agent sends the message quickly and since the device is still booting up, it misses it. So, in the code, I still have to put it in the .onconnect() block. This could be something like configuration, etc.

With that said, you guys are right in that it does receive messages during normal operation while in shallow sleep mode.