-
-
Save toddtreece/feb66ddef602c8ec0c1e to your computer and use it in GitHub Desktop.
http://phantmqtt.sparkfun.com test client
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var mqtt = require('mqtt'), | |
client = mqtt.connect('mqtt://phantmqtt.sparkfun.com'), | |
pub = 'vGArXg1lPgi4yDPZElO1ilyrEeB', | |
prv = 'XpzBK84Xq8Fg3xrOa9NRIEPJ4DV'; | |
client.subscribe('response/' + pub + '/input'); // responses about input | |
client.subscribe('output/' + pub); // JSON encoded full payload | |
client.subscribe('output/' + pub + '/b'); // only subscribe to one field | |
// log everything to the terminal | |
client.on('message', function(topic, message) { | |
console.log('TOPIC: ' + topic, ' PAYLOAD: ' + message); | |
}); | |
// log data | |
client.publish('input/' + pub + '/' + prv, JSON.stringify({ | |
a: 1, | |
b: 'test' | |
})); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "mqtt-client-test", | |
"version": "0.0.0", | |
"description": "test client for phantmqtt.sparkfun.com", | |
"main": "client.js", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"author": "", | |
"license": "ISC", | |
"dependencies": { | |
"mqtt": "^0.3.11" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment