joefly
April 25, 2015, 4:36pm
1
I am doing the spark core example of controlling the LED from the web using HTTP request http://docs.spark.io/examples/#control-leds-over-the-net .
I was able to get it to function properly using http://jflasher.github.io/spark-helper/
now I am trying to post the http request using a Pebble watch app. I can enter the URL of the POSTrequest, but I do not know how to form the required URL for turning on the LED in the example with the required parameters of “params=l1,HIGH”
I am new to this, so hoping someone can help me.
Thanks
you can look at this code we used during a Hackathon last year:
var DEVICE_ID = 'YOUR DEVICE ID HERE';
var ACCESS_TOKEN = 'YOUR ACCESS TOKEN HERE';
simply.on('singleClick', function(e) {
console.log(util2.format('single clicked $button!', e));
var mode = 1;
if ('up' == e.button) {
mode = 2;
simply.subtitle('RAINBOWS!');
} else {
simply.subtitle('FIRE!');
}
ajax(
{
url: 'https://api.spark.io/v1/devices/' + DEVICE_ID + '/params?access_token=' + ACCESS_TOKEN,
method: 'post',
type: 'json',
data: { m: 'mode=' + mode }
},
function(e){ console.log('ajax success: ' + e); },
This file has been truncated. show original
The data for yours should be something like:
data: { m: 'D7,HIGH' }
Of course the code doesn’t work for you out of the box and you will need to read it a little and extract what you need