From 984ae5321361ab857f350c1b4237997b6cfae452 Mon Sep 17 00:00:00 2001 From: Nathan Kellenicki Date: Wed, 13 Nov 2019 16:19:24 -0800 Subject: [PATCH] Version 4.3.0 --- docs/BoostMoveHub.html | 342 ++++++++++++++++++++++++++++++++---- docs/ControlPlusHub.html | 342 ++++++++++++++++++++++++++++++++---- docs/DuploTrainBase.html | 336 +++++++++++++++++++++++++++++++---- docs/Hub.html | 274 +++++++++++++++++++++++++++-- docs/LPF2Hub.html | 320 +++++++++++++++++++++++++++++---- docs/PUPHub.html | 342 ++++++++++++++++++++++++++++++++---- docs/PUPRemote.html | 328 ++++++++++++++++++++++++++++++---- docs/PoweredUP.html | 164 ++++++++++++++++- docs/WeDo2SmartHub.html | 292 ++++++++++++++++++++++++++++-- docs/boostmovehub.js.html | 20 ++- docs/classes.list.html | 144 +++++++-------- docs/consts.js.html | 36 ++-- docs/controlplushub.js.html | 37 ++-- docs/duplotrainbase.js.html | 5 +- docs/global.html | 302 ++++++++++++++++++++++++++++++- docs/hub.js.html | 45 +++-- docs/index.html | 2 +- docs/lpf2hub.js.html | 174 ++++++++++-------- docs/poweredup-node.js.html | 11 +- docs/puphub.js.html | 20 ++- docs/pupremote.js.html | 5 +- docs/quicksearch.html | 2 +- docs/wedo2smarthub.js.html | 2 +- package-lock.json | 2 +- package.json | 2 +- 25 files changed, 3066 insertions(+), 483 deletions(-) diff --git a/docs/BoostMoveHub.html b/docs/BoostMoveHub.html index ee94b67..0e3c54a 100644 --- a/docs/BoostMoveHub.html +++ b/docs/BoostMoveHub.html @@ -327,7 +327,7 @@ @@ -460,7 +460,7 @@ @@ -593,7 +593,140 @@ + + + + + + + + + + + + + + + + +
+
+

<readonly> hardwareVersion

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
firmwareVersion + + +string + + + + +

Hardware version of the hub

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + +
Overrides:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+
@@ -726,7 +859,140 @@ +
+ + + + + + + + + + + + + + + +
+
+

<readonly> primaryMACAddress

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
primaryMACAddress + + +string + + + + +

Primary MAC address of the hub

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + +
Overrides:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+
@@ -859,7 +1125,7 @@
@@ -992,7 +1258,7 @@ @@ -1125,7 +1391,7 @@ @@ -1257,7 +1523,7 @@ @@ -1383,7 +1649,7 @@ @@ -1509,7 +1775,7 @@ @@ -1635,7 +1901,7 @@ @@ -1807,7 +2073,7 @@ @@ -2037,7 +2303,7 @@ @@ -2199,7 +2465,7 @@ @@ -2456,7 +2722,7 @@ @@ -2627,7 +2893,7 @@ @@ -2846,7 +3112,7 @@ @@ -3084,7 +3350,7 @@ @@ -3341,7 +3607,7 @@ @@ -3582,7 +3848,7 @@ @@ -3753,7 +4019,7 @@ @@ -3874,7 +4140,7 @@ @@ -4051,7 +4317,7 @@ @@ -4271,7 +4537,7 @@ @@ -4447,7 +4713,7 @@ @@ -4624,7 +4890,7 @@ @@ -4875,7 +5141,7 @@ @@ -5051,7 +5317,7 @@ @@ -5222,7 +5488,7 @@ @@ -5393,7 +5659,7 @@ @@ -5588,7 +5854,7 @@ @@ -5740,7 +6006,7 @@ @@ -5911,7 +6177,7 @@ @@ -6082,7 +6348,7 @@ @@ -6253,7 +6519,7 @@ @@ -6424,7 +6690,7 @@ @@ -6643,7 +6909,7 @@ @@ -6722,7 +6988,7 @@ Documentation generated by JSDoc 3.6.3 - on Sun Nov 10th 2019 + on Wed Nov 13th 2019 using the DocStrap template. diff --git a/docs/ControlPlusHub.html b/docs/ControlPlusHub.html index 1d34ac4..e9847ee 100644 --- a/docs/ControlPlusHub.html +++ b/docs/ControlPlusHub.html @@ -327,7 +327,7 @@ @@ -460,7 +460,7 @@ @@ -593,7 +593,140 @@ + + + + + + + + + + + + + + + + +
+
+

<readonly> hardwareVersion

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
firmwareVersion + + +string + + + + +

Hardware version of the hub

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + +
Overrides:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+
@@ -726,7 +859,140 @@ +
+ + + + + + + + + + + + + + + +
+
+

<readonly> primaryMACAddress

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
primaryMACAddress + + +string + + + + +

Primary MAC address of the hub

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + +
Overrides:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+
@@ -859,7 +1125,7 @@
@@ -992,7 +1258,7 @@ @@ -1125,7 +1391,7 @@ @@ -1257,7 +1523,7 @@ @@ -1383,7 +1649,7 @@ @@ -1509,7 +1775,7 @@ @@ -1635,7 +1901,7 @@ @@ -1807,7 +2073,7 @@ @@ -2037,7 +2303,7 @@ @@ -2199,7 +2465,7 @@ @@ -2456,7 +2722,7 @@ @@ -2627,7 +2893,7 @@ @@ -2846,7 +3112,7 @@ @@ -3084,7 +3350,7 @@ @@ -3341,7 +3607,7 @@ @@ -3582,7 +3848,7 @@ @@ -3753,7 +4019,7 @@ @@ -3874,7 +4140,7 @@ @@ -4051,7 +4317,7 @@ @@ -4271,7 +4537,7 @@ @@ -4447,7 +4713,7 @@ @@ -4624,7 +4890,7 @@ @@ -4875,7 +5141,7 @@ @@ -5051,7 +5317,7 @@ @@ -5222,7 +5488,7 @@ @@ -5393,7 +5659,7 @@ @@ -5588,7 +5854,7 @@ @@ -5740,7 +6006,7 @@ @@ -5911,7 +6177,7 @@ @@ -6082,7 +6348,7 @@ @@ -6253,7 +6519,7 @@ @@ -6424,7 +6690,7 @@ @@ -6643,7 +6909,7 @@ @@ -6722,7 +6988,7 @@ Documentation generated by JSDoc 3.6.3 - on Sun Nov 10th 2019 + on Wed Nov 13th 2019 using the DocStrap template. diff --git a/docs/DuploTrainBase.html b/docs/DuploTrainBase.html index 454c3d9..0a9860c 100644 --- a/docs/DuploTrainBase.html +++ b/docs/DuploTrainBase.html @@ -327,7 +327,7 @@ @@ -460,7 +460,7 @@ @@ -593,7 +593,140 @@ + + + + + + + + + + + + + + + + +
+
+

