node-poweredup 10.0.0 → 10.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -1
- package/dist/browser/poweredup.js +6193 -0
- package/dist/browser/poweredup.js.map +7 -0
- package/dist/consts.d.ts +40 -0
- package/dist/consts.d.ts.map +1 -1
- package/dist/consts.js +42 -0
- package/dist/consts.js.map +1 -1
- package/dist/devices/absolutemotor.d.ts +8 -6
- package/dist/devices/absolutemotor.d.ts.map +1 -1
- package/dist/devices/absolutemotor.js +24 -31
- package/dist/devices/absolutemotor.js.map +1 -1
- package/dist/devices/basicmotor.d.ts +11 -10
- package/dist/devices/basicmotor.d.ts.map +1 -1
- package/dist/devices/basicmotor.js +16 -22
- package/dist/devices/basicmotor.js.map +1 -1
- package/dist/devices/colordistancesensor.d.ts +13 -12
- package/dist/devices/colordistancesensor.d.ts.map +1 -1
- package/dist/devices/colordistancesensor.js +25 -31
- package/dist/devices/colordistancesensor.js.map +1 -1
- package/dist/devices/device.d.ts +15 -6
- package/dist/devices/device.d.ts.map +1 -1
- package/dist/devices/device.js +209 -21
- package/dist/devices/device.js.map +1 -1
- package/dist/devices/duplotrainbasespeaker.d.ts +4 -4
- package/dist/devices/duplotrainbasespeaker.d.ts.map +1 -1
- package/dist/devices/duplotrainbasespeaker.js +5 -8
- package/dist/devices/duplotrainbasespeaker.js.map +1 -1
- package/dist/devices/hubled.d.ts +5 -4
- package/dist/devices/hubled.d.ts.map +1 -1
- package/dist/devices/hubled.js +24 -24
- package/dist/devices/hubled.js.map +1 -1
- package/dist/devices/light.d.ts +7 -4
- package/dist/devices/light.d.ts.map +1 -1
- package/dist/devices/light.js +11 -17
- package/dist/devices/light.js.map +1 -1
- package/dist/devices/piezobuzzer.d.ts +3 -2
- package/dist/devices/piezobuzzer.d.ts.map +1 -1
- package/dist/devices/piezobuzzer.js +2 -2
- package/dist/devices/piezobuzzer.js.map +1 -1
- package/dist/devices/tachomotor.d.ts +14 -8
- package/dist/devices/tachomotor.d.ts.map +1 -1
- package/dist/devices/tachomotor.js +50 -56
- package/dist/devices/tachomotor.js.map +1 -1
- package/dist/devices/technic3x3colorlightmatrix.d.ts +3 -2
- package/dist/devices/technic3x3colorlightmatrix.d.ts.map +1 -1
- package/dist/devices/technic3x3colorlightmatrix.js +20 -23
- package/dist/devices/technic3x3colorlightmatrix.js.map +1 -1
- package/dist/devices/techniccolorsensor.d.ts +9 -4
- package/dist/devices/techniccolorsensor.d.ts.map +1 -1
- package/dist/devices/techniccolorsensor.js +99 -8
- package/dist/devices/techniccolorsensor.js.map +1 -1
- package/dist/devices/technicdistancesensor.d.ts +1 -1
- package/dist/devices/technicdistancesensor.js +1 -1
- package/dist/devices/technicmediumhubtiltsensor.d.ts +7 -6
- package/dist/devices/technicmediumhubtiltsensor.d.ts.map +1 -1
- package/dist/devices/technicmediumhubtiltsensor.js +9 -18
- package/dist/devices/technicmediumhubtiltsensor.js.map +1 -1
- package/dist/devices/tiltsensor.d.ts +4 -1
- package/dist/devices/tiltsensor.d.ts.map +1 -1
- package/dist/devices/tiltsensor.js +84 -3
- package/dist/devices/tiltsensor.js.map +1 -1
- package/dist/hubs/basehub.d.ts +1 -0
- package/dist/hubs/basehub.d.ts.map +1 -1
- package/dist/hubs/basehub.js +17 -0
- package/dist/hubs/basehub.js.map +1 -1
- package/dist/hubs/lpf2hub.d.ts +1 -0
- package/dist/hubs/lpf2hub.d.ts.map +1 -1
- package/dist/hubs/lpf2hub.js +11 -0
- package/dist/hubs/lpf2hub.js.map +1 -1
- package/dist/portoutputcommand.d.ts +13 -0
- package/dist/portoutputcommand.d.ts.map +1 -0
- package/dist/portoutputcommand.js +30 -0
- package/dist/portoutputcommand.js.map +1 -0
- package/dist/portoutputsleep.d.ts +6 -0
- package/dist/portoutputsleep.d.ts.map +1 -0
- package/dist/portoutputsleep.js +10 -0
- package/dist/portoutputsleep.js.map +1 -0
- package/dist/utils.d.ts +1 -3
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +13 -19
- package/dist/utils.js.map +1 -1
- package/package.json +1 -1
- package/src/consts.ts +44 -0
- package/src/devices/absolutemotor.ts +24 -31
- package/src/devices/basicmotor.ts +16 -22
- package/src/devices/colordistancesensor.ts +23 -29
- package/src/devices/device.ts +198 -20
- package/src/devices/duplotrainbasespeaker.ts +5 -8
- package/src/devices/hubled.ts +22 -22
- package/src/devices/light.ts +11 -18
- package/src/devices/piezobuzzer.ts +3 -3
- package/src/devices/tachomotor.ts +47 -53
- package/src/devices/technic3x3colorlightmatrix.ts +20 -23
- package/src/devices/techniccolorsensor.ts +102 -10
- package/src/devices/technicdistancesensor.ts +1 -1
- package/src/devices/technicmediumhubtiltsensor.ts +9 -18
- package/src/devices/tiltsensor.ts +85 -5
- package/src/hubs/basehub.ts +18 -0
- package/src/hubs/lpf2hub.ts +12 -5
- package/src/portoutputcommand.ts +37 -0
- package/src/portoutputsleep.ts +11 -0
- package/src/utils.ts +14 -19
- package/tsconfig.tsbuildinfo +1 -1
- package/webpack.config.cjs +35 -0
- package/dist/node/color.d.ts +0 -6
- package/dist/node/color.js +0 -15
- package/dist/node/color.js.map +0 -1
- package/dist/node/commands.d.ts +0 -299
- package/dist/node/commands.js +0 -672
- package/dist/node/commands.js.map +0 -1
- package/dist/node/connection.d.ts +0 -187
- package/dist/node/connection.js +0 -478
- package/dist/node/connection.js.map +0 -1
- package/dist/node/consts.d.ts +0 -644
- package/dist/node/consts.js +0 -675
- package/dist/node/consts.js.map +0 -1
- package/dist/node/devices/absolutemotor.d.ts +0 -43
- package/dist/node/devices/absolutemotor.js +0 -118
- package/dist/node/devices/absolutemotor.js.map +0 -1
- package/dist/node/devices/basicmotor.d.ts +0 -40
- package/dist/node/devices/basicmotor.js +0 -61
- package/dist/node/devices/basicmotor.js.map +0 -1
- package/dist/node/devices/colordistancesensor.d.ts +0 -79
- package/dist/node/devices/colordistancesensor.js +0 -284
- package/dist/node/devices/colordistancesensor.js.map +0 -1
- package/dist/node/devices/currentsensor.d.ts +0 -16
- package/dist/node/devices/currentsensor.js +0 -55
- package/dist/node/devices/currentsensor.js.map +0 -1
- package/dist/node/devices/device.d.ts +0 -71
- package/dist/node/devices/device.js +0 -162
- package/dist/node/devices/device.js.map +0 -1
- package/dist/node/devices/duplotrainbasecolorsensor.d.ts +0 -19
- package/dist/node/devices/duplotrainbasecolorsensor.js +0 -77
- package/dist/node/devices/duplotrainbasecolorsensor.js.map +0 -1
- package/dist/node/devices/duplotrainbasemotor.d.ts +0 -9
- package/dist/node/devices/duplotrainbasemotor.js +0 -12
- package/dist/node/devices/duplotrainbasemotor.js.map +0 -1
- package/dist/node/devices/duplotrainbasespeaker.d.ts +0 -28
- package/dist/node/devices/duplotrainbasespeaker.js +0 -40
- package/dist/node/devices/duplotrainbasespeaker.js.map +0 -1
- package/dist/node/devices/duplotrainbasespeedometer.d.ts +0 -16
- package/dist/node/devices/duplotrainbasespeedometer.js +0 -34
- package/dist/node/devices/duplotrainbasespeedometer.js.map +0 -1
- package/dist/node/devices/hubled.d.ts +0 -29
- package/dist/node/devices/hubled.js +0 -60
- package/dist/node/devices/hubled.js.map +0 -1
- package/dist/node/devices/index.d.ts +0 -14
- package/dist/node/devices/index.js +0 -154
- package/dist/node/devices/index.js.map +0 -1
- package/dist/node/devices/led.d.ts +0 -140
- package/dist/node/devices/led.js +0 -295
- package/dist/node/devices/led.js.map +0 -1
- package/dist/node/devices/light.d.ts +0 -25
- package/dist/node/devices/light.js +0 -46
- package/dist/node/devices/light.js.map +0 -1
- package/dist/node/devices/marioaccelerometer.d.ts +0 -17
- package/dist/node/devices/marioaccelerometer.js +0 -50
- package/dist/node/devices/marioaccelerometer.js.map +0 -1
- package/dist/node/devices/mariobarcodesensor.d.ts +0 -17
- package/dist/node/devices/mariobarcodesensor.js +0 -58
- package/dist/node/devices/mariobarcodesensor.js.map +0 -1
- package/dist/node/devices/mariopantssensor.d.ts +0 -16
- package/dist/node/devices/mariopantssensor.js +0 -34
- package/dist/node/devices/mariopantssensor.js.map +0 -1
- package/dist/node/devices/mediumlinearmotor.d.ts +0 -9
- package/dist/node/devices/mediumlinearmotor.js +0 -12
- package/dist/node/devices/mediumlinearmotor.js.map +0 -1
- package/dist/node/devices/motionsensor.d.ts +0 -16
- package/dist/node/devices/motionsensor.js +0 -38
- package/dist/node/devices/motionsensor.js.map +0 -1
- package/dist/node/devices/motor.d.ts +0 -182
- package/dist/node/devices/motor.js +0 -367
- package/dist/node/devices/motor.js.map +0 -1
- package/dist/node/devices/movehubmediumlinearmotor.d.ts +0 -9
- package/dist/node/devices/movehubmediumlinearmotor.js +0 -12
- package/dist/node/devices/movehubmediumlinearmotor.js.map +0 -1
- package/dist/node/devices/movehubtiltsensor.d.ts +0 -16
- package/dist/node/devices/movehubtiltsensor.js +0 -36
- package/dist/node/devices/movehubtiltsensor.js.map +0 -1
- package/dist/node/devices/piezobuzzer.d.ts +0 -17
- package/dist/node/devices/piezobuzzer.js +0 -28
- package/dist/node/devices/piezobuzzer.js.map +0 -1
- package/dist/node/devices/remotecontrolbutton.d.ts +0 -19
- package/dist/node/devices/remotecontrolbutton.js +0 -40
- package/dist/node/devices/remotecontrolbutton.js.map +0 -1
- package/dist/node/devices/sensor.d.ts +0 -305
- package/dist/node/devices/sensor.js +0 -662
- package/dist/node/devices/sensor.js.map +0 -1
- package/dist/node/devices/simplemediumlinearmotor.d.ts +0 -9
- package/dist/node/devices/simplemediumlinearmotor.js +0 -12
- package/dist/node/devices/simplemediumlinearmotor.js.map +0 -1
- package/dist/node/devices/tachomotor.d.ts +0 -70
- package/dist/node/devices/tachomotor.js +0 -167
- package/dist/node/devices/tachomotor.js.map +0 -1
- package/dist/node/devices/technic3x3colorlightmatrix.d.ts +0 -22
- package/dist/node/devices/technic3x3colorlightmatrix.js +0 -54
- package/dist/node/devices/technic3x3colorlightmatrix.js.map +0 -1
- package/dist/node/devices/techniccolorsensor.d.ts +0 -27
- package/dist/node/devices/techniccolorsensor.js +0 -72
- package/dist/node/devices/techniccolorsensor.js.map +0 -1
- package/dist/node/devices/technicdistancesensor.d.ts +0 -27
- package/dist/node/devices/technicdistancesensor.js +0 -58
- package/dist/node/devices/technicdistancesensor.js.map +0 -1
- package/dist/node/devices/technicforcesensor.d.ts +0 -18
- package/dist/node/devices/technicforcesensor.js +0 -58
- package/dist/node/devices/technicforcesensor.js.map +0 -1
- package/dist/node/devices/techniclargeangularmotor.d.ts +0 -12
- package/dist/node/devices/techniclargeangularmotor.js +0 -12
- package/dist/node/devices/techniclargeangularmotor.js.map +0 -1
- package/dist/node/devices/techniclargelinearmotor.d.ts +0 -9
- package/dist/node/devices/techniclargelinearmotor.js +0 -12
- package/dist/node/devices/techniclargelinearmotor.js.map +0 -1
- package/dist/node/devices/technicmediumangularmotor.d.ts +0 -12
- package/dist/node/devices/technicmediumangularmotor.js +0 -12
- package/dist/node/devices/technicmediumangularmotor.js.map +0 -1
- package/dist/node/devices/technicmediumhubaccelerometersensor.d.ts +0 -16
- package/dist/node/devices/technicmediumhubaccelerometersensor.js +0 -38
- package/dist/node/devices/technicmediumhubaccelerometersensor.js.map +0 -1
- package/dist/node/devices/technicmediumhubgyrosensor.d.ts +0 -16
- package/dist/node/devices/technicmediumhubgyrosensor.js +0 -38
- package/dist/node/devices/technicmediumhubgyrosensor.js.map +0 -1
- package/dist/node/devices/technicmediumhubtiltsensor.d.ts +0 -40
- package/dist/node/devices/technicmediumhubtiltsensor.js +0 -106
- package/dist/node/devices/technicmediumhubtiltsensor.js.map +0 -1
- package/dist/node/devices/technicsmallangularmotor.d.ts +0 -12
- package/dist/node/devices/technicsmallangularmotor.js +0 -12
- package/dist/node/devices/technicsmallangularmotor.js.map +0 -1
- package/dist/node/devices/technicxlargelinearmotor.d.ts +0 -9
- package/dist/node/devices/technicxlargelinearmotor.js +0 -12
- package/dist/node/devices/technicxlargelinearmotor.js.map +0 -1
- package/dist/node/devices/tiltsensor.d.ts +0 -16
- package/dist/node/devices/tiltsensor.js +0 -36
- package/dist/node/devices/tiltsensor.js.map +0 -1
- package/dist/node/devices/trainmotor.d.ts +0 -9
- package/dist/node/devices/trainmotor.js +0 -12
- package/dist/node/devices/trainmotor.js.map +0 -1
- package/dist/node/devices/voltagesensor.d.ts +0 -16
- package/dist/node/devices/voltagesensor.js +0 -59
- package/dist/node/devices/voltagesensor.js.map +0 -1
- package/dist/node/hub.d.ts +0 -291
- package/dist/node/hub.js +0 -778
- package/dist/node/hub.js.map +0 -1
- package/dist/node/hubs/basehub.d.ts +0 -162
- package/dist/node/hubs/basehub.js +0 -392
- package/dist/node/hubs/basehub.js.map +0 -1
- package/dist/node/hubs/duplotrainbase.d.ts +0 -17
- package/dist/node/hubs/duplotrainbase.js +0 -35
- package/dist/node/hubs/duplotrainbase.js.map +0 -1
- package/dist/node/hubs/hub.d.ts +0 -19
- package/dist/node/hubs/hub.js +0 -44
- package/dist/node/hubs/hub.js.map +0 -1
- package/dist/node/hubs/lpf2hub.d.ts +0 -48
- package/dist/node/hubs/lpf2hub.js +0 -314
- package/dist/node/hubs/lpf2hub.js.map +0 -1
- package/dist/node/hubs/mario.d.ts +0 -17
- package/dist/node/hubs/mario.js +0 -31
- package/dist/node/hubs/mario.js.map +0 -1
- package/dist/node/hubs/movehub.d.ts +0 -18
- package/dist/node/hubs/movehub.js +0 -46
- package/dist/node/hubs/movehub.js.map +0 -1
- package/dist/node/hubs/remotecontrol.d.ts +0 -17
- package/dist/node/hubs/remotecontrol.js +0 -37
- package/dist/node/hubs/remotecontrol.js.map +0 -1
- package/dist/node/hubs/technicmediumhub.d.ts +0 -17
- package/dist/node/hubs/technicmediumhub.js +0 -42
- package/dist/node/hubs/technicmediumhub.js.map +0 -1
- package/dist/node/hubs/technicsmallhub.d.ts +0 -18
- package/dist/node/hubs/technicsmallhub.js +0 -41
- package/dist/node/hubs/technicsmallhub.js.map +0 -1
- package/dist/node/hubs/wedo2smarthub.d.ts +0 -40
- package/dist/node/hubs/wedo2smarthub.js +0 -188
- package/dist/node/hubs/wedo2smarthub.js.map +0 -1
- package/dist/node/index-browser.d.ts +0 -1
- package/dist/node/index-browser.js +0 -96
- package/dist/node/index-browser.js.map +0 -1
- package/dist/node/index-node.d.ts +0 -49
- package/dist/node/index-node.js +0 -50
- package/dist/node/index-node.js.map +0 -1
- package/dist/node/index.d.ts +0 -31
- package/dist/node/index.js +0 -93
- package/dist/node/index.js.map +0 -1
- package/dist/node/index.mjs +0 -0
- package/dist/node/interfaces.d.ts +0 -23
- package/dist/node/interfaces.js +0 -2
- package/dist/node/interfaces.js.map +0 -1
- package/dist/node/nobleabstraction.d.ts +0 -26
- package/dist/node/nobleabstraction.js +0 -123
- package/dist/node/nobleabstraction.js.map +0 -1
- package/dist/node/poweredup-browser.d.ts +0 -50
- package/dist/node/poweredup-browser.js +0 -216
- package/dist/node/poweredup-browser.js.map +0 -1
- package/dist/node/poweredup-node.d.ts +0 -54
- package/dist/node/poweredup-node.js +0 -173
- package/dist/node/poweredup-node.js.map +0 -1
- package/dist/node/poweredup.d.ts +0 -83
- package/dist/node/poweredup.js +0 -542
- package/dist/node/poweredup.js.map +0 -1
- package/dist/node/protocol-wedo.d.ts +0 -158
- package/dist/node/protocol-wedo.js +0 -342
- package/dist/node/protocol-wedo.js.map +0 -1
- package/dist/node/protocol.d.ts +0 -340
- package/dist/node/protocol.js +0 -730
- package/dist/node/protocol.js.map +0 -1
- package/dist/node/types.d.ts +0 -408
- package/dist/node/types.js +0 -291
- package/dist/node/types.js.map +0 -1
- package/dist/node/utils.d.ts +0 -12
- package/dist/node/utils.js +0 -90
- package/dist/node/utils.js.map +0 -1
- package/dist/node/webbleabstraction.d.ts +0 -26
- package/dist/node/webbleabstraction.js +0 -104
- package/dist/node/webbleabstraction.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
package/dist/node/index.js
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* node-poweredup
|
|
4
|
-
*
|
|
5
|
-
* A Javascript module to interface with LEGO Powered Up components.
|
|
6
|
-
*/
|
|
7
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8
|
-
if (k2 === undefined) k2 = k;
|
|
9
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
10
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
11
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
12
|
-
}
|
|
13
|
-
Object.defineProperty(o, k2, desc);
|
|
14
|
-
}) : (function(o, m, k, k2) {
|
|
15
|
-
if (k2 === undefined) k2 = k;
|
|
16
|
-
o[k2] = m[k];
|
|
17
|
-
}));
|
|
18
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
19
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
20
|
-
}) : function(o, v) {
|
|
21
|
-
o["default"] = v;
|
|
22
|
-
});
|
|
23
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
24
|
-
var ownKeys = function(o) {
|
|
25
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
26
|
-
var ar = [];
|
|
27
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
28
|
-
return ar;
|
|
29
|
-
};
|
|
30
|
-
return ownKeys(o);
|
|
31
|
-
};
|
|
32
|
-
return function (mod) {
|
|
33
|
-
if (mod && mod.__esModule) return mod;
|
|
34
|
-
var result = {};
|
|
35
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
36
|
-
__setModuleDefault(result, mod);
|
|
37
|
-
return result;
|
|
38
|
-
};
|
|
39
|
-
})();
|
|
40
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
41
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
42
|
-
};
|
|
43
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
44
|
-
exports.commands = exports.createHub = exports.DuploTrainBase = exports.RemoteControl = exports.TechnicMediumHub = exports.MoveHub = exports.WeDo2Hub = exports.LWP3Hub = exports.BaseHub = exports.PoweredUpWeb = exports.PoweredUp = void 0;
|
|
45
|
-
const poweredup_1 = require("./poweredup");
|
|
46
|
-
const Consts = __importStar(require("./types"));
|
|
47
|
-
// ============================================================================
|
|
48
|
-
// Re-export everything
|
|
49
|
-
// ============================================================================
|
|
50
|
-
// PoweredUp scanner classes
|
|
51
|
-
var poweredup_2 = require("./poweredup");
|
|
52
|
-
Object.defineProperty(exports, "PoweredUp", { enumerable: true, get: function () { return poweredup_2.PoweredUp; } });
|
|
53
|
-
Object.defineProperty(exports, "PoweredUpWeb", { enumerable: true, get: function () { return poweredup_2.PoweredUpWeb; } });
|
|
54
|
-
// Types and Constants
|
|
55
|
-
__exportStar(require("./types"), exports);
|
|
56
|
-
// Hub classes
|
|
57
|
-
var hub_1 = require("./hub");
|
|
58
|
-
Object.defineProperty(exports, "BaseHub", { enumerable: true, get: function () { return hub_1.BaseHub; } });
|
|
59
|
-
Object.defineProperty(exports, "LWP3Hub", { enumerable: true, get: function () { return hub_1.LWP3Hub; } });
|
|
60
|
-
Object.defineProperty(exports, "WeDo2Hub", { enumerable: true, get: function () { return hub_1.WeDo2Hub; } });
|
|
61
|
-
Object.defineProperty(exports, "MoveHub", { enumerable: true, get: function () { return hub_1.MoveHub; } });
|
|
62
|
-
Object.defineProperty(exports, "TechnicMediumHub", { enumerable: true, get: function () { return hub_1.TechnicMediumHub; } });
|
|
63
|
-
Object.defineProperty(exports, "RemoteControl", { enumerable: true, get: function () { return hub_1.RemoteControl; } });
|
|
64
|
-
Object.defineProperty(exports, "DuploTrainBase", { enumerable: true, get: function () { return hub_1.DuploTrainBase; } });
|
|
65
|
-
Object.defineProperty(exports, "createHub", { enumerable: true, get: function () { return hub_1.createHub; } });
|
|
66
|
-
// Device classes
|
|
67
|
-
__exportStar(require("./devices"), exports);
|
|
68
|
-
// Protocol (for advanced usage)
|
|
69
|
-
__exportStar(require("./protocol"), exports);
|
|
70
|
-
// Commands (for advanced usage)
|
|
71
|
-
exports.commands = __importStar(require("./commands"));
|
|
72
|
-
// ============================================================================
|
|
73
|
-
// Default Export
|
|
74
|
-
// ============================================================================
|
|
75
|
-
/**
|
|
76
|
-
* Default export - PoweredUp class with Consts attached for backward compatibility
|
|
77
|
-
*
|
|
78
|
-
* Usage (ESM):
|
|
79
|
-
* import PoweredUP from "node-poweredup";
|
|
80
|
-
* const poweredUP = new PoweredUP();
|
|
81
|
-
* const led = await hub.waitForDeviceByType(PoweredUP.Consts.DeviceType.HUB_LED);
|
|
82
|
-
*
|
|
83
|
-
* Usage (CommonJS):
|
|
84
|
-
* const PoweredUP = require("node-poweredup");
|
|
85
|
-
* const poweredUP = new PoweredUP.PoweredUp();
|
|
86
|
-
*/
|
|
87
|
-
const PoweredUpDefault = Object.assign(poweredup_1.PoweredUp, {
|
|
88
|
-
Consts,
|
|
89
|
-
PoweredUp: poweredup_1.PoweredUp,
|
|
90
|
-
PoweredUpWeb: poweredup_1.PoweredUpWeb,
|
|
91
|
-
});
|
|
92
|
-
exports.default = PoweredUpDefault;
|
|
93
|
-
//# sourceMappingURL=index.js.map
|
package/dist/node/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,2CAAsD;AACtD,gDAAkC;AAElC,+EAA+E;AAC/E,uBAAuB;AACvB,+EAA+E;AAE/E,4BAA4B;AAC5B,yCAAsD;AAA7C,sGAAA,SAAS,OAAA;AAAE,yGAAA,YAAY,OAAA;AAEhC,sBAAsB;AACtB,0CAAwB;AAExB,cAAc;AACd,6BASe;AARX,8FAAA,OAAO,OAAA;AACP,8FAAA,OAAO,OAAA;AACP,+FAAA,QAAQ,OAAA;AACR,8FAAA,OAAO,OAAA;AACP,uGAAA,gBAAgB,OAAA;AAChB,oGAAA,aAAa,OAAA;AACb,qGAAA,cAAc,OAAA;AACd,gGAAA,SAAS,OAAA;AAGb,iBAAiB;AACjB,4CAA0B;AAE1B,gCAAgC;AAChC,6CAA2B;AAE3B,gCAAgC;AAChC,uDAAuC;AAGvC,+EAA+E;AAC/E,iBAAiB;AACjB,+EAA+E;AAE/E;;;;;;;;;;;GAWG;AACH,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,CAAC,qBAAS,EAAE;IAC9C,MAAM;IACN,SAAS,EAAT,qBAAS;IACT,YAAY,EAAZ,wBAAY;CACf,CAAC,CAAC;AAEH,kBAAe,gBAAgB,CAAC"}
|
package/dist/node/index.mjs
DELETED
|
File without changes
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { EventEmitter } from "events";
|
|
2
|
-
import * as Consts from "./consts";
|
|
3
|
-
export interface IBLEAbstraction extends EventEmitter {
|
|
4
|
-
uuid: string;
|
|
5
|
-
name: string;
|
|
6
|
-
connecting: boolean;
|
|
7
|
-
connected: boolean;
|
|
8
|
-
connect: () => Promise<void>;
|
|
9
|
-
disconnect: () => Promise<void>;
|
|
10
|
-
discoverCharacteristicsForService: (uuid: string) => Promise<void>;
|
|
11
|
-
subscribeToCharacteristic: (uuid: string, callback: (data: Buffer) => void) => void;
|
|
12
|
-
addToCharacteristicMailbox: (uuid: string, data: Buffer) => void;
|
|
13
|
-
readFromCharacteristic: (uuid: string, callback: (err: Error | null, data: Buffer | null) => void) => void;
|
|
14
|
-
writeToCharacteristic: (uuid: string, data: Buffer) => Promise<void>;
|
|
15
|
-
}
|
|
16
|
-
export interface IDeviceInterface extends EventEmitter {
|
|
17
|
-
type: Consts.HubType;
|
|
18
|
-
getPortNameForPortId: (portId: number) => string | undefined;
|
|
19
|
-
send: (message: Buffer, uuid: string) => Promise<void>;
|
|
20
|
-
subscribe: (portId: number, deviceType: number, mode: number) => void;
|
|
21
|
-
isPortVirtual: (portId: number) => boolean;
|
|
22
|
-
sleep: (delay: number) => Promise<any>;
|
|
23
|
-
}
|
package/dist/node/interfaces.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../src/interfaces.ts"],"names":[],"mappings":""}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { EventEmitter } from "events";
|
|
2
|
-
import { IBLEAbstraction } from "./interfaces";
|
|
3
|
-
export declare class NobleDevice extends EventEmitter implements IBLEAbstraction {
|
|
4
|
-
private _noblePeripheral;
|
|
5
|
-
private _uuid;
|
|
6
|
-
private _name;
|
|
7
|
-
private _listeners;
|
|
8
|
-
private _characteristics;
|
|
9
|
-
private _queue;
|
|
10
|
-
private _mailbox;
|
|
11
|
-
private _connected;
|
|
12
|
-
private _connecting;
|
|
13
|
-
constructor(device: any);
|
|
14
|
-
get uuid(): string;
|
|
15
|
-
get name(): string;
|
|
16
|
-
get connecting(): boolean;
|
|
17
|
-
get connected(): boolean;
|
|
18
|
-
connect(): Promise<void>;
|
|
19
|
-
disconnect(): Promise<void>;
|
|
20
|
-
discoverCharacteristicsForService(uuid: string): Promise<void>;
|
|
21
|
-
subscribeToCharacteristic(uuid: string, callback: (data: Buffer) => void): void;
|
|
22
|
-
addToCharacteristicMailbox(uuid: string, data: Buffer): void;
|
|
23
|
-
readFromCharacteristic(uuid: string, callback: (err: string | null, data: Buffer | null) => void): void;
|
|
24
|
-
writeToCharacteristic(uuid: string, data: Buffer): Promise<void>;
|
|
25
|
-
private _sanitizeUUID;
|
|
26
|
-
}
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import { createRequire as _createRequire } from "module";
|
|
2
|
-
const __require = _createRequire(import.meta.url);
|
|
3
|
-
const Debug = __require("debug");
|
|
4
|
-
import { EventEmitter } from "events";
|
|
5
|
-
const debug = Debug("bledevice");
|
|
6
|
-
export class NobleDevice extends EventEmitter {
|
|
7
|
-
constructor(device) {
|
|
8
|
-
super();
|
|
9
|
-
this._name = "";
|
|
10
|
-
this._listeners = {};
|
|
11
|
-
this._characteristics = {};
|
|
12
|
-
this._queue = Promise.resolve();
|
|
13
|
-
this._mailbox = [];
|
|
14
|
-
this._connected = false;
|
|
15
|
-
this._connecting = false;
|
|
16
|
-
this._noblePeripheral = device;
|
|
17
|
-
this._uuid = device.uuid;
|
|
18
|
-
device.on("disconnect", () => {
|
|
19
|
-
this._connecting = false;
|
|
20
|
-
this._connected = false;
|
|
21
|
-
this.emit("disconnect");
|
|
22
|
-
});
|
|
23
|
-
// NK: This hack allows LPF2.0 hubs to send a second advertisement packet consisting of the hub name before we try to read it
|
|
24
|
-
setTimeout(() => {
|
|
25
|
-
this._name = device.advertisement.localName;
|
|
26
|
-
this.emit("discoverComplete");
|
|
27
|
-
}, 1000);
|
|
28
|
-
}
|
|
29
|
-
get uuid() {
|
|
30
|
-
return this._uuid;
|
|
31
|
-
}
|
|
32
|
-
get name() {
|
|
33
|
-
return this._name;
|
|
34
|
-
}
|
|
35
|
-
get connecting() {
|
|
36
|
-
return this._connecting;
|
|
37
|
-
}
|
|
38
|
-
get connected() {
|
|
39
|
-
return this._connected;
|
|
40
|
-
}
|
|
41
|
-
connect() {
|
|
42
|
-
return new Promise((resolve, reject) => {
|
|
43
|
-
this._connecting = true;
|
|
44
|
-
this._noblePeripheral.connect((err) => {
|
|
45
|
-
if (err) {
|
|
46
|
-
return reject(err);
|
|
47
|
-
}
|
|
48
|
-
this._connecting = false;
|
|
49
|
-
this._connected = true;
|
|
50
|
-
return resolve();
|
|
51
|
-
});
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
disconnect() {
|
|
55
|
-
return new Promise((resolve) => {
|
|
56
|
-
this._noblePeripheral.disconnect();
|
|
57
|
-
this._connecting = false;
|
|
58
|
-
this._connected = false;
|
|
59
|
-
return resolve();
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
discoverCharacteristicsForService(uuid) {
|
|
63
|
-
return new Promise(async (discoverResolve, discoverReject) => {
|
|
64
|
-
uuid = this._sanitizeUUID(uuid);
|
|
65
|
-
this._noblePeripheral.discoverServices([uuid], (err, services) => {
|
|
66
|
-
if (err) {
|
|
67
|
-
return discoverReject(err);
|
|
68
|
-
}
|
|
69
|
-
debug("Service/characteristic discovery started");
|
|
70
|
-
const servicePromises = [];
|
|
71
|
-
services.forEach((service) => {
|
|
72
|
-
servicePromises.push(new Promise((resolve) => {
|
|
73
|
-
service.discoverCharacteristics([], (err, characteristics) => {
|
|
74
|
-
characteristics.forEach((characteristic) => {
|
|
75
|
-
this._characteristics[characteristic.uuid] = characteristic;
|
|
76
|
-
});
|
|
77
|
-
return resolve();
|
|
78
|
-
});
|
|
79
|
-
}));
|
|
80
|
-
});
|
|
81
|
-
Promise.all(servicePromises).then(() => {
|
|
82
|
-
debug("Service/characteristic discovery finished");
|
|
83
|
-
return discoverResolve();
|
|
84
|
-
});
|
|
85
|
-
});
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
subscribeToCharacteristic(uuid, callback) {
|
|
89
|
-
uuid = this._sanitizeUUID(uuid);
|
|
90
|
-
this._characteristics[uuid].on("data", (data) => {
|
|
91
|
-
return callback(data);
|
|
92
|
-
});
|
|
93
|
-
this._characteristics[uuid].subscribe((err) => {
|
|
94
|
-
if (err) {
|
|
95
|
-
throw new Error(err);
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
addToCharacteristicMailbox(uuid, data) {
|
|
100
|
-
this._mailbox.push(data);
|
|
101
|
-
}
|
|
102
|
-
readFromCharacteristic(uuid, callback) {
|
|
103
|
-
uuid = this._sanitizeUUID(uuid);
|
|
104
|
-
this._characteristics[uuid].read((err, data) => {
|
|
105
|
-
return callback(err, data);
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
writeToCharacteristic(uuid, data) {
|
|
109
|
-
return new Promise((resolve, reject) => {
|
|
110
|
-
uuid = this._sanitizeUUID(uuid);
|
|
111
|
-
this._characteristics[uuid].write(data, false, (error) => {
|
|
112
|
-
if (error) {
|
|
113
|
-
return reject(error);
|
|
114
|
-
}
|
|
115
|
-
return resolve();
|
|
116
|
-
});
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
_sanitizeUUID(uuid) {
|
|
120
|
-
return uuid.replace(/-/g, "");
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
//# sourceMappingURL=nobleabstraction.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"nobleabstraction.js","sourceRoot":"","sources":["../../src/nobleabstraction.ts"],"names":[],"mappings":";;AAEA,iCAAgC;AAChC,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEtC,MAAM,KAAK,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC;AAGjC,MAAM,OAAO,WAAY,SAAQ,YAAY;IAiBzC,YAAa,MAAW;QACpB,KAAK,EAAE,CAAC;QAbJ,UAAK,GAAW,EAAE,CAAC;QAEnB,eAAU,GAA0B,EAAE,CAAC;QACvC,qBAAgB,GAAqC,EAAE,CAAC;QAExD,WAAM,GAAiB,OAAO,CAAC,OAAO,EAAE,CAAC;QACzC,aAAQ,GAAa,EAAE,CAAC;QAExB,eAAU,GAAY,KAAK,CAAC;QAC5B,gBAAW,GAAY,KAAK,CAAC;QAKjC,IAAI,CAAC,gBAAgB,GAAG,MAAM,CAAC;QAC/B,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC;QACzB,MAAM,CAAC,EAAE,CAAC,YAAY,EAAE,GAAG,EAAE;YACzB,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC;YACzB,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;YACxB,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QAC5B,CAAC,CAAC,CAAC;QACH,6HAA6H;QAC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AO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IAClC,CAAC;CAGJ"}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { EventEmitter } from "events";
|
|
2
|
-
/**
|
|
3
|
-
* @class PoweredUP
|
|
4
|
-
* @extends EventEmitter
|
|
5
|
-
*/
|
|
6
|
-
export declare class PoweredUP extends EventEmitter {
|
|
7
|
-
private _connectedHubs;
|
|
8
|
-
constructor();
|
|
9
|
-
/**
|
|
10
|
-
* Begin scanning for Powered UP Hub devices.
|
|
11
|
-
* @method PoweredUP#scan
|
|
12
|
-
*/
|
|
13
|
-
scan(): Promise<boolean>;
|
|
14
|
-
/**
|
|
15
|
-
* Retrieve a list of Powered UP Hubs.
|
|
16
|
-
* @method PoweredUP#getHubs
|
|
17
|
-
* @returns {BaseHub[]}
|
|
18
|
-
*/
|
|
19
|
-
getHubs(): BaseHub[];
|
|
20
|
-
/**
|
|
21
|
-
* Retrieve a Powered UP Hub by UUID.
|
|
22
|
-
* @method PoweredUP#getHubByUUID
|
|
23
|
-
* @param {string} uuid
|
|
24
|
-
* @returns {BaseHub | null}
|
|
25
|
-
*/
|
|
26
|
-
getHubByUUID(uuid: string): BaseHub;
|
|
27
|
-
/**
|
|
28
|
-
* Retrieve a Powered UP Hub by primary MAC address.
|
|
29
|
-
* @method PoweredUP#getHubByPrimaryMACAddress
|
|
30
|
-
* @param {string} address
|
|
31
|
-
* @returns {BaseHub}
|
|
32
|
-
*/
|
|
33
|
-
getHubByPrimaryMACAddress(address: string): BaseHub;
|
|
34
|
-
/**
|
|
35
|
-
* Retrieve a list of Powered UP Hub by name.
|
|
36
|
-
* @method PoweredUP#getHubsByName
|
|
37
|
-
* @param {string} name
|
|
38
|
-
* @returns {BaseHub[]}
|
|
39
|
-
*/
|
|
40
|
-
getHubsByName(name: string): BaseHub[];
|
|
41
|
-
/**
|
|
42
|
-
* Retrieve a list of Powered UP Hub by type.
|
|
43
|
-
* @method PoweredUP#getHubsByType
|
|
44
|
-
* @param {string} name
|
|
45
|
-
* @returns {BaseHub[]}
|
|
46
|
-
*/
|
|
47
|
-
getHubsByType(hubType: number): BaseHub[];
|
|
48
|
-
private _determineLPF2HubType;
|
|
49
|
-
private _discoveryEventHandler;
|
|
50
|
-
}
|
|
@@ -1,216 +0,0 @@
|
|
|
1
|
-
/// <reference types="web-bluetooth" />
|
|
2
|
-
import { WebBLEDevice } from "./webbleabstraction";
|
|
3
|
-
import { DuploTrainBase } from "./hubs/duplotrainbase";
|
|
4
|
-
import { Hub } from "./hubs/hub";
|
|
5
|
-
import { Mario } from "./hubs/mario";
|
|
6
|
-
import { MoveHub } from "./hubs/movehub";
|
|
7
|
-
import { RemoteControl } from "./hubs/remotecontrol";
|
|
8
|
-
import { TechnicMediumHub } from "./hubs/technicmediumhub";
|
|
9
|
-
import { WeDo2SmartHub } from "./hubs/wedo2smarthub";
|
|
10
|
-
import * as Consts from "./consts";
|
|
11
|
-
import { EventEmitter } from "events";
|
|
12
|
-
import Debug from "debug";
|
|
13
|
-
import { TechnicSmallHub } from "./hubs/technicsmallhub";
|
|
14
|
-
const debug = Debug("poweredup");
|
|
15
|
-
/**
|
|
16
|
-
* @class PoweredUP
|
|
17
|
-
* @extends EventEmitter
|
|
18
|
-
*/
|
|
19
|
-
export class PoweredUP extends EventEmitter {
|
|
20
|
-
constructor() {
|
|
21
|
-
super();
|
|
22
|
-
this._connectedHubs = {};
|
|
23
|
-
this._discoveryEventHandler = this._discoveryEventHandler.bind(this);
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Begin scanning for Powered UP Hub devices.
|
|
27
|
-
* @method PoweredUP#scan
|
|
28
|
-
*/
|
|
29
|
-
async scan() {
|
|
30
|
-
try {
|
|
31
|
-
const device = await navigator.bluetooth.requestDevice({
|
|
32
|
-
filters: [
|
|
33
|
-
{
|
|
34
|
-
services: [
|
|
35
|
-
Consts.BLEService.WEDO2_SMART_HUB
|
|
36
|
-
]
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
services: [
|
|
40
|
-
Consts.BLEService.LPF2_HUB
|
|
41
|
-
]
|
|
42
|
-
}
|
|
43
|
-
],
|
|
44
|
-
optionalServices: [
|
|
45
|
-
Consts.BLEService.WEDO2_SMART_HUB_2,
|
|
46
|
-
"battery_service",
|
|
47
|
-
"device_information"
|
|
48
|
-
]
|
|
49
|
-
});
|
|
50
|
-
// @ts-ignore
|
|
51
|
-
const server = await device.gatt.connect();
|
|
52
|
-
this._discoveryEventHandler.call(this, server);
|
|
53
|
-
return true;
|
|
54
|
-
}
|
|
55
|
-
catch (err) {
|
|
56
|
-
return false;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Retrieve a list of Powered UP Hubs.
|
|
61
|
-
* @method PoweredUP#getHubs
|
|
62
|
-
* @returns {BaseHub[]}
|
|
63
|
-
*/
|
|
64
|
-
getHubs() {
|
|
65
|
-
return Object.values(this._connectedHubs);
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Retrieve a Powered UP Hub by UUID.
|
|
69
|
-
* @method PoweredUP#getHubByUUID
|
|
70
|
-
* @param {string} uuid
|
|
71
|
-
* @returns {BaseHub | null}
|
|
72
|
-
*/
|
|
73
|
-
getHubByUUID(uuid) {
|
|
74
|
-
return this._connectedHubs[uuid];
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Retrieve a Powered UP Hub by primary MAC address.
|
|
78
|
-
* @method PoweredUP#getHubByPrimaryMACAddress
|
|
79
|
-
* @param {string} address
|
|
80
|
-
* @returns {BaseHub}
|
|
81
|
-
*/
|
|
82
|
-
getHubByPrimaryMACAddress(address) {
|
|
83
|
-
return Object.values(this._connectedHubs).filter((hub) => hub.primaryMACAddress === address)[0];
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Retrieve a list of Powered UP Hub by name.
|
|
87
|
-
* @method PoweredUP#getHubsByName
|
|
88
|
-
* @param {string} name
|
|
89
|
-
* @returns {BaseHub[]}
|
|
90
|
-
*/
|
|
91
|
-
getHubsByName(name) {
|
|
92
|
-
return Object.values(this._connectedHubs).filter((hub) => hub.name === name);
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Retrieve a list of Powered UP Hub by type.
|
|
96
|
-
* @method PoweredUP#getHubsByType
|
|
97
|
-
* @param {string} name
|
|
98
|
-
* @returns {BaseHub[]}
|
|
99
|
-
*/
|
|
100
|
-
getHubsByType(hubType) {
|
|
101
|
-
return Object.values(this._connectedHubs).filter((hub) => hub.type === hubType);
|
|
102
|
-
}
|
|
103
|
-
_determineLPF2HubType(device) {
|
|
104
|
-
return new Promise(async (resolve) => {
|
|
105
|
-
let buf = Buffer.alloc(0);
|
|
106
|
-
await device.subscribeToCharacteristic(Consts.BLECharacteristic.LPF2_ALL, (data) => {
|
|
107
|
-
buf = Buffer.concat([buf, data]);
|
|
108
|
-
while (buf[0] <= buf.length) {
|
|
109
|
-
const len = buf[0];
|
|
110
|
-
const message = buf.slice(0, len);
|
|
111
|
-
buf = buf.slice(len);
|
|
112
|
-
if (message[2] === 0x01 && message[3] === 0x0b) {
|
|
113
|
-
switch (message[5]) {
|
|
114
|
-
case Consts.BLEManufacturerData.REMOTE_CONTROL_ID:
|
|
115
|
-
resolve(Consts.HubType.REMOTE_CONTROL);
|
|
116
|
-
break;
|
|
117
|
-
case Consts.BLEManufacturerData.MOVE_HUB_ID:
|
|
118
|
-
resolve(Consts.HubType.MOVE_HUB);
|
|
119
|
-
break;
|
|
120
|
-
case Consts.BLEManufacturerData.HUB_ID:
|
|
121
|
-
resolve(Consts.HubType.HUB);
|
|
122
|
-
break;
|
|
123
|
-
case Consts.BLEManufacturerData.DUPLO_TRAIN_BASE_ID:
|
|
124
|
-
resolve(Consts.HubType.DUPLO_TRAIN_BASE);
|
|
125
|
-
break;
|
|
126
|
-
case Consts.BLEManufacturerData.TECHNIC_SMALL_HUB_ID:
|
|
127
|
-
resolve(Consts.HubType.TECHNIC_SMALL_HUB);
|
|
128
|
-
break;
|
|
129
|
-
case Consts.BLEManufacturerData.TECHNIC_MEDIUM_HUB_ID:
|
|
130
|
-
resolve(Consts.HubType.TECHNIC_MEDIUM_HUB);
|
|
131
|
-
break;
|
|
132
|
-
case Consts.BLEManufacturerData.MARIO_ID:
|
|
133
|
-
resolve(Consts.HubType.MARIO);
|
|
134
|
-
break;
|
|
135
|
-
}
|
|
136
|
-
debug("Hub type determined");
|
|
137
|
-
}
|
|
138
|
-
else {
|
|
139
|
-
debug("Stashed in mailbox (LPF2_ALL)", message);
|
|
140
|
-
device.addToCharacteristicMailbox(Consts.BLECharacteristic.LPF2_ALL, message);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
});
|
|
144
|
-
device.writeToCharacteristic(Consts.BLECharacteristic.LPF2_ALL, Buffer.from([0x05, 0x00, 0x01, 0x0b, 0x05]));
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
async _discoveryEventHandler(server) {
|
|
148
|
-
const device = new WebBLEDevice(server);
|
|
149
|
-
let hub;
|
|
150
|
-
let hubType = Consts.HubType.UNKNOWN;
|
|
151
|
-
let isLPF2Hub = false;
|
|
152
|
-
try {
|
|
153
|
-
await device.discoverCharacteristicsForService(Consts.BLEService.WEDO2_SMART_HUB);
|
|
154
|
-
hubType = Consts.HubType.WEDO2_SMART_HUB;
|
|
155
|
-
// tslint:disable-next-line
|
|
156
|
-
}
|
|
157
|
-
catch (error) { }
|
|
158
|
-
try {
|
|
159
|
-
if (hubType !== Consts.HubType.WEDO2_SMART_HUB) {
|
|
160
|
-
await device.discoverCharacteristicsForService(Consts.BLEService.LPF2_HUB);
|
|
161
|
-
isLPF2Hub = true;
|
|
162
|
-
}
|
|
163
|
-
// tslint:disable-next-line
|
|
164
|
-
}
|
|
165
|
-
catch (error) { }
|
|
166
|
-
if (isLPF2Hub) {
|
|
167
|
-
hubType = await this._determineLPF2HubType(device);
|
|
168
|
-
}
|
|
169
|
-
switch (hubType) {
|
|
170
|
-
case Consts.HubType.WEDO2_SMART_HUB:
|
|
171
|
-
hub = new WeDo2SmartHub(device);
|
|
172
|
-
break;
|
|
173
|
-
case Consts.HubType.MOVE_HUB:
|
|
174
|
-
hub = new MoveHub(device);
|
|
175
|
-
break;
|
|
176
|
-
case Consts.HubType.HUB:
|
|
177
|
-
hub = new Hub(device);
|
|
178
|
-
break;
|
|
179
|
-
case Consts.HubType.REMOTE_CONTROL:
|
|
180
|
-
hub = new RemoteControl(device);
|
|
181
|
-
break;
|
|
182
|
-
case Consts.HubType.DUPLO_TRAIN_BASE:
|
|
183
|
-
hub = new DuploTrainBase(device);
|
|
184
|
-
break;
|
|
185
|
-
case Consts.HubType.TECHNIC_SMALL_HUB:
|
|
186
|
-
hub = new TechnicSmallHub(device);
|
|
187
|
-
break;
|
|
188
|
-
case Consts.HubType.TECHNIC_MEDIUM_HUB:
|
|
189
|
-
hub = new TechnicMediumHub(device);
|
|
190
|
-
break;
|
|
191
|
-
case Consts.HubType.MARIO:
|
|
192
|
-
hub = new Mario(device);
|
|
193
|
-
break;
|
|
194
|
-
default:
|
|
195
|
-
return;
|
|
196
|
-
}
|
|
197
|
-
device.on("discoverComplete", () => {
|
|
198
|
-
hub.on("connect", () => {
|
|
199
|
-
debug(`Hub ${hub.uuid} connected`);
|
|
200
|
-
this._connectedHubs[hub.uuid] = hub;
|
|
201
|
-
});
|
|
202
|
-
hub.on("disconnect", () => {
|
|
203
|
-
debug(`Hub ${hub.uuid} disconnected`);
|
|
204
|
-
delete this._connectedHubs[hub.uuid];
|
|
205
|
-
});
|
|
206
|
-
debug(`Hub ${hub.uuid} discovered`);
|
|
207
|
-
/**
|
|
208
|
-
* Emits when a Powered UP Hub device is found.
|
|
209
|
-
* @event PoweredUP#discover
|
|
210
|
-
* @param {WeDo2SmartHub | MoveHub | TechnicMediumHub | RemoteControl | DuploTrainBase} hub
|
|
211
|
-
*/
|
|
212
|
-
this.emit("discover", hub);
|
|
213
|
-
});
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
//# sourceMappingURL=poweredup-browser.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"poweredup-browser.js","sourceRoot":"","sources":["../../src/poweredup-browser.ts"],"names":[],"mappings":"AAAA,uCAAuC;AAEvC,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAGnD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErD,OAAO,KAAK,MAAM,MAAM,UAAU,CAAC;AAEnC,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,MAAM,KAAK,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC;AAGjC;;;GAGG;AACH,MAAM,OAAO,SAAU,SAAQ,YAAY;IAMvC;QACI,KAAK,EAAE,CAAC;QAJJ,mBAAc,GAA8B,EAAE,CAAC;QAKnD,IAAI,CAAC,sBAAsB,GAAG,IAAI,CAAC,sBAAsB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACzE,CAAC;IAGD;;;OAGG;IACI,KAAK,CAAC,IAAI;QAEb,IAAI,CAAC;YAED,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,SAAS,CAAC,aAAa,CAAC;gBACnD,OAAO,EAAE;oBACL;wBACI,QAAQ,EAAE;4BACN,MAAM,CAAC,UAAU,CAAC,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GAAG,IAAI,eAAe,CAAC,MAAM,CAAC,CAAC;gBAClC,MAAM;YACV,KAAK,MAAM,CAAC,OAAO,CAAC,kBAAkB;gBAClC,GAAG,GAAG,IAAI,gBAAgB,CAAC,MAAM,CAAC,CAAC;gBACnC,MAAM;YACV,KAAK,MAAM,CAAC,OAAO,CAAC,KAAK;gBACrB,GAAG,GAAG,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC;gBACxB,MAAM;YACV;gBACI,OAAO;QACf,CAAC;QAED,MAAM,CAAC,EAAE,CAAC,kBAAkB,EAAE,GAAG,EAAE;YAE/B,GAAG,CAAC,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE;gBACnB,KAAK,CAAC,OAAO,GAAG,CAAC,IAAI,YAAY,CAAC,CAAC;gBACnC,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC;YACxC,CAAC,CAAC,CAAC;YAEH,GAAG,CAAC,EAAE,CAAC,YAAY,EAAE,GAAG,EAAE;gBACtB,KAAK,CAAC,OAAO,GAAG,CAAC,IAAI,eAAe,CAAC,CAAC;gBACtC,OAAO,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YACzC,CAAC,CAAC,CAAC;YAEH,KAAK,CAAC,OAAO,GAAG,CAAC,IAAI,aAAa,CAAC,CAAC;YAEpC;;;;eAIG;YACH,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;QAE/B,CAAC,CAAC,CAAC;IAEP,CAAC;CAEJ"}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { EventEmitter } from "events";
|
|
2
|
-
/**
|
|
3
|
-
* @class PoweredUP
|
|
4
|
-
* @extends EventEmitter
|
|
5
|
-
*/
|
|
6
|
-
export declare class PoweredUP extends EventEmitter {
|
|
7
|
-
private _connectedHubs;
|
|
8
|
-
constructor();
|
|
9
|
-
/**
|
|
10
|
-
* Begin scanning for Powered UP Hub devices.
|
|
11
|
-
* @method PoweredUP#scan
|
|
12
|
-
*/
|
|
13
|
-
scan(): Promise<boolean>;
|
|
14
|
-
/**
|
|
15
|
-
* Stop scanning for Powered UP Hub devices.
|
|
16
|
-
* @method PoweredUP#stop
|
|
17
|
-
*/
|
|
18
|
-
stop(): void;
|
|
19
|
-
/**
|
|
20
|
-
* Retrieve a list of Powered UP Hubs.
|
|
21
|
-
* @method PoweredUP#getHubs
|
|
22
|
-
* @returns {BaseHub[]}
|
|
23
|
-
*/
|
|
24
|
-
getHubs(): BaseHub[];
|
|
25
|
-
/**
|
|
26
|
-
* Retrieve a Powered UP Hub by UUID.
|
|
27
|
-
* @method PoweredUP#getHubByUUID
|
|
28
|
-
* @param {string} uuid
|
|
29
|
-
* @returns {BaseHub | null}
|
|
30
|
-
*/
|
|
31
|
-
getHubByUUID(uuid: string): BaseHub;
|
|
32
|
-
/**
|
|
33
|
-
* Retrieve a Powered UP Hub by primary MAC address.
|
|
34
|
-
* @method PoweredUP#getHubByPrimaryMACAddress
|
|
35
|
-
* @param {string} address
|
|
36
|
-
* @returns {BaseHub}
|
|
37
|
-
*/
|
|
38
|
-
getHubByPrimaryMACAddress(address: string): BaseHub;
|
|
39
|
-
/**
|
|
40
|
-
* Retrieve a list of Powered UP Hub by name.
|
|
41
|
-
* @method PoweredUP#getHubsByName
|
|
42
|
-
* @param {string} name
|
|
43
|
-
* @returns {BaseHub[]}
|
|
44
|
-
*/
|
|
45
|
-
getHubsByName(name: string): BaseHub[];
|
|
46
|
-
/**
|
|
47
|
-
* Retrieve a list of Powered UP Hub by type.
|
|
48
|
-
* @method PoweredUP#getHubsByType
|
|
49
|
-
* @param {string} name
|
|
50
|
-
* @returns {BaseHub[]}
|
|
51
|
-
*/
|
|
52
|
-
getHubsByType(hubType: number): BaseHub[];
|
|
53
|
-
private _discoveryEventHandler;
|
|
54
|
-
}
|