From 2e6d2b0dbc117c03379cf429feb100d3c6adabb4 Mon Sep 17 00:00:00 2001 From: Nathan Kellenicki Date: Mon, 15 Apr 2019 10:46:32 -0700 Subject: [PATCH] Library will now throw error if your firmware is too old --- .gitignore | 1 + docs/BoostMoveHub.html | 14 +++++------ docs/DuploTrainBase.html | 6 ++--- docs/Hub.html | 2 +- docs/LPF2Hub.html | 16 ++++++------- docs/PUPHub.html | 24 +++++++++---------- docs/PUPRemote.html | 6 ++--- docs/PoweredUP.html | 2 +- docs/WeDo2SmartHub.html | 2 +- docs/boostmovehub.js.html | 2 +- docs/classes.list.html | 46 ++++++++++++++++++------------------- docs/consts.js.html | 2 +- docs/duplotrainbase.js.html | 2 +- docs/global.html | 2 +- docs/hub.js.html | 2 +- docs/index.html | 2 +- docs/lpf2hub.js.html | 6 ++++- docs/poweredup-node.js.html | 2 +- docs/puphub.js.html | 11 ++++++++- docs/pupremote.js.html | 2 +- docs/quicksearch.html | 2 +- docs/wedo2smarthub.js.html | 2 +- package-lock.json | 7 +++++- package.json | 3 ++- src/lpf2hub.ts | 6 +++++ src/puphub.ts | 8 +++++++ 26 files changed, 107 insertions(+), 73 deletions(-) diff --git a/.gitignore b/.gitignore index 1dd31ce..27243c4 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ node_modules/ dist/ .vscode/ *.tgz +**/.DS_store diff --git a/docs/BoostMoveHub.html b/docs/BoostMoveHub.html index 68c1f89..a67cae6 100644 --- a/docs/BoostMoveHub.html +++ b/docs/BoostMoveHub.html @@ -4451,7 +4451,7 @@ @@ -4622,7 +4622,7 @@ @@ -4817,7 +4817,7 @@ @@ -5140,7 +5140,7 @@ @@ -5311,7 +5311,7 @@ @@ -5506,7 +5506,7 @@ @@ -5585,7 +5585,7 @@ Documentation generated by JSDoc 3.5.5 - on Fri Apr 12th 2019 + on Mon Apr 15th 2019 using the DocStrap template. diff --git a/docs/DuploTrainBase.html b/docs/DuploTrainBase.html index 64ce479..b701d61 100644 --- a/docs/DuploTrainBase.html +++ b/docs/DuploTrainBase.html @@ -3938,7 +3938,7 @@ @@ -4109,7 +4109,7 @@ @@ -4188,7 +4188,7 @@ Documentation generated by JSDoc 3.5.5 - on Fri Apr 12th 2019 + on Mon Apr 15th 2019 using the DocStrap template. diff --git a/docs/Hub.html b/docs/Hub.html index 8040247..48b0589 100644 --- a/docs/Hub.html +++ b/docs/Hub.html @@ -2467,7 +2467,7 @@ Documentation generated by JSDoc 3.5.5 - on Fri Apr 12th 2019 + on Mon Apr 15th 2019 using the DocStrap template. diff --git a/docs/LPF2Hub.html b/docs/LPF2Hub.html index 8dd4c88..610406c 100644 --- a/docs/LPF2Hub.html +++ b/docs/LPF2Hub.html @@ -3198,7 +3198,7 @@ @@ -3360,7 +3360,7 @@ @@ -3546,7 +3546,7 @@ @@ -3855,7 +3855,7 @@ @@ -4017,7 +4017,7 @@ @@ -4179,7 +4179,7 @@ @@ -4365,7 +4365,7 @@ @@ -4444,7 +4444,7 @@ Documentation generated by JSDoc 3.5.5 - on Fri Apr 12th 2019 + on Mon Apr 15th 2019 using the DocStrap template. diff --git a/docs/PUPHub.html b/docs/PUPHub.html index 5f65006..a58c98f 100644 --- a/docs/PUPHub.html +++ b/docs/PUPHub.html @@ -153,7 +153,7 @@ @@ -1124,7 +1124,7 @@ @@ -1904,7 +1904,7 @@ @@ -2532,7 +2532,7 @@ @@ -2789,7 +2789,7 @@ @@ -3030,7 +3030,7 @@ @@ -4451,7 +4451,7 @@ @@ -4622,7 +4622,7 @@ @@ -4817,7 +4817,7 @@ @@ -5140,7 +5140,7 @@ @@ -5335,7 +5335,7 @@ @@ -5414,7 +5414,7 @@ Documentation generated by JSDoc 3.5.5 - on Fri Apr 12th 2019 + on Mon Apr 15th 2019 using the DocStrap template. diff --git a/docs/PUPRemote.html b/docs/PUPRemote.html index 187331b..c724efe 100644 --- a/docs/PUPRemote.html +++ b/docs/PUPRemote.html @@ -3135,7 +3135,7 @@ @@ -3330,7 +3330,7 @@ @@ -3409,7 +3409,7 @@ Documentation generated by JSDoc 3.5.5 - on Fri Apr 12th 2019 + on Mon Apr 15th 2019 using the DocStrap template. diff --git a/docs/PoweredUP.html b/docs/PoweredUP.html index 380e51d..41a2c81 100644 --- a/docs/PoweredUP.html +++ b/docs/PoweredUP.html @@ -1018,7 +1018,7 @@ Documentation generated by JSDoc 3.5.5 - on Fri Apr 12th 2019 + on Mon Apr 15th 2019 using the DocStrap template. diff --git a/docs/WeDo2SmartHub.html b/docs/WeDo2SmartHub.html index efd9814..7c6787c 100644 --- a/docs/WeDo2SmartHub.html +++ b/docs/WeDo2SmartHub.html @@ -5158,7 +5158,7 @@ Documentation generated by JSDoc 3.5.5 - on Fri Apr 12th 2019 + on Mon Apr 15th 2019 using the DocStrap template. diff --git a/docs/boostmovehub.js.html b/docs/boostmovehub.js.html index bb7191e..22e24c9 100644 --- a/docs/boostmovehub.js.html +++ b/docs/boostmovehub.js.html @@ -353,7 +353,7 @@ exports.BoostMoveHub = BoostMoveHub; Documentation generated by JSDoc 3.5.5 - on Fri Apr 12th 2019 + on Mon Apr 15th 2019 using the DocStrap template. diff --git a/docs/classes.list.html b/docs/classes.list.html index a7a5945..20b02bd 100644 --- a/docs/classes.list.html +++ b/docs/classes.list.html @@ -506,7 +506,7 @@ @@ -677,7 +677,7 @@ @@ -872,7 +872,7 @@ @@ -1195,7 +1195,7 @@ @@ -1366,7 +1366,7 @@ @@ -1561,7 +1561,7 @@ @@ -1732,7 +1732,7 @@ @@ -1903,7 +1903,7 @@ @@ -2536,7 +2536,7 @@ @@ -2698,7 +2698,7 @@ @@ -2884,7 +2884,7 @@ @@ -3193,7 +3193,7 @@ @@ -3355,7 +3355,7 @@ @@ -3517,7 +3517,7 @@ @@ -3703,7 +3703,7 @@ @@ -4200,7 +4200,7 @@ @@ -4371,7 +4371,7 @@ @@ -4566,7 +4566,7 @@ @@ -4889,7 +4889,7 @@ @@ -5084,7 +5084,7 @@ @@ -5255,7 +5255,7 @@ @@ -5450,7 +5450,7 @@ @@ -6681,7 +6681,7 @@ Documentation generated by JSDoc 3.5.5 - on Fri Apr 12th 2019 + on Mon Apr 15th 2019 using the DocStrap template. diff --git a/docs/consts.js.html b/docs/consts.js.html index f53a582..ed67f39 100644 --- a/docs/consts.js.html +++ b/docs/consts.js.html @@ -300,7 +300,7 @@ var BLECharacteristic; Documentation generated by JSDoc 3.5.5 - on Fri Apr 12th 2019 + on Mon Apr 15th 2019 using the DocStrap template. diff --git a/docs/duplotrainbase.js.html b/docs/duplotrainbase.js.html index 4ea7e58..76ff21c 100644 --- a/docs/duplotrainbase.js.html +++ b/docs/duplotrainbase.js.html @@ -300,7 +300,7 @@ exports.DuploTrainBase = DuploTrainBase; Documentation generated by JSDoc 3.5.5 - on Fri Apr 12th 2019 + on Mon Apr 15th 2019 using the DocStrap template. diff --git a/docs/global.html b/docs/global.html index bf93547..b74c789 100644 --- a/docs/global.html +++ b/docs/global.html @@ -3272,7 +3272,7 @@ Documentation generated by JSDoc 3.5.5 - on Fri Apr 12th 2019 + on Mon Apr 15th 2019 using the DocStrap template. diff --git a/docs/hub.js.html b/docs/hub.js.html index 50eceea..0f3b72d 100644 --- a/docs/hub.js.html +++ b/docs/hub.js.html @@ -458,7 +458,7 @@ exports.Hub = Hub; Documentation generated by JSDoc 3.5.5 - on Fri Apr 12th 2019 + on Mon Apr 15th 2019 using the DocStrap template. diff --git a/docs/index.html b/docs/index.html index e229bfd..449439b 100644 --- a/docs/index.html +++ b/docs/index.html @@ -308,7 +308,7 @@ console.log("Scanning for Hubs...");