<readonly> hardwareVersion

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
firmwareVersion + + +string + + + + +

Hardware version of the hub

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + +
Overrides:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+
@@ -726,7 +859,140 @@ +
+ + + + + + + + + + + + + + + +
+
+

<readonly> primaryMACAddress

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
primaryMACAddress + + +string + + + + +

Primary MAC address of the hub

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + +
Overrides:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+
@@ -859,7 +1125,7 @@
@@ -992,7 +1258,7 @@ @@ -1125,7 +1391,7 @@ @@ -1257,7 +1523,7 @@ @@ -1383,7 +1649,7 @@ @@ -1509,7 +1775,7 @@ @@ -1635,7 +1901,7 @@ @@ -1807,7 +2073,7 @@ @@ -1965,7 +2231,7 @@ @@ -2199,7 +2465,7 @@ @@ -2370,7 +2636,7 @@ @@ -2589,7 +2855,7 @@ @@ -2830,7 +3096,7 @@ @@ -3001,7 +3267,7 @@ @@ -3122,7 +3388,7 @@ @@ -3299,7 +3565,7 @@ @@ -3519,7 +3785,7 @@ @@ -3695,7 +3961,7 @@ @@ -3872,7 +4138,7 @@ @@ -4123,7 +4389,7 @@ @@ -4299,7 +4565,7 @@ @@ -4470,7 +4736,7 @@ @@ -4641,7 +4907,7 @@ @@ -4836,7 +5102,7 @@ @@ -4988,7 +5254,7 @@ @@ -5159,7 +5425,7 @@ @@ -5330,7 +5596,7 @@ @@ -5501,7 +5767,7 @@ @@ -5672,7 +5938,7 @@ @@ -5891,7 +6157,7 @@ @@ -5970,7 +6236,7 @@ Documentation generated by JSDoc 3.6.3 - on Sun Nov 10th 2019 + on Wed Nov 13th 2019 using the DocStrap template. diff --git a/docs/Hub.html b/docs/Hub.html index 6a6e706..06dfa3c 100644 --- a/docs/Hub.html +++ b/docs/Hub.html @@ -307,7 +307,7 @@ @@ -426,7 +426,7 @@ @@ -545,7 +545,126 @@ + + + + + + + + + + + + + + + + +
+
+

<readonly> hardwareVersion

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
firmwareVersion + + +string + + + + +

Hardware version of the hub

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+
@@ -664,7 +783,126 @@ +
+ + + + + + + + + + + + + + + +
+
+

<readonly> primaryMACAddress

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
primaryMACAddress + + +string + + + + +

Primary MAC address of the hub

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+
@@ -783,7 +1021,7 @@
@@ -902,7 +1140,7 @@ @@ -1021,7 +1259,7 @@ @@ -1103,7 +1341,7 @@ @@ -1215,7 +1453,7 @@ @@ -1327,7 +1565,7 @@ @@ -1485,7 +1723,7 @@ @@ -1644,7 +1882,7 @@ @@ -1850,7 +2088,7 @@ @@ -2012,7 +2250,7 @@ @@ -2175,7 +2413,7 @@ @@ -2369,7 +2607,7 @@ @@ -2507,7 +2745,7 @@ @@ -2586,7 +2824,7 @@ Documentation generated by JSDoc 3.6.3 - on Sun Nov 10th 2019 + on Wed Nov 13th 2019 using the DocStrap template. diff --git a/docs/LPF2Hub.html b/docs/LPF2Hub.html index 1b17856..dfcf835 100644 --- a/docs/LPF2Hub.html +++ b/docs/LPF2Hub.html @@ -149,7 +149,7 @@ @@ -316,7 +316,7 @@ @@ -444,7 +444,7 @@ @@ -572,7 +572,135 @@ + + + + + + + + + + + + + + + + +
+
+

<readonly> hardwareVersion

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
firmwareVersion + + +string + + + + +

Hardware version of the hub

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+
@@ -700,7 +828,135 @@ +
+ + + + + + + + + + + + + + + +
+
+

<readonly> primaryMACAddress

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
primaryMACAddress + + +string + + + + +

Primary MAC address of the hub

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+
@@ -828,7 +1084,7 @@
@@ -956,7 +1212,7 @@ @@ -1084,7 +1340,7 @@ @@ -1180,7 +1436,7 @@ @@ -1301,7 +1557,7 @@ @@ -1422,7 +1678,7 @@ @@ -1589,7 +1845,7 @@ @@ -1747,7 +2003,7 @@ @@ -1957,7 +2213,7 @@ @@ -2119,7 +2375,7 @@ @@ -2231,7 +2487,7 @@ @@ -2403,7 +2659,7 @@ @@ -2618,7 +2874,7 @@ @@ -2789,7 +3045,7 @@ @@ -2961,7 +3217,7 @@ @@ -3203,7 +3459,7 @@ @@ -3374,7 +3630,7 @@ @@ -3536,7 +3792,7 @@ @@ -3698,7 +3954,7 @@ @@ -3884,7 +4140,7 @@ @@ -4031,7 +4287,7 @@ @@ -4193,7 +4449,7 @@ @@ -4355,7 +4611,7 @@ @@ -4517,7 +4773,7 @@ @@ -4679,7 +4935,7 @@ @@ -4889,7 +5145,7 @@ @@ -4968,7 +5224,7 @@ Documentation generated by JSDoc 3.6.3 - on Sun Nov 10th 2019 + on Wed Nov 13th 2019 using the DocStrap template. diff --git a/docs/PUPHub.html b/docs/PUPHub.html index 70f2ad9..bda0f11 100644 --- a/docs/PUPHub.html +++ b/docs/PUPHub.html @@ -327,7 +327,7 @@ @@ -460,7 +460,7 @@ @@ -593,7 +593,140 @@ + + + + + + + + + + + + + + + + +
+
+

<readonly> hardwareVersion

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
firmwareVersion + + +string + + + + +

Hardware version of the hub

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + +
Overrides:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+
@@ -726,7 +859,140 @@ +
+ + + + + + + + + + + + + + + +
+
+

<readonly> primaryMACAddress

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
primaryMACAddress + + +string + + + + +

