Skip to content

Instantly share code, notes, and snippets.

View celliott's full-sized avatar

chris elliott celliott

  • Chris Elliott
  • portland, or
View GitHub Profile
@celliott
celliott / gist:3bfb9eaa5424e78d367a
Last active August 29, 2015 14:08
button press handler
<!-- This handler is invoked each time that a button push is detected -->
<handler path="/buttonValue">
<behavior>
<method id="onInvoke" params="container, message"><![CDATA[
// only on a rising edge send a tweet
if (button == 0 && message.requestObject == 1) {
// This will send a tweet to our twitter account we registered with bip.io:
wot.send([ "twitter", { "title": "Tweeting from my Kinoma! on " + new Date()}])
}
// save the new value so we can compare with the next rise/fall state
<!-- This handler is invoked each time that a button push is detected -->
<handler path="/buttonValue">
<behavior>
<method id="onInvoke" params="container, message"><![CDATA[
// These values are the device id, and device token provisioned
// with the Apstrata device management api which you can discover
// in your Apstrata workbench.
apstrata_device_id = 'YOUR APSTRATA DEVICE ID'
apstrata_token = 'YOUR APSTRATA DEVICE TOKEN'
@celliott
celliott / gist:1e211695277fa97a08b5
Created October 28, 2014 21:01
message_handler
// Then connect to the echo service feed
wot.connect(function() {
// Upon connection to wot.io register a receive hook that will process each
// incoming message and dispatch data to the led
wot.receive(function(data) {
// if we received an empty message we will abort
if (! data) return;
// The message is and array of format: [ "pin", #, value ]
var value = data[2]
// When we receive a value from wot.io we turn on the led if it is greater than 0
@celliott
celliott / gist:cde6b6548090ba160578
Last active August 29, 2015 14:08
wotio_connection bll
// The following credentials are needed to register with the
// Apstrata device management service, and configure the wot.io
// connection associated with your device:
apstrata_api_key = 'PLEASE ENTER YOUR APSTRATA APP KEY/ID HERE'
apstrata_secret = 'PLEASE ENTER YOUR APSTRATA APP SECRETE HERE'
wot_username = 'PLEASE ENTER YOUR WOTIO USERNAME HERE'
wot_token = 'PLEASE ENTER YOUR WOTIO TOKEN HERE'
// instantiate a new Apstrata Device management platform interface
aps = new apstrata.Apstrata( apstrata_api_key, apstrata_secret, wot_username, wot_token, true)