Agents, Imps and sleeping

If I use server.sleepfor(…) to send the Imp and server to sleep for a while by implementing it in the imp.onidle function, should the Imp wake up when I send data to my agent?

What I observe is that the call gets through to my agent, but never makes it to the device.
When the device wakes up, the corresponding agent.on(“blah”, function()) doesn’t get called either.

What is the expected behaviour please?

Toby

This is expected; server.sleepfor() is a total sleep, with wifi powered off. If you want to wait for an event, you need to stay awake - imp.setpowersave(true) does this, and though it’s ~5-7mA right now, will get lower over time.

OK, thanks for the clarification, this makes more sense now.
Is there any way for the agent to know whether the device is asleep or awake?

Toby

I’m not sure whether this got implemented yet on the server side (AgentGuide.pdf suggests not), but the idea is that the agent gets told when the imp comes and goes, and so can be written to keep hold of any important messages that occur when the imp is asleep, and relay them when it wakes up again.

Peter

Hi Peter,
Thanks for the update, that could certainly be useful for some things.

Toby