Primary MAC address of the hub

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + +
Overrides:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+
@@ -859,7 +1125,7 @@
@@ -992,7 +1258,7 @@ @@ -1125,7 +1391,7 @@ @@ -1257,7 +1523,7 @@ @@ -1383,7 +1649,7 @@ @@ -1509,7 +1775,7 @@ @@ -1635,7 +1901,7 @@ @@ -1807,7 +2073,7 @@ @@ -2037,7 +2303,7 @@ @@ -2199,7 +2465,7 @@ @@ -2456,7 +2722,7 @@ @@ -2627,7 +2893,7 @@ @@ -2846,7 +3112,7 @@ @@ -3084,7 +3350,7 @@ @@ -3341,7 +3607,7 @@ @@ -3582,7 +3848,7 @@ @@ -3753,7 +4019,7 @@ @@ -3874,7 +4140,7 @@ @@ -4051,7 +4317,7 @@ @@ -4271,7 +4537,7 @@ @@ -4447,7 +4713,7 @@ @@ -4624,7 +4890,7 @@ @@ -4875,7 +5141,7 @@ @@ -5051,7 +5317,7 @@ @@ -5222,7 +5488,7 @@ @@ -5393,7 +5659,7 @@ @@ -5588,7 +5854,7 @@ @@ -5740,7 +6006,7 @@ @@ -5911,7 +6177,7 @@ @@ -6082,7 +6348,7 @@ @@ -6253,7 +6519,7 @@ @@ -6424,7 +6690,7 @@ @@ -6643,7 +6909,7 @@ @@ -6722,7 +6988,7 @@ Documentation generated by JSDoc 3.6.3 - on Sun Nov 10th 2019 + on Wed Nov 13th 2019 using the DocStrap template. diff --git a/docs/PUPRemote.html b/docs/PUPRemote.html index f2a52b5..071196f 100644 --- a/docs/PUPRemote.html +++ b/docs/PUPRemote.html @@ -327,7 +327,7 @@ @@ -460,7 +460,7 @@ @@ -593,7 +593,140 @@ + + + + + + + + + + + + + + + + +
+
+

<readonly> hardwareVersion

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
firmwareVersion + + +string + + + + +

Hardware version of the hub

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + +
Overrides:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+
@@ -726,7 +859,140 @@ +
+ + + + + + + + + + + + + + + +
+
+

<readonly> primaryMACAddress

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
primaryMACAddress + + +string + + + + +

Primary MAC address of the hub

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + +
Overrides:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+
@@ -859,7 +1125,7 @@
@@ -992,7 +1258,7 @@ @@ -1125,7 +1391,7 @@ @@ -1221,7 +1487,7 @@ @@ -1347,7 +1613,7 @@ @@ -1473,7 +1739,7 @@ @@ -1645,7 +1911,7 @@ @@ -1812,7 +2078,7 @@ @@ -2031,7 +2297,7 @@ @@ -2202,7 +2468,7 @@ @@ -2323,7 +2589,7 @@ @@ -2500,7 +2766,7 @@ @@ -2720,7 +2986,7 @@ @@ -2896,7 +3162,7 @@ @@ -3073,7 +3339,7 @@ @@ -3324,7 +3590,7 @@ @@ -3500,7 +3766,7 @@ @@ -3671,7 +3937,7 @@ @@ -3842,7 +4108,7 @@ @@ -4037,7 +4303,7 @@ @@ -4189,7 +4455,7 @@ @@ -4360,7 +4626,7 @@ @@ -4531,7 +4797,7 @@ @@ -4702,7 +4968,7 @@ @@ -4873,7 +5139,7 @@ @@ -5092,7 +5358,7 @@ @@ -5171,7 +5437,7 @@ Documentation generated by JSDoc 3.6.3 - on Sun Nov 10th 2019 + on Wed Nov 13th 2019 using the DocStrap template. diff --git a/docs/PoweredUP.html b/docs/PoweredUP.html index be9fd64..47290cc 100644 --- a/docs/PoweredUP.html +++ b/docs/PoweredUP.html @@ -209,6 +209,164 @@
+
+
+

getConnectedHubByPrimaryMACAddress(address)

+ + +
+
+ + +
+

Retrieve a Powered UP Hub by primary MAC address.

+
+ + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
address + + +string + + + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + + + +
+
+ Type +
+
+ +Hub + + + +
+
+ + + + + +
+ + +

getConnectedHubByUUID(uuid)

@@ -585,7 +743,7 @@ @@ -942,7 +1100,7 @@ @@ -1021,7 +1179,7 @@ Documentation generated by JSDoc 3.6.3 - on Sun Nov 10th 2019 + on Wed Nov 13th 2019 using the DocStrap template. diff --git a/docs/WeDo2SmartHub.html b/docs/WeDo2SmartHub.html index 6584d0f..71a97c6 100644 --- a/docs/WeDo2SmartHub.html +++ b/docs/WeDo2SmartHub.html @@ -320,7 +320,7 @@ @@ -448,7 +448,7 @@ @@ -576,7 +576,135 @@ + + + + + + + + +
+ + + + + + + +
+
+

<readonly> hardwareVersion

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
firmwareVersion + + +string + + + + +

Hardware version of the hub

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+
@@ -704,7 +832,135 @@ +
+ + + + + + + + + + + + + + + +
+
+

<readonly> primaryMACAddress

+ + +
+
+ + + + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
primaryMACAddress + + +string + + + + +

Primary MAC address of the hub

