diff --git a/DOCS.md b/DOCS.md
index 9aa5d38..eed7c91 100644
--- a/DOCS.md
+++ b/DOCS.md
@@ -39,7 +39,7 @@ Stop scanning for LPF2 Hub devices.
### lpF2.getConnectedDeviceByUUID(uuid) ⇒ [Hub
](#Hub) \| null
-Retrieve a LPF2 Hub device by UUID
+Retrieve a LPF2 Hub device by UUID.
**Kind**: instance method of [LPF2
](#LPF2)
@@ -50,7 +50,7 @@ Retrieve a LPF2 Hub device by UUID
### lpF2.getConnectedDevices() ⇒ [Array.<Hub>
](#Hub)
-Retrieve a list of LPF2 Hub devices
+Retrieve a list of LPF2 Hub devices.
**Kind**: instance method of [LPF2
](#LPF2)
@@ -62,7 +62,7 @@ Emits when a LPF2 Hub device is found.
| Param | Type |
| --- | --- |
-| hub | [Hub
](#Hub) |
+| hub | [WeDo2Hub
](#WeDo2Hub) \| [BoostHub
](#BoostHub) |
@@ -90,7 +90,7 @@ Emits when a LPF2 Hub device is found.
Set the color of the LED on the Hub via a color value.
**Kind**: instance method of [BoostHub
](#BoostHub)
-**Returns**: Promise
- Resolved upon successful completion of command.
+**Returns**: Promise
- Resolved upon successful issuance of command.
| Param | Type | Description |
| --- | --- | --- |
@@ -248,7 +248,7 @@ Emits when a rotation sensor is activated.
Set the color of the LED on the Hub via a color value.
**Kind**: instance method of [WeDo2Hub
](#WeDo2Hub)
-**Returns**: Promise
- Resolved upon successful completion of command.
+**Returns**: Promise
- Resolved upon successful issuance of command.
| Param | Type | Description |
| --- | --- | --- |
@@ -260,7 +260,7 @@ Set the color of the LED on the Hub via a color value.
Set the color of the LED on the Hub via RGB values.
**Kind**: instance method of [WeDo2Hub
](#WeDo2Hub)
-**Returns**: Promise
- Resolved upon successful completion of command.
+**Returns**: Promise
- Resolved upon successful issuance of command.
| Param | Type |
| --- | --- |
@@ -274,7 +274,7 @@ Set the color of the LED on the Hub via RGB values.
Set the motor speed on a given port.
**Kind**: instance method of [WeDo2Hub
](#WeDo2Hub)
-**Returns**: Promise
- Resolved upon successful completion of command.
+**Returns**: Promise
- Resolved upon successful issuance of command.
| Param | Type | Description |
| --- | --- | --- |
diff --git a/README.md b/README.md
index 2527f49..044e40b 100644
--- a/README.md
+++ b/README.md
@@ -79,7 +79,7 @@ Stop scanning for LPF2 Hub devices.
### lpF2.getConnectedDeviceByUUID(uuid) ⇒ [Hub
](#Hub) \| null
-Retrieve a LPF2 Hub device by UUID
+Retrieve a LPF2 Hub device by UUID.
**Kind**: instance method of [LPF2
](#LPF2)
@@ -90,7 +90,7 @@ Retrieve a LPF2 Hub device by UUID
### lpF2.getConnectedDevices() ⇒ [Array.<Hub>
](#Hub)
-Retrieve a list of LPF2 Hub devices
+Retrieve a list of LPF2 Hub devices.
**Kind**: instance method of [LPF2
](#LPF2)
@@ -102,7 +102,7 @@ Emits when a LPF2 Hub device is found.
| Param | Type |
| --- | --- |
-| hub | [Hub
](#Hub) |
+| hub | [WeDo2Hub
](#WeDo2Hub) \| [BoostHub
](#BoostHub) |
@@ -130,7 +130,7 @@ Emits when a LPF2 Hub device is found.
Set the color of the LED on the Hub via a color value.
**Kind**: instance method of [BoostHub
](#BoostHub)
-**Returns**: Promise
- Resolved upon successful completion of command.
+**Returns**: Promise
- Resolved upon successful issuance of command.
| Param | Type | Description |
| --- | --- | --- |
@@ -288,7 +288,7 @@ Emits when a rotation sensor is activated.
Set the color of the LED on the Hub via a color value.
**Kind**: instance method of [WeDo2Hub
](#WeDo2Hub)
-**Returns**: Promise
- Resolved upon successful completion of command.
+**Returns**: Promise
- Resolved upon successful issuance of command.
| Param | Type | Description |
| --- | --- | --- |
@@ -300,7 +300,7 @@ Set the color of the LED on the Hub via a color value.
Set the color of the LED on the Hub via RGB values.
**Kind**: instance method of [WeDo2Hub
](#WeDo2Hub)
-**Returns**: Promise
- Resolved upon successful completion of command.
+**Returns**: Promise
- Resolved upon successful issuance of command.
| Param | Type |
| --- | --- |
@@ -314,7 +314,7 @@ Set the color of the LED on the Hub via RGB values.
Set the motor speed on a given port.
**Kind**: instance method of [WeDo2Hub
](#WeDo2Hub)
-**Returns**: Promise
- Resolved upon successful completion of command.
+**Returns**: Promise
- Resolved upon successful issuance of command.
| Param | Type | Description |
| --- | --- | --- |
diff --git a/boosthub.ts b/boosthub.ts
index 2320519..0ba7c9a 100644
--- a/boosthub.ts
+++ b/boosthub.ts
@@ -57,7 +57,7 @@ export class BoostHub extends Hub {
* Set the color of the LED on the Hub via a color value.
* @method BoostHub#setLEDColor
* @param {number} color A number representing one of the LED color consts.
- * @returns {Promise} Resolved upon successful completion of command.
+ * @returns {Promise} Resolved upon successful issuance of command.
*/
public setLEDColor (color: number | boolean) {
return new Promise((resolve, reject) => {
diff --git a/hub.ts b/hub.ts
index d46d966..10f9c99 100644
--- a/hub.ts
+++ b/hub.ts
@@ -123,11 +123,15 @@ export class Hub extends EventEmitter {
* @param {number} [mode] The sensor mode to activate. If no mode is provided, the default for that sensor will be chosen.
*/
public subscribe (port: string, mode?: number) {
- let newMode = 0x00;
- if (mode && !(typeof mode === "number")) {
- newMode = this._getModeForDeviceType(this._ports[port].type);
- }
- this._activatePortDevice(this._ports[port].value, this._ports[port].type, newMode, 0x00);
+ return new Promise((resolve, reject) => {
+ let newMode = 0x00;
+ if (mode && !(typeof mode === "number")) {
+ newMode = this._getModeForDeviceType(this._ports[port].type);
+ }
+ this._activatePortDevice(this._ports[port].value, this._ports[port].type, newMode, 0x00, () => {
+ return resolve();
+ });
+ });
}
/**
@@ -136,8 +140,12 @@ export class Hub extends EventEmitter {
* @param {string} port
*/
public unsubscribe (port: string) {
- const mode = this._getModeForDeviceType(this._ports[port].type);
- this._deactivatePortDevice(this._ports[port].value, this._ports[port].type, mode, 0x00);
+ return new Promise((resolve, reject) => {
+ const mode = this._getModeForDeviceType(this._ports[port].type);
+ this._deactivatePortDevice(this._ports[port].value, this._ports[port].type, mode, 0x00, () => {
+ return resolve();
+ });
+ });
}
diff --git a/lpf2.ts b/lpf2.ts
index 1184563..bfb72f3 100644
--- a/lpf2.ts
+++ b/lpf2.ts
@@ -86,7 +86,7 @@ export class LPF2 extends EventEmitter {
/**
* Emits when a LPF2 Hub device is found.
* @event LPF2#discover
- * @param {Hub} hub
+ * @param {WeDo2Hub | BoostHub} hub
*/
this.emit("discover", hub);
@@ -110,7 +110,7 @@ export class LPF2 extends EventEmitter {
/**
- * Retrieve a LPF2 Hub device by UUID
+ * Retrieve a LPF2 Hub device by UUID.
* @method LPF2#getConnectedDeviceByUUID
* @param {string} uuid
* @returns {Hub | null}
@@ -121,7 +121,7 @@ export class LPF2 extends EventEmitter {
/**
- * Retrieve a list of LPF2 Hub devices
+ * Retrieve a list of LPF2 Hub devices.
* @method LPF2#getConnectedDevices
* @returns {Hub[]}
*/
diff --git a/wedo2hub.ts b/wedo2hub.ts
index 62599ac..1397d3f 100644
--- a/wedo2hub.ts
+++ b/wedo2hub.ts
@@ -53,7 +53,7 @@ export class WeDo2Hub extends Hub {
* Set the color of the LED on the Hub via a color value.
* @method WeDo2Hub#setLEDColor
* @param {number} color A number representing one of the LED color consts.
- * @returns {Promise} Resolved upon successful completion of command.
+ * @returns {Promise} Resolved upon successful issuance of command.
*/
public setLEDColor (color: number | boolean) {
return new Promise((resolve, reject) => {
@@ -79,7 +79,7 @@ export class WeDo2Hub extends Hub {
* @param {number} red
* @param {number} green
* @param {number} blue
- * @returns {Promise} Resolved upon successful completion of command.
+ * @returns {Promise} Resolved upon successful issuance of command.
*/
public setLEDRGB (red: number, green: number, blue: number) {
return new Promise((resolve, reject) => {
@@ -101,7 +101,7 @@ export class WeDo2Hub extends Hub {
* @method WeDo2Hub#setMotorSpeed
* @param {string} port
* @param {number} speed For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0.
- * @returns {Promise} Resolved upon successful completion of command.
+ * @returns {Promise} Resolved upon successful issuance of command.
*/
public setMotorSpeed (port: string, speed: number) {
return new Promise((resolve, reject) => {