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: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)
@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
<!-- 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: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
@celliott
celliott / gist:8ab5fc3c8bc6826122fa
Created November 7, 2014 22:40
wot connection bipio
// 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)
@celliott
celliott / gist:41f3c40b71f6ef95a13d
Created November 7, 2014 22:53
wotio_connection apstrata
// 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
@celliott
celliott / gist:ae40090218b4d0ab384c
Last active August 29, 2015 14:09
bll_software_button
<container id="labeledButton" left="100" right="100" top="180" height="40" like="BUTTONS.LabeledButton">
<behavior like="BUTTONS.LabeledButtonBehavior">
<method id="onTap" params="container, message"><![CDATA[
// If the button is less than 1, then set it to 0. Othewise set it to 1
button = button < 0.9 ? 1 : 0;
// We use the global wot variable to send a message to wot.io with timestamp
wot.send([ "button", button, new Date.now() ]);
]]></method>
</behavior>
</container>
@celliott
celliott / gist:361bb7a2208e1fbecec9
Last active August 29, 2015 14:09
bll_simulator_wotio_connection
// 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 = 'APSTRATA_API_KEY';
apstrata_secret = 'APSTRATA_SECRET';
wot_username = 'WOTIO_USERNAME';
wot_token = 'WOTIO_TOKEN';
@celliott
celliott / gist:4d43ebe01ac6adb1e3c0
Created November 17, 2014 18:00
apstrata_device_id_and_token
// 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 = 'APSTRATA_DEVICE_ID';
apstrata_token = 'APSTRATA_DEVICE_TOKEN';
try
[ method, args... ] = JSON.parse message.data.toString()
catch e
console.log "not json #{message.data}"
# attempt to pass the data to a wildcard handler so we can interpret
$["*"].apply $, [ message.data ] if message.data?
return