+
+ + + + + + + + +
Inherited From:
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+
@@ -832,7 +1088,7 @@
@@ -960,7 +1216,7 @@ @@ -1088,7 +1344,7 @@ @@ -1346,7 +1602,7 @@ @@ -1467,7 +1723,7 @@ @@ -1588,7 +1844,7 @@ @@ -1755,7 +2011,7 @@ @@ -3465,7 +3721,7 @@ @@ -3680,7 +3936,7 @@ @@ -3851,7 +4107,7 @@ @@ -4023,7 +4279,7 @@ @@ -4226,7 +4482,7 @@ @@ -4697,7 +4953,7 @@ @@ -5286,7 +5542,7 @@ Documentation generated by JSDoc 3.6.3 - on Sun Nov 10th 2019 + on Wed Nov 13th 2019 using the DocStrap template. diff --git a/docs/boostmovehub.js.html b/docs/boostmovehub.js.html index 601f8b5..74a382c 100644 --- a/docs/boostmovehub.js.html +++ b/docs/boostmovehub.js.html @@ -109,16 +109,10 @@ const debug = Debug("boostmovehub"); * @extends Hub */ class BoostMoveHub extends lpf2hub_1.LPF2Hub { - static IsBoostMoveHub(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.BOOST_MOVE_HUB_ID); - } constructor(device, autoSubscribe = true) { super(device, autoSubscribe); + this._currentPort = 0x3b; + this._voltagePort = 0x3c; this.type = Consts.HubType.BOOST_MOVE_HUB; this._ports = { "A": new port_1.Port("A", 0), @@ -132,6 +126,14 @@ class BoostMoveHub extends lpf2hub_1.LPF2Hub { }); debug("Discovered Boost Move Hub"); } + static IsBoostMoveHub(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.BOOST_MOVE_HUB_ID); + } connect() { return new Promise(async (resolve, reject) => { debug("Connecting to Boost Move Hub"); @@ -421,7 +423,7 @@ exports.BoostMoveHub = BoostMoveHub; Documentation generated by JSDoc 3.6.3 - on Sun Nov 10th 2019 + on Wed Nov 13th 2019 using the DocStrap template. diff --git a/docs/classes.list.html b/docs/classes.list.html index 0de84f9..8465b00 100644 --- a/docs/classes.list.html +++ b/docs/classes.list.html @@ -381,7 +381,7 @@ @@ -557,7 +557,7 @@ @@ -728,7 +728,7 @@ @@ -899,7 +899,7 @@ @@ -1094,7 +1094,7 @@ @@ -1246,7 +1246,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 @@ @@ -2544,7 +2544,7 @@ @@ -2715,7 +2715,7 @@ @@ -2886,7 +2886,7 @@ @@ -3081,7 +3081,7 @@ @@ -3233,7 +3233,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 @@ @@ -4531,7 +4531,7 @@ @@ -4702,7 +4702,7 @@ @@ -4873,7 +4873,7 @@ @@ -5068,7 +5068,7 @@ @@ -5220,7 +5220,7 @@ @@ -5391,7 +5391,7 @@ @@ -5562,7 +5562,7 @@ @@ -5733,7 +5733,7 @@ @@ -5904,7 +5904,7 @@ @@ -6123,7 +6123,7 @@ @@ -6285,7 +6285,7 @@ @@ -6423,7 +6423,7 @@ @@ -6633,7 +6633,7 @@ @@ -6804,7 +6804,7 @@ @@ -6966,7 +6966,7 @@ @@ -7128,7 +7128,7 @@ @@ -7314,7 +7314,7 @@ @@ -7461,7 +7461,7 @@ @@ -7623,7 +7623,7 @@ @@ -7785,7 +7785,7 @@ @@ -7947,7 +7947,7 @@ @@ -8109,7 +8109,7 @@ @@ -8319,7 +8319,7 @@ @@ -8472,7 +8472,7 @@ @@ -8691,7 +8691,7 @@ @@ -8867,7 +8867,7 @@ @@ -9038,7 +9038,7 @@ @@ -9209,7 +9209,7 @@ @@ -9404,7 +9404,7 @@ @@ -9556,7 +9556,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 @@ @@ -10854,7 +10854,7 @@ @@ -11025,7 +11025,7 @@ @@ -11196,7 +11196,7 @@ @@ -11391,7 +11391,7 @@ @@ -11543,7 +11543,7 @@ @@ -11714,7 +11714,7 @@ @@ -11885,7 +11885,7 @@ @@ -12056,7 +12056,7 @@ @@ -12227,7 +12227,7 @@ @@ -12446,7 +12446,7 @@ @@ -12617,7 +12617,7 @@ @@ -13088,7 +13088,7 @@ @@ -13677,7 +13677,7 @@ Documentation generated by JSDoc 3.6.3 - on Sun Nov 10th 2019 + on Wed Nov 13th 2019 using the DocStrap template. diff --git a/docs/consts.js.html b/docs/consts.js.html index c85c506..5b95611 100644 --- a/docs/consts.js.html +++ b/docs/consts.js.html @@ -107,18 +107,17 @@ var HubType; HubType[HubType["CONTROL_PLUS_HUB"] = 6] = "CONTROL_PLUS_HUB"; })(HubType = exports.HubType || (exports.HubType = {})); // tslint:disable-next-line -exports.HubTypeNames = Object.keys(HubType).reduce((result, item) => { - // @ts-ignore - result[HubType[item]] = item; - return result; -}, {}); +exports.HubTypeNames = HubType; /** * @typedef DeviceType * @property {number} UNKNOWN 0 * @property {number} BASIC_MOTOR 1 * @property {number} TRAIN_MOTOR 2 * @property {number} LED_LIGHTS 8 - * @property {number} BOOST_LED 22 + * @property {number} VOLTAGE 20 + * @property {number} CURRENT 21 + * @property {number} PIEZO_TONE 22 + * @property {number} RGB_LIGHT 23 * @property {number} WEDO2_TILT 34 * @property {number} WEDO2_DISTANCE 35 * @property {number} BOOST_DISTANCE 37 @@ -132,6 +131,9 @@ exports.HubTypeNames = Object.keys(HubType).reduce((result, item) => { * @property {number} CONTROL_PLUS_LARGE_MOTOR 46 * @property {number} CONTROL_PLUS_XLARGE_MOTOR 47 * @property {number} POWERED_UP_REMOTE_BUTTON 55 + * @property {number} RSSI 56 + * @property {number} CONTROL_PLUS_ACCELEROMETER 58 + * @property {number} CONTROL_PLUS_TILT 59 */ var DeviceType; (function (DeviceType) { @@ -139,7 +141,10 @@ var DeviceType; DeviceType[DeviceType["BASIC_MOTOR"] = 1] = "BASIC_MOTOR"; DeviceType[DeviceType["TRAIN_MOTOR"] = 2] = "TRAIN_MOTOR"; DeviceType[DeviceType["LED_LIGHTS"] = 8] = "LED_LIGHTS"; - DeviceType[DeviceType["BOOST_LED"] = 22] = "BOOST_LED"; + DeviceType[DeviceType["VOLTAGE"] = 20] = "VOLTAGE"; + DeviceType[DeviceType["CURRENT"] = 21] = "CURRENT"; + DeviceType[DeviceType["PIEZO_TONE"] = 22] = "PIEZO_TONE"; + DeviceType[DeviceType["RGB_LIGHT"] = 23] = "RGB_LIGHT"; DeviceType[DeviceType["WEDO2_TILT"] = 34] = "WEDO2_TILT"; DeviceType[DeviceType["WEDO2_DISTANCE"] = 35] = "WEDO2_DISTANCE"; DeviceType[DeviceType["BOOST_DISTANCE"] = 37] = "BOOST_DISTANCE"; @@ -153,13 +158,12 @@ var DeviceType; DeviceType[DeviceType["CONTROL_PLUS_LARGE_MOTOR"] = 46] = "CONTROL_PLUS_LARGE_MOTOR"; DeviceType[DeviceType["CONTROL_PLUS_XLARGE_MOTOR"] = 47] = "CONTROL_PLUS_XLARGE_MOTOR"; DeviceType[DeviceType["POWERED_UP_REMOTE_BUTTON"] = 55] = "POWERED_UP_REMOTE_BUTTON"; + DeviceType[DeviceType["RSSI"] = 56] = "RSSI"; + DeviceType[DeviceType["CONTROL_PLUS_ACCELEROMETER"] = 58] = "CONTROL_PLUS_ACCELEROMETER"; + DeviceType[DeviceType["CONTROL_PLUS_TILT"] = 59] = "CONTROL_PLUS_TILT"; })(DeviceType = exports.DeviceType || (exports.DeviceType = {})); // tslint:disable-next-line -exports.DeviceTypeNames = Object.keys(DeviceType).reduce((result, item) => { - // @ts-ignore - result[DeviceType[item]] = item; - return result; -}, {}); +exports.DeviceTypeNames = DeviceType; /** * @typedef Color * @property {number} BLACK 0 @@ -191,11 +195,7 @@ var Color; Color[Color["NONE"] = 255] = "NONE"; })(Color = exports.Color || (exports.Color = {})); // tslint:disable-next-line -exports.ColorNames = Object.keys(Color).reduce((result, item) => { - // @ts-ignore - result[Color[item]] = item; - return result; -}, {}); +exports.ColorNames = Color; /** * @typedef ButtonState * @property {number} PRESSED 0 @@ -307,7 +307,7 @@ var BLECharacteristic; Documentation generated by JSDoc 3.6.3 - on Sun Nov 10th 2019 + on Wed Nov 13th 2019 using the DocStrap template. diff --git a/docs/controlplushub.js.html b/docs/controlplushub.js.html index 980f075..ab3961e 100644 --- a/docs/controlplushub.js.html +++ b/docs/controlplushub.js.html @@ -105,6 +105,25 @@ const debug = Debug("ControlPlusHub"); * @extends Hub */ class ControlPlusHub extends lpf2hub_1.LPF2Hub { + constructor(device, autoSubscribe = true) { + super(device, autoSubscribe); + this._currentPort = 0x3b; + this._voltagePort = 0x3c; + this._voltageMaxRaw = 4095; + this.type = Consts.HubType.CONTROL_PLUS_HUB; + this._ports = { + "A": new port_1.Port("A", 0), + "B": new port_1.Port("B", 1), + "C": new port_1.Port("C", 2), + "D": new port_1.Port("D", 3), + "ACCEL": new port_1.Port("ACCEL", 98), + "TILT": new port_1.Port("TILT", 99) + }; + this.on("attach", (port, type) => { + this._combinePorts(port, type); + }); + debug("Discovered Control+ Hub"); + } static IsControlPlusHub(peripheral) { return (peripheral.advertisement && peripheral.advertisement.serviceUuids && @@ -113,26 +132,10 @@ class ControlPlusHub extends lpf2hub_1.LPF2Hub { peripheral.advertisement.manufacturerData.length > 3 && peripheral.advertisement.manufacturerData[3] === Consts.BLEManufacturerData.CONTROL_PLUS_LARGE_HUB); } - constructor(device, autoSubscribe = true) { - super(device, autoSubscribe); - this.type = Consts.HubType.CONTROL_PLUS_HUB; - this._ports = { - "A": new port_1.Port("A", 0), - "B": new port_1.Port("B", 1), - "C": new port_1.Port("C", 2), - "D": new port_1.Port("D", 3), - }; - this.on("attach", (port, type) => { - this._combinePorts(port, type); - }); - debug("Discovered Control+ Hub"); - } connect() { return new Promise(async (resolve, reject) => { debug("Connecting to Control+ Hub"); await super.connect(); - this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, Buffer.from([0x41, 0x62, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x01])); // Accelerometer - this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, Buffer.from([0x41, 0x63, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01])); // Gyro/Tilt this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, Buffer.from([0x41, 0x3d, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x01])); // Temperature debug("Connect completed"); return resolve(); @@ -411,7 +414,7 @@ exports.ControlPlusHub = ControlPlusHub; Documentation generated by JSDoc 3.6.3 - on Sun Nov 10th 2019 + on Wed Nov 13th 2019 using the DocStrap template. diff --git a/docs/duplotrainbase.js.html b/docs/duplotrainbase.js.html index 713a929..45a3553 100644 --- a/docs/duplotrainbase.js.html +++ b/docs/duplotrainbase.js.html @@ -108,6 +108,9 @@ class DuploTrainBase extends lpf2hub_1.LPF2Hub { constructor(device, autoSubscribe = true) { super(device, autoSubscribe); this._ledPort = 0x11; + this._voltagePort = 0x14; + this._voltageMaxV = 6.4; + this._voltageMaxRaw = 3047; this.type = Consts.HubType.DUPLO_TRAIN_HUB; this._ports = { "MOTOR": new port_1.Port("MOTOR", 0), @@ -259,7 +262,7 @@ exports.DuploTrainBase = DuploTrainBase; Documentation generated by JSDoc 3.6.3 - on Sun Nov 10th 2019 + on Wed Nov 13th 2019 using the DocStrap template. diff --git a/docs/global.html b/docs/global.html index 4e96785..87b9672 100644 --- a/docs/global.html +++ b/docs/global.html @@ -954,7 +954,7 @@ @@ -1337,7 +1337,7 @@ @@ -1493,7 +1493,55 @@ - BOOST_LED + VOLTAGE + + + + + +number + + + + + + + + + + +

20

+ + + + + + + CURRENT + + + + + +number + + + + + + + + + + +

21

+ + + + + + + PIEZO_TONE @@ -1515,6 +1563,30 @@ + + + RGB_LIGHT + + + + + +number + + + + + + + + + + +

23

+ + + + WEDO2_TILT @@ -1826,6 +1898,78 @@ + + + + RSSI + + + + + +number + + + + + + + + + + +

56

+ + + + + + + CONTROL_PLUS_ACCELEROMETER + + + + + +number + + + + + + + + + + +

58

+ + + + + + + CONTROL_PLUS_TILT + + + + + +number + + + + + + + + + + +

59

+ + + @@ -1864,7 +2008,7 @@ @@ -2020,7 +2164,55 @@ - BOOST_LED + VOLTAGE + + + + + +number + + + + + + + + + + +

20

+ + + + + + + CURRENT + + + + + +number + + + + + + + + + + +

21

+ + + + + + + PIEZO_TONE @@ -2042,6 +2234,30 @@ + + + RGB_LIGHT + + + + + +number + + + + + + + + + + +

23

+ + + + WEDO2_TILT @@ -2353,6 +2569,78 @@ + + + + RSSI + + + + + +number + + + + + + + + + + +

56

+ + + + + + + CONTROL_PLUS_ACCELEROMETER + + + + + +number + + + + + + + + + + +

58

+ + + + + + + CONTROL_PLUS_TILT + + + + + +number + + + + + + + + + + +

59

+ + + @@ -2391,7 +2679,7 @@ @@ -3416,7 +3704,7 @@ Documentation generated by JSDoc 3.6.3 - on Sun Nov 10th 2019 + on Wed Nov 13th 2019 using the DocStrap template. diff --git a/docs/hub.js.html b/docs/hub.js.html index 2246b96..3f5f9ef 100644 --- a/docs/hub.js.html +++ b/docs/hub.js.html @@ -111,10 +111,12 @@ class Hub extends events_1.EventEmitter { this._virtualPorts = {}; this._name = ""; this._firmwareVersion = "0.0.00.0000"; + this._hardwareVersion = "0.0.00.0000"; + this._primaryMACAddress = "00:00:00:00:00:00"; this._batteryLevel = 100; this._voltage = 0; this._current = 0; - this._rssi = -100; + this._rssi = -60; this._isConnecting = false; this._isConnected = false; this.autoSubscribe = !!autoSubscribe; @@ -137,6 +139,20 @@ class Hub extends events_1.EventEmitter { get firmwareVersion() { return this._firmwareVersion; } + /** + * @readonly + * @property {string} firmwareVersion Hardware version of the hub + */ + get hardwareVersion() { + return this._hardwareVersion; + } + /** + * @readonly + * @property {string} primaryMACAddress Primary MAC address of the hub + */ + get primaryMACAddress() { + return this._primaryMACAddress; + } /** * @readonly * @property {string} uuid UUID of the hub @@ -144,13 +160,6 @@ class Hub extends events_1.EventEmitter { get uuid() { return this._bleDevice.uuid; } - /** - * @readonly - * @property {number} rssi Signal strength of the hub - */ - get rssi() { - return this._rssi; - } /** * @readonly * @property {number} batteryLevel Battery level of the hub (Percentage between 0-100) @@ -158,6 +167,13 @@ class Hub extends events_1.EventEmitter { get batteryLevel() { return this._batteryLevel; } + /** + * @readonly + * @property {number} rssi Signal strength of the hub + */ + get rssi() { + return this._rssi; + } /** * @readonly * @property {number} voltage Voltage of the hub (Volts) @@ -196,7 +212,6 @@ class Hub extends events_1.EventEmitter { * @returns {Promise} Resolved upon successful disconnect. */ async disconnect() { - this.emit("disconnect"); this._bleDevice.disconnect(); } /** @@ -389,12 +404,6 @@ class Hub extends events_1.EventEmitter { } return port; } - _lpad(str, length) { - while (str.length < length) { - str = "0" + str; - } - return str; - } _getModeForDeviceType(type) { switch (type) { case Consts.DeviceType.BASIC_MOTOR: @@ -409,6 +418,10 @@ class Hub extends events_1.EventEmitter { return 0x02; case Consts.DeviceType.CONTROL_PLUS_XLARGE_MOTOR: return 0x02; + case Consts.DeviceType.CONTROL_PLUS_TILT: + return 0x00; + case Consts.DeviceType.CONTROL_PLUS_ACCELEROMETER: + return 0x00; case Consts.DeviceType.BOOST_DISTANCE: return (this.type === Consts.HubType.WEDO2_SMART_HUB ? 0x00 : 0x08); case Consts.DeviceType.BOOST_TILT: @@ -464,7 +477,7 @@ exports.Hub = Hub; Documentation generated by JSDoc 3.6.3 - on Sun Nov 10th 2019 + on Wed Nov 13th 2019 using the DocStrap template. diff --git a/docs/index.html b/docs/index.html index 49ab709..a3c6c91 100644 --- a/docs/index.html +++ b/docs/index.html @@ -360,7 +360,7 @@ console.log("Scanning for Hubs..."); Documentation generated by JSDoc 3.6.3 - on Sun Nov 10th 2019 + on Wed Nov 13th 2019 using the DocStrap template. diff --git a/docs/lpf2hub.js.html b/docs/lpf2hub.js.html index c17408a..cd18f54 100644 --- a/docs/lpf2hub.js.html +++ b/docs/lpf2hub.js.html @@ -96,6 +96,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); const hub_1 = require("./hub"); const port_1 = require("./port"); const Consts = __importStar(require("./consts")); +const utils_1 = require("./utils"); const Debug = require("debug"); const debug = Debug("lpf2hub"); const modeInfoDebug = Debug("lpf2hubmodeinfo"); @@ -107,6 +108,10 @@ class LPF2Hub extends hub_1.Hub { constructor() { super(...arguments); this._ledPort = 0x32; + this._voltageMaxV = 9.6; + this._voltageMaxRaw = 3893; + this._currentMaxMA = 2444; + this._currentMaxRaw = 4095; this._lastTiltX = 0; this._lastTiltY = 0; this._lastTiltZ = 0; @@ -116,24 +121,32 @@ class LPF2Hub extends hub_1.Hub { const t = v.toString(16).padStart(8, "0"); return [t[0], t[1], t.substring(2, 4), t.substring(4)].join("."); } + static decodeMACAddress(v) { + return Array.from(v).map((n) => utils_1.toHex(n, 2)).join(":"); + } connect() { return new Promise(async (resolve, reject) => { await super.connect(); await this._bleDevice.discoverCharacteristicsForService(Consts.BLEService.LPF2_HUB); this._bleDevice.subscribeToCharacteristic(Consts.BLECharacteristic.LPF2_ALL, this._parseMessage.bind(this)); - this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, Buffer.from([0x01, 0x02, 0x02])); // Activate button reports - this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, Buffer.from([0x01, 0x03, 0x05])); // Request firmware version - this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, Buffer.from([0x01, 0x06, 0x02])); // Activate battery level reports - this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, Buffer.from([0x41, 0x3c, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01])); // Activate voltage reports - this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, Buffer.from([0x41, 0x3b, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01])); // Activate current reports + if (this._voltagePort !== undefined) { + this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, Buffer.from([0x41, this._voltagePort, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01])); // Activate voltage reports + } + if (this._currentPort !== undefined) { + this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, Buffer.from([0x41, this._currentPort, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01])); // Activate current reports + } if (this.type === Consts.HubType.DUPLO_TRAIN_HUB) { this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, Buffer.from([0x41, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01])); } + await this.sleep(100); + this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, Buffer.from([0x01, 0x02, 0x02])); // Activate button reports + this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, Buffer.from([0x01, 0x03, 0x05])); // Request firmware version + this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, Buffer.from([0x01, 0x04, 0x05])); // Request hardware version + this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, Buffer.from([0x01, 0x05, 0x02])); // Activate RSSI updates + this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, Buffer.from([0x01, 0x06, 0x02])); // Activate battery level reports + this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, Buffer.from([0x01, 0x0d, 0x05])); // Request primary MAC address this.emit("connect"); resolve(); - setTimeout(() => { - this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, Buffer.from([0x01, 0x03, 0x05])); // Request firmware version again - }, 200); }); } /** @@ -304,6 +317,22 @@ class LPF2Hub extends hub_1.Hub { else if (data[3] === 0x03) { this._firmwareVersion = LPF2Hub.decodeVersion(data.readInt32LE(5)); this._checkFirmware(this._firmwareVersion); + // Hardware version + } + else if (data[3] === 0x04) { + this._hardwareVersion = LPF2Hub.decodeVersion(data.readInt32LE(5)); + // RSSI update + } + else if (data[3] === 0x05) { + const rssi = data.readInt8(5); + if (rssi !== 0) { + this._rssi = rssi; + this.emit("rssiChange", this._rssi); + } + // primary MAC Address + } + else if (data[3] === 0x0d) { + this._primaryMACAddress = LPF2Hub.decodeMACAddress(data.slice(4, 10)); // Battery level reports } else if (data[3] === 0x06) { @@ -312,7 +341,13 @@ class LPF2Hub extends hub_1.Hub { } _parsePortMessage(data) { let port = this._getPortForPortNumber(data[3]); - if (data[4] === 0x01) { + const type = data[4] ? data.readUInt16LE(5) : 0; + if (data[4] === 0x01 && modeInfoDebug.enabled) { + const typeName = Consts.DeviceTypeNames[data[5]] || "unknown"; + modeInfoDebug(`Port ${utils_1.toHex(data[3])}, type ${utils_1.toHex(type, 4)} (${typeName})`); + const hwVersion = LPF2Hub.decodeVersion(data.readInt32LE(7)); + const swVersion = LPF2Hub.decodeVersion(data.readInt32LE(11)); + modeInfoDebug(`Port ${utils_1.toHex(data[3])}, hardware version ${hwVersion}, software version ${swVersion}`); this._sendPortInformationRequest(data[3]); } if (!port) { @@ -324,7 +359,7 @@ class LPF2Hub extends hub_1.Hub { port = this._getPortForPortNumber(data[3]); if (port) { port.connected = true; - this._registerDeviceAttachment(port, data[5]); + this._registerDeviceAttachment(port, type); } else { return; @@ -340,31 +375,41 @@ class LPF2Hub extends hub_1.Hub { } else { port.connected = (data[4] === 0x01 || data[4] === 0x02) ? true : false; - this._registerDeviceAttachment(port, data[5]); + this._registerDeviceAttachment(port, type); } } _sendPortInformationRequest(port) { this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, Buffer.from([0x21, port, 0x01])); + this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, Buffer.from([0x21, port, 0x02])); // Mode combinations } _parsePortInformationResponse(data) { const port = data[3]; + if (data[4] === 2) { + const modeCombinationMasks = []; + for (let i = 5; i < data.length; i += 2) { + modeCombinationMasks.push(data.readUInt16LE(i)); + } + modeInfoDebug(`Port ${utils_1.toHex(port)}, mode combinations [${modeCombinationMasks.map((c) => utils_1.toBin(c, 0)).join(", ")}]`); + return; + } const count = data[6]; - const input = data.readUInt16LE(7); - const output = data.readUInt16LE(9); - modeInfoDebug(`Port ${port}, total modes ${count}, input modes ${input.toString(2)}, output modes ${output.toString(2)}`); + const input = utils_1.toBin(data.readUInt16LE(7), count); + const output = utils_1.toBin(data.readUInt16LE(9), count); + modeInfoDebug(`Port ${utils_1.toHex(port)}, total modes ${count}, input modes ${input}, output modes ${output}`); for (let i = 0; i < count; i++) { this._sendModeInformationRequest(port, i, 0x00); // Mode Name this._sendModeInformationRequest(port, i, 0x01); // RAW Range this._sendModeInformationRequest(port, i, 0x02); // PCT Range this._sendModeInformationRequest(port, i, 0x03); // SI Range this._sendModeInformationRequest(port, i, 0x04); // SI Symbol + this._sendModeInformationRequest(port, i, 0x80); // Value Format } } _sendModeInformationRequest(port, mode, type) { this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, Buffer.from([0x22, port, mode, type])); } _parseModeInformationResponse(data) { - const port = data[3]; + const port = utils_1.toHex(data[3]); const mode = data[4]; const type = data[5]; switch (type) { @@ -383,6 +428,12 @@ class LPF2Hub extends hub_1.Hub { case 0x04: // SI Symbol modeInfoDebug(`Port ${port}, mode ${mode}, SI symbol ${data.slice(6, data.length).toString()}`); break; + case 0x80: // Value Format + const numValues = data[6]; + const dataType = ["8bit", "16bit", "32bit", "float"][data[7]]; + const totalFigures = data[8]; + const decimals = data[9]; + modeInfoDebug(`Port ${port}, mode ${mode}, Value ${numValues} x ${dataType}, Decimal format ${totalFigures}.${decimals}`); } } _parsePortAction(data) { @@ -398,69 +449,15 @@ class LPF2Hub extends hub_1.Hub { } } } - _padMessage(data, len) { - if (data.length < len) { - data = Buffer.concat([data, Buffer.alloc(len - data.length)]); - } - return data; - } _parseSensorMessage(data) { - if ((data[3] === 0x3b && this.type === Consts.HubType.POWERED_UP_REMOTE)) { // Voltage (PUP Remote) - data = this._padMessage(data, 6); - const voltage = data.readUInt16LE(4); - this._voltage = 6400.0 * voltage / 3200.0 / 1000.0; + if (data[3] === this._voltagePort) { + const voltageRaw = data.readUInt16LE(4); + this._voltage = voltageRaw * this._voltageMaxV / this._voltageMaxRaw; return; } - else if ((data[3] === 0x3c && this.type === Consts.HubType.POWERED_UP_HUB)) { // Voltage (PUP Hub) - data = this._padMessage(data, 6); - const voltage = data.readUInt16LE(4); - this._voltage = 9620.0 * voltage / 3893.0 / 1000.0; - return; - } - else if ((data[3] === 0x3c && this.type === Consts.HubType.CONTROL_PLUS_HUB)) { // Voltage (Control+ Hub) - data = this._padMessage(data, 6); - const voltage = data.readUInt16LE(4); - this._voltage = 9615.0 * voltage / 4095.0 / 1000.0; - return; - } - else if (data[3] === 0x3c) { // Voltage (Others) - data = this._padMessage(data, 6); - const voltage = data.readUInt16LE(4); - this._voltage = 9600.0 * voltage / 3893.0 / 1000.0; - return; - } - else if (data[3] === 0x3c && this.type === Consts.HubType.POWERED_UP_REMOTE) { // RSSI (PUP Remote) - return; - } - else if (data[3] === 0x3b) { // Current (Others) - data = this._padMessage(data, 6); - const current = data.readUInt16LE(4); - this._current = 2444 * current / 4095.0; - return; - } - if ((data[3] === 0x62 && this.type === Consts.HubType.CONTROL_PLUS_HUB)) { // Control+ Accelerometer - const accelX = Math.round((data.readInt16LE(4) / 28571) * 2000); - const accelY = Math.round((data.readInt16LE(6) / 28571) * 2000); - const accelZ = Math.round((data.readInt16LE(8) / 28571) * 2000); - /** - * Emits when accelerometer detects movement. Measured in DPS - degrees per second. - * @event LPF2Hub#accel - * @param {string} port - * @param {number} x - * @param {number} y - * @param {number} z - */ - this.emit("accel", "ACCEL", accelX, accelY, accelZ); - return; - } - if ((data[3] === 0x63 && this.type === Consts.HubType.CONTROL_PLUS_HUB)) { // Control+ Accelerometer - const tiltZ = data.readInt16LE(4); - const tiltY = data.readInt16LE(6); - const tiltX = data.readInt16LE(8); - this._lastTiltX = tiltX; - this._lastTiltY = tiltY; - this._lastTiltZ = tiltZ; - this.emit("tilt", "TILT", this._lastTiltX, this._lastTiltY, this._lastTiltZ); + else if (data[3] === this._currentPort) { + const currentRaw = data.readUInt16LE(4); + this._current = this._currentMaxMA * currentRaw / this._currentMaxRaw; return; } if ((data[3] === 0x3d && this.type === Consts.HubType.CONTROL_PLUS_HUB)) { // Control+ CPU Temperature @@ -564,6 +561,31 @@ class LPF2Hub extends hub_1.Hub { this.emit("rotate", port.id, rotation); break; } + case Consts.DeviceType.CONTROL_PLUS_TILT: { + const tiltZ = data.readInt16LE(4); + const tiltY = data.readInt16LE(6); + const tiltX = data.readInt16LE(8); + this._lastTiltX = tiltX; + this._lastTiltY = tiltY; + this._lastTiltZ = tiltZ; + this.emit("tilt", "TILT", this._lastTiltX, this._lastTiltY, this._lastTiltZ); + break; + } + case Consts.DeviceType.CONTROL_PLUS_ACCELEROMETER: { + const accelX = Math.round((data.readInt16LE(4) / 28571) * 2000); + const accelY = Math.round((data.readInt16LE(6) / 28571) * 2000); + const accelZ = Math.round((data.readInt16LE(8) / 28571) * 2000); + /** + * Emits when accelerometer detects movement. Measured in DPS - degrees per second. + * @event LPF2Hub#accel + * @param {string} port + * @param {number} x + * @param {number} y + * @param {number} z + */ + this.emit("accel", "ACCEL", accelX, accelY, accelZ); + break; + } case Consts.DeviceType.BOOST_TILT: { const tiltX = data.readInt8(4); const tiltY = data.readInt8(5); @@ -660,7 +682,7 @@ exports.LPF2Hub = LPF2Hub; Documentation generated by JSDoc 3.6.3 - on Sun Nov 10th 2019 + on Wed Nov 13th 2019 using the DocStrap template. diff --git a/docs/poweredup-node.js.html b/docs/poweredup-node.js.html index 2c5fd0e..9a30885 100644 --- a/docs/poweredup-node.js.html +++ b/docs/poweredup-node.js.html @@ -171,6 +171,15 @@ class PoweredUP extends events_1.EventEmitter { getConnectedHubByUUID(uuid) { return this._connectedHubs[uuid]; } + /** + * Retrieve a Powered UP Hub by primary MAC address. + * @method PoweredUP#getConnectedHubByPrimaryMACAddress + * @param {string} address + * @returns {Hub} + */ + getConnectedHubByPrimaryMACAddress(address) { + return Object.keys(this._connectedHubs).map((uuid) => this._connectedHubs[uuid]).filter((hub) => hub.primaryMACAddress === address)[0]; + } /** * Retrieve a list of Powered UP Hub by name. * @method PoweredUP#getConnectedHubsByName @@ -273,7 +282,7 @@ exports.PoweredUP = PoweredUP; Documentation generated by JSDoc 3.6.3 - on Sun Nov 10th 2019 + on Wed Nov 13th 2019 using the DocStrap template. diff --git a/docs/puphub.js.html b/docs/puphub.js.html index 238efff..65cb01a 100644 --- a/docs/puphub.js.html +++ b/docs/puphub.js.html @@ -109,16 +109,10 @@ const debug = Debug("puphub"); * @extends Hub */ class PUPHub extends lpf2hub_1.LPF2Hub { - static IsPUPHub(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.POWERED_UP_HUB_ID); - } constructor(device, autoSubscribe = true) { super(device, autoSubscribe); + this._currentPort = 0x3b; + this._voltagePort = 0x3c; this.type = Consts.HubType.POWERED_UP_HUB; this._ports = { "A": new port_1.Port("A", 0), @@ -129,6 +123,14 @@ class PUPHub extends lpf2hub_1.LPF2Hub { }); debug("Discovered Powered UP Hub"); } + static IsPUPHub(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.POWERED_UP_HUB_ID); + } connect() { return new Promise(async (resolve, reject) => { debug("Connecting to Powered UP Hub"); @@ -415,7 +417,7 @@ exports.PUPHub = PUPHub; Documentation generated by JSDoc 3.6.3 - on Sun Nov 10th 2019 + on Wed Nov 13th 2019 using the DocStrap template. diff --git a/docs/pupremote.js.html b/docs/pupremote.js.html index 7cde181..65499c0 100644 --- a/docs/pupremote.js.html +++ b/docs/pupremote.js.html @@ -108,6 +108,9 @@ class PUPRemote extends lpf2hub_1.LPF2Hub { constructor(device, autoSubscribe = true) { super(device, autoSubscribe); this._ledPort = 0x34; + this._voltagePort = 0x3b; + this._voltageMaxV = 6.4; + this._voltageMaxRaw = 3200; this.type = Consts.HubType.POWERED_UP_REMOTE; this._ports = { "LEFT": new port_1.Port("LEFT", 0), @@ -178,7 +181,7 @@ exports.PUPRemote = PUPRemote; Documentation generated by JSDoc 3.6.3 - on Sun Nov 10th 2019 + on Wed Nov 13th 2019 using the DocStrap template. diff --git a/docs/quicksearch.html b/docs/quicksearch.html index bb2130e..a8ae974 100644 --- a/docs/quicksearch.html +++ b/docs/quicksearch.html @@ -7,7 +7,7 @@