Skip to content

Instantly share code, notes, and snippets.

@electricimp
Last active December 19, 2015 00:29
Show Gist options
  • Save electricimp/5868873 to your computer and use it in GitHub Desktop.
Save electricimp/5868873 to your computer and use it in GitHub Desktop.
This code demonstrates the connection flow of an agent and its device: (1) device connected to agent, (2) device online, (3) device sleeps, (4) device disconnected from agent.
device.onconnect(function() {server.log("Device connected to agent");});
device.ondisconnect(function() {server.log("Device disconnected from agent");});
server.log("Device online");
imp.wakeup(5.0, function() {server.sleepfor(20.0);});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment