diff --git a/DOCS.md b/DOCS.md
index ad43842..1943db0 100644
--- a/DOCS.md
+++ b/DOCS.md
@@ -78,6 +78,7 @@ Emits when a LPF2 Hub device is found.
* [.disconnect()](#Hub+disconnect) ⇒ Promise
* [.subscribe(port, [mode])](#Hub+subscribe) ⇒ Promise
* [.unsubscribe(port)](#Hub+unsubscribe) ⇒ Promise
+ * [.wait(delay)](#Hub+wait) ⇒ Promise
* ["button" (button, state)](#BoostHub+event_button)
* ["distance" (port, distance)](#BoostHub+event_distance)
* ["color" (port, color)](#BoostHub+event_color)
@@ -164,6 +165,20 @@ Unsubscribe to sensor notifications on a given port.
| --- | --- |
| port | string
|
+
+
+### boostHub.wait(delay) ⇒ Promise
+Wait 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 [BoostHub
](#BoostHub)
+**Returns**: Promise
- Resolved after the delay is finished.
+
+| Param | Type | Description |
+| --- | --- | --- |
+| delay | number
| How long to wait (in milliseconds). |
+
### "button" (button, state)
@@ -239,6 +254,7 @@ Emits when a rotation sensor is activated.
* [.disconnect()](#Hub+disconnect) ⇒ Promise
* [.subscribe(port, [mode])](#Hub+subscribe) ⇒ Promise
* [.unsubscribe(port)](#Hub+unsubscribe) ⇒ Promise
+ * [.wait(delay)](#Hub+wait) ⇒ Promise
* ["button" (button, state)](#WeDo2Hub+event_button)
* ["distance" (port, distance)](#WeDo2Hub+event_distance)
* ["color" (port, color)](#WeDo2Hub+event_color)
@@ -324,6 +340,20 @@ Unsubscribe to sensor notifications on a given port.
| --- | --- |
| port | string
|
+
+
+### weDo2Hub.wait(delay) ⇒ Promise
+Wait 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 [WeDo2Hub
](#WeDo2Hub)
+**Returns**: Promise
- Resolved after the delay is finished.
+
+| Param | Type | Description |
+| --- | --- | --- |
+| delay | number
| How long to wait (in milliseconds). |
+
### "button" (button, state)
@@ -396,6 +426,7 @@ Emits when a rotation sensor is activated.
* [.disconnect()](#Hub+disconnect) ⇒ Promise
* [.subscribe(port, [mode])](#Hub+subscribe) ⇒ Promise
* [.unsubscribe(port)](#Hub+unsubscribe) ⇒ Promise
+ * [.wait(delay)](#Hub+wait) ⇒ Promise
@@ -436,3 +467,17 @@ Unsubscribe to sensor notifications on a given port.
| --- | --- |
| port | string
|
+
+
+### hub.wait(delay) ⇒ Promise
+Wait 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 [Hub
](#Hub)
+**Returns**: Promise
- Resolved after the delay is finished.
+
+| Param | Type | Description |
+| --- | --- | --- |
+| delay | number
| How long to wait (in milliseconds). |
+
diff --git a/README.md b/README.md
index 266374f..006c4a7 100644
--- a/README.md
+++ b/README.md
@@ -118,6 +118,7 @@ Emits when a LPF2 Hub device is found.
* [.disconnect()](#Hub+disconnect) ⇒ Promise
* [.subscribe(port, [mode])](#Hub+subscribe) ⇒ Promise
* [.unsubscribe(port)](#Hub+unsubscribe) ⇒ Promise
+ * [.wait(delay)](#Hub+wait) ⇒ Promise
* ["button" (button, state)](#BoostHub+event_button)
* ["distance" (port, distance)](#BoostHub+event_distance)
* ["color" (port, color)](#BoostHub+event_color)
@@ -204,6 +205,20 @@ Unsubscribe to sensor notifications on a given port.
| --- | --- |
| port | string
|
+
+
+### boostHub.wait(delay) ⇒ Promise
+Wait 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 [BoostHub
](#BoostHub)
+**Returns**: Promise
- Resolved after the delay is finished.
+
+| Param | Type | Description |
+| --- | --- | --- |
+| delay | number
| How long to wait (in milliseconds). |
+
### "button" (button, state)
@@ -279,6 +294,7 @@ Emits when a rotation sensor is activated.
* [.disconnect()](#Hub+disconnect) ⇒ Promise
* [.subscribe(port, [mode])](#Hub+subscribe) ⇒ Promise
* [.unsubscribe(port)](#Hub+unsubscribe) ⇒ Promise
+ * [.wait(delay)](#Hub+wait) ⇒ Promise
* ["button" (button, state)](#WeDo2Hub+event_button)
* ["distance" (port, distance)](#WeDo2Hub+event_distance)
* ["color" (port, color)](#WeDo2Hub+event_color)
@@ -364,6 +380,20 @@ Unsubscribe to sensor notifications on a given port.
| --- | --- |
| port | string
|
+
+
+### weDo2Hub.wait(delay) ⇒ Promise
+Wait 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 [WeDo2Hub
](#WeDo2Hub)
+**Returns**: Promise
- Resolved after the delay is finished.
+
+| Param | Type | Description |
+| --- | --- | --- |
+| delay | number
| How long to wait (in milliseconds). |
+
### "button" (button, state)
@@ -436,6 +466,7 @@ Emits when a rotation sensor is activated.
* [.disconnect()](#Hub+disconnect) ⇒ Promise
* [.subscribe(port, [mode])](#Hub+subscribe) ⇒ Promise
* [.unsubscribe(port)](#Hub+unsubscribe) ⇒ Promise
+ * [.wait(delay)](#Hub+wait) ⇒ Promise
@@ -476,3 +507,17 @@ Unsubscribe to sensor notifications on a given port.
| --- | --- |
| port | string
|
+
+
+### hub.wait(delay) ⇒ Promise
+Wait 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 [Hub
](#Hub)
+**Returns**: Promise
- Resolved after the delay is finished.
+
+| Param | Type | Description |
+| --- | --- | --- |
+| delay | number
| How long to wait (in milliseconds). |
+
diff --git a/hub.ts b/hub.ts
index 3159445..4daf1f9 100644
--- a/hub.ts
+++ b/hub.ts
@@ -156,6 +156,21 @@ export class Hub extends EventEmitter {
}
+ /**
+ * Wait a given amount of time.
+ *
+ * This is a helper method to make it easier to add delays into a chain of commands.
+ * @method Hub#wait
+ * @param {number} delay How long to wait (in milliseconds).
+ * @returns {Promise} Resolved after the delay is finished.
+ */
+ public wait (delay: number) {
+ return new Promise((resolve) => {
+ setTimeout(resolve, delay);
+ });
+ }
+
+
protected _subscribeToCharacteristic (characteristic: Characteristic, callback: (data: Buffer) => void) {
characteristic.on("data", (data: Buffer) => {
return callback(data);