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 Remote Monitoring Application 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
// Asynchronous Remote Monitoring Application 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
// Refrigerator Monitor Application 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
// Simple Remote Monitoring Application Agent Code | |
// --------------------------------------------------- | |
// CLOUD SERVICE LIBRARY | |
// --------------------------------------------------- | |
// Libraries must be required before all other code | |
// Initial State Library | |
#require "InitialState.class.nut:1.0.0" |
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
// Simple Refrigerator Monitor Application Agent Code | |
// --------------------------------------------------- | |
// CLOUD SERVICE LIBRARY | |
// --------------------------------------------------- | |
// Libraries must be required before all other code | |
// Initial State Library | |
#require "InitialState.class.nut:1.0.0" |
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
// Reading a Sensor Agent Code | |
// --------------------------------------------------- | |
// CLOUD SERVICE LIBRARY | |
// --------------------------------------------------- | |
// Libraries must be included before all other code | |
// Initial State Library | |
#require "InitialState.class.nut:1.0.0" |
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
// Copyright (c) 2018, Electric Imp, Inc. | |
// Licence: MIT | |
// IMPORTS | |
#require "rocky.class.nut:2.0.2" | |
// CONSTANTS | |
const DATA_PER_SECOND = 50.0; | |
const TWO_PI = 6.283185307179586; | |
const HTML_DATA = @" |
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
// CONSTANTS | |
// Full PKCS#8 key omitted but can be generated with: | |
// $ openssl req -x509 -nodes -newkey rsa:2048 -batch -keyout key.pem | |
const RSA_PRIVATE8_KEY_PEM = @" | |
-----BEGIN PRIVATE KEY----- | |
... | |
-----END PRIVATE KEY-----"; | |
function decodePrivatePem(pemString) { | |
local lines = split(pemString, "\n"); |
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
// Post-reconnection attempt handler | |
function reconnect(reason) { | |
if (reason != SERVER_CONNECTED) { | |
// Reconnection failed, so re-attempt in 1 minute | |
imp.wakeup(60, function() { | |
server.connect(reconnect, 30); | |
}); | |
} | |
} |
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.device.nut | |
// Version: 1.1.2 | |
// | |
// Copyright 2015-18 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 |