Last active
December 19, 2015 00:29
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
device.onconnect(function() {server.log("Device connected to agent");}); | |
device.ondisconnect(function() {server.log("Device disconnected from agent");}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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