var request = require('request');
// Check Meshblu status
request('http://meshblu.octoblu.com/status', function (error, response, body) {
if (!error && response.statusCode == 200) {
console.log(body) // Print Meshblu status.
}
})
// Subscribe to UUID
// curl -X GET http://meshblu.octoblu.com/subscribe/0d3a53a0-2a0b-11e3-b09c-ff4de847b2cc?token=qirqglm6yb1vpldixflopnux4phtcsor
console.log('Subscribing to UUID: 0d3a53a0-2a0b-11e3-b09c-ff4de847b2cc')
request.get('http://meshblu.octoblu.com/subscribe/0d3a53a0-2a0b-11e3-b09c-ff4de847b2cc',
{qs: {'token': 'qirqglm6yb1vpldixflopnux4phtcsor'}}
, function (error, response, body) {
if (!error && response.statusCode == 200) {
console.log(body) // Print device activity.
}
})
// Send message
// curl -X POST -d '{"devices": "0d3a53a0-2a0b-11e3-b09c-ff4de847b2cc", "payload": {"yellow":"off"}}' http://meshblu.octoblu.com/messages
setTimeout(function(){
request.post('http://meshblu.octoblu.com/messages',
{form: {'devices':'0d3a53a0-2a0b-11e3-b09c-ff4de847b2cc', 'payload': 'test'}}
, function (error, response, body) {
if(response.statusCode == 200){
console.log(body);
}
});
},1000);