diff --git a/docs/BoostMoveHub.html b/docs/BoostMoveHub.html
index 41c0681..ee94b67 100644
--- a/docs/BoostMoveHub.html
+++ b/docs/BoostMoveHub.html
@@ -2627,7 +2627,7 @@
@@ -2846,7 +2846,7 @@
@@ -3753,7 +3753,7 @@
@@ -3874,7 +3874,7 @@
@@ -4875,7 +4875,7 @@
@@ -5222,7 +5222,7 @@
@@ -5393,7 +5393,7 @@
@@ -5588,7 +5588,7 @@
@@ -5911,7 +5911,7 @@
@@ -6082,7 +6082,7 @@
@@ -6253,7 +6253,7 @@
@@ -6424,7 +6424,7 @@
@@ -6643,7 +6643,7 @@
diff --git a/docs/ControlPlusHub.html b/docs/ControlPlusHub.html
index b725c88..1d34ac4 100644
--- a/docs/ControlPlusHub.html
+++ b/docs/ControlPlusHub.html
@@ -2627,7 +2627,7 @@
@@ -2846,7 +2846,7 @@
@@ -3753,7 +3753,7 @@
@@ -3874,7 +3874,7 @@
@@ -4875,7 +4875,7 @@
@@ -5222,7 +5222,7 @@
@@ -5393,7 +5393,7 @@
@@ -5588,7 +5588,7 @@
@@ -5911,7 +5911,7 @@
@@ -6082,7 +6082,7 @@
@@ -6253,7 +6253,7 @@
@@ -6424,7 +6424,7 @@
@@ -6643,7 +6643,7 @@
diff --git a/docs/DuploTrainBase.html b/docs/DuploTrainBase.html
index d1d7652..454c3d9 100644
--- a/docs/DuploTrainBase.html
+++ b/docs/DuploTrainBase.html
@@ -1257,7 +1257,7 @@
@@ -1965,7 +1965,7 @@
@@ -2199,7 +2199,7 @@
@@ -2264,7 +2264,7 @@
-
Set the color of the LED on the train via a color value.
+
Set the color of the LED on the Hub via a color value.
@@ -2334,12 +2334,16 @@
+ Inherited From:
+
+
+
+
-
- Overrides:
-
@@ -2365,8 +2369,8 @@
@@ -2585,7 +2589,7 @@
@@ -2826,7 +2830,7 @@
@@ -2997,7 +3001,7 @@
@@ -3118,7 +3122,7 @@
@@ -4119,7 +4123,7 @@
@@ -4466,7 +4470,7 @@
@@ -4637,7 +4641,7 @@
@@ -4832,7 +4836,7 @@
@@ -5155,7 +5159,7 @@
@@ -5326,7 +5330,7 @@
@@ -5497,7 +5501,7 @@
@@ -5668,7 +5672,7 @@
@@ -5887,7 +5891,7 @@
diff --git a/docs/LPF2Hub.html b/docs/LPF2Hub.html
index f14e092..1b17856 100644
--- a/docs/LPF2Hub.html
+++ b/docs/LPF2Hub.html
@@ -1747,7 +1747,7 @@
@@ -1957,7 +1957,7 @@
@@ -2119,7 +2119,7 @@
@@ -2231,7 +2231,7 @@
@@ -3203,7 +3203,7 @@
@@ -3536,7 +3536,7 @@
@@ -3698,7 +3698,7 @@
@@ -3884,7 +3884,7 @@
@@ -4193,7 +4193,7 @@
@@ -4355,7 +4355,7 @@
@@ -4517,7 +4517,7 @@
@@ -4679,7 +4679,7 @@
@@ -4889,7 +4889,7 @@
diff --git a/docs/PUPHub.html b/docs/PUPHub.html
index 7cb19ee..70f2ad9 100644
--- a/docs/PUPHub.html
+++ b/docs/PUPHub.html
@@ -2627,7 +2627,7 @@
@@ -2846,7 +2846,7 @@
@@ -3753,7 +3753,7 @@
@@ -3874,7 +3874,7 @@
@@ -4875,7 +4875,7 @@
@@ -5222,7 +5222,7 @@
@@ -5393,7 +5393,7 @@
@@ -5588,7 +5588,7 @@
@@ -5911,7 +5911,7 @@
@@ -6082,7 +6082,7 @@
@@ -6253,7 +6253,7 @@
@@ -6424,7 +6424,7 @@
@@ -6643,7 +6643,7 @@
diff --git a/docs/PUPRemote.html b/docs/PUPRemote.html
index 6c93385..f2a52b5 100644
--- a/docs/PUPRemote.html
+++ b/docs/PUPRemote.html
@@ -1706,7 +1706,7 @@
-
Set the color of the LED on the Remote via a color value.
+
Set the color of the LED on the Hub via a color value.
@@ -1776,12 +1776,16 @@
+ Inherited From:
+
+
+
+
-
- Overrides:
-
@@ -1807,8 +1811,8 @@
@@ -1991,12 +1995,16 @@
+ Inherited From:
+
+
+
+
-
- Overrides:
-
@@ -2022,8 +2030,8 @@
@@ -2194,7 +2202,7 @@
@@ -2315,7 +2323,7 @@
@@ -3316,7 +3324,7 @@
@@ -3663,7 +3671,7 @@
@@ -3834,7 +3842,7 @@
@@ -4029,7 +4037,7 @@
@@ -4352,7 +4360,7 @@
@@ -4523,7 +4531,7 @@
@@ -4694,7 +4702,7 @@
@@ -4865,7 +4873,7 @@
@@ -5084,7 +5092,7 @@
diff --git a/docs/WeDo2SmartHub.html b/docs/WeDo2SmartHub.html
index 8a75840..6584d0f 100644
--- a/docs/WeDo2SmartHub.html
+++ b/docs/WeDo2SmartHub.html
@@ -4388,7 +4388,7 @@
@@ -4550,7 +4550,7 @@
@@ -4859,7 +4859,7 @@
@@ -5021,7 +5021,7 @@
@@ -5207,7 +5207,7 @@
diff --git a/docs/boostmovehub.js.html b/docs/boostmovehub.js.html
index 53cc6e8..601f8b5 100644
--- a/docs/boostmovehub.js.html
+++ b/docs/boostmovehub.js.html
@@ -370,7 +370,7 @@ class BoostMoveHub extends lpf2hub_1.LPF2Hub {
});
}
_checkFirmware(version) {
- if (compare_versions_1.default("2.0.00.0023", version) === 1) {
+ if (compare_versions_1.default("2.0.00.0017", 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/docs/classes.list.html b/docs/classes.list.html
index efdcec9..0de84f9 100644
--- a/docs/classes.list.html
+++ b/docs/classes.list.html
@@ -381,7 +381,7 @@
@@ -728,7 +728,7 @@
@@ -899,7 +899,7 @@
@@ -1094,7 +1094,7 @@
@@ -1417,7 +1417,7 @@
@@ -1588,7 +1588,7 @@
@@ -1759,7 +1759,7 @@
@@ -1930,7 +1930,7 @@
@@ -2149,7 +2149,7 @@
@@ -2368,7 +2368,7 @@
@@ -2715,7 +2715,7 @@
@@ -2886,7 +2886,7 @@
@@ -3081,7 +3081,7 @@
@@ -3404,7 +3404,7 @@
@@ -3575,7 +3575,7 @@
@@ -3746,7 +3746,7 @@
@@ -3917,7 +3917,7 @@
@@ -4136,7 +4136,7 @@
@@ -4355,7 +4355,7 @@
@@ -4702,7 +4702,7 @@
@@ -4873,7 +4873,7 @@
@@ -5068,7 +5068,7 @@
@@ -5391,7 +5391,7 @@
@@ -5562,7 +5562,7 @@
@@ -5733,7 +5733,7 @@
@@ -5904,7 +5904,7 @@
@@ -6123,7 +6123,7 @@
@@ -6633,7 +6633,7 @@
@@ -6966,7 +6966,7 @@
@@ -7128,7 +7128,7 @@
@@ -7314,7 +7314,7 @@
@@ -7623,7 +7623,7 @@
@@ -7785,7 +7785,7 @@
@@ -7947,7 +7947,7 @@
@@ -8109,7 +8109,7 @@
@@ -8319,7 +8319,7 @@
@@ -8691,7 +8691,7 @@
@@ -9038,7 +9038,7 @@
@@ -9209,7 +9209,7 @@
@@ -9404,7 +9404,7 @@
@@ -9727,7 +9727,7 @@
@@ -9898,7 +9898,7 @@
@@ -10069,7 +10069,7 @@
@@ -10240,7 +10240,7 @@
@@ -10459,7 +10459,7 @@
@@ -10678,7 +10678,7 @@
@@ -11025,7 +11025,7 @@
@@ -11196,7 +11196,7 @@
@@ -11391,7 +11391,7 @@
@@ -11714,7 +11714,7 @@
@@ -11885,7 +11885,7 @@
@@ -12056,7 +12056,7 @@
@@ -12227,7 +12227,7 @@
@@ -12446,7 +12446,7 @@
@@ -12779,7 +12779,7 @@
@@ -12941,7 +12941,7 @@
@@ -13250,7 +13250,7 @@
@@ -13412,7 +13412,7 @@
@@ -13598,7 +13598,7 @@
diff --git a/docs/duplotrainbase.js.html b/docs/duplotrainbase.js.html
index 1598cb2..713a929 100644
--- a/docs/duplotrainbase.js.html
+++ b/docs/duplotrainbase.js.html
@@ -105,16 +105,9 @@ const debug = Debug("duplotrainbase");
* @extends Hub
*/
class DuploTrainBase extends lpf2hub_1.LPF2Hub {
- static IsDuploTrainBase(peripheral) {
- return (peripheral.advertisement &&
- peripheral.advertisement.serviceUuids &&
- peripheral.advertisement.serviceUuids.indexOf(Consts.BLEService.LPF2_HUB.replace(/-/g, "")) >= 0 &&
- peripheral.advertisement.manufacturerData &&
- peripheral.advertisement.manufacturerData.length > 3 &&
- peripheral.advertisement.manufacturerData[3] === Consts.BLEManufacturerData.DUPLO_TRAIN_HUB_ID);
- }
constructor(device, autoSubscribe = true) {
super(device, autoSubscribe);
+ this._ledPort = 0x11;
this.type = Consts.HubType.DUPLO_TRAIN_HUB;
this._ports = {
"MOTOR": new port_1.Port("MOTOR", 0),
@@ -123,6 +116,14 @@ class DuploTrainBase extends lpf2hub_1.LPF2Hub {
};
debug("Discovered Duplo Train Base");
}
+ static IsDuploTrainBase(peripheral) {
+ return (peripheral.advertisement &&
+ peripheral.advertisement.serviceUuids &&
+ peripheral.advertisement.serviceUuids.indexOf(Consts.BLEService.LPF2_HUB.replace(/-/g, "")) >= 0 &&
+ peripheral.advertisement.manufacturerData &&
+ peripheral.advertisement.manufacturerData.length > 3 &&
+ peripheral.advertisement.manufacturerData[3] === Consts.BLEManufacturerData.DUPLO_TRAIN_HUB_ID);
+ }
connect() {
return new Promise(async (resolve, reject) => {
debug("Connecting to Duplo Train Base");
@@ -131,22 +132,6 @@ class DuploTrainBase extends lpf2hub_1.LPF2Hub {
return resolve();
});
}
- /**
- * Set the color of the LED on the train via a color value.
- * @method DuploTrainBase#setLEDColor
- * @param {Color} color
- * @returns {Promise} Resolved upon successful issuance of command.
- */
- setLEDColor(color) {
- return new Promise((resolve, reject) => {
- if (typeof color === "boolean") {
- color = 0;
- }
- const data = Buffer.from([0x81, 0x11, 0x11, 0x51, 0x00, color]);
- this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, data);
- return resolve();
- });
- }
/**
* Set the motor speed on a given port.
* @method DuploTrainBase#setMotorSpeed
diff --git a/docs/hub.js.html b/docs/hub.js.html
index 3820eea..2246b96 100644
--- a/docs/hub.js.html
+++ b/docs/hub.js.html
@@ -110,7 +110,7 @@ class Hub extends events_1.EventEmitter {
this._ports = {};
this._virtualPorts = {};
this._name = "";
- this._firmwareInfo = { major: 0, minor: 0, bugFix: 0, build: 0 };
+ this._firmwareVersion = "0.0.00.0000";
this._batteryLevel = 100;
this._voltage = 0;
this._current = 0;
@@ -135,7 +135,7 @@ class Hub extends events_1.EventEmitter {
* @property {string} firmwareVersion Firmware version of the hub
*/
get firmwareVersion() {
- return `${this._firmwareInfo.major}.${this._firmwareInfo.minor}.${this._lpad(this._firmwareInfo.bugFix.toString(), 2)}.${this._lpad(this._firmwareInfo.build.toString(), 4)}`;
+ return this._firmwareVersion;
}
/**
* @readonly
@@ -209,7 +209,7 @@ class Hub extends events_1.EventEmitter {
subscribe(port, mode) {
return new Promise((resolve, reject) => {
let newMode = this._getModeForDeviceType(this._portLookup(port).type);
- if (mode) {
+ if (mode !== undefined) {
newMode = mode;
}
this._activatePortDevice(this._portLookup(port).value, this._portLookup(port).type, newMode, 0x00, () => {
@@ -381,11 +381,13 @@ class Hub extends events_1.EventEmitter {
port.setEventTimer(interval);
return emitter;
}
- _portLookup(port) {
- if (!this._ports[port.toUpperCase()] && !this._virtualPorts[port.toUpperCase()]) {
- throw new Error(`Port ${port.toUpperCase()} does not exist on this Hub type`);
+ _portLookup(portName) {
+ const portNameUpper = portName.toUpperCase();
+ const port = this._ports[portNameUpper] || this._virtualPorts[portNameUpper];
+ if (!port) {
+ throw new Error(`Port ${portNameUpper} does not exist on this Hub type`);
}
- return this._ports[port] || this._virtualPorts[port];
+ return port;
}
_lpad(str, length) {
while (str.length < length) {
diff --git a/docs/index.html b/docs/index.html
index 6e9dd48..49ab709 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -206,7 +206,7 @@
No |
Yes |
Yes |
-42099 |
+42099 42100 |
Control+ XLarge Motor |
diff --git a/docs/lpf2hub.js.html b/docs/lpf2hub.js.html
index 1f31e12..c17408a 100644
--- a/docs/lpf2hub.js.html
+++ b/docs/lpf2hub.js.html
@@ -106,11 +106,16 @@ const modeInfoDebug = Debug("lpf2hubmodeinfo");
class LPF2Hub extends hub_1.Hub {
constructor() {
super(...arguments);
+ this._ledPort = 0x32;
this._lastTiltX = 0;
this._lastTiltY = 0;
this._lastTiltZ = 0;
this._messageBuffer = Buffer.alloc(0);
}
+ static decodeVersion(v) {
+ const t = v.toString(16).padStart(8, "0");
+ return [t[0], t[1], t.substring(2, 4), t.substring(4)].join(".");
+ }
connect() {
return new Promise(async (resolve, reject) => {
await super.connect();
@@ -171,12 +176,12 @@ class LPF2Hub extends hub_1.Hub {
*/
setLEDColor(color) {
return new Promise((resolve, reject) => {
- let data = Buffer.from([0x41, 0x32, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00]);
+ let data = Buffer.from([0x41, this._ledPort, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00]);
this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, data);
if (typeof color === "boolean") {
color = 0;
}
- data = Buffer.from([0x81, 0x32, 0x11, 0x51, 0x00, color]);
+ data = Buffer.from([0x81, this._ledPort, 0x11, 0x51, 0x00, color]);
this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, data);
return resolve();
});
@@ -191,9 +196,9 @@ class LPF2Hub extends hub_1.Hub {
*/
setLEDRGB(red, green, blue) {
return new Promise((resolve, reject) => {
- let data = Buffer.from([0x41, 0x32, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00]);
+ let data = Buffer.from([0x41, this._ledPort, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00]);
this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, data);
- data = Buffer.from([0x81, 0x32, 0x11, 0x51, 0x01, red, green, blue]);
+ data = Buffer.from([0x81, this._ledPort, 0x11, 0x51, 0x01, red, green, blue]);
this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, data);
return resolve();
});
@@ -297,12 +302,8 @@ class LPF2Hub extends hub_1.Hub {
// Firmware version
}
else if (data[3] === 0x03) {
- const build = data.readUInt16LE(5);
- const bugFix = data.readUInt8(7);
- const major = data.readUInt8(8) >>> 4;
- const minor = data.readUInt8(8) & 0xf;
- this._firmwareInfo = { major, minor, bugFix, build };
- this._checkFirmware(this.firmwareVersion);
+ this._firmwareVersion = LPF2Hub.decodeVersion(data.readInt32LE(5));
+ this._checkFirmware(this._firmwareVersion);
// Battery level reports
}
else if (data[3] === 0x06) {
@@ -522,8 +523,8 @@ class LPF2Hub extends hub_1.Hub {
break;
}
case Consts.DeviceType.WEDO2_TILT: {
- const tiltX = data[4] > 160 ? data[4] - 255 : data[4] - (data[4] * 2);
- const tiltY = data[5] > 160 ? 255 - data[5] : data[5] - (data[5] * 2);
+ const tiltX = data.readInt8(4);
+ const tiltY = data.readInt8(5);
this._lastTiltX = tiltX;
this._lastTiltY = tiltY;
/**
@@ -564,8 +565,8 @@ class LPF2Hub extends hub_1.Hub {
break;
}
case Consts.DeviceType.BOOST_TILT: {
- const tiltX = data[4] > 160 ? data[4] - 255 : data[4];
- const tiltY = data[5] > 160 ? 255 - data[5] : data[5] - (data[5] * 2);
+ const tiltX = data.readInt8(4);
+ const tiltY = data.readInt8(5);
this._lastTiltX = tiltX;
this._lastTiltY = tiltY;
this.emit("tilt", port.id, this._lastTiltX, this._lastTiltY, this._lastTiltZ);
diff --git a/docs/pupremote.js.html b/docs/pupremote.js.html
index cc56642..7cde181 100644
--- a/docs/pupremote.js.html
+++ b/docs/pupremote.js.html
@@ -105,6 +105,16 @@ const debug = Debug("pupremote");
* @extends Hub
*/
class PUPRemote extends lpf2hub_1.LPF2Hub {
+ constructor(device, autoSubscribe = true) {
+ super(device, autoSubscribe);
+ this._ledPort = 0x34;
+ this.type = Consts.HubType.POWERED_UP_REMOTE;
+ this._ports = {
+ "LEFT": new port_1.Port("LEFT", 0),
+ "RIGHT": new port_1.Port("RIGHT", 1)
+ };
+ debug("Discovered Powered UP Remote");
+ }
static IsPUPRemote(peripheral) {
return (peripheral.advertisement &&
peripheral.advertisement.serviceUuids &&
@@ -113,15 +123,6 @@ class PUPRemote extends lpf2hub_1.LPF2Hub {
peripheral.advertisement.manufacturerData.length > 3 &&
peripheral.advertisement.manufacturerData[3] === Consts.BLEManufacturerData.POWERED_UP_REMOTE_ID);
}
- constructor(device, autoSubscribe = true) {
- super(device, autoSubscribe);
- this.type = Consts.HubType.POWERED_UP_REMOTE;
- this._ports = {
- "LEFT": new port_1.Port("LEFT", 0),
- "RIGHT": new port_1.Port("RIGHT", 1)
- };
- debug("Discovered Powered UP Remote");
- }
connect() {
return new Promise(async (resolve, reject) => {
debug("Connecting to Powered UP Remote");
@@ -130,41 +131,6 @@ class PUPRemote extends lpf2hub_1.LPF2Hub {
return resolve();
});
}
- /**
- * Set the color of the LED on the Remote via a color value.
- * @method PUPRemote#setLEDColor
- * @param {Color} color
- * @returns {Promise} Resolved upon successful issuance of command.
- */
- setLEDColor(color) {
- return new Promise((resolve, reject) => {
- let data = Buffer.from([0x41, 0x34, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00]);
- this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, data);
- if (typeof color === "boolean") {
- color = 0;
- }
- data = Buffer.from([0x81, 0x34, 0x11, 0x51, 0x00, color]);
- this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, data);
- return resolve();
- });
- }
- /**
- * Set the color of the LED on the Hub via RGB values.
- * @method PUPRemote#setLEDRGB
- * @param {number} red
- * @param {number} green
- * @param {number} blue
- * @returns {Promise} Resolved upon successful issuance of command.
- */
- setLEDRGB(red, green, blue) {
- return new Promise((resolve, reject) => {
- let data = Buffer.from([0x41, 0x34, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00]);
- this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, data);
- data = Buffer.from([0x81, 0x34, 0x11, 0x51, 0x01, red, green, blue]);
- this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, data);
- return resolve();
- });
- }
}
exports.PUPRemote = PUPRemote;
//# sourceMappingURL=pupremote.js.map
diff --git a/docs/quicksearch.html b/docs/quicksearch.html
index 6e1a8d6..bb2130e 100644
--- a/docs/quicksearch.html
+++ b/docs/quicksearch.html
@@ -7,7 +7,7 @@