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
/** | |
* Generic development-oriented crash report service | |
* | |
* @author Tony Smith (@smittytone) | |
* @licence MIT | |
* @version 1.0.0 | |
*/ | |
crashReporter <- { | |
/** |
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
const RETRY_TIME = 120; | |
const CONNECT_TIMEOUT = 30; | |
// Set the reconnection/error trigger policy (RETURN_ON_ERROR) early | |
server.setsendtimeoutpolicy(RETURN_ON_ERROR, WAIT_TIL_SENT, 10); | |
function connectHandler(reason) { | |
if (reason != SERVER_CONNECTED) { | |
// Queue up a reconnection attempt | |
imp.wakeup(RETRY_TIME, reconnect); |
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
// ------------------------------------------------------------------------------ | |
// File: factory.firmware.dut.agent.nut | |
// Version: 2.1.1 | |
// | |
// Copyright 2020 Twilio | |
// | |
// SPDX-License-Identifier: MIT | |
// | |
// Permission is hereby granted, free of charge, to any person obtaining a copy | |
// of this software and associated documentation files (the "Software"), to deal |
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
// VERSION 1.0.1 | |
function jsonencode(obj, opts = null, ins = 0) { | |
local cp = "compact" in opts ? opts.compact : false; | |
local es = cp ? "" : " "; | |
local sp = ""; | |
if (!cp && ins > 0) { | |
for (local i = 0 ; i < ins ; i++) sp += " "; | |
} | |
// Branch on type of object being processed | |
switch (typeof obj) { |
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
// MIT License | |
// Copyright 2018 Electric Imp | |
// | |
// SPDX-License-Identifier: MIT | |
// | |
// Permission is hereby granted, free of charge, to any person obtaining a copy | |
// of this software and associated documentation files (the "Software"), to deal | |
// in the Software without restriction, including without limitation the rights | |
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
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
// Zigbee Lamp Simulator - Gateway Agent Code | |
// Copyright Electric Imp, Inc. 2018 | |
// IMPORTS | |
#require "Rocky.class.nut:2.0.1" | |
// CONSTANTS | |
const HTML_STRING = @" | |
<!DOCTYPE html> | |
<html lang='en-US'> |
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
local debug = true; | |
local infoTable = {}; | |
local wifiData = imp.net.counters(); | |
if ("wwd_wifi" in wifiData) { | |
// Get the raw WiFi data from the WICED WiFi profile and use it | |
// to populate a Squirrel table of WiFi information | |
local dataBlob = wifiData.wwd_wifi; | |
infoTable.version <- dataBlob.readn('w'); | |
infoTable.length <- dataBlob.readn('w'); |
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
// To use a rescue pin, add the following function to your factory firmware | |
// and modify the pin and logic state as required | |
function setRescuePin() { | |
// Set up the rescue pin. We only need call this in our factory firmware | |
// if we are implementing a rescue pin, and this is why this function is | |
// not a part of our standard factory firmware example at | |
// https://developer.electricimp.com/examples/factoryfirmware | |
// Configure for impC001's pin G, set to go HIGH to trigger a rescue | |
imp.setrescuepin(hardware.pinG, 1); |
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
// Power Efficient Refrigerator Monitor Agent Code | |
// ------------------------------------------------------- | |
// CLOUD SERVICE LIBRARY | |
// ------------------------------------------------------- | |
// Libraries must be required before all other code | |
// Initial State Library | |
#require "InitialState.class.nut:1.0.0" | |
// Library to manage agent/device communication |
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
// Remote Monitoring Application With Interrupt Agent Code | |
// ------------------------------------------------------- | |
// CLOUD SERVICE LIBRARY | |
// ------------------------------------------------------- | |
// Libraries must be required before all other code | |
// Initial State Library | |
#require "InitialState.class.nut:1.0.0" | |
// Library to manage agent/device communication |