Skip to content

Instantly share code, notes, and snippets.

#require "rocky.class.nut:1.2.2"
#require "Twitter.class.nut:1.2.0"
const API_KEY = "";
const API_SECRET = "";
const AUTH_TOKEN = "";
const TOKEN_SECRET = "";
html <- @"
<!DOCTYPE html>
@betzrhodes
betzrhodes / NoraExample.agent.nut
Last active September 29, 2015 22:10
Basic Nora Example
#require "Firebase.class.nut:1.0.0"
///////// Application Code ///////////
// VARIABLES
agentID <- split(http.agenturl(), "/").pop();
// INITIALIZE CLASS
@betzrhodes
betzrhodes / LICENSE
Last active October 14, 2015 23:02
Nora Basic Example
The MIT License (MIT)
Copyright (c) 2015 Electric Imp
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
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@betzrhodes
betzrhodes / wakeup_bindenv_example.nut
Created February 16, 2016 00:19
Electric Imp imp.wakeup/bindenv example
local global_this = this;
class Test {
var1 = null;
var2 = null;
timer = null;
test_this = null;
constructor(one, two) {
@betzrhodes
betzrhodes / W5500.class.nut
Created October 27, 2016 00:18
Wiznet with PHY getter and setter
// CONTROL PHASE
// --------------------------------------------------
// BLOCK SELECT BITS
const W5500_COMMON_REGISTER = 0x00;
const W5500_S0_REGISTER = 0x08;
const W5500_S0_TX_BUFFER = 0x10;
const W5500_S0_RX_BUFFER = 0x18;
function update() {
server.log("in update")
}
// When the device reconnects, send it power and a holding pattern.
device.on("status", function (status) {
device.send("setPower", 100);
device.send("setSpeed", 4);
if (status == "boot") {
device.send("pushQueue", {"message": "26.35"});
// The MCP2515 has three transmit and two receive
// buffers, two acceptance masks (one for each receive
// buffer) and a total of six acceptance filters. Figure 1-3
// shows a block diagram of these buffers and their
// connection to the protocol engine.
// TX Buffer addresses
const MCP2515_TX_BUFF_0_CTRL_REG = 0x30;
const MCP2515_TX_BUFF_1_CTRL_REG = 0x40;
const MCP2515_TX_BUFF_2_CTRL_REG = 0x50;
@betzrhodes
betzrhodes / imp004-device.device.nut
Created February 20, 2019 17:25
iBeacon Bi-Directional
// iBeacon Bi-Directional Device Application
// Map hardware pins to global variables
BLE_REG_ON <- hardware.pinJ;
BLE_LPO <- hardware.pinE;
BLE_UART_TX <- hardware.pinF;
BLE_UART_RX <- hardware.pinG;
BLE_UART <- hardware.uartFGJH;
// BLE FIRMWARE
@betzrhodes
betzrhodes / agent.nut
Created July 31, 2019 19:34
Ping Time Example
server.log("AGENT RUNNING...");
// Setup listener for device side ping
device.on("dPing", function(pingStart) {
// Send pong back to device with the starting timestamp
device.send("dPong", pingStart);
})
device.on("aPong", function(pingStart) {
local now = date();
@betzrhodes
betzrhodes / CM_Ext_ShowConnReason_WithMessageManager_v3.device.nut
Last active October 11, 2019 16:21
Connection Manager extension that bubbles server.connect connection reason up to connection handlers
#require "ConnectionManager.lib.nut:3.1.1"
#require "MessageManager.lib.nut:2.4.0"
class MyConnectionManager extends ConnectionManager {
// Attempts to connect. If the server is already connected, or the
// connection attempt was successful, run the onConnect handler, and
// any other onConnected tasks
function connect() {