Agent timer / wakeup function

There does not seem to be a way to set a timer to get the Agent to do something after a specific set of time, similar to a imp.wakeup(). For example, if I want the agent to periodically send an http.post to a host, I have to rely on the imp to trigger the agent via an agent.send(). The design of the agent is such that it only responds to incoming requests via an HTTP or a device.on(). The issue with this is that if the imp is hosed, the agent has no way of knowing that anything is wrong. I unplugged an imp from a socket and the Planner console eventually stated that the imp was offline, but the agent did not get a device.ondisconnect(). In this case, I have no way of checking periodically if the imp went on vacation and is no longer responding.

imp.wakeup() works on the agent too?

Why of course :slight_smile: So, I created a simple test to see what objects/methods are available on the Agent - bet you already knew this:

imp.wakeup(); // Yes imp.sleep(); // Yes server.log( imp.getmacaddress()); // No server.log( imp.getmacaddress()); // No server.log( imp.getbssid()); // No server.log( imp.getmemoryfree()); // No server.log( imp.getpowersave()); // No server.log( imp.rssi()); // No server.log(hardware.*); // No to entire object server.log(server.permanent.AnswertotheUltimateQuestion); // No server.setpermanentvalues({AnswertotheUltimateQuestion = 42}); // No

Why am I doing this? I need to userstand what is available if the imp goes offline - power outage, gets unplugged,etc. It does appear that the Agent, once instantiated, remains alive and can receive/reply http requests even though the imp is down. This makes sense as the agent code is in the cloud. However, once the agent goes down (by trying to load new software) the only way to get communication back is to wait for the imp to come back online - an understandable design restriction.
The odd thing, as far as I can tell, is that the Agent does not have access to server.permanent values. It would be nice for server.permanent values to be available to share between the Agent and imp.

OK, we could totally document that better. The devwiki attempts to make clear when entire objects (hardware, http) are available on only one out of the agent and the imp, but you’re dead right it isn’t so helpful when there’s an object (server, imp) only some of whose methods are available on the agent.

Peter

Thanks Peter,
No complaints, just posting observations to help others save a bit of time during the learning process.