From 7b61b6981a0b3a5f6ae8af8559e6560ac5962fc1 Mon Sep 17 00:00:00 2001 From: Nathan Kellenicki Date: Fri, 2 Aug 2019 21:11:31 -0700 Subject: [PATCH] Updated for latest Boost Move Hub firmware --- package.json | 2 +- src/boostmovehub.ts | 16 ++++++++++++---- src/lpf2hub.ts | 1 + 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 4dceee1..a45cbcb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "node-poweredup", - "version": "2.5.3", + "version": "2.6.0", "description": "A Javascript module to interface with LEGO Powered Up components.", "homepage": "https://github.com/nathankellenicki/node-poweredup/", "main": "dist/node/index-node.js", diff --git a/src/boostmovehub.ts b/src/boostmovehub.ts index 84f9a81..932f025 100644 --- a/src/boostmovehub.ts +++ b/src/boostmovehub.ts @@ -1,3 +1,4 @@ +import compareVersion from "compare-versions"; import { Peripheral } from "noble"; import { LPF2Hub } from "./lpf2hub"; @@ -38,11 +39,11 @@ export class BoostMoveHub extends LPF2Hub { super(device, autoSubscribe); this.type = Consts.HubType.BOOST_MOVE_HUB; this._ports = { - "A": new Port("A", 55), - "B": new Port("B", 56), + "A": new Port("A", 0), + "B": new Port("B", 1), "TILT": new Port("TILT", 58), - "C": new Port("C", 1), - "D": new Port("D", 2) + "C": new Port("C", 2), + "D": new Port("D", 3) }; this.on("attach", (port, type) => { this._combinePorts(port, type); @@ -236,4 +237,11 @@ export class BoostMoveHub extends LPF2Hub { } + protected _checkFirmware (version: string) { + if (compareVersion("2.0.00.0023", version) === 1) { + throw new Error(`Your Boost Move Hub's (${this.name}) firmware is out of date and unsupported by this library. Please update it via the official Powered Up app.`); + } + } + + } diff --git a/src/lpf2hub.ts b/src/lpf2hub.ts index dc16c07..e071c71 100644 --- a/src/lpf2hub.ts +++ b/src/lpf2hub.ts @@ -153,6 +153,7 @@ export class LPF2Hub extends Hub { if (portObj) { Object.keys(this._ports).forEach((id) => { if (this._ports[id].type === type && this._ports[id].value !== portObj.value && !this._virtualPorts[`${portObj.value < this._ports[id].value ? portObj.id : this._ports[id].id}${portObj.value > this._ports[id].value ? portObj.id : this._ports[id].id}`]) { + debug("Combining ports", portObj.value < this._ports[id].value ? portObj.id : id, portObj.value > this._ports[id].value ? portObj.id : id); this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, Buffer.from([0x61, 0x01, portObj.value < this._ports[id].value ? portObj.value : this._ports[id].value, portObj.value > this._ports[id].value ? portObj.value : this._ports[id].value])); } });