Skip to content

Instantly share code, notes, and snippets.

@ElectricImpSampleCode
Last active March 25, 2019 12:58
Show Gist options
  • Save ElectricImpSampleCode/17a66dcfd981a3f18964 to your computer and use it in GitHub Desktop.
Save ElectricImpSampleCode/17a66dcfd981a3f18964 to your computer and use it in GitHub Desktop.
This code snippet shows how you might set a device to boot (warm or cold) into an offline state.
// Set the reconnection policy as early as possible in the code
server.setsendtimeoutpolicy(RETURN_ON_ERROR, WAIT_TIL_SENT, 30.0);
// Disable the BlinkUp LED (enforced 60s after boot)
imp.enableblinkup(false);
local willNeedBlinkupFlag = false;
local netData = imp.net.info();
if ("active" in netData) {
local interface = netData.interface[netData.active];
if (interface.ssid == "") {
// imp-enabled device is not configured for WiFi, so it can’t currently connect.
// Record the fact there is no configuration in case we need to know later
willNeedBlinkupFlag = true;
} else {
// imp-enabled device is configured for WiFi, so manually disconnect
// when the device and impOS go idle
imp.onidle(function() {
server.flush(10);
server.disconnect();
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment