Restart an agent

Hi, I have the code working for my online counter (thanks to the hackathon) but now I have an issue when putting it all together.

Basically if I “build and run” the software it works great but if I power off my imp then power it back on, I need the Agent to restart to initialize everything.

Is there a way to restart the Agent if a power up is detected?

I want it so I can just plug in the counter and everything will work without having to manually restart the Agent.



You use the agent and device functions to send information back and forth between the two. You could put something like this in your device code:

agent.send(“reboot”, “”);

and then in the agent:

device.on(“reboot”, function(data) {
Note: If you don’t need to pass any data to the agent, then the second parameter isn’t needed, but you still need to pass an empty string, or something.