More examples are Documentation generated by JSDoc 3.5.5 - on Fri Apr 12th 2019 + on Mon Apr 15th 2019 using the DocStrap template. diff --git a/docs/lpf2hub.js.html b/docs/lpf2hub.js.html index 4d5c251..257c962 100644 --- a/docs/lpf2hub.js.html +++ b/docs/lpf2hub.js.html @@ -228,6 +228,9 @@ class LPF2Hub extends hub_1.Hub { }); } } + _checkFirmware(version) { + return; + } _parseMessage(data) { if (data) { this._messageBuffer = Buffer.concat([this._messageBuffer, data]); @@ -288,6 +291,7 @@ class LPF2Hub extends hub_1.Hub { const major = data.readUInt8(8) >>> 4; const minor = data.readUInt8(8) & 0xf; this._firmwareInfo = { major, minor, bugFix, build }; + this._checkFirmware(this.firmwareVersion); // Battery level reports } else if (data[3] === 0x06) { @@ -542,7 +546,7 @@ exports.LPF2Hub = LPF2Hub; Documentation generated by JSDoc 3.5.5 - on Fri Apr 12th 2019 + on Mon Apr 15th 2019 using the DocStrap template. diff --git a/docs/poweredup-node.js.html b/docs/poweredup-node.js.html index 7d7fe0b..72c800f 100644 --- a/docs/poweredup-node.js.html +++ b/docs/poweredup-node.js.html @@ -269,7 +269,7 @@ exports.PoweredUP = PoweredUP; Documentation generated by JSDoc 3.5.5 - on Fri Apr 12th 2019 + on Mon Apr 15th 2019 using the DocStrap template. diff --git a/docs/puphub.js.html b/docs/puphub.js.html index cc70831..9fded74 100644 --- a/docs/puphub.js.html +++ b/docs/puphub.js.html @@ -85,6 +85,9 @@

"use strict";
+var __importDefault = (this && this.__importDefault) || function (mod) {
+    return (mod && mod.__esModule) ? mod : { "default": mod };
+};
 var __importStar = (this && this.__importStar) || function (mod) {
     if (mod && mod.__esModule) return mod;
     var result = {};
@@ -93,6 +96,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
     return result;
 };
 Object.defineProperty(exports, "__esModule", { value: true });
+const compare_versions_1 = __importDefault(require("compare-versions"));
 const lpf2hub_1 = require("./lpf2hub");
 const port_1 = require("./port");
 const Consts = __importStar(require("./consts"));
@@ -307,6 +311,11 @@ class PUPHub extends lpf2hub_1.LPF2Hub {
             }
         });
     }
+    _checkFirmware(version) {
+        if (compare_versions_1.default("1.1.00.0004", version) === 1) {
+            throw new Error(`Your Powered Up Hub's (${this.name}) firmware is out of date and unsupported by this library. Please update it via the official Powered Up app.`);
+        }
+    }
 }
 exports.PUPHub = PUPHub;
 //# sourceMappingURL=puphub.js.map
@@ -354,7 +363,7 @@ exports.PUPHub = PUPHub; Documentation generated by JSDoc 3.5.5 - on Fri Apr 12th 2019 + on Mon Apr 15th 2019 using the DocStrap template. diff --git a/docs/pupremote.js.html b/docs/pupremote.js.html index 5847f3d..2c3b6cb 100644 --- a/docs/pupremote.js.html +++ b/docs/pupremote.js.html @@ -238,7 +238,7 @@ exports.PUPRemote = PUPRemote; Documentation generated by JSDoc 3.5.5 - on Fri Apr 12th 2019 + on Mon Apr 15th 2019 using the DocStrap template. diff --git a/docs/quicksearch.html b/docs/quicksearch.html index 3837f8e..9a063bb 100644 --- a/docs/quicksearch.html +++ b/docs/quicksearch.html @@ -7,7 +7,7 @@