diff --git a/.circleci/config.yml b/.circleci/config.yml
deleted file mode 100644
index 24f6e1c..0000000
--- a/.circleci/config.yml
+++ /dev/null
@@ -1,54 +0,0 @@
-version: 2
-
-defaults: &defaults
- working_directory: ~/repo
- docker:
- - image: circleci/node:8.11.4
-
-jobs:
- build:
- <<: *defaults
- steps:
- - checkout
- - restore_cache:
- keys:
- - v1-dependencies-{{ checksum "package.json" }}
- - v1-dependencies-
- - run: sudo apt-get install -y bluetooth bluez libbluetooth-dev libudev-dev
- - run: npm install
- - save_cache:
- paths:
- - node_modules
- key: v1-dependencies-{{ checksum "package.json" }}
- - run: npm run all
- - persist_to_workspace:
- root: ~/repo
- paths: .
- deploy:
- <<: *defaults
- steps:
- - attach_workspace:
- at: ~/repo
- - run:
- name: Authenticate with registry
- command: echo "//registry.npmjs.org/:_authToken=$npm_TOKEN" > ~/repo/.npmrc
- - run:
- name: Publish package
- command: npm publish
-
-workflows:
- version: 2
- build-deploy:
- jobs:
- - build:
- filters:
- tags:
- only: /^v.*/
- - deploy:
- requires:
- - build
- filters:
- tags:
- only: /^v.*/
- branches:
- ignore: /.*/
diff --git a/.drone.yml b/.drone.yml
new file mode 100644
index 0000000..1aef699
--- /dev/null
+++ b/.drone.yml
@@ -0,0 +1,22 @@
+pipeline:
+
+ install:
+ image: node:10.15.1
+ commands:
+ - apt-get update
+ - apt-get install -y bluetooth bluez libbluetooth-dev libudev-dev
+ - npm install
+
+ build:
+ image: node:10.15.1
+ commands:
+ - npm run all
+
+ publish:
+ image: plugins/npm
+ username: nathankellenicki
+ token:
+ from_secret: NPM_TOKEN
+ when:
+ ref:
+ - refs/tags/v*
\ No newline at end of file
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/.npmignore b/.npmignore
index 2f9bc82..ac12c38 100644
--- a/.npmignore
+++ b/.npmignore
@@ -1,17 +1,5 @@
-boostmovehub.ts
-consts.ts
-duplotrainbase.ts
-hub.ts
-index.ts
-lpf2hub.ts
-port.ts
-poweredup.ts
-puphub.ts
-pupremote.ts
package-lock.json
tsconfig.json
tslint.json
-utils.ts
-wedo2smarthub.ts
.vscode/
examples/
\ No newline at end of file
diff --git a/ABOUT.md b/ABOUT.md
deleted file mode 100644
index 4362f64..0000000
--- a/ABOUT.md
+++ /dev/null
@@ -1,83 +0,0 @@
-[](https://circleci.com/gh/nathankellenicki/node-poweredup)
-[](https://gitter.im/node-poweredup?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
-
-
-# **node-poweredup** - A Node.js module to interface with LEGO Powered UP components.
-
-### Introduction
-
-LEGO Powered UP is the successor to Power Functions, the system for adding electronics to LEGO models. Powered UP is a collection of ranges - starting with LEGO WeDo 2.0 released in 2016, LEGO Boost released in 2017, and LEGO Powered UP released in 2018. It also includes the 2018 Duplo App-Controlled Train sets.
-
-Powered UP has a few improvements over Power Functions:
-
-1. The use of Bluetooth Low Energy makes it easy to control from a computer, and even write code for.
-
-2. The ability to use sensors to react to events happening in the real world opens up a whole new world of possibilities.
-
-3. As Powered UP hubs and remotes pair with each other, the system allows for a near unlimited number of independently controlled models in the same room. Power Functions was limited to 8 due to the use of infra-red for communication.
-
-### Installation
-
-Node.js v8.0 required.
-
-```javascript
-npm install node-poweredup --save
-```
-
-node-poweredup uses the Noble BLE library by Sandeep Mistry. On macOS everything should function out of the box. On Linux and Windows there are [certain dependencies which may need installed first](https://github.com/noble/noble#prerequisites).
-
-Note: node-poweredup has been tested on macOS 10.13 and Debian/Raspbian on the Raspberry Pi 3 Model B.
-
-### Compatibility
-
-While most Powered UP components and Hubs are compatible with each other, there are exceptions. For example, there is limited backwards compatibility between newer components and the WeDo 2.0 Smart Hub. However WeDo 2.0 components are fully forwards compatible with newer Hubs.
-
-| Name | Type | WeDo 2.0 Smart Hub | Boost Move Hub | Powered UP Hub | Availability |
-| ------------------------------- | ------------- | ------------------ | -------------- | -------------- | ------------ |
-| WeDo 2.0 Tilt Sensor | Sensor | Yes | Yes | Yes | 45300 |
-| WeDo 2.0 Motion Sensor | Sensor | Yes | Yes | Yes | 45300 |
-| WeDo 2.0 Medium Motor | Motor | Yes | Yes | Yes | 45300 76112 |
-| Boost Color and Distance Sensor | Sensor | *Partial* | Yes | Yes | 17101 |
-| Boost Tacho Motor | Motor/Sensor | *Partial* | Yes | *Partial* | 17101 |
-| Powered UP Train Motor | Motor | Yes | Yes | Yes | 60197 60198 |
-| Powered UP LED Lights | Light | Yes | Yes | Yes | 88005 |
-
-
-### Known Issues and Limitations
-
-* The Boost Color and Distance sensor only works in color mode with the WeDo 2.0 Smart Hub.
-
-* When used with the WeDo 2.0 Smart Hub, the Boost Tacho Motor does not support rotating the motor by angle.
-
-* When used with the Powered UP Hub, the Boost Tacho Motor does not support rotating the motor by angle. It also does not support rotation detection.
-
-* Plugging two Boost Tacho Motors into the Powered UP Hub will crash the Hub (This requires a firmware update from LEGO to fix).
-
-### Usage
-
-```javascript
-const PoweredUP = require("node-poweredup");
-const poweredUP = new PoweredUP.PoweredUP();
-
-poweredUP.on("discover", async (hub) => { // Wait to discover a Hub
- await hub.connect(); // Connect to the Hub
- await hub.sleep(3000); // Sleep for 3 seconds before starting
-
- while (true) { // Repeat indefinitely
- hub.setMotorSpeed("B", 75); // Start a motor attached to port B to run a 3/4 speed (75) indefinitely
- await hub.setMotorSpeed("A", 100, 2000); // Run a motor attached to port A for 2 seconds at maximum speed (100) then stop
- await hub.sleep(1000); // Do nothing for 1 second
- await hub.setMotorSpeed("A", -50, 1000); // Run a motor attached to port A for 1 second at 1/2 speed in reverse (-50) then stop
- await hub.sleep(1000); // Do nothing for 1 second
- }
-});
-
-poweredUP.scan(); // Start scanning for Hubs
-```
-
-More examples are available in the "examples" directory.
-
-### Credits
-
-Thanks go to Jorge Pereira ([@JorgePe](https://github.com/JorgePe)), Sebastian Raff ([@hobbyquaker](https://github.com/hobbyquaker)), Valentin Heun ([@vheun](https://github.com/vheun)), Johan Korten ([@jakorten](https://github.com/jakorten)), and Andrey Pokhilko ([@undera](https://github.com/undera)) for their various works, contributions, and assistance on figuring out the LEGO Boost, WeDo 2.0, and Powered UP protocols.
-
diff --git a/DOCS.md b/DOCS.md
deleted file mode 100644
index 4637f11..0000000
--- a/DOCS.md
+++ /dev/null
@@ -1,1612 +0,0 @@
-## Classes
-
-
-
-
-
-## PoweredUP ⇐ EventEmitter
-**Kind**: global class
-**Extends**: EventEmitter
-
-* [PoweredUP](#PoweredUP) ⇐ EventEmitter
- * [.scan()](#PoweredUP+scan)
- * [.stop()](#PoweredUP+stop)
- * [.getConnectedHubByUUID(uuid)](#PoweredUP+getConnectedHubByUUID) ⇒ Hub \| null
- * [.getConnectedHubs()](#PoweredUP+getConnectedHubs) ⇒ Array.<Hub>
- * ["discover" (hub)](#PoweredUP+event_discover)
-
-
-
-### poweredUP.scan()
-Begin scanning for Powered UP Hub devices.
-
-**Kind**: instance method of [PoweredUP](#PoweredUP)
-
-
-### poweredUP.stop()
-Stop scanning for Powered UP Hub devices.
-
-**Kind**: instance method of [PoweredUP](#PoweredUP)
-
-
-### poweredUP.getConnectedHubByUUID(uuid) ⇒ Hub \| null
-Retrieve a Powered UP Hub by UUID.
-
-**Kind**: instance method of [PoweredUP](#PoweredUP)
-
-| Param | Type |
-| --- | --- |
-| uuid | string |
-
-
-
-### poweredUP.getConnectedHubs() ⇒ Array.<Hub>
-Retrieve a list of Powered UP Hubs.
-
-**Kind**: instance method of [PoweredUP](#PoweredUP)
-
-
-### "discover" (hub)
-Emits when a Powered UP Hub device is found.
-
-**Kind**: event emitted by [PoweredUP](#PoweredUP)
-
-| Param | Type |
-| --- | --- |
-| hub | [WeDo2SmartHub](#WeDo2SmartHub) \| [BoostMoveHub](#BoostMoveHub) \| [PUPHub](#PUPHub) \| [PUPRemote](#PUPRemote) \| [DuploTrainBase](#DuploTrainBase) |
-
-
-
-## WeDo2SmartHub ⇐ Hub
-**Kind**: global class
-**Extends**: Hub
-
-* [WeDo2SmartHub](#WeDo2SmartHub) ⇐ Hub
- * [new WeDo2SmartHub()](#new_WeDo2SmartHub_new)
- * [.name](#Hub+name)
- * [.uuid](#Hub+uuid)
- * [.rssi](#Hub+rssi)
- * [.batteryLevel](#Hub+batteryLevel)
- * [.setName(name)](#WeDo2SmartHub+setName) ⇒ Promise
- * [.setLEDColor(color)](#WeDo2SmartHub+setLEDColor) ⇒ Promise
- * [.setLEDRGB(red, green, blue)](#WeDo2SmartHub+setLEDRGB) ⇒ Promise
- * [.setMotorSpeed(port, speed, [time])](#WeDo2SmartHub+setMotorSpeed) ⇒ Promise
- * [.rampMotorSpeed(port, fromSpeed, toSpeed, time)](#WeDo2SmartHub+rampMotorSpeed) ⇒ Promise
- * [.playTone(frequency, time)](#WeDo2SmartHub+playTone) ⇒ Promise
- * [.setLightBrightness(port, brightness, [time])](#WeDo2SmartHub+setLightBrightness) ⇒ Promise
- * [.connect()](#Hub+connect) ⇒ Promise
- * [.disconnect()](#Hub+disconnect) ⇒ Promise
- * [.subscribe(port, [mode])](#Hub+subscribe) ⇒ Promise
- * [.unsubscribe(port)](#Hub+unsubscribe) ⇒ Promise
- * [.sleep(delay)](#Hub+sleep) ⇒ Promise
- * [.wait(commands)](#Hub+wait) ⇒ Promise
- * ["button" (button, state)](#WeDo2SmartHub+event_button)
- * ["distance" (port, distance)](#WeDo2SmartHub+event_distance)
- * ["color" (port, color)](#WeDo2SmartHub+event_color)
- * ["tilt" (port, x, y)](#WeDo2SmartHub+event_tilt)
- * ["rotate" (port, rotation)](#WeDo2SmartHub+event_rotate)
- * ["attach" (port, type)](#Hub+event_attach)
- * ["detach" (port)](#Hub+event_detach)
-
-
-
-### new WeDo2SmartHub()
-The WeDo2SmartHub is emitted if the discovered device is a WeDo 2.0 Smart Hub.
-
-
-
-### weDo2SmartHub.name
-**Kind**: instance property of [WeDo2SmartHub](#WeDo2SmartHub)
-**Read only**: true
-**Properties**
-
-| Name | Type | Description |
-| --- | --- | --- |
-| name | string | Name of the hub |
-
-
-
-### weDo2SmartHub.uuid
-**Kind**: instance property of [WeDo2SmartHub](#WeDo2SmartHub)
-**Read only**: true
-**Properties**
-
-| Name | Type | Description |
-| --- | --- | --- |
-| uuid | string | UUID of the hub |
-
-
-
-### weDo2SmartHub.rssi
-**Kind**: instance property of [WeDo2SmartHub](#WeDo2SmartHub)
-**Read only**: true
-**Properties**
-
-| Name | Type | Description |
-| --- | --- | --- |
-| rssi | number | Signal strength of the hub |
-
-
-
-### weDo2SmartHub.batteryLevel
-**Kind**: instance property of [WeDo2SmartHub](#WeDo2SmartHub)
-**Read only**: true
-**Properties**
-
-| Name | Type | Description |
-| --- | --- | --- |
-| batteryLevel | number | Battery level of the hub (Percentage between 0-100) |
-
-
-
-### weDo2SmartHub.setName(name) ⇒ Promise
-Set the name of the Hub.
-
-**Kind**: instance method of [WeDo2SmartHub](#WeDo2SmartHub)
-**Returns**: Promise - Resolved upon successful issuance of command.
-
-| Param | Type | Description |
-| --- | --- | --- |
-| name | string | New name of the hub (14 characters or less, ASCII only). |
-
-
-
-### weDo2SmartHub.setLEDColor(color) ⇒ Promise
-Set the color of the LED on the Hub via a color value.
-
-**Kind**: instance method of [WeDo2SmartHub](#WeDo2SmartHub)
-**Returns**: Promise - Resolved upon successful issuance of command.
-
-| Param | Type | Description |
-| --- | --- | --- |
-| color | number | A number representing one of the LED color consts. |
-
-
-
-### weDo2SmartHub.setLEDRGB(red, green, blue) ⇒ Promise
-Set the color of the LED on the Hub via RGB values.
-
-**Kind**: instance method of [WeDo2SmartHub](#WeDo2SmartHub)
-**Returns**: Promise - Resolved upon successful issuance of command.
-
-| Param | Type |
-| --- | --- |
-| red | number |
-| green | number |
-| blue | number |
-
-
-
-### weDo2SmartHub.setMotorSpeed(port, speed, [time]) ⇒ Promise
-Set the motor speed on a given port.
-
-**Kind**: instance method of [WeDo2SmartHub](#WeDo2SmartHub)
-**Returns**: Promise - Resolved upon successful completion of command. If time is specified, this is once the motor is finished.
-
-| Param | Type | Description |
-| --- | --- | --- |
-| port | string | |
-| speed | number | For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0. |
-| [time] | number | How long to activate the motor for (in milliseconds). Leave empty to turn the motor on indefinitely. |
-
-
-
-### weDo2SmartHub.rampMotorSpeed(port, fromSpeed, toSpeed, time) ⇒ Promise
-Ramp the motor speed on a given port.
-
-**Kind**: instance method of [WeDo2SmartHub](#WeDo2SmartHub)
-**Returns**: Promise - Resolved upon successful completion of command.
-
-| Param | Type | Description |
-| --- | --- | --- |
-| port | string | |
-| fromSpeed | number | For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0. |
-| toSpeed | number | For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0. |
-| time | number | How long the ramp should last (in milliseconds). |
-
-
-
-### weDo2SmartHub.playTone(frequency, time) ⇒ Promise
-Play a tone on the Hub's in-built buzzer
-
-**Kind**: instance method of [WeDo2SmartHub](#WeDo2SmartHub)
-**Returns**: Promise - Resolved upon successful completion of command (ie. once the tone has finished playing).
-
-| Param | Type | Description |
-| --- | --- | --- |
-| frequency | number | |
-| time | number | How long the tone should play for (in milliseconds). |
-
-
-
-### weDo2SmartHub.setLightBrightness(port, brightness, [time]) ⇒ Promise
-Set the light brightness on a given port.
-
-**Kind**: instance method of [WeDo2SmartHub](#WeDo2SmartHub)
-**Returns**: Promise - Resolved upon successful completion of command. If time is specified, this is once the light is turned off.
-
-| Param | Type | Description |
-| --- | --- | --- |
-| port | string | |
-| brightness | number | Brightness value between 0-100 (0 is off) |
-| [time] | number | How long to turn the light on (in milliseconds). Leave empty to turn the light on indefinitely. |
-
-
-
-### weDo2SmartHub.connect() ⇒ Promise
-Connect to the Hub.
-
-**Kind**: instance method of [WeDo2SmartHub](#WeDo2SmartHub)
-**Overrides**: [connect](#Hub+connect)
-**Returns**: Promise - Resolved upon successful connect.
-
-
-### weDo2SmartHub.disconnect() ⇒ Promise
-Disconnect the Hub.
-
-**Kind**: instance method of [WeDo2SmartHub](#WeDo2SmartHub)
-**Returns**: Promise - Resolved upon successful disconnect.
-
-
-### weDo2SmartHub.subscribe(port, [mode]) ⇒ Promise
-Subscribe to sensor notifications on a given port.
-
-**Kind**: instance method of [WeDo2SmartHub](#WeDo2SmartHub)
-**Returns**: Promise - Resolved upon successful issuance of command.
-
-| Param | Type | Description |
-| --- | --- | --- |
-| port | string | |
-| [mode] | number | The sensor mode to activate. If no mode is provided, the default for that sensor will be chosen. |
-
-
-
-### weDo2SmartHub.unsubscribe(port) ⇒ Promise
-Unsubscribe to sensor notifications on a given port.
-
-**Kind**: instance method of [WeDo2SmartHub](#WeDo2SmartHub)
-**Returns**: Promise - Resolved upon successful issuance of command.
-
-| Param | Type |
-| --- | --- |
-| port | string |
-
-
-
-### weDo2SmartHub.sleep(delay) ⇒ Promise
-Sleep a given amount of time.
-
-This is a helper method to make it easier to add delays into a chain of commands.
-
-**Kind**: instance method of [WeDo2SmartHub](#WeDo2SmartHub)
-**Returns**: Promise - Resolved after the delay is finished.
-
-| Param | Type | Description |
-| --- | --- | --- |
-| delay | number | How long to sleep (in milliseconds). |
-
-
-
-### weDo2SmartHub.wait(commands) ⇒ Promise
-Wait until a given list of concurrently running commands are complete.
-
-This is a helper method to make it easier to wait for concurrent commands to complete.
-
-**Kind**: instance method of [WeDo2SmartHub](#WeDo2SmartHub)
-**Returns**: Promise - Resolved after the commands are finished.
-
-| Param | Type | Description |
-| --- | --- | --- |
-| commands | Array.<Promise.<any>> | Array of executing commands. |
-
-
-
-### "button" (button, state)
-Emits when a button is pressed.
-
-**Kind**: event emitted by [WeDo2SmartHub](#WeDo2SmartHub)
-
-| Param | Type | Description |
-| --- | --- | --- |
-| button | string | |
-| state | number | A number representing one of the button state consts. |
-
-
-
-### "distance" (port, distance)
-Emits when a distance sensor is activated.
-
-**Kind**: event emitted by [WeDo2SmartHub](#WeDo2SmartHub)
-
-| Param | Type | Description |
-| --- | --- | --- |
-| port | string | |
-| distance | number | Distance, in millimeters. |
-
-
-
-### "color" (port, color)
-Emits when a color sensor is activated.
-
-**Kind**: event emitted by [WeDo2SmartHub](#WeDo2SmartHub)
-
-| Param | Type | Description |
-| --- | --- | --- |
-| port | string | |
-| color | number | A number representing one of the LED color consts. |
-
-
-
-### "tilt" (port, x, y)
-Emits when a tilt sensor is activated.
-
-**Kind**: event emitted by [WeDo2SmartHub](#WeDo2SmartHub)
-
-| Param | Type |
-| --- | --- |
-| port | string |
-| x | number |
-| y | number |
-
-
-
-### "rotate" (port, rotation)
-Emits when a rotation sensor is activated.
-
-**Kind**: event emitted by [WeDo2SmartHub](#WeDo2SmartHub)
-
-| Param | Type |
-| --- | --- |
-| port | string |
-| rotation | number |
-
-
-
-### "attach" (port, type)
-Emits when a motor or sensor is attached to the Hub.
-
-**Kind**: event emitted by [WeDo2SmartHub](#WeDo2SmartHub)
-
-| Param | Type | Description |
-| --- | --- | --- |
-| port | string | |
-| type | number | A number representing one of the peripheral consts. |
-
-
-
-### "detach" (port)
-Emits when an attached motor or sensor is detached from the Hub.
-
-**Kind**: event emitted by [WeDo2SmartHub](#WeDo2SmartHub)
-
-| Param | Type |
-| --- | --- |
-| port | string |
-
-
-
-## BoostMoveHub ⇐ LPF2Hub
-**Kind**: global class
-**Extends**: LPF2Hub, Hub
-
-* [BoostMoveHub](#BoostMoveHub) ⇐ LPF2Hub
- * [new BoostMoveHub()](#new_BoostMoveHub_new)
- * [.current](#LPF2Hub+current)
- * [.name](#Hub+name)
- * [.uuid](#Hub+uuid)
- * [.rssi](#Hub+rssi)
- * [.batteryLevel](#Hub+batteryLevel)
- * [.setMotorSpeed(port, speed, [time])](#BoostMoveHub+setMotorSpeed) ⇒ Promise
- * [.rampMotorSpeed(port, fromSpeed, toSpeed, time)](#BoostMoveHub+rampMotorSpeed) ⇒ Promise
- * [.setMotorAngle(port, angle, [speed])](#BoostMoveHub+setMotorAngle) ⇒ Promise
- * [.setLightBrightness(port, brightness, [time])](#BoostMoveHub+setLightBrightness) ⇒ Promise
- * [.setName(name)](#LPF2Hub+setName) ⇒ Promise
- * [.setLEDColor(color)](#LPF2Hub+setLEDColor) ⇒ Promise
- * [.setLEDRGB(red, green, blue)](#LPF2Hub+setLEDRGB) ⇒ Promise
- * [.connect()](#Hub+connect) ⇒ Promise
- * [.disconnect()](#Hub+disconnect) ⇒ Promise
- * [.subscribe(port, [mode])](#Hub+subscribe) ⇒ Promise
- * [.unsubscribe(port)](#Hub+unsubscribe) ⇒ Promise
- * [.sleep(delay)](#Hub+sleep) ⇒ Promise
- * [.wait(commands)](#Hub+wait) ⇒ Promise
- * ["button" (button, state)](#LPF2Hub+event_button)
- * ["distance" (port, distance)](#LPF2Hub+event_distance)
- * ["color" (port, color)](#LPF2Hub+event_color)
- * ["colorAndDistance" (port, color, distance)](#LPF2Hub+event_colorAndDistance)
- * ["tilt" (port, x, y)](#LPF2Hub+event_tilt)
- * ["rotate" (port, rotation)](#LPF2Hub+event_rotate)
- * ["attach" (port, type)](#Hub+event_attach)
- * ["detach" (port)](#Hub+event_detach)
-
-
-
-### new BoostMoveHub()
-The BoostMoveHub is emitted if the discovered device is a Boost Move Hub.
-
-
-
-### boostMoveHub.current
-**Kind**: instance property of [BoostMoveHub](#BoostMoveHub)
-**Read only**: true
-**Properties**
-
-| Name | Type | Description |
-| --- | --- | --- |
-| current | number | Current usage of the hub (Amps) |
-
-
-
-### boostMoveHub.name
-**Kind**: instance property of [BoostMoveHub](#BoostMoveHub)
-**Overrides**: [name](#Hub+name)
-**Read only**: true
-**Properties**
-
-| Name | Type | Description |
-| --- | --- | --- |
-| name | string | Name of the hub |
-
-
-
-### boostMoveHub.uuid
-**Kind**: instance property of [BoostMoveHub](#BoostMoveHub)
-**Overrides**: [uuid](#Hub+uuid)
-**Read only**: true
-**Properties**
-
-| Name | Type | Description |
-| --- | --- | --- |
-| uuid | string | UUID of the hub |
-
-
-
-### boostMoveHub.rssi
-**Kind**: instance property of [BoostMoveHub](#BoostMoveHub)
-**Overrides**: [rssi](#Hub+rssi)
-**Read only**: true
-**Properties**
-
-| Name | Type | Description |
-| --- | --- | --- |
-| rssi | number | Signal strength of the hub |
-
-
-
-### boostMoveHub.batteryLevel
-**Kind**: instance property of [BoostMoveHub](#BoostMoveHub)
-**Overrides**: [batteryLevel](#Hub+batteryLevel)
-**Read only**: true
-**Properties**
-
-| Name | Type | Description |
-| --- | --- | --- |
-| batteryLevel | number | Battery level of the hub (Percentage between 0-100) |
-
-
-
-### boostMoveHub.setMotorSpeed(port, speed, [time]) ⇒ Promise
-Set the motor speed on a given port.
-
-**Kind**: instance method of [BoostMoveHub](#BoostMoveHub)
-**Returns**: Promise - Resolved upon successful completion of command. If time is specified, this is once the motor is finished.
-
-| Param | Type | Description |
-| --- | --- | --- |
-| port | string | |
-| speed | number \| Array.<number> | For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0. If you are specifying port AB to control both motors, you can optionally supply a tuple of speeds. |
-| [time] | number | How long to activate the motor for (in milliseconds). Leave empty to turn the motor on indefinitely. |
-
-
-
-### boostMoveHub.rampMotorSpeed(port, fromSpeed, toSpeed, time) ⇒ Promise
-Ramp the motor speed on a given port.
-
-**Kind**: instance method of [BoostMoveHub](#BoostMoveHub)
-**Returns**: Promise - Resolved upon successful completion of command.
-
-| Param | Type | Description |
-| --- | --- | --- |
-| port | string | |
-| fromSpeed | number | For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0. |
-| toSpeed | number | For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0. |
-| time | number | How long the ramp should last (in milliseconds). |
-
-
-
-### boostMoveHub.setMotorAngle(port, angle, [speed]) ⇒ Promise
-Rotate a motor by a given angle.
-
-**Kind**: instance method of [BoostMoveHub](#BoostMoveHub)
-**Returns**: Promise - Resolved upon successful completion of command (ie. once the motor is finished).
-
-| Param | Type | Default | Description |
-| --- | --- | --- | --- |
-| port | string | | |
-| angle | number | | How much the motor should be rotated (in degrees). |
-| [speed] | number \| Array.<number> | 100 | For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0. If you are specifying port AB to control both motors, you can optionally supply a tuple of speeds. |
-
-
-
-### boostMoveHub.setLightBrightness(port, brightness, [time]) ⇒ Promise
-Set the light brightness on a given port.
-
-**Kind**: instance method of [BoostMoveHub](#BoostMoveHub)
-**Returns**: Promise - Resolved upon successful completion of command. If time is specified, this is once the light is turned off.
-
-| Param | Type | Description |
-| --- | --- | --- |
-| port | string | |
-| brightness | number | Brightness value between 0-100 (0 is off) |
-| [time] | number | How long to turn the light on (in milliseconds). Leave empty to turn the light on indefinitely. |
-
-
-
-### boostMoveHub.setName(name) ⇒ Promise
-Set the name of the Hub.
-
-**Kind**: instance method of [BoostMoveHub](#BoostMoveHub)
-**Returns**: Promise - Resolved upon successful issuance of command.
-
-| Param | Type | Description |
-| --- | --- | --- |
-| name | string | New name of the hub (14 characters or less, ASCII only). |
-
-
-
-### boostMoveHub.setLEDColor(color) ⇒ Promise
-Set the color of the LED on the Hub via a color value.
-
-**Kind**: instance method of [BoostMoveHub](#BoostMoveHub)
-**Returns**: Promise - Resolved upon successful issuance of command.
-
-| Param | Type | Description |
-| --- | --- | --- |
-| color | number | A number representing one of the LED color consts. |
-
-
-
-### boostMoveHub.setLEDRGB(red, green, blue) ⇒ Promise
-Set the color of the LED on the Hub via RGB values.
-
-**Kind**: instance method of [BoostMoveHub](#BoostMoveHub)
-**Returns**: Promise - Resolved upon successful issuance of command.
-
-| Param | Type |
-| --- | --- |
-| red | number |
-| green | number |
-| blue | number |
-
-
-
-### boostMoveHub.connect() ⇒ Promise
-Connect to the Hub.
-
-**Kind**: instance method of [BoostMoveHub](#BoostMoveHub)
-**Overrides**: [connect](#Hub+connect)
-**Returns**: Promise - Resolved upon successful connect.
-
-
-### boostMoveHub.disconnect() ⇒ Promise
-Disconnect the Hub.
-
-**Kind**: instance method of [BoostMoveHub](#BoostMoveHub)
-**Overrides**: [disconnect](#Hub+disconnect)
-**Returns**: Promise - Resolved upon successful disconnect.
-
-
-### boostMoveHub.subscribe(port, [mode]) ⇒ Promise
-Subscribe to sensor notifications on a given port.
-
-**Kind**: instance method of [BoostMoveHub](#BoostMoveHub)
-**Overrides**: [subscribe](#Hub+subscribe)
-**Returns**: Promise - Resolved upon successful issuance of command.
-
-| Param | Type | Description |
-| --- | --- | --- |
-| port | string | |
-| [mode] | number | The sensor mode to activate. If no mode is provided, the default for that sensor will be chosen. |
-
-
-
-### boostMoveHub.unsubscribe(port) ⇒ Promise
-Unsubscribe to sensor notifications on a given port.
-
-**Kind**: instance method of [BoostMoveHub](#BoostMoveHub)
-**Overrides**: [unsubscribe](#Hub+unsubscribe)
-**Returns**: Promise - Resolved upon successful issuance of command.
-
-| Param | Type |
-| --- | --- |
-| port | string |
-
-
-
-### boostMoveHub.sleep(delay) ⇒ Promise
-Sleep a given amount of time.
-
-This is a helper method to make it easier to add delays into a chain of commands.
-
-**Kind**: instance method of [BoostMoveHub](#BoostMoveHub)
-**Overrides**: [sleep](#Hub+sleep)
-**Returns**: Promise - Resolved after the delay is finished.
-
-| Param | Type | Description |
-| --- | --- | --- |
-| delay | number | How long to sleep (in milliseconds). |
-
-
-
-### boostMoveHub.wait(commands) ⇒ Promise
-Wait until a given list of concurrently running commands are complete.
-
-This is a helper method to make it easier to wait for concurrent commands to complete.
-
-**Kind**: instance method of [BoostMoveHub](#BoostMoveHub)
-**Overrides**: [wait](#Hub+wait)
-**Returns**: Promise - Resolved after the commands are finished.
-
-| Param | Type | Description |
-| --- | --- | --- |
-| commands | Array.<Promise.<any>> | Array of executing commands. |
-
-
-
-### "button" (button, state)
-Emits when a button is pressed.
-
-**Kind**: event emitted by [BoostMoveHub](#BoostMoveHub)
-
-| Param | Type | Description |
-| --- | --- | --- |
-| button | string | |
-| state | number | A number representing one of the button state consts. |
-
-
-
-### "distance" (port, distance)
-Emits when a distance sensor is activated.
-
-**Kind**: event emitted by [BoostMoveHub](#BoostMoveHub)
-
-| Param | Type | Description |
-| --- | --- | --- |
-| port | string | |
-| distance | number | Distance, in millimeters. |
-
-
-
-### "color" (port, color)
-Emits when a color sensor is activated.
-
-**Kind**: event emitted by [BoostMoveHub](#BoostMoveHub)
-
-| Param | Type | Description |
-| --- | --- | --- |
-| port | string | |
-| color | number | A number representing one of the LED color consts. |
-
-
-
-### "colorAndDistance" (port, color, distance)
-A combined color and distance event, emits when the sensor is activated.
-
-**Kind**: event emitted by [BoostMoveHub](#BoostMoveHub)
-
-| Param | Type | Description |
-| --- | --- | --- |
-| port | string | |
-| color | number | A number representing one of the LED color consts. |
-| distance | number | Distance, in millimeters. |
-
-
-
-### "tilt" (port, x, y)
-Emits when a tilt sensor is activated.
-
-**Kind**: event emitted by [BoostMoveHub](#BoostMoveHub)
-
-| Param | Type | Description |
-| --- | --- | --- |
-| port | string | If the event is fired from the Move Hub's in-built tilt sensor, the special port "TILT" is used. |
-| x | number | |
-| y | number | |
-
-
-
-### "rotate" (port, rotation)
-Emits when a rotation sensor is activated.
-
-**Kind**: event emitted by [BoostMoveHub](#BoostMoveHub)
-
-| Param | Type |
-| --- | --- |
-| port | string |
-| rotation | number |
-
-
-
-### "attach" (port, type)
-Emits when a motor or sensor is attached to the Hub.
-
-**Kind**: event emitted by [BoostMoveHub](#BoostMoveHub)
-**Overrides**: [attach](#Hub+event_attach)
-
-| Param | Type | Description |
-| --- | --- | --- |
-| port | string | |
-| type | number | A number representing one of the peripheral consts. |
-
-
-
-### "detach" (port)
-Emits when an attached motor or sensor is detached from the Hub.
-
-**Kind**: event emitted by [BoostMoveHub](#BoostMoveHub)
-**Overrides**: [detach](#Hub+event_detach)
-
-| Param | Type |
-| --- | --- |
-| port | string |
-
-
-
-## PUPHub ⇐ LPF2Hub
-**Kind**: global class
-**Extends**: LPF2Hub, Hub
-
-* [PUPHub](#PUPHub) ⇐ LPF2Hub
- * [new PUPHub()](#new_PUPHub_new)
- * [.current](#LPF2Hub+current)
- * [.name](#Hub+name)
- * [.uuid](#Hub+uuid)
- * [.rssi](#Hub+rssi)
- * [.batteryLevel](#Hub+batteryLevel)
- * [.setMotorSpeed(port, speed, [time])](#PUPHub+setMotorSpeed) ⇒ Promise
- * [.rampMotorSpeed(port, fromSpeed, toSpeed, time)](#PUPHub+rampMotorSpeed) ⇒ Promise
- * [.setLightBrightness(port, brightness, [time])](#PUPHub+setLightBrightness) ⇒ Promise
- * [.setName(name)](#LPF2Hub+setName) ⇒ Promise
- * [.setLEDColor(color)](#LPF2Hub+setLEDColor) ⇒ Promise
- * [.setLEDRGB(red, green, blue)](#LPF2Hub+setLEDRGB) ⇒ Promise
- * [.connect()](#Hub+connect) ⇒ Promise
- * [.disconnect()](#Hub+disconnect) ⇒ Promise
- * [.subscribe(port, [mode])](#Hub+subscribe) ⇒ Promise
- * [.unsubscribe(port)](#Hub+unsubscribe) ⇒ Promise
- * [.sleep(delay)](#Hub+sleep) ⇒ Promise
- * [.wait(commands)](#Hub+wait) ⇒ Promise
- * ["button" (button, state)](#LPF2Hub+event_button)
- * ["distance" (port, distance)](#LPF2Hub+event_distance)
- * ["color" (port, color)](#LPF2Hub+event_color)
- * ["colorAndDistance" (port, color, distance)](#LPF2Hub+event_colorAndDistance)
- * ["tilt" (port, x, y)](#LPF2Hub+event_tilt)
- * ["attach" (port, type)](#Hub+event_attach)
- * ["detach" (port)](#Hub+event_detach)
-
-
-
-### new PUPHub()
-The PUPHub is emitted if the discovered device is a Powered UP Hub.
-
-
-
-### pupHub.current
-**Kind**: instance property of [PUPHub](#PUPHub)
-**Read only**: true
-**Properties**
-
-| Name | Type | Description |
-| --- | --- | --- |
-| current | number | Current usage of the hub (Amps) |
-
-
-
-### pupHub.name
-**Kind**: instance property of [PUPHub](#PUPHub)
-**Overrides**: [name](#Hub+name)
-**Read only**: true
-**Properties**
-
-| Name | Type | Description |
-| --- | --- | --- |
-| name | string | Name of the hub |
-
-
-
-### pupHub.uuid
-**Kind**: instance property of [PUPHub](#PUPHub)
-**Overrides**: [uuid](#Hub+uuid)
-**Read only**: true
-**Properties**
-
-| Name | Type | Description |
-| --- | --- | --- |
-| uuid | string | UUID of the hub |
-
-
-
-### pupHub.rssi
-**Kind**: instance property of [PUPHub](#PUPHub)
-**Overrides**: [rssi](#Hub+rssi)
-**Read only**: true
-**Properties**
-
-| Name | Type | Description |
-| --- | --- | --- |
-| rssi | number | Signal strength of the hub |
-
-
-
-### pupHub.batteryLevel
-**Kind**: instance property of [PUPHub](#PUPHub)
-**Overrides**: [batteryLevel](#Hub+batteryLevel)
-**Read only**: true
-**Properties**
-
-| Name | Type | Description |
-| --- | --- | --- |
-| batteryLevel | number | Battery level of the hub (Percentage between 0-100) |
-
-
-
-### pupHub.setMotorSpeed(port, speed, [time]) ⇒ Promise
-Set the motor speed on a given port.
-
-**Kind**: instance method of [PUPHub](#PUPHub)
-**Returns**: Promise - Resolved upon successful completion of command. If time is specified, this is once the motor is finished.
-
-| Param | Type | Description |
-| --- | --- | --- |
-| port | string | |
-| speed | number \| Array.<number> | For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0. If you are specifying port AB to control both motors, you can optionally supply a tuple of speeds. |
-| [time] | number | How long to activate the motor for (in milliseconds). Leave empty to turn the motor on indefinitely. |
-
-
-
-### pupHub.rampMotorSpeed(port, fromSpeed, toSpeed, time) ⇒ Promise
-Ramp the motor speed on a given port.
-
-**Kind**: instance method of [PUPHub](#PUPHub)
-**Returns**: Promise - Resolved upon successful completion of command.
-
-| Param | Type | Description |
-| --- | --- | --- |
-| port | string | |
-| fromSpeed | number | For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0. |
-| toSpeed | number | For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0. |
-| time | number | How long the ramp should last (in milliseconds). |
-
-
-
-### pupHub.setLightBrightness(port, brightness, [time]) ⇒ Promise
-Set the light brightness on a given port.
-
-**Kind**: instance method of [PUPHub](#PUPHub)
-**Returns**: Promise - Resolved upon successful completion of command. If time is specified, this is once the light is turned off.
-
-| Param | Type | Description |
-| --- | --- | --- |
-| port | string | |
-| brightness | number | Brightness value between 0-100 (0 is off) |
-| [time] | number | How long to turn the light on (in milliseconds). Leave empty to turn the light on indefinitely. |
-
-
-
-### pupHub.setName(name) ⇒ Promise
-Set the name of the Hub.
-
-**Kind**: instance method of [PUPHub](#PUPHub)
-**Returns**: Promise - Resolved upon successful issuance of command.
-
-| Param | Type | Description |
-| --- | --- | --- |
-| name | string | New name of the hub (14 characters or less, ASCII only). |
-
-
-
-### pupHub.setLEDColor(color) ⇒ Promise
-Set the color of the LED on the Hub via a color value.
-
-**Kind**: instance method of [PUPHub](#PUPHub)
-**Returns**: Promise - Resolved upon successful issuance of command.
-
-| Param | Type | Description |
-| --- | --- | --- |
-| color | number | A number representing one of the LED color consts. |
-
-
-
-### pupHub.setLEDRGB(red, green, blue) ⇒ Promise
-Set the color of the LED on the Hub via RGB values.
-
-**Kind**: instance method of [PUPHub](#PUPHub)
-**Returns**: Promise - Resolved upon successful issuance of command.
-
-| Param | Type |
-| --- | --- |
-| red | number |
-| green | number |
-| blue | number |
-
-
-
-### pupHub.connect() ⇒ Promise
-Connect to the Hub.
-
-**Kind**: instance method of [PUPHub](#PUPHub)
-**Overrides**: [connect](#Hub+connect)
-**Returns**: Promise - Resolved upon successful connect.
-
-
-### pupHub.disconnect() ⇒ Promise
-Disconnect the Hub.
-
-**Kind**: instance method of [PUPHub](#PUPHub)
-**Overrides**: [disconnect](#Hub+disconnect)
-**Returns**: Promise - Resolved upon successful disconnect.
-
-
-### pupHub.subscribe(port, [mode]) ⇒ Promise
-Subscribe to sensor notifications on a given port.
-
-**Kind**: instance method of [PUPHub](#PUPHub)
-**Overrides**: [subscribe](#Hub+subscribe)
-**Returns**: Promise - Resolved upon successful issuance of command.
-
-| Param | Type | Description |
-| --- | --- | --- |
-| port | string | |
-| [mode] | number | The sensor mode to activate. If no mode is provided, the default for that sensor will be chosen. |
-
-
-
-### pupHub.unsubscribe(port) ⇒ Promise
-Unsubscribe to sensor notifications on a given port.
-
-**Kind**: instance method of [PUPHub](#PUPHub)
-**Overrides**: [unsubscribe](#Hub+unsubscribe)
-**Returns**: Promise - Resolved upon successful issuance of command.
-
-| Param | Type |
-| --- | --- |
-| port | string |
-
-
-
-### pupHub.sleep(delay) ⇒ Promise
-Sleep a given amount of time.
-
-This is a helper method to make it easier to add delays into a chain of commands.
-
-**Kind**: instance method of [PUPHub](#PUPHub)
-**Overrides**: [sleep](#Hub+sleep)
-**Returns**: Promise - Resolved after the delay is finished.
-
-| Param | Type | Description |
-| --- | --- | --- |
-| delay | number | How long to sleep (in milliseconds). |
-
-
-
-### pupHub.wait(commands) ⇒ Promise
-Wait until a given list of concurrently running commands are complete.
-
-This is a helper method to make it easier to wait for concurrent commands to complete.
-
-**Kind**: instance method of [PUPHub](#PUPHub)
-**Overrides**: [wait](#Hub+wait)
-**Returns**: Promise - Resolved after the commands are finished.
-
-| Param | Type | Description |
-| --- | --- | --- |
-| commands | Array.<Promise.<any>> | Array of executing commands. |
-
-
-
-### "button" (button, state)
-Emits when a button is pressed.
-
-**Kind**: event emitted by [PUPHub](#PUPHub)
-
-| Param | Type | Description |
-| --- | --- | --- |
-| button | string | |
-| state | number | A number representing one of the button state consts. |
-
-
-
-### "distance" (port, distance)
-Emits when a distance sensor is activated.
-
-**Kind**: event emitted by [PUPHub](#PUPHub)
-
-| Param | Type | Description |
-| --- | --- | --- |
-| port | string | |
-| distance | number | Distance, in millimeters. |
-
-
-
-### "color" (port, color)
-Emits when a color sensor is activated.
-
-**Kind**: event emitted by [PUPHub](#PUPHub)
-
-| Param | Type | Description |
-| --- | --- | --- |
-| port | string | |
-| color | number | A number representing one of the LED color consts. |
-
-
-
-### "colorAndDistance" (port, color, distance)
-A combined color and distance event, emits when the sensor is activated.
-
-**Kind**: event emitted by [PUPHub](#PUPHub)
-
-| Param | Type | Description |
-| --- | --- | --- |
-| port | string | |
-| color | number | A number representing one of the LED color consts. |
-| distance | number | Distance, in millimeters. |
-
-
-
-### "tilt" (port, x, y)
-Emits when a tilt sensor is activated.
-
-**Kind**: event emitted by [PUPHub](#PUPHub)
-
-| Param | Type | Description |
-| --- | --- | --- |
-| port | string | If the event is fired from the Move Hub's in-built tilt sensor, the special port "TILT" is used. |
-| x | number | |
-| y | number | |
-
-
-
-### "attach" (port, type)
-Emits when a motor or sensor is attached to the Hub.
-
-**Kind**: event emitted by [PUPHub](#PUPHub)
-**Overrides**: [attach](#Hub+event_attach)
-
-| Param | Type | Description |
-| --- | --- | --- |
-| port | string | |
-| type | number | A number representing one of the peripheral consts. |
-
-
-
-### "detach" (port)
-Emits when an attached motor or sensor is detached from the Hub.
-
-**Kind**: event emitted by [PUPHub](#PUPHub)
-**Overrides**: [detach](#Hub+event_detach)
-
-| Param | Type |
-| --- | --- |
-| port | string |
-
-
-
-## PUPRemote ⇐ LPF2Hub
-**Kind**: global class
-**Extends**: LPF2Hub, Hub
-
-* [PUPRemote](#PUPRemote) ⇐ LPF2Hub
- * [new PUPRemote()](#new_PUPRemote_new)
- * [.current](#LPF2Hub+current)
- * [.name](#Hub+name)
- * [.uuid](#Hub+uuid)
- * [.rssi](#Hub+rssi)
- * [.batteryLevel](#Hub+batteryLevel)
- * [.setLEDColor(color)](#PUPRemote+setLEDColor) ⇒ Promise
- * [.setLEDRGB(red, green, blue)](#PUPRemote+setLEDRGB) ⇒ Promise
- * [.setName(name)](#LPF2Hub+setName) ⇒ Promise
- * [.connect()](#Hub+connect) ⇒ Promise
- * [.disconnect()](#Hub+disconnect) ⇒ Promise
- * [.subscribe(port, [mode])](#Hub+subscribe) ⇒ Promise
- * [.unsubscribe(port)](#Hub+unsubscribe) ⇒ Promise
- * [.sleep(delay)](#Hub+sleep) ⇒ Promise
- * [.wait(commands)](#Hub+wait) ⇒ Promise
- * ["button" (button, state)](#LPF2Hub+event_button)
- * ["colorAndDistance" (port, color, distance)](#LPF2Hub+event_colorAndDistance)
-
-
-
-### new PUPRemote()
-The PUPRemote is emitted if the discovered device is a Powered UP Remote.
-
-
-
-### pupRemote.current
-**Kind**: instance property of [PUPRemote](#PUPRemote)
-**Read only**: true
-**Properties**
-
-| Name | Type | Description |
-| --- | --- | --- |
-| current | number | Current usage of the hub (Amps) |
-
-
-
-### pupRemote.name
-**Kind**: instance property of [PUPRemote](#PUPRemote)
-**Overrides**: [name](#Hub+name)
-**Read only**: true
-**Properties**
-
-| Name | Type | Description |
-| --- | --- | --- |
-| name | string | Name of the hub |
-
-
-
-### pupRemote.uuid
-**Kind**: instance property of [PUPRemote](#PUPRemote)
-**Overrides**: [uuid](#Hub+uuid)
-**Read only**: true
-**Properties**
-
-| Name | Type | Description |
-| --- | --- | --- |
-| uuid | string | UUID of the hub |
-
-
-
-### pupRemote.rssi
-**Kind**: instance property of [PUPRemote](#PUPRemote)
-**Overrides**: [rssi](#Hub+rssi)
-**Read only**: true
-**Properties**
-
-| Name | Type | Description |
-| --- | --- | --- |
-| rssi | number | Signal strength of the hub |
-
-
-
-### pupRemote.batteryLevel
-**Kind**: instance property of [PUPRemote](#PUPRemote)
-**Overrides**: [batteryLevel](#Hub+batteryLevel)
-**Read only**: true
-**Properties**
-
-| Name | Type | Description |
-| --- | --- | --- |
-| batteryLevel | number | Battery level of the hub (Percentage between 0-100) |
-
-
-
-### pupRemote.setLEDColor(color) ⇒ Promise
-Set the color of the LED on the Remote via a color value.
-
-**Kind**: instance method of [PUPRemote](#PUPRemote)
-**Overrides**: [setLEDColor](#LPF2Hub+setLEDColor)
-**Returns**: Promise - Resolved upon successful issuance of command.
-
-| Param | Type | Description |
-| --- | --- | --- |
-| color | number | A number representing one of the LED color consts. |
-
-
-
-### pupRemote.setLEDRGB(red, green, blue) ⇒ Promise
-Set the color of the LED on the Hub via RGB values.
-
-**Kind**: instance method of [PUPRemote](#PUPRemote)
-**Overrides**: [setLEDRGB](#LPF2Hub+setLEDRGB)
-**Returns**: Promise - Resolved upon successful issuance of command.
-
-| Param | Type |
-| --- | --- |
-| red | number |
-| green | number |
-| blue | number |
-
-
-
-### pupRemote.setName(name) ⇒ Promise
-Set the name of the Hub.
-
-**Kind**: instance method of [PUPRemote](#PUPRemote)
-**Returns**: Promise - Resolved upon successful issuance of command.
-
-| Param | Type | Description |
-| --- | --- | --- |
-| name | string | New name of the hub (14 characters or less, ASCII only). |
-
-
-
-### pupRemote.connect() ⇒ Promise
-Connect to the Hub.
-
-**Kind**: instance method of [PUPRemote](#PUPRemote)
-**Overrides**: [connect](#Hub+connect)
-**Returns**: Promise - Resolved upon successful connect.
-
-
-### pupRemote.disconnect() ⇒ Promise
-Disconnect the Hub.
-
-**Kind**: instance method of [PUPRemote](#PUPRemote)
-**Overrides**: [disconnect](#Hub+disconnect)
-**Returns**: Promise - Resolved upon successful disconnect.
-
-
-### pupRemote.subscribe(port, [mode]) ⇒ Promise
-Subscribe to sensor notifications on a given port.
-
-**Kind**: instance method of [PUPRemote](#PUPRemote)
-**Overrides**: [subscribe](#Hub+subscribe)
-**Returns**: Promise - Resolved upon successful issuance of command.
-
-| Param | Type | Description |
-| --- | --- | --- |
-| port | string | |
-| [mode] | number | The sensor mode to activate. If no mode is provided, the default for that sensor will be chosen. |
-
-
-
-### pupRemote.unsubscribe(port) ⇒ Promise
-Unsubscribe to sensor notifications on a given port.
-
-**Kind**: instance method of [PUPRemote](#PUPRemote)
-**Overrides**: [unsubscribe](#Hub+unsubscribe)
-**Returns**: Promise - Resolved upon successful issuance of command.
-
-| Param | Type |
-| --- | --- |
-| port | string |
-
-
-
-### pupRemote.sleep(delay) ⇒ Promise
-Sleep a given amount of time.
-
-This is a helper method to make it easier to add delays into a chain of commands.
-
-**Kind**: instance method of [PUPRemote](#PUPRemote)
-**Overrides**: [sleep](#Hub+sleep)
-**Returns**: Promise - Resolved after the delay is finished.
-
-| Param | Type | Description |
-| --- | --- | --- |
-| delay | number | How long to sleep (in milliseconds). |
-
-
-
-### pupRemote.wait(commands) ⇒ Promise
-Wait until a given list of concurrently running commands are complete.
-
-This is a helper method to make it easier to wait for concurrent commands to complete.
-
-**Kind**: instance method of [PUPRemote](#PUPRemote)
-**Overrides**: [wait](#Hub+wait)
-**Returns**: Promise - Resolved after the commands are finished.
-
-| Param | Type | Description |
-| --- | --- | --- |
-| commands | Array.<Promise.<any>> | Array of executing commands. |
-
-
-
-### "button" (button, state)
-Emits when a button is pressed.
-
-**Kind**: event emitted by [PUPRemote](#PUPRemote)
-
-| Param | Type | Description |
-| --- | --- | --- |
-| button | string | |
-| state | number | A number representing one of the button state consts. |
-
-
-
-### "colorAndDistance" (port, color, distance)
-A combined color and distance event, emits when the sensor is activated.
-
-**Kind**: event emitted by [PUPRemote](#PUPRemote)
-
-| Param | Type | Description |
-| --- | --- | --- |
-| port | string | |
-| color | number | A number representing one of the LED color consts. |
-| distance | number | Distance, in millimeters. |
-
-
-
-## DuploTrainBase ⇐ LPF2Hub
-**Kind**: global class
-**Extends**: LPF2Hub, Hub
-
-* [DuploTrainBase](#DuploTrainBase) ⇐ LPF2Hub
- * [new DuploTrainBase()](#new_DuploTrainBase_new)
- * [.current](#LPF2Hub+current)
- * [.name](#Hub+name)
- * [.uuid](#Hub+uuid)
- * [.rssi](#Hub+rssi)
- * [.batteryLevel](#Hub+batteryLevel)
- * [.setLEDColor(color)](#DuploTrainBase+setLEDColor) ⇒ Promise
- * [.setMotorSpeed(port, speed, [time])](#DuploTrainBase+setMotorSpeed) ⇒ Promise
- * [.playSound(sound)](#DuploTrainBase+playSound) ⇒ Promise
- * [.rampMotorSpeed(port, fromSpeed, toSpeed, time)](#DuploTrainBase+rampMotorSpeed) ⇒ Promise
- * [.setName(name)](#LPF2Hub+setName) ⇒ Promise
- * [.setLEDRGB(red, green, blue)](#LPF2Hub+setLEDRGB) ⇒ Promise
- * [.connect()](#Hub+connect) ⇒ Promise
- * [.disconnect()](#Hub+disconnect) ⇒ Promise
- * [.subscribe(port, [mode])](#Hub+subscribe) ⇒ Promise
- * [.unsubscribe(port)](#Hub+unsubscribe) ⇒ Promise
- * [.sleep(delay)](#Hub+sleep) ⇒ Promise
- * [.wait(commands)](#Hub+wait) ⇒ Promise
- * ["color" (port, color)](#LPF2Hub+event_color)
- * ["colorAndDistance" (port, color, distance)](#LPF2Hub+event_colorAndDistance)
- * ["speed" (port, speed)](#LPF2Hub+event_speed)
-
-
-
-### new DuploTrainBase()
-The DuploTrainBase is emitted if the discovered device is a Duplo Train Base.
-
-
-
-### duploTrainBase.current
-**Kind**: instance property of [DuploTrainBase](#DuploTrainBase)
-**Read only**: true
-**Properties**
-
-| Name | Type | Description |
-| --- | --- | --- |
-| current | number | Current usage of the hub (Amps) |
-
-
-
-### duploTrainBase.name
-**Kind**: instance property of [DuploTrainBase](#DuploTrainBase)
-**Overrides**: [name](#Hub+name)
-**Read only**: true
-**Properties**
-
-| Name | Type | Description |
-| --- | --- | --- |
-| name | string | Name of the hub |
-
-
-
-### duploTrainBase.uuid
-**Kind**: instance property of [DuploTrainBase](#DuploTrainBase)
-**Overrides**: [uuid](#Hub+uuid)
-**Read only**: true
-**Properties**
-
-| Name | Type | Description |
-| --- | --- | --- |
-| uuid | string | UUID of the hub |
-
-
-
-### duploTrainBase.rssi
-**Kind**: instance property of [DuploTrainBase](#DuploTrainBase)
-**Overrides**: [rssi](#Hub+rssi)
-**Read only**: true
-**Properties**
-
-| Name | Type | Description |
-| --- | --- | --- |
-| rssi | number | Signal strength of the hub |
-
-
-
-### duploTrainBase.batteryLevel
-**Kind**: instance property of [DuploTrainBase](#DuploTrainBase)
-**Overrides**: [batteryLevel](#Hub+batteryLevel)
-**Read only**: true
-**Properties**
-
-| Name | Type | Description |
-| --- | --- | --- |
-| batteryLevel | number | Battery level of the hub (Percentage between 0-100) |
-
-
-
-### duploTrainBase.setLEDColor(color) ⇒ Promise
-Set the color of the LED on the train via a color value.
-
-**Kind**: instance method of [DuploTrainBase](#DuploTrainBase)
-**Overrides**: [setLEDColor](#LPF2Hub+setLEDColor)
-**Returns**: Promise - Resolved upon successful issuance of command.
-
-| Param | Type | Description |
-| --- | --- | --- |
-| color | number | A number representing one of the LED color consts. |
-
-
-
-### duploTrainBase.setMotorSpeed(port, speed, [time]) ⇒ Promise
-Set the motor speed on a given port.
-
-**Kind**: instance method of [DuploTrainBase](#DuploTrainBase)
-**Returns**: Promise - Resolved upon successful completion of command. If time is specified, this is once the motor is finished.
-
-| Param | Type | Description |
-| --- | --- | --- |
-| port | string | |
-| speed | number \| Array.<number> | For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0. If you are specifying port AB to control both motors, you can optionally supply a tuple of speeds. |
-| [time] | number | How long to activate the motor for (in milliseconds). Leave empty to turn the motor on indefinitely. |
-
-
-
-### duploTrainBase.playSound(sound) ⇒ Promise
-Play a built-in train sound.
-
-**Kind**: instance method of [DuploTrainBase](#DuploTrainBase)
-**Returns**: Promise - Resolved upon successful issuance of command.
-
-| Param | Type | Description |
-| --- | --- | --- |
-| sound | number | A number representing one of the Train Base sound consts. |
-
-
-
-### duploTrainBase.rampMotorSpeed(port, fromSpeed, toSpeed, time) ⇒ Promise
-Ramp the motor speed on a given port.
-
-**Kind**: instance method of [DuploTrainBase](#DuploTrainBase)
-**Returns**: Promise - Resolved upon successful completion of command.
-
-| Param | Type | Description |
-| --- | --- | --- |
-| port | string | |
-| fromSpeed | number | For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0. |
-| toSpeed | number | For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0. |
-| time | number | How long the ramp should last (in milliseconds). |
-
-
-
-### duploTrainBase.setName(name) ⇒ Promise
-Set the name of the Hub.
-
-**Kind**: instance method of [DuploTrainBase](#DuploTrainBase)
-**Returns**: Promise - Resolved upon successful issuance of command.
-
-| Param | Type | Description |
-| --- | --- | --- |
-| name | string | New name of the hub (14 characters or less, ASCII only). |
-
-
-
-### duploTrainBase.setLEDRGB(red, green, blue) ⇒ Promise
-Set the color of the LED on the Hub via RGB values.
-
-**Kind**: instance method of [DuploTrainBase](#DuploTrainBase)
-**Returns**: Promise - Resolved upon successful issuance of command.
-
-| Param | Type |
-| --- | --- |
-| red | number |
-| green | number |
-| blue | number |
-
-
-
-### duploTrainBase.connect() ⇒ Promise
-Connect to the Hub.
-
-**Kind**: instance method of [DuploTrainBase](#DuploTrainBase)
-**Overrides**: [connect](#Hub+connect)
-**Returns**: Promise - Resolved upon successful connect.
-
-
-### duploTrainBase.disconnect() ⇒ Promise
-Disconnect the Hub.
-
-**Kind**: instance method of [DuploTrainBase](#DuploTrainBase)
-**Overrides**: [disconnect](#Hub+disconnect)
-**Returns**: Promise - Resolved upon successful disconnect.
-
-
-### duploTrainBase.subscribe(port, [mode]) ⇒ Promise
-Subscribe to sensor notifications on a given port.
-
-**Kind**: instance method of [DuploTrainBase](#DuploTrainBase)
-**Overrides**: [subscribe](#Hub+subscribe)
-**Returns**: Promise - Resolved upon successful issuance of command.
-
-| Param | Type | Description |
-| --- | --- | --- |
-| port | string | |
-| [mode] | number | The sensor mode to activate. If no mode is provided, the default for that sensor will be chosen. |
-
-
-
-### duploTrainBase.unsubscribe(port) ⇒ Promise
-Unsubscribe to sensor notifications on a given port.
-
-**Kind**: instance method of [DuploTrainBase](#DuploTrainBase)
-**Overrides**: [unsubscribe](#Hub+unsubscribe)
-**Returns**: Promise - Resolved upon successful issuance of command.
-
-| Param | Type |
-| --- | --- |
-| port | string |
-
-
-
-### duploTrainBase.sleep(delay) ⇒ Promise
-Sleep a given amount of time.
-
-This is a helper method to make it easier to add delays into a chain of commands.
-
-**Kind**: instance method of [DuploTrainBase](#DuploTrainBase)
-**Overrides**: [sleep](#Hub+sleep)
-**Returns**: Promise - Resolved after the delay is finished.
-
-| Param | Type | Description |
-| --- | --- | --- |
-| delay | number | How long to sleep (in milliseconds). |
-
-
-
-### duploTrainBase.wait(commands) ⇒ Promise
-Wait until a given list of concurrently running commands are complete.
-
-This is a helper method to make it easier to wait for concurrent commands to complete.
-
-**Kind**: instance method of [DuploTrainBase](#DuploTrainBase)
-**Overrides**: [wait](#Hub+wait)
-**Returns**: Promise - Resolved after the commands are finished.
-
-| Param | Type | Description |
-| --- | --- | --- |
-| commands | Array.<Promise.<any>> | Array of executing commands. |
-
-
-
-### "color" (port, color)
-Emits when a color sensor is activated.
-
-**Kind**: event emitted by [DuploTrainBase](#DuploTrainBase)
-
-| Param | Type | Description |
-| --- | --- | --- |
-| port | string | |
-| color | number | A number representing one of the LED color consts. |
-
-
-
-### "colorAndDistance" (port, color, distance)
-A combined color and distance event, emits when the sensor is activated.
-
-**Kind**: event emitted by [DuploTrainBase](#DuploTrainBase)
-
-| Param | Type | Description |
-| --- | --- | --- |
-| port | string | |
-| color | number | A number representing one of the LED color consts. |
-| distance | number | Distance, in millimeters. |
-
-
-
-### "speed" (port, speed)
-Emits on a speed change.
-
-**Kind**: event emitted by [DuploTrainBase](#DuploTrainBase)
-
-| Param | Type |
-| --- | --- |
-| port | string |
-| speed | number |
-
diff --git a/README.md b/README.md
index fc1b123..dbb1771 100644
--- a/README.md
+++ b/README.md
@@ -1,22 +1,15 @@
-[](https://circleci.com/gh/nathankellenicki/node-poweredup)
-[](https://gitter.im/node-poweredup?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
-
+[](https://drone.kellenicki.com/nkellenicki/node-poweredup)
+[](https://www.npmjs.com/package/node-poweredup)
-# **node-poweredup** - A Node.js module to interface with LEGO Powered UP components.
+# **node-poweredup** - A Javascript module to interface with LEGO Powered Up components.
### Introduction
-LEGO Powered UP is the successor to Power Functions, the system for adding electronics to LEGO models. Powered UP is a collection of ranges - starting with LEGO WeDo 2.0 released in 2016, LEGO Boost released in 2017, and LEGO Powered UP released in 2018. It also includes the 2018 Duplo App-Controlled Train sets.
+LEGO Powered Up is the successor to Power Functions, the system for adding electronics to LEGO models. Powered Up is a collection of ranges - starting with LEGO WeDo 2.0 released in 2016, LEGO Boost released in 2017, LEGO Powered Up released in 2018, and LEGO Technic CONTROL+ released in 2019. It also includes the 2018 Duplo App-Controlled Train sets.
-Powered UP has a few improvements over Power Functions:
+This library allows communication and control of Powered Up devices and peripherals via Javascript, both from Node.js and from the browser using Web Bluetooth.
-1. The use of Bluetooth Low Energy makes it easy to control from a computer, and even write code for.
-
-2. The ability to use sensors to react to events happening in the real world opens up a whole new world of possibilities.
-
-3. As Powered UP hubs and remotes pair with each other, the system allows for a near unlimited number of independently controlled models in the same room. Power Functions was limited to 8 due to the use of infra-red for communication.
-
-### Installation
+### Node.js Installation
Node.js v8.0 required.
@@ -30,1666 +23,74 @@ Note: node-poweredup has been tested on macOS 10.13 and Debian/Raspbian on the R
### Compatibility
-While most Powered UP components and Hubs are compatible with each other, there are exceptions. For example, there is limited backwards compatibility between newer components and the WeDo 2.0 Smart Hub. However WeDo 2.0 components are fully forwards compatible with newer Hubs.
+While most Powered Up components and Hubs are compatible with each other, there are exceptions. For example, there is limited backwards compatibility between newer components and the WeDo 2.0 Smart Hub. However WeDo 2.0 components are fully forwards compatible with newer Hubs.
-| Name | Type | WeDo 2.0 Smart Hub | Boost Move Hub | Powered UP Hub | Availability |
-| ------------------------------- | ------------- | ------------------ | -------------- | -------------- | ------------ |
-| WeDo 2.0 Tilt Sensor | Sensor | Yes | Yes | Yes | 45300 |
-| WeDo 2.0 Motion Sensor | Sensor | Yes | Yes | Yes | 45300 |
-| WeDo 2.0 Medium Motor | Motor | Yes | Yes | Yes | 45300 76112 |
-| Boost Color and Distance Sensor | Sensor | *Partial* | Yes | Yes | 17101 |
-| Boost Tacho Motor | Motor/Sensor | *Partial* | Yes | *Partial* | 17101 |
-| Powered UP Train Motor | Motor | Yes | Yes | Yes | 60197 60198 |
-| Powered UP LED Lights | Light | Yes | Yes | Yes | 88005 |
+| Device Name | Product Code | Type | WeDo 2.0 Smart Hub | Boost Move Hub | Powered Up Hub | Control+ Hub | Availability |
+| ------------------------------- | ------------ | ------------- | ------------------ | -------------- | -------------- | ------------ | ----- |
+| WeDo 2.0 Tilt Sensor | 45305 | Sensor | Yes | Yes | Yes | Yes | 45300 |
+| WeDo 2.0 Motion Sensor | 45304 | Sensor | Yes | Yes | Yes | Yes | 45300 |
+| WeDo 2.0 Medium Motor | 45303 | Motor | Yes | Yes | Yes | Yes | 45300 76112 |
+| Boost Color and Distance Sensor | 88007 | Sensor | *Partial* | Yes | Yes | Yes | 17101 |
+| Boost Tacho Motor | 88008 | Motor/Sensor | *Partial* | Yes | Yes | Yes | 17101 |
+| Powered Up Train Motor | 88011 | Motor | Yes | Yes | Yes | Yes | 60197 60198 |
+| Powered Up LED Lights | 88005 | Light | Yes | Yes | Yes | Yes | 88005 |
+| Control+ Large Motor | 22169 | Motor/Sensor | *Partial* | No | Yes | Yes | 42099 42100 |
+| Control+ XLarge Motor | 22172 | Motor/Sensor | *Partial* | No | Yes | Yes | 42099 42100 |
+In addition, the Hubs themselves have certain built-in features which this library exposes.
+
+| Hub Name | Product Code | Built-In Features | Availability |
+| ------------------ | ------------ | ---------------------- | ------------ |
+| WeDo 2.0 Smart hub | 45301 | RGB LED Piezo Buzzer Button | 45300 |
+| Boost Move Hub | 88006 | RGB LED Tilt Sensor 2x Tacho Motors Button | 17101 |
+| Powered Up Hub | 88009 | RGB LED Button | 60197 60198 76112 |
+| Powered Up Remote | 88010 | RGB LED Left and Right Control Buttons Button | 60197 60198 |
+| Duplo Train Base | 28743 | RGB LED/Headlights Speaker Speedometer Motor Color and Distance Sensor Button | 10874 10875 |
+| Control+ Hub | 22127 | RGB LED Button Tilt Sensor Accelerometer | 42099 42100 |
### Known Issues and Limitations
* The Boost Color and Distance sensor only works in color mode with the WeDo 2.0 Smart Hub.
-* When used with the WeDo 2.0 Smart Hub, the Boost Tacho Motor does not support rotating the motor by angle.
+* When used with the WeDo 2.0 Smart Hub, the Boost Tacho Motor and Control+ Motors do not support rotating the motor by angle.
-* When used with the Powered UP Hub, the Boost Tacho Motor does not support rotating the motor by angle. It also does not support rotation detection.
+* When used with the Boost Move Hub, the Control+ Motors do not currently accept commands.
-* Plugging two Boost Tacho Motors into the Powered UP Hub will crash the Hub (This requires a firmware update from LEGO to fix).
+### Documentation
-### Usage
+[Full documentation is available here.](https://nathankellenicki.github.io/node-poweredup/)
+
+### Node.js Sample Usage
```javascript
const PoweredUP = require("node-poweredup");
const poweredUP = new PoweredUP.PoweredUP();
poweredUP.on("discover", async (hub) => { // Wait to discover a Hub
+ console.log(`Discovered ${hub.name}!`);
await hub.connect(); // Connect to the Hub
+ console.log("Connected");
await hub.sleep(3000); // Sleep for 3 seconds before starting
while (true) { // Repeat indefinitely
+ console.log("Running motor B at speed 75");
hub.setMotorSpeed("B", 75); // Start a motor attached to port B to run a 3/4 speed (75) indefinitely
+ console.log("Running motor A at speed 100 for 2 seconds");
await hub.setMotorSpeed("A", 100, 2000); // Run a motor attached to port A for 2 seconds at maximum speed (100) then stop
await hub.sleep(1000); // Do nothing for 1 second
+ console.log("Running motor A at speed -50 for 1 seconds");
await hub.setMotorSpeed("A", -50, 1000); // Run a motor attached to port A for 1 second at 1/2 speed in reverse (-50) then stop
await hub.sleep(1000); // Do nothing for 1 second
}
});
poweredUP.scan(); // Start scanning for Hubs
+console.log("Scanning for Hubs...");
```
More examples are available in the "examples" directory.
### Credits
-Thanks go to Jorge Pereira ([@JorgePe](https://github.com/JorgePe)), Sebastian Raff ([@hobbyquaker](https://github.com/hobbyquaker)), Valentin Heun ([@vheun](https://github.com/vheun)), Johan Korten ([@jakorten](https://github.com/jakorten)), and Andrey Pokhilko ([@undera](https://github.com/undera)) for their various works, contributions, and assistance on figuring out the LEGO Boost, WeDo 2.0, and Powered UP protocols.
-
-## Classes
-
-
-
-
-
-## PoweredUP ⇐ EventEmitter
-**Kind**: global class
-**Extends**: EventEmitter
-
-* [PoweredUP](#PoweredUP) ⇐ EventEmitter
- * [.scan()](#PoweredUP+scan)
- * [.stop()](#PoweredUP+stop)
- * [.getConnectedHubByUUID(uuid)](#PoweredUP+getConnectedHubByUUID) ⇒ Hub \| null
- * [.getConnectedHubs()](#PoweredUP+getConnectedHubs) ⇒ Array.<Hub>
- * ["discover" (hub)](#PoweredUP+event_discover)
-
-
-
-### poweredUP.scan()
-Begin scanning for Powered UP Hub devices.
-
-**Kind**: instance method of [PoweredUP](#PoweredUP)
-
-
-### poweredUP.stop()
-Stop scanning for Powered UP Hub devices.
-
-**Kind**: instance method of [PoweredUP](#PoweredUP)
-
-
-### poweredUP.getConnectedHubByUUID(uuid) ⇒ Hub \| null
-Retrieve a Powered UP Hub by UUID.
-
-**Kind**: instance method of [PoweredUP](#PoweredUP)
-
-| Param | Type |
-| --- | --- |
-| uuid | string |
-
-
-
-### poweredUP.getConnectedHubs() ⇒ Array.<Hub>
-Retrieve a list of Powered UP Hubs.
-
-**Kind**: instance method of [PoweredUP](#PoweredUP)
-
-
-### "discover" (hub)
-Emits when a Powered UP Hub device is found.
-
-**Kind**: event emitted by [PoweredUP](#PoweredUP)
-
-| Param | Type |
-| --- | --- |
-| hub | [WeDo2SmartHub](#WeDo2SmartHub) \| [BoostMoveHub](#BoostMoveHub) \| [PUPHub](#PUPHub) \| [PUPRemote](#PUPRemote) \| [DuploTrainBase](#DuploTrainBase) |
-
-
-
-## WeDo2SmartHub ⇐ Hub
-**Kind**: global class
-**Extends**: Hub
-
-* [WeDo2SmartHub](#WeDo2SmartHub) ⇐ Hub
- * [new WeDo2SmartHub()](#new_WeDo2SmartHub_new)
- * [.name](#Hub+name)
- * [.uuid](#Hub+uuid)
- * [.rssi](#Hub+rssi)
- * [.batteryLevel](#Hub+batteryLevel)
- * [.setName(name)](#WeDo2SmartHub+setName) ⇒ Promise
- * [.setLEDColor(color)](#WeDo2SmartHub+setLEDColor) ⇒ Promise
- * [.setLEDRGB(red, green, blue)](#WeDo2SmartHub+setLEDRGB) ⇒ Promise
- * [.setMotorSpeed(port, speed, [time])](#WeDo2SmartHub+setMotorSpeed) ⇒ Promise
- * [.rampMotorSpeed(port, fromSpeed, toSpeed, time)](#WeDo2SmartHub+rampMotorSpeed) ⇒ Promise
- * [.playTone(frequency, time)](#WeDo2SmartHub+playTone) ⇒ Promise
- * [.setLightBrightness(port, brightness, [time])](#WeDo2SmartHub+setLightBrightness) ⇒ Promise
- * [.connect()](#Hub+connect) ⇒ Promise
- * [.disconnect()](#Hub+disconnect) ⇒ Promise
- * [.subscribe(port, [mode])](#Hub+subscribe) ⇒ Promise
- * [.unsubscribe(port)](#Hub+unsubscribe) ⇒ Promise
- * [.sleep(delay)](#Hub+sleep) ⇒ Promise
- * [.wait(commands)](#Hub+wait) ⇒ Promise
- * ["button" (button, state)](#WeDo2SmartHub+event_button)
- * ["distance" (port, distance)](#WeDo2SmartHub+event_distance)
- * ["color" (port, color)](#WeDo2SmartHub+event_color)
- * ["tilt" (port, x, y)](#WeDo2SmartHub+event_tilt)
- * ["rotate" (port, rotation)](#WeDo2SmartHub+event_rotate)
- * ["attach" (port, type)](#Hub+event_attach)
- * ["detach" (port)](#Hub+event_detach)
-
-
-
-### new WeDo2SmartHub()
-The WeDo2SmartHub is emitted if the discovered device is a WeDo 2.0 Smart Hub.
-
-
-
-### weDo2SmartHub.name
-**Kind**: instance property of [WeDo2SmartHub](#WeDo2SmartHub)
-**Read only**: true
-**Properties**
-
-| Name | Type | Description |
-| --- | --- | --- |
-| name | string | Name of the hub |
-
-
-
-### weDo2SmartHub.uuid
-**Kind**: instance property of [WeDo2SmartHub](#WeDo2SmartHub)
-**Read only**: true
-**Properties**
-
-| Name | Type | Description |
-| --- | --- | --- |
-| uuid | string | UUID of the hub |
-
-
-
-### weDo2SmartHub.rssi
-**Kind**: instance property of [WeDo2SmartHub](#WeDo2SmartHub)
-**Read only**: true
-**Properties**
-
-| Name | Type | Description |
-| --- | --- | --- |
-| rssi | number | Signal strength of the hub |
-
-
-
-### weDo2SmartHub.batteryLevel
-**Kind**: instance property of [WeDo2SmartHub](#WeDo2SmartHub)
-**Read only**: true
-**Properties**
-
-| Name | Type | Description |
-| --- | --- | --- |
-| batteryLevel | number | Battery level of the hub (Percentage between 0-100) |
-
-
-
-### weDo2SmartHub.setName(name) ⇒ Promise
-Set the name of the Hub.
-
-**Kind**: instance method of [WeDo2SmartHub](#WeDo2SmartHub)
-**Returns**: Promise - Resolved upon successful issuance of command.
-
-| Param | Type | Description |
-| --- | --- | --- |
-| name | string | New name of the hub (14 characters or less, ASCII only). |
-
-
-
-### weDo2SmartHub.setLEDColor(color) ⇒ Promise
-Set the color of the LED on the Hub via a color value.
-
-**Kind**: instance method of [WeDo2SmartHub](#WeDo2SmartHub)
-**Returns**: Promise - Resolved upon successful issuance of command.
-
-| Param | Type | Description |
-| --- | --- | --- |
-| color | number | A number representing one of the LED color consts. |
-
-
-
-### weDo2SmartHub.setLEDRGB(red, green, blue) ⇒ Promise
-Set the color of the LED on the Hub via RGB values.
-
-**Kind**: instance method of [WeDo2SmartHub](#WeDo2SmartHub)
-**Returns**: Promise - Resolved upon successful issuance of command.
-
-| Param | Type |
-| --- | --- |
-| red | number |
-| green | number |
-| blue | number |
-
-
-
-### weDo2SmartHub.setMotorSpeed(port, speed, [time]) ⇒ Promise
-Set the motor speed on a given port.
-
-**Kind**: instance method of [WeDo2SmartHub](#WeDo2SmartHub)
-**Returns**: Promise - Resolved upon successful completion of command. If time is specified, this is once the motor is finished.
-
-| Param | Type | Description |
-| --- | --- | --- |
-| port | string | |
-| speed | number | For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0. |
-| [time] | number | How long to activate the motor for (in milliseconds). Leave empty to turn the motor on indefinitely. |
-
-
-
-### weDo2SmartHub.rampMotorSpeed(port, fromSpeed, toSpeed, time) ⇒ Promise
-Ramp the motor speed on a given port.
-
-**Kind**: instance method of [WeDo2SmartHub](#WeDo2SmartHub)
-**Returns**: Promise - Resolved upon successful completion of command.
-
-| Param | Type | Description |
-| --- | --- | --- |
-| port | string | |
-| fromSpeed | number | For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0. |
-| toSpeed | number | For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0. |
-| time | number | How long the ramp should last (in milliseconds). |
-
-
-
-### weDo2SmartHub.playTone(frequency, time) ⇒ Promise
-Play a tone on the Hub's in-built buzzer
-
-**Kind**: instance method of [WeDo2SmartHub](#WeDo2SmartHub)
-**Returns**: Promise - Resolved upon successful completion of command (ie. once the tone has finished playing).
-
-| Param | Type | Description |
-| --- | --- | --- |
-| frequency | number | |
-| time | number | How long the tone should play for (in milliseconds). |
-
-
-
-### weDo2SmartHub.setLightBrightness(port, brightness, [time]) ⇒ Promise
-Set the light brightness on a given port.
-
-**Kind**: instance method of [WeDo2SmartHub](#WeDo2SmartHub)
-**Returns**: Promise - Resolved upon successful completion of command. If time is specified, this is once the light is turned off.
-
-| Param | Type | Description |
-| --- | --- | --- |
-| port | string | |
-| brightness | number | Brightness value between 0-100 (0 is off) |
-| [time] | number | How long to turn the light on (in milliseconds). Leave empty to turn the light on indefinitely. |
-
-
-
-### weDo2SmartHub.connect() ⇒ Promise
-Connect to the Hub.
-
-**Kind**: instance method of [WeDo2SmartHub](#WeDo2SmartHub)
-**Overrides**: [connect](#Hub+connect)
-**Returns**: Promise - Resolved upon successful connect.
-
-
-### weDo2SmartHub.disconnect() ⇒ Promise
-Disconnect the Hub.
-
-**Kind**: instance method of [WeDo2SmartHub](#WeDo2SmartHub)
-**Returns**: Promise - Resolved upon successful disconnect.
-
-
-### weDo2SmartHub.subscribe(port, [mode]) ⇒ Promise
-Subscribe to sensor notifications on a given port.
-
-**Kind**: instance method of [WeDo2SmartHub](#WeDo2SmartHub)
-**Returns**: Promise - Resolved upon successful issuance of command.
-
-| Param | Type | Description |
-| --- | --- | --- |
-| port | string | |
-| [mode] | number | The sensor mode to activate. If no mode is provided, the default for that sensor will be chosen. |
-
-
-
-### weDo2SmartHub.unsubscribe(port) ⇒ Promise
-Unsubscribe to sensor notifications on a given port.
-
-**Kind**: instance method of [WeDo2SmartHub](#WeDo2SmartHub)
-**Returns**: Promise - Resolved upon successful issuance of command.
-
-| Param | Type |
-| --- | --- |
-| port | string |
-
-
-
-### weDo2SmartHub.sleep(delay) ⇒ Promise
-Sleep a given amount of time.
-
-This is a helper method to make it easier to add delays into a chain of commands.
-
-**Kind**: instance method of [WeDo2SmartHub](#WeDo2SmartHub)
-**Returns**: Promise - Resolved after the delay is finished.
-
-| Param | Type | Description |
-| --- | --- | --- |
-| delay | number | How long to sleep (in milliseconds). |
-
-
-
-### weDo2SmartHub.wait(commands) ⇒ Promise
-Wait until a given list of concurrently running commands are complete.
-
-This is a helper method to make it easier to wait for concurrent commands to complete.
-
-**Kind**: instance method of [WeDo2SmartHub](#WeDo2SmartHub)
-**Returns**: Promise - Resolved after the commands are finished.
-
-| Param | Type | Description |
-| --- | --- | --- |
-| commands | Array.<Promise.<any>> | Array of executing commands. |
-
-
-
-### "button" (button, state)
-Emits when a button is pressed.
-
-**Kind**: event emitted by [WeDo2SmartHub](#WeDo2SmartHub)
-
-| Param | Type | Description |
-| --- | --- | --- |
-| button | string | |
-| state | number | A number representing one of the button state consts. |
-
-
-
-### "distance" (port, distance)
-Emits when a distance sensor is activated.
-
-**Kind**: event emitted by [WeDo2SmartHub](#WeDo2SmartHub)
-
-| Param | Type | Description |
-| --- | --- | --- |
-| port | string | |
-| distance | number | Distance, in millimeters. |
-
-
-
-### "color" (port, color)
-Emits when a color sensor is activated.
-
-**Kind**: event emitted by [WeDo2SmartHub](#WeDo2SmartHub)
-
-| Param | Type | Description |
-| --- | --- | --- |
-| port | string | |
-| color | number | A number representing one of the LED color consts. |
-
-
-
-### "tilt" (port, x, y)
-Emits when a tilt sensor is activated.
-
-**Kind**: event emitted by [WeDo2SmartHub](#WeDo2SmartHub)
-
-| Param | Type |
-| --- | --- |
-| port | string |
-| x | number |
-| y | number |
-
-
-
-### "rotate" (port, rotation)
-Emits when a rotation sensor is activated.
-
-**Kind**: event emitted by [WeDo2SmartHub](#WeDo2SmartHub)
-
-| Param | Type |
-| --- | --- |
-| port | string |
-| rotation | number |
-
-
-
-### "attach" (port, type)
-Emits when a motor or sensor is attached to the Hub.
-
-**Kind**: event emitted by [WeDo2SmartHub](#WeDo2SmartHub)
-
-| Param | Type | Description |
-| --- | --- | --- |
-| port | string | |
-| type | number | A number representing one of the peripheral consts. |
-
-
-
-### "detach" (port)
-Emits when an attached motor or sensor is detached from the Hub.
-
-**Kind**: event emitted by [WeDo2SmartHub](#WeDo2SmartHub)
-
-| Param | Type |
-| --- | --- |
-| port | string |
-
-
-
-## BoostMoveHub ⇐ LPF2Hub
-**Kind**: global class
-**Extends**: LPF2Hub, Hub
-
-* [BoostMoveHub](#BoostMoveHub) ⇐ LPF2Hub
- * [new BoostMoveHub()](#new_BoostMoveHub_new)
- * [.current](#LPF2Hub+current)
- * [.name](#Hub+name)
- * [.uuid](#Hub+uuid)
- * [.rssi](#Hub+rssi)
- * [.batteryLevel](#Hub+batteryLevel)
- * [.setMotorSpeed(port, speed, [time])](#BoostMoveHub+setMotorSpeed) ⇒ Promise
- * [.rampMotorSpeed(port, fromSpeed, toSpeed, time)](#BoostMoveHub+rampMotorSpeed) ⇒ Promise
- * [.setMotorAngle(port, angle, [speed])](#BoostMoveHub+setMotorAngle) ⇒ Promise
- * [.setLightBrightness(port, brightness, [time])](#BoostMoveHub+setLightBrightness) ⇒ Promise
- * [.setName(name)](#LPF2Hub+setName) ⇒ Promise
- * [.setLEDColor(color)](#LPF2Hub+setLEDColor) ⇒ Promise
- * [.setLEDRGB(red, green, blue)](#LPF2Hub+setLEDRGB) ⇒ Promise
- * [.connect()](#Hub+connect) ⇒ Promise
- * [.disconnect()](#Hub+disconnect) ⇒ Promise
- * [.subscribe(port, [mode])](#Hub+subscribe) ⇒ Promise
- * [.unsubscribe(port)](#Hub+unsubscribe) ⇒ Promise
- * [.sleep(delay)](#Hub+sleep) ⇒ Promise
- * [.wait(commands)](#Hub+wait) ⇒ Promise
- * ["button" (button, state)](#LPF2Hub+event_button)
- * ["distance" (port, distance)](#LPF2Hub+event_distance)
- * ["color" (port, color)](#LPF2Hub+event_color)
- * ["colorAndDistance" (port, color, distance)](#LPF2Hub+event_colorAndDistance)
- * ["tilt" (port, x, y)](#LPF2Hub+event_tilt)
- * ["rotate" (port, rotation)](#LPF2Hub+event_rotate)
- * ["attach" (port, type)](#Hub+event_attach)
- * ["detach" (port)](#Hub+event_detach)
-
-
-
-### new BoostMoveHub()
-The BoostMoveHub is emitted if the discovered device is a Boost Move Hub.
-
-
-
-### boostMoveHub.current
-**Kind**: instance property of [BoostMoveHub](#BoostMoveHub)
-**Read only**: true
-**Properties**
-
-| Name | Type | Description |
-| --- | --- | --- |
-| current | number | Current usage of the hub (Amps) |
-
-
-
-### boostMoveHub.name
-**Kind**: instance property of [BoostMoveHub](#BoostMoveHub)
-**Overrides**: [name](#Hub+name)
-**Read only**: true
-**Properties**
-
-| Name | Type | Description |
-| --- | --- | --- |
-| name | string | Name of the hub |
-
-
-
-### boostMoveHub.uuid
-**Kind**: instance property of [BoostMoveHub](#BoostMoveHub)
-**Overrides**: [uuid](#Hub+uuid)
-**Read only**: true
-**Properties**
-
-| Name | Type | Description |
-| --- | --- | --- |
-| uuid | string | UUID of the hub |
-
-
-
-### boostMoveHub.rssi
-**Kind**: instance property of [BoostMoveHub](#BoostMoveHub)
-**Overrides**: [rssi](#Hub+rssi)
-**Read only**: true
-**Properties**
-
-| Name | Type | Description |
-| --- | --- | --- |
-| rssi | number | Signal strength of the hub |
-
-
-
-### boostMoveHub.batteryLevel
-**Kind**: instance property of [BoostMoveHub](#BoostMoveHub)
-**Overrides**: [batteryLevel](#Hub+batteryLevel)
-**Read only**: true
-**Properties**
-
-| Name | Type | Description |
-| --- | --- | --- |
-| batteryLevel | number | Battery level of the hub (Percentage between 0-100) |
-
-
-
-### boostMoveHub.setMotorSpeed(port, speed, [time]) ⇒ Promise
-Set the motor speed on a given port.
-
-**Kind**: instance method of [BoostMoveHub](#BoostMoveHub)
-**Returns**: Promise - Resolved upon successful completion of command. If time is specified, this is once the motor is finished.
-
-| Param | Type | Description |
-| --- | --- | --- |
-| port | string | |
-| speed | number \| Array.<number> | For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0. If you are specifying port AB to control both motors, you can optionally supply a tuple of speeds. |
-| [time] | number | How long to activate the motor for (in milliseconds). Leave empty to turn the motor on indefinitely. |
-
-
-
-### boostMoveHub.rampMotorSpeed(port, fromSpeed, toSpeed, time) ⇒ Promise
-Ramp the motor speed on a given port.
-
-**Kind**: instance method of [BoostMoveHub](#BoostMoveHub)
-**Returns**: Promise - Resolved upon successful completion of command.
-
-| Param | Type | Description |
-| --- | --- | --- |
-| port | string | |
-| fromSpeed | number | For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0. |
-| toSpeed | number | For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0. |
-| time | number | How long the ramp should last (in milliseconds). |
-
-
-
-### boostMoveHub.setMotorAngle(port, angle, [speed]) ⇒ Promise
-Rotate a motor by a given angle.
-
-**Kind**: instance method of [BoostMoveHub](#BoostMoveHub)
-**Returns**: Promise - Resolved upon successful completion of command (ie. once the motor is finished).
-
-| Param | Type | Default | Description |
-| --- | --- | --- | --- |
-| port | string | | |
-| angle | number | | How much the motor should be rotated (in degrees). |
-| [speed] | number \| Array.<number> | 100 | For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0. If you are specifying port AB to control both motors, you can optionally supply a tuple of speeds. |
-
-
-
-### boostMoveHub.setLightBrightness(port, brightness, [time]) ⇒ Promise
-Set the light brightness on a given port.
-
-**Kind**: instance method of [BoostMoveHub](#BoostMoveHub)
-**Returns**: Promise - Resolved upon successful completion of command. If time is specified, this is once the light is turned off.
-
-| Param | Type | Description |
-| --- | --- | --- |
-| port | string | |
-| brightness | number | Brightness value between 0-100 (0 is off) |
-| [time] | number | How long to turn the light on (in milliseconds). Leave empty to turn the light on indefinitely. |
-
-
-
-### boostMoveHub.setName(name) ⇒ Promise
-Set the name of the Hub.
-
-**Kind**: instance method of [BoostMoveHub](#BoostMoveHub)
-**Returns**: Promise - Resolved upon successful issuance of command.
-
-| Param | Type | Description |
-| --- | --- | --- |
-| name | string | New name of the hub (14 characters or less, ASCII only). |
-
-
-
-### boostMoveHub.setLEDColor(color) ⇒ Promise
-Set the color of the LED on the Hub via a color value.
-
-**Kind**: instance method of [BoostMoveHub](#BoostMoveHub)
-**Returns**: Promise - Resolved upon successful issuance of command.
-
-| Param | Type | Description |
-| --- | --- | --- |
-| color | number | A number representing one of the LED color consts. |
-
-
-
-### boostMoveHub.setLEDRGB(red, green, blue) ⇒ Promise
-Set the color of the LED on the Hub via RGB values.
-
-**Kind**: instance method of [BoostMoveHub](#BoostMoveHub)
-**Returns**: Promise - Resolved upon successful issuance of command.
-
-| Param | Type |
-| --- | --- |
-| red | number |
-| green | number |
-| blue | number |
-
-
-
-### boostMoveHub.connect() ⇒ Promise
-Connect to the Hub.
-
-**Kind**: instance method of [BoostMoveHub](#BoostMoveHub)
-**Overrides**: [connect](#Hub+connect)
-**Returns**: Promise - Resolved upon successful connect.
-
-
-### boostMoveHub.disconnect() ⇒ Promise
-Disconnect the Hub.
-
-**Kind**: instance method of [BoostMoveHub](#BoostMoveHub)
-**Overrides**: [disconnect](#Hub+disconnect)
-**Returns**: Promise - Resolved upon successful disconnect.
-
-
-### boostMoveHub.subscribe(port, [mode]) ⇒ Promise
-Subscribe to sensor notifications on a given port.
-
-**Kind**: instance method of [BoostMoveHub](#BoostMoveHub)
-**Overrides**: [subscribe](#Hub+subscribe)
-**Returns**: Promise - Resolved upon successful issuance of command.
-
-| Param | Type | Description |
-| --- | --- | --- |
-| port | string | |
-| [mode] | number | The sensor mode to activate. If no mode is provided, the default for that sensor will be chosen. |
-
-
-
-### boostMoveHub.unsubscribe(port) ⇒ Promise
-Unsubscribe to sensor notifications on a given port.
-
-**Kind**: instance method of [BoostMoveHub](#BoostMoveHub)
-**Overrides**: [unsubscribe](#Hub+unsubscribe)
-**Returns**: Promise - Resolved upon successful issuance of command.
-
-| Param | Type |
-| --- | --- |
-| port | string |
-
-
-
-### boostMoveHub.sleep(delay) ⇒ Promise
-Sleep a given amount of time.
-
-This is a helper method to make it easier to add delays into a chain of commands.
-
-**Kind**: instance method of [BoostMoveHub](#BoostMoveHub)
-**Overrides**: [sleep](#Hub+sleep)
-**Returns**: Promise - Resolved after the delay is finished.
-
-| Param | Type | Description |
-| --- | --- | --- |
-| delay | number | How long to sleep (in milliseconds). |
-
-
-
-### boostMoveHub.wait(commands) ⇒ Promise
-Wait until a given list of concurrently running commands are complete.
-
-This is a helper method to make it easier to wait for concurrent commands to complete.
-
-**Kind**: instance method of [BoostMoveHub](#BoostMoveHub)
-**Overrides**: [wait](#Hub+wait)
-**Returns**: Promise - Resolved after the commands are finished.
-
-| Param | Type | Description |
-| --- | --- | --- |
-| commands | Array.<Promise.<any>> | Array of executing commands. |
-
-
-
-### "button" (button, state)
-Emits when a button is pressed.
-
-**Kind**: event emitted by [BoostMoveHub](#BoostMoveHub)
-
-| Param | Type | Description |
-| --- | --- | --- |
-| button | string | |
-| state | number | A number representing one of the button state consts. |
-
-
-
-### "distance" (port, distance)
-Emits when a distance sensor is activated.
-
-**Kind**: event emitted by [BoostMoveHub](#BoostMoveHub)
-
-| Param | Type | Description |
-| --- | --- | --- |
-| port | string | |
-| distance | number | Distance, in millimeters. |
-
-
-
-### "color" (port, color)
-Emits when a color sensor is activated.
-
-**Kind**: event emitted by [BoostMoveHub](#BoostMoveHub)
-
-| Param | Type | Description |
-| --- | --- | --- |
-| port | string | |
-| color | number | A number representing one of the LED color consts. |
-
-
-
-### "colorAndDistance" (port, color, distance)
-A combined color and distance event, emits when the sensor is activated.
-
-**Kind**: event emitted by [BoostMoveHub](#BoostMoveHub)
-
-| Param | Type | Description |
-| --- | --- | --- |
-| port | string | |
-| color | number | A number representing one of the LED color consts. |
-| distance | number | Distance, in millimeters. |
-
-
-
-### "tilt" (port, x, y)
-Emits when a tilt sensor is activated.
-
-**Kind**: event emitted by [BoostMoveHub](#BoostMoveHub)
-
-| Param | Type | Description |
-| --- | --- | --- |
-| port | string | If the event is fired from the Move Hub's in-built tilt sensor, the special port "TILT" is used. |
-| x | number | |
-| y | number | |
-
-
-
-### "rotate" (port, rotation)
-Emits when a rotation sensor is activated.
-
-**Kind**: event emitted by [BoostMoveHub](#BoostMoveHub)
-
-| Param | Type |
-| --- | --- |
-| port | string |
-| rotation | number |
-
-
-
-### "attach" (port, type)
-Emits when a motor or sensor is attached to the Hub.
-
-**Kind**: event emitted by [BoostMoveHub](#BoostMoveHub)
-**Overrides**: [attach](#Hub+event_attach)
-
-| Param | Type | Description |
-| --- | --- | --- |
-| port | string | |
-| type | number | A number representing one of the peripheral consts. |
-
-
-
-### "detach" (port)
-Emits when an attached motor or sensor is detached from the Hub.
-
-**Kind**: event emitted by [BoostMoveHub](#BoostMoveHub)
-**Overrides**: [detach](#Hub+event_detach)
-
-| Param | Type |
-| --- | --- |
-| port | string |
-
-
-
-## PUPHub ⇐ LPF2Hub
-**Kind**: global class
-**Extends**: LPF2Hub, Hub
-
-* [PUPHub](#PUPHub) ⇐ LPF2Hub
- * [new PUPHub()](#new_PUPHub_new)
- * [.current](#LPF2Hub+current)
- * [.name](#Hub+name)
- * [.uuid](#Hub+uuid)
- * [.rssi](#Hub+rssi)
- * [.batteryLevel](#Hub+batteryLevel)
- * [.setMotorSpeed(port, speed, [time])](#PUPHub+setMotorSpeed) ⇒ Promise
- * [.rampMotorSpeed(port, fromSpeed, toSpeed, time)](#PUPHub+rampMotorSpeed) ⇒ Promise
- * [.setLightBrightness(port, brightness, [time])](#PUPHub+setLightBrightness) ⇒ Promise
- * [.setName(name)](#LPF2Hub+setName) ⇒ Promise
- * [.setLEDColor(color)](#LPF2Hub+setLEDColor) ⇒ Promise
- * [.setLEDRGB(red, green, blue)](#LPF2Hub+setLEDRGB) ⇒ Promise
- * [.connect()](#Hub+connect) ⇒ Promise
- * [.disconnect()](#Hub+disconnect) ⇒ Promise
- * [.subscribe(port, [mode])](#Hub+subscribe) ⇒ Promise
- * [.unsubscribe(port)](#Hub+unsubscribe) ⇒ Promise
- * [.sleep(delay)](#Hub+sleep) ⇒ Promise
- * [.wait(commands)](#Hub+wait) ⇒ Promise
- * ["button" (button, state)](#LPF2Hub+event_button)
- * ["distance" (port, distance)](#LPF2Hub+event_distance)
- * ["color" (port, color)](#LPF2Hub+event_color)
- * ["colorAndDistance" (port, color, distance)](#LPF2Hub+event_colorAndDistance)
- * ["tilt" (port, x, y)](#LPF2Hub+event_tilt)
- * ["attach" (port, type)](#Hub+event_attach)
- * ["detach" (port)](#Hub+event_detach)
-
-
-
-### new PUPHub()
-The PUPHub is emitted if the discovered device is a Powered UP Hub.
-
-
-
-### pupHub.current
-**Kind**: instance property of [PUPHub](#PUPHub)
-**Read only**: true
-**Properties**
-
-| Name | Type | Description |
-| --- | --- | --- |
-| current | number | Current usage of the hub (Amps) |
-
-
-
-### pupHub.name
-**Kind**: instance property of [PUPHub](#PUPHub)
-**Overrides**: [name](#Hub+name)
-**Read only**: true
-**Properties**
-
-| Name | Type | Description |
-| --- | --- | --- |
-| name | string | Name of the hub |
-
-
-
-### pupHub.uuid
-**Kind**: instance property of [PUPHub](#PUPHub)
-**Overrides**: [uuid](#Hub+uuid)
-**Read only**: true
-**Properties**
-
-| Name | Type | Description |
-| --- | --- | --- |
-| uuid | string | UUID of the hub |
-
-
-
-### pupHub.rssi
-**Kind**: instance property of [PUPHub](#PUPHub)
-**Overrides**: [rssi](#Hub+rssi)
-**Read only**: true
-**Properties**
-
-| Name | Type | Description |
-| --- | --- | --- |
-| rssi | number | Signal strength of the hub |
-
-
-
-### pupHub.batteryLevel
-**Kind**: instance property of [PUPHub](#PUPHub)
-**Overrides**: [batteryLevel](#Hub+batteryLevel)
-**Read only**: true
-**Properties**
-
-| Name | Type | Description |
-| --- | --- | --- |
-| batteryLevel | number | Battery level of the hub (Percentage between 0-100) |
-
-
-
-### pupHub.setMotorSpeed(port, speed, [time]) ⇒ Promise
-Set the motor speed on a given port.
-
-**Kind**: instance method of [PUPHub](#PUPHub)
-**Returns**: Promise - Resolved upon successful completion of command. If time is specified, this is once the motor is finished.
-
-| Param | Type | Description |
-| --- | --- | --- |
-| port | string | |
-| speed | number \| Array.<number> | For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0. If you are specifying port AB to control both motors, you can optionally supply a tuple of speeds. |
-| [time] | number | How long to activate the motor for (in milliseconds). Leave empty to turn the motor on indefinitely. |
-
-
-
-### pupHub.rampMotorSpeed(port, fromSpeed, toSpeed, time) ⇒ Promise
-Ramp the motor speed on a given port.
-
-**Kind**: instance method of [PUPHub](#PUPHub)
-**Returns**: Promise - Resolved upon successful completion of command.
-
-| Param | Type | Description |
-| --- | --- | --- |
-| port | string | |
-| fromSpeed | number | For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0. |
-| toSpeed | number | For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0. |
-| time | number | How long the ramp should last (in milliseconds). |
-
-
-
-### pupHub.setLightBrightness(port, brightness, [time]) ⇒ Promise
-Set the light brightness on a given port.
-
-**Kind**: instance method of [PUPHub](#PUPHub)
-**Returns**: Promise - Resolved upon successful completion of command. If time is specified, this is once the light is turned off.
-
-| Param | Type | Description |
-| --- | --- | --- |
-| port | string | |
-| brightness | number | Brightness value between 0-100 (0 is off) |
-| [time] | number | How long to turn the light on (in milliseconds). Leave empty to turn the light on indefinitely. |
-
-
-
-### pupHub.setName(name) ⇒ Promise
-Set the name of the Hub.
-
-**Kind**: instance method of [PUPHub](#PUPHub)
-**Returns**: Promise - Resolved upon successful issuance of command.
-
-| Param | Type | Description |
-| --- | --- | --- |
-| name | string | New name of the hub (14 characters or less, ASCII only). |
-
-
-
-### pupHub.setLEDColor(color) ⇒ Promise
-Set the color of the LED on the Hub via a color value.
-
-**Kind**: instance method of [PUPHub](#PUPHub)
-**Returns**: Promise - Resolved upon successful issuance of command.
-
-| Param | Type | Description |
-| --- | --- | --- |
-| color | number | A number representing one of the LED color consts. |
-
-
-
-### pupHub.setLEDRGB(red, green, blue) ⇒ Promise
-Set the color of the LED on the Hub via RGB values.
-
-**Kind**: instance method of [PUPHub](#PUPHub)
-**Returns**: Promise - Resolved upon successful issuance of command.
-
-| Param | Type |
-| --- | --- |
-| red | number |
-| green | number |
-| blue | number |
-
-
-
-### pupHub.connect() ⇒ Promise
-Connect to the Hub.
-
-**Kind**: instance method of [PUPHub](#PUPHub)
-**Overrides**: [connect](#Hub+connect)
-**Returns**: Promise - Resolved upon successful connect.
-
-
-### pupHub.disconnect() ⇒ Promise
-Disconnect the Hub.
-
-**Kind**: instance method of [PUPHub](#PUPHub)
-**Overrides**: [disconnect](#Hub+disconnect)
-**Returns**: Promise - Resolved upon successful disconnect.
-
-
-### pupHub.subscribe(port, [mode]) ⇒ Promise
-Subscribe to sensor notifications on a given port.
-
-**Kind**: instance method of [PUPHub](#PUPHub)
-**Overrides**: [subscribe](#Hub+subscribe)
-**Returns**: Promise - Resolved upon successful issuance of command.
-
-| Param | Type | Description |
-| --- | --- | --- |
-| port | string | |
-| [mode] | number | The sensor mode to activate. If no mode is provided, the default for that sensor will be chosen. |
-
-
-
-### pupHub.unsubscribe(port) ⇒ Promise
-Unsubscribe to sensor notifications on a given port.
-
-**Kind**: instance method of [PUPHub](#PUPHub)
-**Overrides**: [unsubscribe](#Hub+unsubscribe)
-**Returns**: Promise - Resolved upon successful issuance of command.
-
-| Param | Type |
-| --- | --- |
-| port | string |
-
-
-
-### pupHub.sleep(delay) ⇒ Promise
-Sleep a given amount of time.
-
-This is a helper method to make it easier to add delays into a chain of commands.
-
-**Kind**: instance method of [PUPHub](#PUPHub)
-**Overrides**: [sleep](#Hub+sleep)
-**Returns**: Promise - Resolved after the delay is finished.
-
-| Param | Type | Description |
-| --- | --- | --- |
-| delay | number | How long to sleep (in milliseconds). |
-
-
-
-### pupHub.wait(commands) ⇒ Promise
-Wait until a given list of concurrently running commands are complete.
-
-This is a helper method to make it easier to wait for concurrent commands to complete.
-
-**Kind**: instance method of [PUPHub](#PUPHub)
-**Overrides**: [wait](#Hub+wait)
-**Returns**: Promise - Resolved after the commands are finished.
-
-| Param | Type | Description |
-| --- | --- | --- |
-| commands | Array.<Promise.<any>> | Array of executing commands. |
-
-
-
-### "button" (button, state)
-Emits when a button is pressed.
-
-**Kind**: event emitted by [PUPHub](#PUPHub)
-
-| Param | Type | Description |
-| --- | --- | --- |
-| button | string | |
-| state | number | A number representing one of the button state consts. |
-
-
-
-### "distance" (port, distance)
-Emits when a distance sensor is activated.
-
-**Kind**: event emitted by [PUPHub](#PUPHub)
-
-| Param | Type | Description |
-| --- | --- | --- |
-| port | string | |
-| distance | number | Distance, in millimeters. |
-
-
-
-### "color" (port, color)
-Emits when a color sensor is activated.
-
-**Kind**: event emitted by [PUPHub](#PUPHub)
-
-| Param | Type | Description |
-| --- | --- | --- |
-| port | string | |
-| color | number | A number representing one of the LED color consts. |
-
-
-
-### "colorAndDistance" (port, color, distance)
-A combined color and distance event, emits when the sensor is activated.
-
-**Kind**: event emitted by [PUPHub](#PUPHub)
-
-| Param | Type | Description |
-| --- | --- | --- |
-| port | string | |
-| color | number | A number representing one of the LED color consts. |
-| distance | number | Distance, in millimeters. |
-
-
-
-### "tilt" (port, x, y)
-Emits when a tilt sensor is activated.
-
-**Kind**: event emitted by [PUPHub](#PUPHub)
-
-| Param | Type | Description |
-| --- | --- | --- |
-| port | string | If the event is fired from the Move Hub's in-built tilt sensor, the special port "TILT" is used. |
-| x | number | |
-| y | number | |
-
-
-
-### "attach" (port, type)
-Emits when a motor or sensor is attached to the Hub.
-
-**Kind**: event emitted by [PUPHub](#PUPHub)
-**Overrides**: [attach](#Hub+event_attach)
-
-| Param | Type | Description |
-| --- | --- | --- |
-| port | string | |
-| type | number | A number representing one of the peripheral consts. |
-
-
-
-### "detach" (port)
-Emits when an attached motor or sensor is detached from the Hub.
-
-**Kind**: event emitted by [PUPHub](#PUPHub)
-**Overrides**: [detach](#Hub+event_detach)
-
-| Param | Type |
-| --- | --- |
-| port | string |
-
-
-
-## PUPRemote ⇐ LPF2Hub
-**Kind**: global class
-**Extends**: LPF2Hub, Hub
-
-* [PUPRemote](#PUPRemote) ⇐ LPF2Hub
- * [new PUPRemote()](#new_PUPRemote_new)
- * [.current](#LPF2Hub+current)
- * [.name](#Hub+name)
- * [.uuid](#Hub+uuid)
- * [.rssi](#Hub+rssi)
- * [.batteryLevel](#Hub+batteryLevel)
- * [.setLEDColor(color)](#PUPRemote+setLEDColor) ⇒ Promise
- * [.setLEDRGB(red, green, blue)](#PUPRemote+setLEDRGB) ⇒ Promise
- * [.setName(name)](#LPF2Hub+setName) ⇒ Promise
- * [.connect()](#Hub+connect) ⇒ Promise
- * [.disconnect()](#Hub+disconnect) ⇒ Promise
- * [.subscribe(port, [mode])](#Hub+subscribe) ⇒ Promise
- * [.unsubscribe(port)](#Hub+unsubscribe) ⇒ Promise
- * [.sleep(delay)](#Hub+sleep) ⇒ Promise
- * [.wait(commands)](#Hub+wait) ⇒ Promise
- * ["button" (button, state)](#LPF2Hub+event_button)
- * ["colorAndDistance" (port, color, distance)](#LPF2Hub+event_colorAndDistance)
-
-
-
-### new PUPRemote()
-The PUPRemote is emitted if the discovered device is a Powered UP Remote.
-
-
-
-### pupRemote.current
-**Kind**: instance property of [PUPRemote](#PUPRemote)
-**Read only**: true
-**Properties**
-
-| Name | Type | Description |
-| --- | --- | --- |
-| current | number | Current usage of the hub (Amps) |
-
-
-
-### pupRemote.name
-**Kind**: instance property of [PUPRemote](#PUPRemote)
-**Overrides**: [name](#Hub+name)
-**Read only**: true
-**Properties**
-
-| Name | Type | Description |
-| --- | --- | --- |
-| name | string | Name of the hub |
-
-
-
-### pupRemote.uuid
-**Kind**: instance property of [PUPRemote](#PUPRemote)
-**Overrides**: [uuid](#Hub+uuid)
-**Read only**: true
-**Properties**
-
-| Name | Type | Description |
-| --- | --- | --- |
-| uuid | string | UUID of the hub |
-
-
-
-### pupRemote.rssi
-**Kind**: instance property of [PUPRemote](#PUPRemote)
-**Overrides**: [rssi](#Hub+rssi)
-**Read only**: true
-**Properties**
-
-| Name | Type | Description |
-| --- | --- | --- |
-| rssi | number | Signal strength of the hub |
-
-
-
-### pupRemote.batteryLevel
-**Kind**: instance property of [PUPRemote](#PUPRemote)
-**Overrides**: [batteryLevel](#Hub+batteryLevel)
-**Read only**: true
-**Properties**
-
-| Name | Type | Description |
-| --- | --- | --- |
-| batteryLevel | number | Battery level of the hub (Percentage between 0-100) |
-
-
-
-### pupRemote.setLEDColor(color) ⇒ Promise
-Set the color of the LED on the Remote via a color value.
-
-**Kind**: instance method of [PUPRemote](#PUPRemote)
-**Overrides**: [setLEDColor](#LPF2Hub+setLEDColor)
-**Returns**: Promise - Resolved upon successful issuance of command.
-
-| Param | Type | Description |
-| --- | --- | --- |
-| color | number | A number representing one of the LED color consts. |
-
-
-
-### pupRemote.setLEDRGB(red, green, blue) ⇒ Promise
-Set the color of the LED on the Hub via RGB values.
-
-**Kind**: instance method of [PUPRemote](#PUPRemote)
-**Overrides**: [setLEDRGB](#LPF2Hub+setLEDRGB)
-**Returns**: Promise - Resolved upon successful issuance of command.
-
-| Param | Type |
-| --- | --- |
-| red | number |
-| green | number |
-| blue | number |
-
-
-
-### pupRemote.setName(name) ⇒ Promise
-Set the name of the Hub.
-
-**Kind**: instance method of [PUPRemote](#PUPRemote)
-**Returns**: Promise - Resolved upon successful issuance of command.
-
-| Param | Type | Description |
-| --- | --- | --- |
-| name | string | New name of the hub (14 characters or less, ASCII only). |
-
-
-
-### pupRemote.connect() ⇒ Promise
-Connect to the Hub.
-
-**Kind**: instance method of [PUPRemote](#PUPRemote)
-**Overrides**: [connect](#Hub+connect)
-**Returns**: Promise - Resolved upon successful connect.
-
-
-### pupRemote.disconnect() ⇒ Promise
-Disconnect the Hub.
-
-**Kind**: instance method of [PUPRemote](#PUPRemote)
-**Overrides**: [disconnect](#Hub+disconnect)
-**Returns**: Promise - Resolved upon successful disconnect.
-
-
-### pupRemote.subscribe(port, [mode]) ⇒ Promise
-Subscribe to sensor notifications on a given port.
-
-**Kind**: instance method of [PUPRemote](#PUPRemote)
-**Overrides**: [subscribe](#Hub+subscribe)
-**Returns**: Promise - Resolved upon successful issuance of command.
-
-| Param | Type | Description |
-| --- | --- | --- |
-| port | string | |
-| [mode] | number | The sensor mode to activate. If no mode is provided, the default for that sensor will be chosen. |
-
-
-
-### pupRemote.unsubscribe(port) ⇒ Promise
-Unsubscribe to sensor notifications on a given port.
-
-**Kind**: instance method of [PUPRemote](#PUPRemote)
-**Overrides**: [unsubscribe](#Hub+unsubscribe)
-**Returns**: Promise - Resolved upon successful issuance of command.
-
-| Param | Type |
-| --- | --- |
-| port | string |
-
-
-
-### pupRemote.sleep(delay) ⇒ Promise
-Sleep a given amount of time.
-
-This is a helper method to make it easier to add delays into a chain of commands.
-
-**Kind**: instance method of [PUPRemote](#PUPRemote)
-**Overrides**: [sleep](#Hub+sleep)
-**Returns**: Promise - Resolved after the delay is finished.
-
-| Param | Type | Description |
-| --- | --- | --- |
-| delay | number | How long to sleep (in milliseconds). |
-
-
-
-### pupRemote.wait(commands) ⇒ Promise
-Wait until a given list of concurrently running commands are complete.
-
-This is a helper method to make it easier to wait for concurrent commands to complete.
-
-**Kind**: instance method of [PUPRemote](#PUPRemote)
-**Overrides**: [wait](#Hub+wait)
-**Returns**: Promise - Resolved after the commands are finished.
-
-| Param | Type | Description |
-| --- | --- | --- |
-| commands | Array.<Promise.<any>> | Array of executing commands. |
-
-
-
-### "button" (button, state)
-Emits when a button is pressed.
-
-**Kind**: event emitted by [PUPRemote](#PUPRemote)
-
-| Param | Type | Description |
-| --- | --- | --- |
-| button | string | |
-| state | number | A number representing one of the button state consts. |
-
-
-
-### "colorAndDistance" (port, color, distance)
-A combined color and distance event, emits when the sensor is activated.
-
-**Kind**: event emitted by [PUPRemote](#PUPRemote)
-
-| Param | Type | Description |
-| --- | --- | --- |
-| port | string | |
-| color | number | A number representing one of the LED color consts. |
-| distance | number | Distance, in millimeters. |
-
-
-
-## DuploTrainBase ⇐ LPF2Hub
-**Kind**: global class
-**Extends**: LPF2Hub, Hub
-
-* [DuploTrainBase](#DuploTrainBase) ⇐ LPF2Hub
- * [new DuploTrainBase()](#new_DuploTrainBase_new)
- * [.current](#LPF2Hub+current)
- * [.name](#Hub+name)
- * [.uuid](#Hub+uuid)
- * [.rssi](#Hub+rssi)
- * [.batteryLevel](#Hub+batteryLevel)
- * [.setLEDColor(color)](#DuploTrainBase+setLEDColor) ⇒ Promise
- * [.setMotorSpeed(port, speed, [time])](#DuploTrainBase+setMotorSpeed) ⇒ Promise
- * [.playSound(sound)](#DuploTrainBase+playSound) ⇒ Promise
- * [.rampMotorSpeed(port, fromSpeed, toSpeed, time)](#DuploTrainBase+rampMotorSpeed) ⇒ Promise
- * [.setName(name)](#LPF2Hub+setName) ⇒ Promise
- * [.setLEDRGB(red, green, blue)](#LPF2Hub+setLEDRGB) ⇒ Promise
- * [.connect()](#Hub+connect) ⇒ Promise
- * [.disconnect()](#Hub+disconnect) ⇒ Promise
- * [.subscribe(port, [mode])](#Hub+subscribe) ⇒ Promise
- * [.unsubscribe(port)](#Hub+unsubscribe) ⇒ Promise
- * [.sleep(delay)](#Hub+sleep) ⇒ Promise
- * [.wait(commands)](#Hub+wait) ⇒ Promise
- * ["color" (port, color)](#LPF2Hub+event_color)
- * ["colorAndDistance" (port, color, distance)](#LPF2Hub+event_colorAndDistance)
- * ["speed" (port, speed)](#LPF2Hub+event_speed)
-
-
-
-### new DuploTrainBase()
-The DuploTrainBase is emitted if the discovered device is a Duplo Train Base.
-
-
-
-### duploTrainBase.current
-**Kind**: instance property of [DuploTrainBase](#DuploTrainBase)
-**Read only**: true
-**Properties**
-
-| Name | Type | Description |
-| --- | --- | --- |
-| current | number | Current usage of the hub (Amps) |
-
-
-
-### duploTrainBase.name
-**Kind**: instance property of [DuploTrainBase](#DuploTrainBase)
-**Overrides**: [name](#Hub+name)
-**Read only**: true
-**Properties**
-
-| Name | Type | Description |
-| --- | --- | --- |
-| name | string | Name of the hub |
-
-
-
-### duploTrainBase.uuid
-**Kind**: instance property of [DuploTrainBase](#DuploTrainBase)
-**Overrides**: [uuid](#Hub+uuid)
-**Read only**: true
-**Properties**
-
-| Name | Type | Description |
-| --- | --- | --- |
-| uuid | string | UUID of the hub |
-
-
-
-### duploTrainBase.rssi
-**Kind**: instance property of [DuploTrainBase](#DuploTrainBase)
-**Overrides**: [rssi](#Hub+rssi)
-**Read only**: true
-**Properties**
-
-| Name | Type | Description |
-| --- | --- | --- |
-| rssi | number | Signal strength of the hub |
-
-
-
-### duploTrainBase.batteryLevel
-**Kind**: instance property of [DuploTrainBase](#DuploTrainBase)
-**Overrides**: [batteryLevel](#Hub+batteryLevel)
-**Read only**: true
-**Properties**
-
-| Name | Type | Description |
-| --- | --- | --- |
-| batteryLevel | number | Battery level of the hub (Percentage between 0-100) |
-
-
-
-### duploTrainBase.setLEDColor(color) ⇒ Promise
-Set the color of the LED on the train via a color value.
-
-**Kind**: instance method of [DuploTrainBase](#DuploTrainBase)
-**Overrides**: [setLEDColor](#LPF2Hub+setLEDColor)
-**Returns**: Promise - Resolved upon successful issuance of command.
-
-| Param | Type | Description |
-| --- | --- | --- |
-| color | number | A number representing one of the LED color consts. |
-
-
-
-### duploTrainBase.setMotorSpeed(port, speed, [time]) ⇒ Promise
-Set the motor speed on a given port.
-
-**Kind**: instance method of [DuploTrainBase](#DuploTrainBase)
-**Returns**: Promise - Resolved upon successful completion of command. If time is specified, this is once the motor is finished.
-
-| Param | Type | Description |
-| --- | --- | --- |
-| port | string | |
-| speed | number \| Array.<number> | For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0. If you are specifying port AB to control both motors, you can optionally supply a tuple of speeds. |
-| [time] | number | How long to activate the motor for (in milliseconds). Leave empty to turn the motor on indefinitely. |
-
-
-
-### duploTrainBase.playSound(sound) ⇒ Promise
-Play a built-in train sound.
-
-**Kind**: instance method of [DuploTrainBase](#DuploTrainBase)
-**Returns**: Promise - Resolved upon successful issuance of command.
-
-| Param | Type | Description |
-| --- | --- | --- |
-| sound | number | A number representing one of the Train Base sound consts. |
-
-
-
-### duploTrainBase.rampMotorSpeed(port, fromSpeed, toSpeed, time) ⇒ Promise
-Ramp the motor speed on a given port.
-
-**Kind**: instance method of [DuploTrainBase](#DuploTrainBase)
-**Returns**: Promise - Resolved upon successful completion of command.
-
-| Param | Type | Description |
-| --- | --- | --- |
-| port | string | |
-| fromSpeed | number | For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0. |
-| toSpeed | number | For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0. |
-| time | number | How long the ramp should last (in milliseconds). |
-
-
-
-### duploTrainBase.setName(name) ⇒ Promise
-Set the name of the Hub.
-
-**Kind**: instance method of [DuploTrainBase](#DuploTrainBase)
-**Returns**: Promise - Resolved upon successful issuance of command.
-
-| Param | Type | Description |
-| --- | --- | --- |
-| name | string | New name of the hub (14 characters or less, ASCII only). |
-
-
-
-### duploTrainBase.setLEDRGB(red, green, blue) ⇒ Promise
-Set the color of the LED on the Hub via RGB values.
-
-**Kind**: instance method of [DuploTrainBase](#DuploTrainBase)
-**Returns**: Promise - Resolved upon successful issuance of command.
-
-| Param | Type |
-| --- | --- |
-| red | number |
-| green | number |
-| blue | number |
-
-
-
-### duploTrainBase.connect() ⇒ Promise
-Connect to the Hub.
-
-**Kind**: instance method of [DuploTrainBase](#DuploTrainBase)
-**Overrides**: [connect](#Hub+connect)
-**Returns**: Promise - Resolved upon successful connect.
-
-
-### duploTrainBase.disconnect() ⇒ Promise
-Disconnect the Hub.
-
-**Kind**: instance method of [DuploTrainBase](#DuploTrainBase)
-**Overrides**: [disconnect](#Hub+disconnect)
-**Returns**: Promise - Resolved upon successful disconnect.
-
-
-### duploTrainBase.subscribe(port, [mode]) ⇒ Promise
-Subscribe to sensor notifications on a given port.
-
-**Kind**: instance method of [DuploTrainBase](#DuploTrainBase)
-**Overrides**: [subscribe](#Hub+subscribe)
-**Returns**: Promise - Resolved upon successful issuance of command.
-
-| Param | Type | Description |
-| --- | --- | --- |
-| port | string | |
-| [mode] | number | The sensor mode to activate. If no mode is provided, the default for that sensor will be chosen. |
-
-
-
-### duploTrainBase.unsubscribe(port) ⇒ Promise
-Unsubscribe to sensor notifications on a given port.
-
-**Kind**: instance method of [DuploTrainBase](#DuploTrainBase)
-**Overrides**: [unsubscribe](#Hub+unsubscribe)
-**Returns**: Promise - Resolved upon successful issuance of command.
-
-| Param | Type |
-| --- | --- |
-| port | string |
-
-
-
-### duploTrainBase.sleep(delay) ⇒ Promise
-Sleep a given amount of time.
-
-This is a helper method to make it easier to add delays into a chain of commands.
-
-**Kind**: instance method of [DuploTrainBase](#DuploTrainBase)
-**Overrides**: [sleep](#Hub+sleep)
-**Returns**: Promise - Resolved after the delay is finished.
-
-| Param | Type | Description |
-| --- | --- | --- |
-| delay | number | How long to sleep (in milliseconds). |
-
-
-
-### duploTrainBase.wait(commands) ⇒ Promise
-Wait until a given list of concurrently running commands are complete.
-
-This is a helper method to make it easier to wait for concurrent commands to complete.
-
-**Kind**: instance method of [DuploTrainBase](#DuploTrainBase)
-**Overrides**: [wait](#Hub+wait)
-**Returns**: Promise - Resolved after the commands are finished.
-
-| Param | Type | Description |
-| --- | --- | --- |
-| commands | Array.<Promise.<any>> | Array of executing commands. |
-
-
-
-### "color" (port, color)
-Emits when a color sensor is activated.
-
-**Kind**: event emitted by [DuploTrainBase](#DuploTrainBase)
-
-| Param | Type | Description |
-| --- | --- | --- |
-| port | string | |
-| color | number | A number representing one of the LED color consts. |
-
-
-
-### "colorAndDistance" (port, color, distance)
-A combined color and distance event, emits when the sensor is activated.
-
-**Kind**: event emitted by [DuploTrainBase](#DuploTrainBase)
-
-| Param | Type | Description |
-| --- | --- | --- |
-| port | string | |
-| color | number | A number representing one of the LED color consts. |
-| distance | number | Distance, in millimeters. |
-
-
-
-### "speed" (port, speed)
-Emits on a speed change.
-
-**Kind**: event emitted by [DuploTrainBase](#DuploTrainBase)
-
-| Param | Type |
-| --- | --- |
-| port | string |
-| speed | number |
+Thanks go to Jorge Pereira ([@JorgePe](https://github.com/JorgePe)), Sebastian Raff ([@hobbyquaker](https://github.com/hobbyquaker)), Valentin Heun ([@vheun](https://github.com/vheun)), Johan Korten ([@jakorten](https://github.com/jakorten)), and Andrey Pokhilko ([@undera](https://github.com/undera)) for their various works, contributions, and assistance on figuring out the LEGO Boost, WeDo 2.0, and Powered Up protocols.
diff --git a/abandonware-noble.d.ts b/abandonware-noble.d.ts
new file mode 100644
index 0000000..8b9ad93
--- /dev/null
+++ b/abandonware-noble.d.ts
@@ -0,0 +1,129 @@
+declare module "@abandonware/noble" {
+ // Type definitions for noble
+ // Project: https://github.com/sandeepmistry/noble
+ // Definitions by: Seon-Wook Park
+ // Shantanu Bhadoria
+ // Luke Libraro
+ // Dan Chao
+ // Michal Lower
+ // Rob Moran
+ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
+
+ ///
+
+ import events = require("events");
+
+ export function startScanning(callback?: (error?: Error) => void): void;
+ export function startScanning(serviceUUIDs: string[], callback?: (error?: Error) => void): void;
+ export function startScanning(serviceUUIDs: string[], allowDuplicates: boolean, callback?: (error?: Error) => void): void;
+ export function stopScanning(callback?: () => void): void;
+
+ export function on(event: "stateChange", listener: (state: string) => void): events.EventEmitter;
+ export function on(event: "scanStart", listener: () => void): events.EventEmitter;
+ export function on(event: "scanStop", listener: () => void): events.EventEmitter;
+ export function on(event: "discover", listener: (peripheral: Peripheral) => void): events.EventEmitter;
+ export function on(event: string, listener: Function): events.EventEmitter;
+
+ export function removeListener(event: "stateChange", listener: (state: string) => void): events.EventEmitter;
+ export function removeListener(event: "scanStart", listener: () => void): events.EventEmitter;
+ export function removeListener(event: "scanStop", listener: () => void): events.EventEmitter;
+ export function removeListener(event: "discover", listener: (peripheral: Peripheral) => void): events.EventEmitter;
+ export function removeListener(event: string, listener: Function): events.EventEmitter;
+
+ export var state:string;
+
+ export class Peripheral extends events.EventEmitter {
+ id: string;
+ uuid: string;
+ address: string;
+ addressType: string;
+ connectable: boolean;
+ advertisement: Advertisement;
+ rssi: number;
+ services: Service[];
+ state: 'error' | 'connecting' | 'connected' | 'disconnecting' | 'disconnected';
+
+ connect(callback?: (error: string) => void): void;
+ disconnect(callback?: () => void): void;
+ updateRssi(callback?: (error: string, rssi: number) => void): void;
+ discoverServices(serviceUUIDs: string[], callback?: (error: string, services: Service[]) => void): void;
+ discoverAllServicesAndCharacteristics(callback?: (error: string, services: Service[], characteristics: Characteristic[]) => void): void;
+ discoverSomeServicesAndCharacteristics(serviceUUIDs: string[], characteristicUUIDs: string[], callback?: (error: string, services: Service[], characteristics: Characteristic[]) => void): void;
+
+ readHandle(handle: Buffer, callback: (error: string, data: Buffer) => void): void;
+ writeHandle(handle: Buffer, data: Buffer, withoutResponse: boolean, callback: (error: string) => void): void;
+ toString(): string;
+
+ on(event: "connect", listener: (error: string) => void): this;
+ on(event: "disconnect", listener: (error: string) => void): this;
+ on(event: "rssiUpdate", listener: (rssi: number) => void): this;
+ on(event: "servicesDiscover", listener: (services: Service[]) => void): this;
+ on(event: string, listener: Function): this;
+ }
+
+ export interface Advertisement {
+ localName: string;
+ serviceData: {
+ uuid: string,
+ data: Buffer
+ };
+ txPowerLevel: number;
+ manufacturerData: Buffer;
+ serviceUuids: string[];
+ }
+
+ export class Service extends events.EventEmitter {
+ uuid: string;
+ name: string;
+ type: string;
+ includedServiceUuids: string[];
+ characteristics: Characteristic[];
+
+ discoverIncludedServices(serviceUUIDs: string[], callback?: (error: string, includedServiceUuids: string[]) => void): void;
+ discoverCharacteristics(characteristicUUIDs: string[], callback?: (error: string, characteristics: Characteristic[]) => void): void;
+ toString(): string;
+
+ on(event: "includedServicesDiscover", listener: (includedServiceUuids: string[]) => void): this;
+ on(event: "characteristicsDiscover", listener: (characteristics: Characteristic[]) => void): this;
+ on(event: string, listener: Function): this;
+ }
+
+ export class Characteristic extends events.EventEmitter {
+ uuid: string;
+ name: string;
+ type: string;
+ properties: string[];
+ descriptors: Descriptor[];
+
+ read(callback?: (error: string, data: Buffer) => void): void;
+ write(data: Buffer, notify: boolean, callback?: (error: string) => void): void;
+ broadcast(broadcast: boolean, callback?: (error: string) => void): void;
+ notify(notify: boolean, callback?: (error: string) => void): void;
+ discoverDescriptors(callback?: (error: string, descriptors: Descriptor[]) => void): void;
+ toString(): string;
+ subscribe(callback?: (error: string) => void): void;
+ unsubscribe(callback?: (error: string) => void): void;
+
+ on(event: "read", listener: (data: Buffer, isNotification: boolean) => void): this;
+ on(event: "write", withoutResponse: boolean, listener: (error: string) => void): this;
+ on(event: "broadcast", listener: (state: string) => void): this;
+ on(event: "notify", listener: (state: string) => void): this;
+ on(event: "descriptorsDiscover", listener: (descriptors: Descriptor[]) => void): this;
+ on(event: string, listener: Function): this;
+ on(event: string, option: boolean, listener: Function): this;
+ }
+
+ export class Descriptor extends events.EventEmitter {
+ uuid: string;
+ name: string;
+ type: string;
+
+ readValue(callback?: (error: string, data: Buffer) => void): void;
+ writeValue(data: Buffer, callback?: (error: string) => void): void;
+ toString(): string;
+
+ on(event: "valueRead", listener: (error: string, data: Buffer) => void): this;
+ on(event: "valueWrite", listener: (error: string) => void): this;
+ on(event: string, listener: Function): this;
+ }
+}
\ No newline at end of file
diff --git a/consts.ts b/consts.ts
deleted file mode 100644
index 1c29f54..0000000
--- a/consts.ts
+++ /dev/null
@@ -1,92 +0,0 @@
-export enum Hubs {
- UNKNOWN = 0,
- WEDO2_SMART_HUB = 1,
- BOOST_MOVE_HUB = 2,
- POWERED_UP_HUB = 3,
- POWERED_UP_REMOTE = 4,
- DUPLO_TRAIN_HUB = 5
-}
-
-
-export enum Devices {
- UNKNOWN = 0,
- BASIC_MOTOR = 1,
- TRAIN_MOTOR = 2,
- LED_LIGHTS = 8,
- BOOST_LED = 22,
- WEDO2_TILT = 34,
- WEDO2_DISTANCE = 35,
- BOOST_DISTANCE = 37,
- BOOST_TACHO_MOTOR = 38,
- BOOST_MOVE_HUB_MOTOR = 39,
- BOOST_TILT = 40,
- DUPLO_TRAIN_BASE_MOTOR = 41,
- DUPLO_TRAIN_BASE_SPEAKER = 42,
- DUPLO_TRAIN_BASE_COLOR = 43,
- DUPLO_TRAIN_BASE_SPEEDOMETER = 44,
- POWERED_UP_REMOTE_BUTTON = 55
-}
-
-
-export enum Colors {
- BLACK = 0,
- PINK = 1,
- PURPLE = 2,
- BLUE = 3,
- LIGHT_BLUE = 4,
- CYAN = 5,
- GREEN = 6,
- YELLOW = 7,
- ORANGE = 8,
- RED = 9,
- WHITE = 10,
- NONE = 255
-}
-
-
-export enum ButtonStates {
- PRESSED = 0,
- RELEASED = 1,
- UP = 2,
- DOWN = 3,
- STOP = 4
-}
-
-
-export enum DuploTrainBaseSounds {
- BREAK = 3,
- STATION_DEPARTURE = 5,
- WATER_REFILL = 7,
- HORN = 9,
- STEAM = 10
-}
-
-
-export enum BLEManufacturerData {
- BOOST_MOVE_HUB_ID = 64,
- POWERED_UP_HUB_ID = 65,
- POWERED_UP_REMOTE_ID = 66,
- DUPLO_TRAIN_HUB_ID = 32
-}
-
-
-export enum BLEServices {
- WEDO2_SMART_HUB = "00001523-1212-efde-1523-785feabcd123",
- LPF2_HUB = "00001623-1212-efde-1623-785feabcd123"
-}
-
-
-export enum BLECharacteristics {
- WEDO2_BATTERY = "2a19",
- WEDO2_BUTTON = "00001526-1212-efde-1523-785feabcd123", // "1526"
- WEDO2_PORT_TYPE = "00001527-1212-efde-1523-785feabcd123", // "1527" // Handles plugging and unplugging of devices on WeDo 2.0 Smart Hub
- WEDO2_LOW_VOLTAGE_ALERT = "00001528-1212-efde-1523-785feabcd123", // "1528"
- WEDO2_HIGH_CURRENT_ALERT = "00001529-1212-efde-1523-785feabcd123", // "1529"
- WEDO2_LOW_SIGNAL_ALERT = "0000152a-1212-efde-1523-785feabcd123", // "152a"
- WEDO2_SENSOR_VALUE = "00001560-1212-efde-1523-785feabcd123", // "1560"
- WEDO2_VALUE_FORMAT = "00001561-1212-efde-1523-785feabcd123", // "1561"
- WEDO2_PORT_TYPE_WRITE = "00001563-1212-efde-1523-785feabcd123", // "1563"
- WEDO2_MOTOR_VALUE_WRITE = "00001565-1212-efde-1523-785feabcd123", // "1565"
- WEDO2_NAME_ID = "00001524-1212-efde-1523-785feabcd123", // "1524"
- LPF2_ALL = "00001624-1212-efde-1623-785feabcd123"
-}
diff --git a/docs/BoostMoveHub.html b/docs/BoostMoveHub.html
new file mode 100644
index 0000000..0e3c54a
--- /dev/null
+++ b/docs/BoostMoveHub.html
@@ -0,0 +1,7082 @@
+
+
+
+
+
+
+ node-poweredup Class: BoostMoveHub
+
+
+
+
+
+
+
+
+
+
+
Resolved upon successful completion of command. If time is specified, this is once the light is turned off.
+
+
+
+
+
+
+ Type
+
+
+
+Promise
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
setMotorAngle(port, angle [, speed])
+
+
+
+
+
+
+
+
Rotate a motor by a given angle.
+
+
+
+
+
+
+
+
+
+
Parameters:
+
+
+
+
+
+
+
Name
+
+
+
Type
+
+
+
Argument
+
+
+
+
Default
+
+
+
Description
+
+
+
+
+
+
+
+
+
port
+
+
+
+
+
+string
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
angle
+
+
+
+
+
+number
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
How much the motor should be rotated (in degrees).
+
+
+
+
+
+
+
speed
+
+
+
+
+
+number
+|
+
+Array.<number>
+
+
+
+
+
+
+
+
+
+ <optional>
+
+
+
+
+
+
+
+
+
+
+
+ 100
+
+
+
+
+
For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0. If you are specifying port AB to control both motors, you can optionally supply a tuple of speeds.
Resolved upon successful completion of command (ie. once the motor is finished).
+
+
+
+
+
+
+ Type
+
+
+
+Promise
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
setMotorSpeed(port, speed [, time])
+
+
+
+
+
+
+
+
Set the motor speed on a given port.
+
+
+
+
+
+
+
+
+
+
Parameters:
+
+
+
+
+
+
+
Name
+
+
+
Type
+
+
+
Argument
+
+
+
+
+
Description
+
+
+
+
+
+
+
+
+
port
+
+
+
+
+
+string
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
speed
+
+
+
+
+
+number
+|
+
+Array.<number>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0. If you are specifying port AB to control both motors, you can optionally supply a tuple of speeds.
+
+
+
+
+
+
+
time
+
+
+
+
+
+number
+
+
+
+
+
+
+
+
+
+ <optional>
+
+
+
+
+
+
+
+
+
+
+
How long to activate the motor for (in milliseconds). Leave empty to turn the motor on indefinitely.
Resolved upon successful completion of command. If time is specified, this is once the light is turned off.
+
+
+
+
+
+
+ Type
+
+
+
+Promise
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
setMotorAngle(port, angle [, speed])
+
+
+
+
+
+
+
+
Rotate a motor by a given angle.
+
+
+
+
+
+
+
+
+
+
Parameters:
+
+
+
+
+
+
+
Name
+
+
+
Type
+
+
+
Argument
+
+
+
+
Default
+
+
+
Description
+
+
+
+
+
+
+
+
+
port
+
+
+
+
+
+string
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
angle
+
+
+
+
+
+number
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
How much the motor should be rotated (in degrees).
+
+
+
+
+
+
+
speed
+
+
+
+
+
+number
+|
+
+Array.<number>
+
+
+
+
+
+
+
+
+
+ <optional>
+
+
+
+
+
+
+
+
+
+
+
+ 100
+
+
+
+
+
For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0. If you are specifying port AB to control both motors, you can optionally supply a tuple of speeds.
Resolved upon successful completion of command (ie. once the motor is finished).
+
+
+
+
+
+
+ Type
+
+
+
+Promise
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
setMotorSpeed(port, speed [, time])
+
+
+
+
+
+
+
+
Set the motor speed on a given port.
+
+
+
+
+
+
+
+
+
+
Parameters:
+
+
+
+
+
+
+
Name
+
+
+
Type
+
+
+
Argument
+
+
+
+
+
Description
+
+
+
+
+
+
+
+
+
port
+
+
+
+
+
+string
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
speed
+
+
+
+
+
+number
+|
+
+Array.<number>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0. If you are specifying port AB to control both motors, you can optionally supply a tuple of speeds.
+
+
+
+
+
+
+
time
+
+
+
+
+
+number
+
+
+
+
+
+
+
+
+
+ <optional>
+
+
+
+
+
+
+
+
+
+
+
How long to activate the motor for (in milliseconds). Leave empty to turn the motor on indefinitely.
For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0. If you are specifying port AB to control both motors, you can optionally supply a tuple of speeds.
+
+
+
+
+
+
+
time
+
+
+
+
+
+number
+
+
+
+
+
+
+
+
+
+ <optional>
+
+
+
+
+
+
+
+
+
+
+
How long to activate the motor for (in milliseconds). Leave empty to turn the motor on indefinitely.
Resolved upon successful completion of command. If time is specified, this is once the light is turned off.
+
+
+
+
+
+
+ Type
+
+
+
+Promise
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
setMotorAngle(port, angle [, speed])
+
+
+
+
+
+
+
+
Rotate a motor by a given angle.
+
+
+
+
+
+
+
+
+
+
Parameters:
+
+
+
+
+
+
+
Name
+
+
+
Type
+
+
+
Argument
+
+
+
+
Default
+
+
+
Description
+
+
+
+
+
+
+
+
+
port
+
+
+
+
+
+string
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
angle
+
+
+
+
+
+number
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
How much the motor should be rotated (in degrees).
+
+
+
+
+
+
+
speed
+
+
+
+
+
+number
+|
+
+Array.<number>
+
+
+
+
+
+
+
+
+
+ <optional>
+
+
+
+
+
+
+
+
+
+
+
+ 100
+
+
+
+
+
For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0. If you are specifying port AB to control both motors, you can optionally supply a tuple of speeds.
Resolved upon successful completion of command (ie. once the motor is finished).
+
+
+
+
+
+
+ Type
+
+
+
+Promise
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
setMotorSpeed(port, speed [, time])
+
+
+
+
+
+
+
+
Set the motor speed on a given port.
+
+
+
+
+
+
+
+
+
+
Parameters:
+
+
+
+
+
+
+
Name
+
+
+
Type
+
+
+
Argument
+
+
+
+
+
Description
+
+
+
+
+
+
+
+
+
port
+
+
+
+
+
+string
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
speed
+
+
+
+
+
+number
+|
+
+Array.<number>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0. If you are specifying port AB to control both motors, you can optionally supply a tuple of speeds.
+
+
+
+
+
+
+
time
+
+
+
+
+
+number
+
+
+
+
+
+
+
+
+
+ <optional>
+
+
+
+
+
+
+
+
+
+
+
How long to activate the motor for (in milliseconds). Leave empty to turn the motor on indefinitely.
"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 = {};
+ if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
+ result["default"] = 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"));
+const Debug = require("debug");
+const debug = Debug("boostmovehub");
+/**
+ * The BoostMoveHub is emitted if the discovered device is a Boost Move Hub.
+ * @class BoostMoveHub
+ * @extends LPF2Hub
+ * @extends Hub
+ */
+class BoostMoveHub extends lpf2hub_1.LPF2Hub {
+ 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),
+ "B": new port_1.Port("B", 1),
+ "C": new port_1.Port("C", 2),
+ "D": new port_1.Port("D", 3),
+ "TILT": new port_1.Port("TILT", 58)
+ };
+ this.on("attach", (port, type) => {
+ this._combinePorts(port, type);
+ });
+ 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");
+ await super.connect();
+ debug("Connect completed");
+ return resolve();
+ });
+ }
+ /**
+ * Set the motor speed on a given port.
+ * @method BoostMoveHub#setMotorSpeed
+ * @param {string} port
+ * @param {number | Array.<number>} speed For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0. If you are specifying port AB to control both motors, you can optionally supply a tuple of speeds.
+ * @param {number} [time] How long to activate the motor for (in milliseconds). Leave empty to turn the motor on indefinitely.
+ * @returns {Promise} Resolved upon successful completion of command. If time is specified, this is once the motor is finished.
+ */
+ setMotorSpeed(port, speed, time) {
+ const portObj = this._portLookup(port);
+ if (!this._virtualPorts[portObj.id] && speed instanceof Array) {
+ throw new Error(`Port ${portObj.id} can only accept a single speed`);
+ }
+ let cancelEventTimer = true;
+ if (typeof time === "boolean") {
+ if (time === true) {
+ cancelEventTimer = false;
+ }
+ time = undefined;
+ }
+ if (cancelEventTimer) {
+ portObj.cancelEventTimer();
+ }
+ return new Promise((resolve, reject) => {
+ if (time && typeof time === "number") {
+ if (portObj.type === Consts.DeviceType.BOOST_TACHO_MOTOR ||
+ portObj.type === Consts.DeviceType.BOOST_MOVE_HUB_MOTOR ||
+ portObj.type === Consts.DeviceType.CONTROL_PLUS_LARGE_MOTOR ||
+ portObj.type === Consts.DeviceType.CONTROL_PLUS_XLARGE_MOTOR) {
+ portObj.busy = true;
+ let data = null;
+ if (this._virtualPorts[portObj.id]) {
+ data = Buffer.from([0x81, portObj.value, 0x11, 0x0a, 0x00, 0x00, this._mapSpeed(speed instanceof Array ? speed[0] : speed), this._mapSpeed(speed instanceof Array ? speed[1] : speed), 0x64, 0x7f, 0x03]);
+ }
+ else {
+ // @ts-ignore: The type of speed is properly checked at the start
+ data = Buffer.from([0x81, portObj.value, 0x11, 0x09, 0x00, 0x00, this._mapSpeed(speed), 0x64, 0x7f, 0x03]);
+ }
+ data.writeUInt16LE(time > 65535 ? 65535 : time, 4);
+ this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, data);
+ portObj.finished = () => {
+ return resolve();
+ };
+ }
+ else {
+ // @ts-ignore: The type of speed is properly checked at the start
+ const data = Buffer.from([0x81, portObj.value, 0x11, 0x51, 0x00, this._mapSpeed(speed)]);
+ this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, data);
+ const timeout = global.setTimeout(() => {
+ const data = Buffer.from([0x81, portObj.value, 0x11, 0x51, 0x00, 0x00]);
+ this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, data);
+ return resolve();
+ // @ts-ignore: The type of time is properly checked at the start
+ }, time);
+ portObj.setEventTimer(timeout);
+ }
+ }
+ else {
+ if (portObj.type === Consts.DeviceType.BOOST_TACHO_MOTOR ||
+ portObj.type === Consts.DeviceType.BOOST_MOVE_HUB_MOTOR ||
+ portObj.type === Consts.DeviceType.CONTROL_PLUS_LARGE_MOTOR ||
+ portObj.type === Consts.DeviceType.CONTROL_PLUS_XLARGE_MOTOR) {
+ portObj.busy = true;
+ let data = null;
+ if (this._virtualPorts[portObj.id]) {
+ data = Buffer.from([0x81, portObj.value, 0x11, 0x02, this._mapSpeed(speed instanceof Array ? speed[0] : speed), this._mapSpeed(speed instanceof Array ? speed[1] : speed), 0x64, 0x7f, 0x03]);
+ }
+ else {
+ // @ts-ignore: The type of speed is properly checked at the start
+ data = Buffer.from([0x81, portObj.value, 0x11, 0x01, this._mapSpeed(speed), 0x64, 0x7f, 0x03]);
+ }
+ this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, data);
+ portObj.finished = () => {
+ return resolve();
+ };
+ }
+ else {
+ // @ts-ignore: The type of speed is properly checked at the start
+ const data = Buffer.from([0x81, portObj.value, 0x11, 0x51, 0x00, this._mapSpeed(speed)]);
+ this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, data);
+ }
+ }
+ });
+ }
+ /**
+ * Ramp the motor speed on a given port.
+ * @method BoostMoveHub#rampMotorSpeed
+ * @param {string} port
+ * @param {number} fromSpeed For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0.
+ * @param {number} toSpeed For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0.
+ * @param {number} time How long the ramp should last (in milliseconds).
+ * @returns {Promise} Resolved upon successful completion of command.
+ */
+ rampMotorSpeed(port, fromSpeed, toSpeed, time) {
+ const portObj = this._portLookup(port);
+ portObj.cancelEventTimer();
+ return new Promise((resolve, reject) => {
+ this._calculateRamp(fromSpeed, toSpeed, time, portObj)
+ .on("changeSpeed", (speed) => {
+ this.setMotorSpeed(port, speed, true);
+ })
+ .on("finished", resolve);
+ });
+ }
+ /**
+ * Rotate a motor by a given angle.
+ * @method BoostMoveHub#setMotorAngle
+ * @param {string} port
+ * @param {number} angle How much the motor should be rotated (in degrees).
+ * @param {number | Array.<number>} [speed=100] For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0. If you are specifying port AB to control both motors, you can optionally supply a tuple of speeds.
+ * @returns {Promise} Resolved upon successful completion of command (ie. once the motor is finished).
+ */
+ setMotorAngle(port, angle, speed = 100) {
+ const portObj = this._portLookup(port);
+ if (!(portObj.type === Consts.DeviceType.BOOST_TACHO_MOTOR ||
+ portObj.type === Consts.DeviceType.BOOST_MOVE_HUB_MOTOR ||
+ portObj.type === Consts.DeviceType.CONTROL_PLUS_LARGE_MOTOR ||
+ portObj.type === Consts.DeviceType.CONTROL_PLUS_XLARGE_MOTOR)) {
+ throw new Error("Angle rotation is only available when using a Boost Tacho Motor, Boost Move Hub Motor, Control+ Medium Motor, or Control+ Large Motor");
+ }
+ if (!this._virtualPorts[portObj.id] && speed instanceof Array) {
+ throw new Error(`Port ${portObj.id} can only accept a single speed`);
+ }
+ portObj.cancelEventTimer();
+ return new Promise((resolve, reject) => {
+ portObj.busy = true;
+ let data = null;
+ if (this._virtualPorts[portObj.id]) {
+ data = Buffer.from([0x81, portObj.value, 0x11, 0x0c, 0x00, 0x00, 0x00, 0x00, this._mapSpeed(speed instanceof Array ? speed[0] : speed), this._mapSpeed(speed instanceof Array ? speed[1] : speed), 0x64, 0x7f, 0x03]);
+ }
+ else {
+ // @ts-ignore: The type of speed is properly checked at the start
+ data = Buffer.from([0x81, portObj.value, 0x11, 0x0b, 0x00, 0x00, 0x00, 0x00, this._mapSpeed(speed), 0x64, 0x7f, 0x03]);
+ }
+ data.writeUInt32LE(angle, 4);
+ this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, data);
+ portObj.finished = () => {
+ return resolve();
+ };
+ });
+ }
+ /**
+ * Tell motor to goto an absolute position
+ * @method BoostMoveHub#setAbsolutePosition
+ * @param {string} port
+ * @param {number} pos The position of the motor to go to
+ * @param {number | Array.<number>} [speed=100] A value between 1 - 100 should be set (Direction does not apply when going to absolute position)
+ * @returns {Promise} Resolved upon successful completion of command (ie. once the motor is finished).
+ */
+ setAbsolutePosition(port, pos, speed = 100) {
+ const portObj = this._portLookup(port);
+ if (!(portObj.type === Consts.DeviceType.CONTROL_PLUS_LARGE_MOTOR ||
+ portObj.type === Consts.DeviceType.CONTROL_PLUS_XLARGE_MOTOR)) {
+ throw new Error("Absolute positioning is only available when using a Control+ Medium Motor, or Control+ Large Motor");
+ }
+ portObj.cancelEventTimer();
+ return new Promise((resolve, reject) => {
+ portObj.busy = true;
+ let data = null;
+ if (this._virtualPorts[portObj.id]) {
+ data = Buffer.from([0x81, portObj.value, 0x11, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, this._mapSpeed(speed), 0x64, 0x7f, 0x03]);
+ data.writeInt32LE(pos, 4);
+ data.writeInt32LE(pos, 8);
+ }
+ else {
+ // @ts-ignore: The type of speed is properly checked at the start
+ data = Buffer.from([0x81, portObj.value, 0x11, 0x0d, 0x00, 0x00, 0x00, 0x00, this._mapSpeed(speed), 0x64, 0x7f, 0x03]);
+ data.writeInt32LE(pos, 4);
+ }
+ this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, data);
+ portObj.finished = () => {
+ return resolve();
+ };
+ });
+ }
+ /**
+ * Reset the current motor position as absolute position zero
+ * @method BoostMoveHub#resetAbsolutePosition
+ * @param {string} port
+ * @returns {Promise} Resolved upon successful completion of command (ie. once the motor is finished).
+ */
+ resetAbsolutePosition(port) {
+ const portObj = this._portLookup(port);
+ if (!(portObj.type === Consts.DeviceType.CONTROL_PLUS_LARGE_MOTOR ||
+ portObj.type === Consts.DeviceType.CONTROL_PLUS_XLARGE_MOTOR)) {
+ throw new Error("Absolute positioning is only available when using a Control+ Medium Motor, or Control+ Large Motor");
+ }
+ return new Promise((resolve) => {
+ const data = Buffer.from([0x81, portObj.value, 0x11, 0x51, 0x02, 0x00, 0x00, 0x00, 0x00]);
+ this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, data);
+ return resolve();
+ });
+ }
+ /**
+ * Fully (hard) stop the motor on a given port.
+ * @method BoostMoveHub#brakeMotor
+ * @param {string} port
+ * @returns {Promise} Resolved upon successful completion of command.
+ */
+ brakeMotor(port) {
+ return this.setMotorSpeed(port, 127);
+ }
+ /**
+ * Set the light brightness on a given port.
+ * @method BoostMoveHub#setLightBrightness
+ * @param {string} port
+ * @param {number} brightness Brightness value between 0-100 (0 is off)
+ * @param {number} [time] How long to turn the light on (in milliseconds). Leave empty to turn the light on indefinitely.
+ * @returns {Promise} Resolved upon successful completion of command. If time is specified, this is once the light is turned off.
+ */
+ setLightBrightness(port, brightness, time) {
+ const portObj = this._portLookup(port);
+ portObj.cancelEventTimer();
+ return new Promise((resolve, reject) => {
+ const data = Buffer.from([0x81, portObj.value, 0x11, 0x51, 0x00, brightness]);
+ this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, data);
+ if (time) {
+ const timeout = global.setTimeout(() => {
+ const data = Buffer.from([0x81, portObj.value, 0x11, 0x51, 0x00, 0x00]);
+ this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, data);
+ return resolve();
+ }, time);
+ portObj.setEventTimer(timeout);
+ }
+ else {
+ return resolve();
+ }
+ });
+ }
+ _checkFirmware(version) {
+ if (compare_versions_1.default("2.0.00.0017", version) === 1) {
+ throw new Error(`Your Boost Move Hub's (${this.name}) firmware is out of date and unsupported by this library. Please update it via the official Powered Up app.`);
+ }
+ }
+}
+exports.BoostMoveHub = BoostMoveHub;
+//# sourceMappingURL=boostmovehub.js.map
"use strict";
+var __importStar = (this && this.__importStar) || function (mod) {
+ if (mod && mod.__esModule) return mod;
+ var result = {};
+ if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
+ result["default"] = mod;
+ return result;
+};
+Object.defineProperty(exports, "__esModule", { value: true });
+const lpf2hub_1 = require("./lpf2hub");
+const port_1 = require("./port");
+const Consts = __importStar(require("./consts"));
+const Debug = require("debug");
+const debug = Debug("ControlPlusHub");
+/**
+ * The ControlPlusHub is emitted if the discovered device is a Control+ Hub.
+ * @class ControlPlusHub
+ * @extends LPF2Hub
+ * @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 &&
+ 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.CONTROL_PLUS_LARGE_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, 0x3d, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x01])); // Temperature
+ debug("Connect completed");
+ return resolve();
+ });
+ }
+ /**
+ * Set the motor speed on a given port.
+ * @method ControlPlusHub#setMotorSpeed
+ * @param {string} port
+ * @param {number | Array.<number>} speed For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0. If you are specifying port AB to control both motors, you can optionally supply a tuple of speeds.
+ * @param {number} [time] How long to activate the motor for (in milliseconds). Leave empty to turn the motor on indefinitely.
+ * @returns {Promise} Resolved upon successful completion of command. If time is specified, this is once the motor is finished.
+ */
+ setMotorSpeed(port, speed, time) {
+ const portObj = this._portLookup(port);
+ if (!this._virtualPorts[portObj.id] && speed instanceof Array) {
+ throw new Error(`Port ${portObj.id} can only accept a single speed`);
+ }
+ let cancelEventTimer = true;
+ if (typeof time === "boolean") {
+ if (time === true) {
+ cancelEventTimer = false;
+ }
+ time = undefined;
+ }
+ if (cancelEventTimer) {
+ portObj.cancelEventTimer();
+ }
+ return new Promise((resolve, reject) => {
+ if (time && typeof time === "number") {
+ if (portObj.type === Consts.DeviceType.BOOST_TACHO_MOTOR ||
+ portObj.type === Consts.DeviceType.BOOST_MOVE_HUB_MOTOR ||
+ portObj.type === Consts.DeviceType.CONTROL_PLUS_LARGE_MOTOR ||
+ portObj.type === Consts.DeviceType.CONTROL_PLUS_XLARGE_MOTOR) {
+ portObj.busy = true;
+ let data = null;
+ if (this._virtualPorts[portObj.id]) {
+ data = Buffer.from([0x81, portObj.value, 0x11, 0x0a, 0x00, 0x00, this._mapSpeed(speed instanceof Array ? speed[0] : speed), this._mapSpeed(speed instanceof Array ? speed[1] : speed), 0x64, 0x7f, 0x03]);
+ }
+ else {
+ // @ts-ignore: The type of speed is properly checked at the start
+ data = Buffer.from([0x81, portObj.value, 0x11, 0x09, 0x00, 0x00, this._mapSpeed(speed), 0x64, 0x7f, 0x03]);
+ }
+ data.writeUInt16LE(time > 65535 ? 65535 : time, 4);
+ this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, data);
+ portObj.finished = () => {
+ return resolve();
+ };
+ }
+ else {
+ // @ts-ignore: The type of speed is properly checked at the start
+ const data = Buffer.from([0x81, portObj.value, 0x11, 0x51, 0x00, this._mapSpeed(speed)]);
+ this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, data);
+ const timeout = global.setTimeout(() => {
+ const data = Buffer.from([0x81, portObj.value, 0x11, 0x51, 0x00, 0x00]);
+ this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, data);
+ return resolve();
+ // @ts-ignore: The type of time is properly checked at the start
+ }, time);
+ portObj.setEventTimer(timeout);
+ }
+ }
+ else {
+ if (portObj.type === Consts.DeviceType.BOOST_TACHO_MOTOR || portObj.type === Consts.DeviceType.BOOST_MOVE_HUB_MOTOR) {
+ portObj.busy = true;
+ let data = null;
+ if (this._virtualPorts[portObj.id]) {
+ data = Buffer.from([0x81, portObj.value, 0x11, 0x02, this._mapSpeed(speed instanceof Array ? speed[0] : speed), this._mapSpeed(speed instanceof Array ? speed[1] : speed), 0x64, 0x7f, 0x03]);
+ }
+ else {
+ // @ts-ignore: The type of speed is properly checked at the start
+ data = Buffer.from([0x81, portObj.value, 0x11, 0x01, this._mapSpeed(speed), 0x64, 0x7f, 0x03]);
+ }
+ this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, data);
+ portObj.finished = () => {
+ return resolve();
+ };
+ }
+ else {
+ // @ts-ignore: The type of speed is properly checked at the start
+ const data = Buffer.from([0x81, portObj.value, 0x11, 0x51, 0x00, this._mapSpeed(speed)]);
+ this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, data);
+ }
+ }
+ });
+ }
+ /**
+ * Ramp the motor speed on a given port.
+ * @method ControlPlusHub#rampMotorSpeed
+ * @param {string} port
+ * @param {number} fromSpeed For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0.
+ * @param {number} toSpeed For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0.
+ * @param {number} time How long the ramp should last (in milliseconds).
+ * @returns {Promise} Resolved upon successful completion of command.
+ */
+ rampMotorSpeed(port, fromSpeed, toSpeed, time) {
+ const portObj = this._portLookup(port);
+ portObj.cancelEventTimer();
+ return new Promise((resolve, reject) => {
+ this._calculateRamp(fromSpeed, toSpeed, time, portObj)
+ .on("changeSpeed", (speed) => {
+ this.setMotorSpeed(port, speed, true);
+ })
+ .on("finished", resolve);
+ });
+ }
+ /**
+ * Rotate a motor by a given angle.
+ * @method ControlPlusHub#setMotorAngle
+ * @param {string} port
+ * @param {number} angle How much the motor should be rotated (in degrees).
+ * @param {number | Array.<number>} [speed=100] For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0. If you are specifying port AB to control both motors, you can optionally supply a tuple of speeds.
+ * @returns {Promise} Resolved upon successful completion of command (ie. once the motor is finished).
+ */
+ setMotorAngle(port, angle, speed = 100) {
+ const portObj = this._portLookup(port);
+ if (!(portObj.type === Consts.DeviceType.BOOST_TACHO_MOTOR ||
+ portObj.type === Consts.DeviceType.BOOST_MOVE_HUB_MOTOR ||
+ portObj.type === Consts.DeviceType.CONTROL_PLUS_LARGE_MOTOR ||
+ portObj.type === Consts.DeviceType.CONTROL_PLUS_XLARGE_MOTOR)) {
+ throw new Error("Angle rotation is only available when using a Boost Tacho Motor, Boost Move Hub Motor, Control+ Medium Motor, or Control+ Large Motor");
+ }
+ if (!this._virtualPorts[portObj.id] && speed instanceof Array) {
+ throw new Error(`Port ${portObj.id} can only accept a single speed`);
+ }
+ portObj.cancelEventTimer();
+ return new Promise((resolve, reject) => {
+ portObj.busy = true;
+ let data = null;
+ if (this._virtualPorts[portObj.id]) {
+ data = Buffer.from([0x81, portObj.value, 0x11, 0x0c, 0x00, 0x00, 0x00, 0x00, this._mapSpeed(speed instanceof Array ? speed[0] : speed), this._mapSpeed(speed instanceof Array ? speed[1] : speed), 0x64, 0x7f, 0x03]);
+ }
+ else {
+ // @ts-ignore: The type of speed is properly checked at the start
+ data = Buffer.from([0x81, portObj.value, 0x11, 0x0b, 0x00, 0x00, 0x00, 0x00, this._mapSpeed(speed), 0x64, 0x7f, 0x03]);
+ }
+ data.writeUInt32LE(angle, 4);
+ this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, data);
+ portObj.finished = () => {
+ return resolve();
+ };
+ });
+ }
+ /**
+ * Tell motor to goto an absolute position
+ * @method ControlPlusHub#setAbsolutePosition
+ * @param {string} port
+ * @param {number} pos The position of the motor to go to
+ * @param {number | Array.<number>} [speed=100] A value between 1 - 100 should be set (Direction does not apply when going to absolute position)
+ * @returns {Promise} Resolved upon successful completion of command (ie. once the motor is finished).
+ */
+ setAbsolutePosition(port, pos, speed = 100) {
+ const portObj = this._portLookup(port);
+ if (!(portObj.type === Consts.DeviceType.CONTROL_PLUS_LARGE_MOTOR ||
+ portObj.type === Consts.DeviceType.CONTROL_PLUS_XLARGE_MOTOR)) {
+ throw new Error("Absolute positioning is only available when using a Control+ Medium Motor, or Control+ Large Motor");
+ }
+ portObj.cancelEventTimer();
+ return new Promise((resolve, reject) => {
+ portObj.busy = true;
+ let data = null;
+ if (this._virtualPorts[portObj.id]) {
+ data = Buffer.from([0x81, portObj.value, 0x11, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, this._mapSpeed(speed), 0x64, 0x7f, 0x03]);
+ data.writeInt32LE(pos, 4);
+ data.writeInt32LE(pos, 8);
+ }
+ else {
+ // @ts-ignore: The type of speed is properly checked at the start
+ data = Buffer.from([0x81, portObj.value, 0x11, 0x0d, 0x00, 0x00, 0x00, 0x00, this._mapSpeed(speed), 0x64, 0x7f, 0x03]);
+ data.writeInt32LE(pos, 4);
+ }
+ this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, data);
+ portObj.finished = () => {
+ return resolve();
+ };
+ });
+ }
+ /**
+ * Reset the current motor position as absolute position zero
+ * @method ControlPlusHub#resetAbsolutePosition
+ * @param {string} port
+ * @returns {Promise} Resolved upon successful completion of command (ie. once the motor is finished).
+ */
+ resetAbsolutePosition(port) {
+ const portObj = this._portLookup(port);
+ if (!(portObj.type === Consts.DeviceType.CONTROL_PLUS_LARGE_MOTOR ||
+ portObj.type === Consts.DeviceType.CONTROL_PLUS_XLARGE_MOTOR)) {
+ throw new Error("Absolute positioning is only available when using a Control+ Medium Motor, or Control+ Large Motor");
+ }
+ return new Promise((resolve) => {
+ const data = Buffer.from([0x81, portObj.value, 0x11, 0x51, 0x02, 0x00, 0x00, 0x00, 0x00]);
+ this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, data);
+ return resolve();
+ });
+ }
+ /**
+ * Fully (hard) stop the motor on a given port.
+ * @method ControlPlusHub#brakeMotor
+ * @param {string} port
+ * @returns {Promise} Resolved upon successful completion of command.
+ */
+ brakeMotor(port) {
+ return this.setMotorSpeed(port, 127);
+ }
+ /**
+ * Set the light brightness on a given port.
+ * @method ControlPlusHub#setLightBrightness
+ * @param {string} port
+ * @param {number} brightness Brightness value between 0-100 (0 is off)
+ * @param {number} [time] How long to turn the light on (in milliseconds). Leave empty to turn the light on indefinitely.
+ * @returns {Promise} Resolved upon successful completion of command. If time is specified, this is once the light is turned off.
+ */
+ setLightBrightness(port, brightness, time) {
+ const portObj = this._portLookup(port);
+ portObj.cancelEventTimer();
+ return new Promise((resolve, reject) => {
+ const data = Buffer.from([0x81, portObj.value, 0x11, 0x51, 0x00, brightness]);
+ this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, data);
+ if (time) {
+ const timeout = global.setTimeout(() => {
+ const data = Buffer.from([0x81, portObj.value, 0x11, 0x51, 0x00, 0x00]);
+ this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, data);
+ return resolve();
+ }, time);
+ portObj.setEventTimer(timeout);
+ }
+ else {
+ return resolve();
+ }
+ });
+ }
+}
+exports.ControlPlusHub = ControlPlusHub;
+//# sourceMappingURL=controlplushub.js.map
node-poweredup - A Javascript module to interface with LEGO Powered Up components.
+
Introduction
+
LEGO Powered Up is the successor to Power Functions, the system for adding electronics to LEGO models. Powered Up is a collection of ranges - starting with LEGO WeDo 2.0 released in 2016, LEGO Boost released in 2017, LEGO Powered Up released in 2018, and LEGO Technic CONTROL+ released in 2019. It also includes the 2018 Duplo App-Controlled Train sets.
+
This library allows communication and control of Powered Up devices and peripherals via Javascript, both from Node.js and from the browser using Web Bluetooth.
Note: node-poweredup has been tested on macOS 10.13 and Debian/Raspbian on the Raspberry Pi 3 Model B.
+
Compatibility
+
While most Powered Up components and Hubs are compatible with each other, there are exceptions. For example, there is limited backwards compatibility between newer components and the WeDo 2.0 Smart Hub. However WeDo 2.0 components are fully forwards compatible with newer Hubs.
const PoweredUP = require("node-poweredup");
+const poweredUP = new PoweredUP.PoweredUP();
+
+poweredUP.on("discover", async (hub) => { // Wait to discover a Hub
+ console.log(`Discovered ${hub.name}!`);
+ await hub.connect(); // Connect to the Hub
+ console.log("Connected");
+ await hub.sleep(3000); // Sleep for 3 seconds before starting
+
+ while (true) { // Repeat indefinitely
+ console.log("Running motor B at speed 75");
+ hub.setMotorSpeed("B", 75); // Start a motor attached to port B to run a 3/4 speed (75) indefinitely
+ console.log("Running motor A at speed 100 for 2 seconds");
+ await hub.setMotorSpeed("A", 100, 2000); // Run a motor attached to port A for 2 seconds at maximum speed (100) then stop
+ await hub.sleep(1000); // Do nothing for 1 second
+ console.log("Running motor A at speed -50 for 1 seconds");
+ await hub.setMotorSpeed("A", -50, 1000); // Run a motor attached to port A for 1 second at 1/2 speed in reverse (-50) then stop
+ await hub.sleep(1000); // Do nothing for 1 second
+ }
+});
+
+poweredUP.scan(); // Start scanning for Hubs
+console.log("Scanning for Hubs...");
+
+
More examples are available in the "examples" directory.
+
Credits
+
Thanks go to Jorge Pereira (@JorgePe), Sebastian Raff (@hobbyquaker), Valentin Heun (@vheun), Johan Korten (@jakorten), and Andrey Pokhilko (@undera) for their various works, contributions, and assistance on figuring out the LEGO Boost, WeDo 2.0, and Powered Up protocols.
"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 = {};
+ if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
+ result["default"] = 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"));
+const Debug = require("debug");
+const debug = Debug("puphub");
+/**
+ * The PUPHub is emitted if the discovered device is a Powered UP Hub.
+ * @class PUPHub
+ * @extends LPF2Hub
+ * @extends Hub
+ */
+class PUPHub extends lpf2hub_1.LPF2Hub {
+ 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),
+ "B": new port_1.Port("B", 1)
+ };
+ this.on("attach", (port, type) => {
+ this._combinePorts(port, type);
+ });
+ 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");
+ await super.connect();
+ debug("Connect completed");
+ return resolve();
+ });
+ }
+ /**
+ * Set the motor speed on a given port.
+ * @method PUPHub#setMotorSpeed
+ * @param {string} port
+ * @param {number | Array.<number>} speed For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0. If you are specifying port AB to control both motors, you can optionally supply a tuple of speeds.
+ * @param {number} [time] How long to activate the motor for (in milliseconds). Leave empty to turn the motor on indefinitely.
+ * @returns {Promise} Resolved upon successful completion of command. If time is specified, this is once the motor is finished.
+ */
+ setMotorSpeed(port, speed, time) {
+ const portObj = this._portLookup(port);
+ if (!this._virtualPorts[portObj.id] && speed instanceof Array) {
+ throw new Error(`Port ${portObj.id} can only accept a single speed`);
+ }
+ let cancelEventTimer = true;
+ if (typeof time === "boolean") {
+ if (time === true) {
+ cancelEventTimer = false;
+ }
+ time = undefined;
+ }
+ if (cancelEventTimer) {
+ portObj.cancelEventTimer();
+ }
+ return new Promise((resolve, reject) => {
+ if (time && typeof time === "number") {
+ if (portObj.type === Consts.DeviceType.BOOST_TACHO_MOTOR ||
+ portObj.type === Consts.DeviceType.BOOST_MOVE_HUB_MOTOR ||
+ portObj.type === Consts.DeviceType.CONTROL_PLUS_LARGE_MOTOR ||
+ portObj.type === Consts.DeviceType.CONTROL_PLUS_XLARGE_MOTOR) {
+ portObj.busy = true;
+ let data = null;
+ if (this._virtualPorts[portObj.id]) {
+ data = Buffer.from([0x81, portObj.value, 0x11, 0x0a, 0x00, 0x00, this._mapSpeed(speed instanceof Array ? speed[0] : speed), this._mapSpeed(speed instanceof Array ? speed[1] : speed), 0x64, 0x7f, 0x03]);
+ }
+ else {
+ // @ts-ignore: The type of speed is properly checked at the start
+ data = Buffer.from([0x81, portObj.value, 0x11, 0x09, 0x00, 0x00, this._mapSpeed(speed), 0x64, 0x7f, 0x03]);
+ }
+ data.writeUInt16LE(time > 65535 ? 65535 : time, 4);
+ this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, data);
+ portObj.finished = () => {
+ return resolve();
+ };
+ }
+ else {
+ // @ts-ignore: The type of speed is properly checked at the start
+ const data = Buffer.from([0x81, portObj.value, 0x11, 0x51, 0x00, this._mapSpeed(speed)]);
+ this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, data);
+ const timeout = global.setTimeout(() => {
+ const data = Buffer.from([0x81, portObj.value, 0x11, 0x51, 0x00, 0x00]);
+ this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, data);
+ return resolve();
+ // @ts-ignore: The type of time is properly checked at the start
+ }, time);
+ portObj.setEventTimer(timeout);
+ }
+ }
+ else {
+ if (portObj.type === Consts.DeviceType.BOOST_TACHO_MOTOR || portObj.type === Consts.DeviceType.BOOST_MOVE_HUB_MOTOR) {
+ portObj.busy = true;
+ let data = null;
+ if (this._virtualPorts[portObj.id]) {
+ data = Buffer.from([0x81, portObj.value, 0x11, 0x02, this._mapSpeed(speed instanceof Array ? speed[0] : speed), this._mapSpeed(speed instanceof Array ? speed[1] : speed), 0x64, 0x7f, 0x03]);
+ }
+ else {
+ // @ts-ignore: The type of speed is properly checked at the start
+ data = Buffer.from([0x81, portObj.value, 0x11, 0x01, this._mapSpeed(speed), 0x64, 0x7f, 0x03]);
+ }
+ this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, data);
+ portObj.finished = () => {
+ return resolve();
+ };
+ }
+ else {
+ // @ts-ignore: The type of speed is properly checked at the start
+ const data = Buffer.from([0x81, portObj.value, 0x11, 0x51, 0x00, this._mapSpeed(speed)]);
+ this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, data);
+ }
+ }
+ });
+ }
+ /**
+ * Ramp the motor speed on a given port.
+ * @method PUPHub#rampMotorSpeed
+ * @param {string} port
+ * @param {number} fromSpeed For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0.
+ * @param {number} toSpeed For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0.
+ * @param {number} time How long the ramp should last (in milliseconds).
+ * @returns {Promise} Resolved upon successful completion of command.
+ */
+ rampMotorSpeed(port, fromSpeed, toSpeed, time) {
+ const portObj = this._portLookup(port);
+ portObj.cancelEventTimer();
+ return new Promise((resolve, reject) => {
+ this._calculateRamp(fromSpeed, toSpeed, time, portObj)
+ .on("changeSpeed", (speed) => {
+ this.setMotorSpeed(port, speed, true);
+ })
+ .on("finished", resolve);
+ });
+ }
+ /**
+ * Rotate a motor by a given angle.
+ * @method PUPHub#setMotorAngle
+ * @param {string} port
+ * @param {number} angle How much the motor should be rotated (in degrees).
+ * @param {number | Array.<number>} [speed=100] For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0. If you are specifying port AB to control both motors, you can optionally supply a tuple of speeds.
+ * @returns {Promise} Resolved upon successful completion of command (ie. once the motor is finished).
+ */
+ setMotorAngle(port, angle, speed = 100) {
+ const portObj = this._portLookup(port);
+ if (!(portObj.type === Consts.DeviceType.BOOST_TACHO_MOTOR ||
+ portObj.type === Consts.DeviceType.BOOST_MOVE_HUB_MOTOR ||
+ portObj.type === Consts.DeviceType.CONTROL_PLUS_LARGE_MOTOR ||
+ portObj.type === Consts.DeviceType.CONTROL_PLUS_XLARGE_MOTOR)) {
+ throw new Error("Angle rotation is only available when using a Boost Tacho Motor, Boost Move Hub Motor, Control+ Medium Motor, or Control+ Large Motor");
+ }
+ if (!this._virtualPorts[portObj.id] && speed instanceof Array) {
+ throw new Error(`Port ${portObj.id} can only accept a single speed`);
+ }
+ portObj.cancelEventTimer();
+ return new Promise((resolve, reject) => {
+ portObj.busy = true;
+ let data = null;
+ if (this._virtualPorts[portObj.id]) {
+ data = Buffer.from([0x81, portObj.value, 0x11, 0x0c, 0x00, 0x00, 0x00, 0x00, this._mapSpeed(speed instanceof Array ? speed[0] : speed), this._mapSpeed(speed instanceof Array ? speed[1] : speed), 0x64, 0x7f, 0x03]);
+ }
+ else {
+ // @ts-ignore: The type of speed is properly checked at the start
+ data = Buffer.from([0x81, portObj.value, 0x11, 0x0b, 0x00, 0x00, 0x00, 0x00, this._mapSpeed(speed), 0x64, 0x7f, 0x03]);
+ }
+ data.writeUInt32LE(angle, 4);
+ this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, data);
+ portObj.finished = () => {
+ return resolve();
+ };
+ });
+ }
+ /**
+ * Tell motor to goto an absolute position
+ * @method PUPHub#setAbsolutePosition
+ * @param {string} port
+ * @param {number} pos The position of the motor to go to
+ * @param {number | Array.<number>} [speed=100] A value between 1 - 100 should be set (Direction does not apply when going to absolute position)
+ * @returns {Promise} Resolved upon successful completion of command (ie. once the motor is finished).
+ */
+ setAbsolutePosition(port, pos, speed = 100) {
+ const portObj = this._portLookup(port);
+ if (!(portObj.type === Consts.DeviceType.CONTROL_PLUS_LARGE_MOTOR ||
+ portObj.type === Consts.DeviceType.CONTROL_PLUS_XLARGE_MOTOR)) {
+ throw new Error("Absolute positioning is only available when using a Control+ Medium Motor, or Control+ Large Motor");
+ }
+ portObj.cancelEventTimer();
+ return new Promise((resolve, reject) => {
+ portObj.busy = true;
+ let data = null;
+ if (this._virtualPorts[portObj.id]) {
+ data = Buffer.from([0x81, portObj.value, 0x11, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, this._mapSpeed(speed), 0x64, 0x7f, 0x03]);
+ data.writeInt32LE(pos, 4);
+ data.writeInt32LE(pos, 8);
+ }
+ else {
+ // @ts-ignore: The type of speed is properly checked at the start
+ data = Buffer.from([0x81, portObj.value, 0x11, 0x0d, 0x00, 0x00, 0x00, 0x00, this._mapSpeed(speed), 0x64, 0x7f, 0x03]);
+ data.writeInt32LE(pos, 4);
+ }
+ this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, data);
+ portObj.finished = () => {
+ return resolve();
+ };
+ });
+ }
+ /**
+ * Reset the current motor position as absolute position zero
+ * @method PUPHub#resetAbsolutePosition
+ * @param {string} port
+ * @returns {Promise} Resolved upon successful completion of command (ie. once the motor is finished).
+ */
+ resetAbsolutePosition(port) {
+ const portObj = this._portLookup(port);
+ if (!(portObj.type === Consts.DeviceType.CONTROL_PLUS_LARGE_MOTOR ||
+ portObj.type === Consts.DeviceType.CONTROL_PLUS_XLARGE_MOTOR)) {
+ throw new Error("Absolute positioning is only available when using a Control+ Medium Motor, or Control+ Large Motor");
+ }
+ return new Promise((resolve) => {
+ const data = Buffer.from([0x81, portObj.value, 0x11, 0x51, 0x02, 0x00, 0x00, 0x00, 0x00]);
+ this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, data);
+ return resolve();
+ });
+ }
+ /**
+ * Fully (hard) stop the motor on a given port.
+ * @method PUPHub#brakeMotor
+ * @param {string} port
+ * @returns {Promise} Resolved upon successful completion of command.
+ */
+ brakeMotor(port) {
+ return this.setMotorSpeed(port, 127);
+ }
+ /**
+ * Set the light brightness on a given port.
+ * @method PUPHub#setLightBrightness
+ * @param {string} port
+ * @param {number} brightness Brightness value between 0-100 (0 is off)
+ * @param {number} [time] How long to turn the light on (in milliseconds). Leave empty to turn the light on indefinitely.
+ * @returns {Promise} Resolved upon successful completion of command. If time is specified, this is once the light is turned off.
+ */
+ setLightBrightness(port, brightness, time) {
+ const portObj = this._portLookup(port);
+ portObj.cancelEventTimer();
+ return new Promise((resolve, reject) => {
+ const data = Buffer.from([0x81, portObj.value, 0x11, 0x51, 0x00, brightness]);
+ this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, data);
+ if (time) {
+ const timeout = global.setTimeout(() => {
+ const data = Buffer.from([0x81, portObj.value, 0x11, 0x51, 0x00, 0x00]);
+ this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, data);
+ return resolve();
+ }, time);
+ portObj.setEventTimer(timeout);
+ }
+ else {
+ return resolve();
+ }
+ });
+ }
+ _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