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 key omitted but can be generated with: | |
// $ openssl genrsa -out rsa.key 2048 | |
const RSA_PRIVATE_KEY_PEM = @" | |
-----BEGIN RSA PRIVATE KEY----- | |
... | |
-----END RSA PRIVATE KEY-----"; | |
// The public key must be extracted from the private key file: | |
// $ openssl rsa -pubout < rsa.key > rsa.pub |
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#1 key omitted but can be generated with: | |
// $ openssl genrsa -out rsa.key 2048 | |
const RSA_PRIVATE_KEY_PEM = @" | |
-----BEGIN RSA PRIVATE KEY----- | |
... | |
-----END RSA PRIVATE KEY----- | |
"; | |
function decodePrivatePem(pemString) { |
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.activation.agent.nut | |
// Version: 1.0.4 | |
// | |
// 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 |
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
// Set up the variables | |
local receiveBuffers = []; | |
local size = 0; | |
// Define the handler for storing audio from the device | |
device.on("store.audio.data", function(buffer) { | |
// Break the incoming data down into 1024-byte chunks | |
while (buffer.tell() < buffer.len()) { | |
local store = blob(); | |
local bytesleft = buffer.len() - buffer.tell(); |
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
// impMonitor AGENT CODE | |
// Copyright (c) 2018, Electric Imp, Inc. | |
// Writer: Tony Smith | |
// Licence: MIT | |
// Version: 1.1.1 | |
// IMPORTS | |
#require "Rocky.class.nut:2.0.2" | |
// If you are not using Squinter or an equivalent tool to combine multiple Squirrel files, | |
// you need to paste the contents of the accompanying files over the following four lines |
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 address = ""; | |
function checkIP() { | |
local connectionData = device.info(); | |
if (connectionData.isconnected) { | |
server.log(format("Device %s is connected", connectionData.id); | |
if (address.len() == 0) { | |
server.log(format("Device %s has connected with IP address %s", connectionData.id, connectionData.ipaddress)); | |
} else if (connectionData.ipaddress != address) |
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
// Just respond to 'ping' messages by immmediately | |
// sending back a 'pong' message to the device | |
device.on("ping", function(dummy) { | |
device.send("pong", true); | |
}); |
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
/** | |
* Boot-time device information functions | |
* | |
* Code which logs impOS and network information. It is intended to be included early in the runtime (hence the name). | |
* Includes functions and code to trigger those functions | |
* | |
* @author Tony Smith (@smittytone) | |
* @copyright Electric Imp, 2017-18 | |
* @licence MIT | |
* @version 2.2.2 |
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
dac <- hardware.fixedfrequencydac; | |
dac.configure(hardware.pwmpairKD, | |
mySampleRate, | |
myBufferArray, | |
myBufferFunction, | |
audioOptions); | |
dac.start(); |
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
// Set up a table of static calendar functions | |
utilities <- {}; | |
utilities.dayOfWeek <- function(d, m, y) { | |
local dim = [ | |
[31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31], | |
[31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] | |
]; | |
local ad = ((y - 1) * 365) + _totalLeapDays(y) + d - 5; |