From 4f3f12131933eca6d593756b686e0a8c480f1ae8 Mon Sep 17 00:00:00 2001 From: Nathan Kunicki Date: Tue, 31 Jul 2018 22:10:18 +0100 Subject: [PATCH] More reliable motor command for PUP hub --- lpf2hub.ts | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/lpf2hub.ts b/lpf2hub.ts index ece9eb1..a6efb6e 100644 --- a/lpf2hub.ts +++ b/lpf2hub.ts @@ -133,25 +133,16 @@ export class LPF2Hub extends Hub { return resolve(); }; } else { - let data = Buffer.from([0x08, 0x00, 0x81, portObj.value, 0x11, 0x51, 0x00, this._mapSpeed(speed)]); - if (this.type === Consts.Hubs.POWERED_UP_HUB && portObj.type === Consts.Devices.BOOST_INTERACTIVE_MOTOR) { - data = Buffer.from([0x07, 0x00, 0x81, portObj.value, 0x11, 0x02, this._mapSpeed(speed)]); - } + const data = Buffer.from([0x0a, 0x00, 0x81, portObj.value, 0x11, 0x60, 0x00, this._mapSpeed(speed), 0x00, 0x00]); this._writeMessage(Consts.BLECharacteristics.BOOST_ALL, data); setTimeout(() => { - let data = Buffer.from([0x08, 0x00, 0x81, portObj.value, 0x11, 0x51, 0x00, 0x00]); - if (this.type === Consts.Hubs.POWERED_UP_HUB && portObj.type === Consts.Devices.BOOST_INTERACTIVE_MOTOR) { - data = Buffer.from([0x07, 0x00, 0x81, portObj.value, 0x11, 0x02, 0x00]); - } + const data = Buffer.from([0x0a, 0x00, 0x81, portObj.value, 0x11, 0x60, 0x00, 0x00, 0x00, 0x00]); this._writeMessage(Consts.BLECharacteristics.BOOST_ALL, data); return resolve(); }, time); } } else { - let data = Buffer.from([0x08, 0x00, 0x81, portObj.value, 0x11, 0x51, 0x00, this._mapSpeed(speed)]); - if (this.type === Consts.Hubs.POWERED_UP_HUB && portObj.type === Consts.Devices.BOOST_INTERACTIVE_MOTOR) { - data = Buffer.from([0x07, 0x00, 0x81, portObj.value, 0x11, 0x02, this._mapSpeed(speed)]); - } + const data = Buffer.from([0x0a, 0x00, 0x81, portObj.value, 0x11, 0x60, 0x00, this._mapSpeed(speed), 0x00, 0x00]); this._writeMessage(Consts.BLECharacteristics.BOOST_ALL, data); return resolve(); }