Add MQTT control #1
16
mqtt-test.js
Normal file
16
mqtt-test.js
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
const mqtt = require('mqtt')
|
||||||
|
const client = mqtt.connect('mqtt://mqtt.srv.jnf.me', {
|
||||||
|
clientId: 'pictureframe_' + Math.random().toString(16).substr(2, 8),
|
||||||
|
username: 'pictureframe',
|
||||||
|
password: 'pictureframe'
|
||||||
|
})
|
||||||
|
|
||||||
|
client.on('connect', () => {
|
||||||
|
client.subscribe('pictureframe/#', (err) => {
|
||||||
|
if (err) console.log(err)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
client.on('message', (topic, message) => {
|
||||||
|
console.log(topic + ' : ' + message.toString())
|
||||||
|
})
|
||||||
Reference in New Issue
Block a user