Updated for latest Boost Move Hub firmware
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing

This commit is contained in:
Nathan Kellenicki 2019-08-02 21:11:31 -07:00
parent ac4bcbaca0
commit 7b61b6981a
3 changed files with 14 additions and 5 deletions

View File

@ -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",

View File

@ -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.`);
}
}
}

View File

@ -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]));
}
});