From 7913792a6a9c5b651e7caa79fe4f0610272e0f58 Mon Sep 17 00:00:00 2001 From: Martial Simon Date: Mon, 25 Mar 2024 13:10:02 +0200 Subject: feat: mqtt client --- robot.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'robot.js') diff --git a/robot.js b/robot.js index 5c259fe..f318441 100644 --- a/robot.js +++ b/robot.js @@ -1,5 +1,4 @@ -const mqtt = require("mqtt"); -const client = mqtt.connect("mqtt://marcelus.net"); +const client = mqtt.connect("ws://marcelus.net:9001"); function wait(ms) { @@ -47,18 +46,19 @@ async function moveTo(x,y) } -client.on('connect', function () { +client.on('connect', () => { + console.log(client) console.log('Connecté au courtier MQTT'); - client.subscribe('move'); - client.publish('move','ULT1') + client.subscribe('move') + moveTo(1000,1000) }); +// client.publish('move','ULT1') -client.on('message', function (topic, message) { +/* client.on('message', function (topic, message) { console.log('Received from ', topic, ' : ', message.toString()); -}); +}); */ -client.on('close', function () { +/* client.on('close', function () { console.log('Déconnecté du courtier MQTT'); -}); +});*/ -moveTo(1000,1000) \ No newline at end of file -- cgit v1.2.3