Skip to content

Instantly share code, notes, and snippets.

View amcjen's full-sized avatar

Allison Clift-Jennings amcjen

View GitHub Profile
static bool receiveSpecialMessage(NWK_DataInd_t *ind);
Scout.meshListen(2, receiveSpecialMessage);
static bool receiveSpecialMessage(NWK_DataInd_t *ind) {
Serial.print(F("Received message of "));
Serial.print(data);
Serial.print(F(" from "));
Serial.print(ind->srcAddr, DEC);
Serial.print(F(" lqi "));
/**
This is the Pinoccio Bootstrap sketch from https://github.com/Pinoccio/library-pinoccio
Modified by @JacobRosenthal to be a wrapper for the excellent TimerThree library
from PJRC so you'll need that: http://www.pjrc.com/teensy/td_libs_TimerOne.html
Follow the directions there, but basically after uploading this you'll still have
all your Scout and HQ functions but now you you can call the TimerThree functions
from scoutscript.
Note:
You can only use pins 3, 4 and 5
#include <Scout.h>
#include <SPI.h>
#include <Wire.h>
#include <Scout.h>
#include <GS.h>
#include <bitlash.h>
#include <lwm.h>
#include <js0n.h>
void setup() {
static numvar meshSetKey(void) {
if (!checkArgs(1, F("usage: mesh.setkey(\"key\")"))) {
return 0;
}
char key[16] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
strncpy(key, (const char*)getstringarg(1), 16);
key[strlen((const char*)getstringarg(1))] = 0xFF; // remove null termination char
Scout.meshSetSecurityKey((const uint8_t *)key);
return 1;
}
void WiFiBackpack::onAssociate(void *data) {
WiFiBackpack& wifi = *(WiFiBackpack*)data;
#ifdef USE_TLS
// Do a timesync
IPAddress ip = wifi.gs.dnsLookup(NTP_SERVER);
if (ip == INADDR_NONE ||
!wifi.gs.timeSync(ip, NTP_INTERVAL)) {
Serial.println("Time sync failed, reassociating to retry");
wifi.autoConnectHq();
> function foo {power.hibernate(5000, "uptime.report"); };
saved
> uptime.report
{"type":"uptime","millis":159890,"sleep":0,"random":-18558,"reset":"External"}
> foo
> {"type":"uptime","millis":161433,"sleep":5000,"random":-9528,"reset":"External"}
/**************************************************************************\
* Pinoccio Library *
* https://github.com/Pinoccio/library-pinoccio *
* Copyright (c) 2014, Pinoccio Inc. All rights reserved. *
* ------------------------------------------------------------------------ *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the MIT License as described in license.txt. *
\**************************************************************************/
#include <SPI.h>
#include <Wire.h>
/Volumes/Data/Users/eric/Documents/Arduino/libraries/pinoccio/src/SleepHandler.cpp: In static member function 'static void SleepHandler::doHibernate(uint32_t, bool)':
/Volumes/Data/Users/eric/Documents/Arduino/libraries/pinoccio/src/SleepHandler.cpp:137:45: error: 'RX0' was not declared in this scope
if (UCSR0B & (1 << TXEN0) && !digitalRead(RX0))
^
#include <SPI.h>
#include <Wire.h>
#include <Scout.h>
#include <GS.h>
#include <bitlash.h>
#include <lwm.h>
#include <js0n.h>
#include <Brain.h>
function startup { timer3.initialize(20000); };
function left { timer3.pwm(5, arg(1)); };
function center { timer3.pwm(4, arg(1)); };
function right { timer3.pwm(3, arg(1)); };
function centerleft { center(56) };
function centerright { center(68) };
function centercenter { center(62) };
function rightforward { right(72) };
function rightbackward { right(52) };
function rightcenter { right(64) };