From 70081a1829c11f439592bdff13a406de04e35715 Mon Sep 17 00:00:00 2001 From: Silver Kuusik Date: Wed, 12 Sep 2018 14:30:13 +0200 Subject: [PATCH] update websocket messages --- assets/js/sumorobot.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/assets/js/sumorobot.js b/assets/js/sumorobot.js index 5bbee19..e478b6b 100755 --- a/assets/js/sumorobot.js +++ b/assets/js/sumorobot.js @@ -38,8 +38,6 @@ Sumorobot.prototype.connect = function() { }, 3000); // When the WebSocket gets connected this.websocket.onopen = function(evt) { - // Send authentication packet - self.websocket.send(`{"setID": "browser-${self.robotId}@00000514", "passwd": "salakala"}`); // Setup a timer to ping the robot self.watchdogTimer = setInterval(function() { // Send a ping to the robot @@ -65,6 +63,7 @@ Sumorobot.prototype.connect = function() { self.sensors = JSON.parse(data); // When sensor data received if (self.sensors['battery_voltage']) { + console.log(self.sensors); if (self.sensors['battery_voltage'] > 4.0) { $("#battery img").attr("src", "assets/img/battery_full.png"); } else if (self.sensors['battery_voltage'] > 3.1) { @@ -93,9 +92,9 @@ Sumorobot.prototype.send = function(cmd, val) { // https://developer.mozilla.org/en-US/docs/Web/API/WebSocket if (!this.terminate && this.websocket.readyState == 1) { if (val) { - this.websocket.send(`{"to": "sumo-${this.robotId}@00000514", "cmd": "${cmd}", "val": "${val}"}`); + this.websocket.send(`{"cmd": "${cmd}", "val": "${val}"}`); } else { - this.websocket.send(`{"to": "sumo-${this.robotId}@00000514", "cmd": "${cmd}"}`); + this.websocket.send(`{"cmd": "${cmd}"}`); } } };