Removed all callback apis
This commit is contained in:
parent
fdd4bb8114
commit
92248caca5
30
DOCS.md
30
DOCS.md
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
* [LPF2](#LPF2) ⇐ <code>EventEmitter</code>
|
* [LPF2](#LPF2) ⇐ <code>EventEmitter</code>
|
||||||
* [.scan()](#LPF2+scan)
|
* [.scan()](#LPF2+scan)
|
||||||
* [.scan()](#LPF2+scan)
|
* [.stop()](#LPF2+stop)
|
||||||
* [.getConnectedDeviceByUUID(uuid)](#LPF2+getConnectedDeviceByUUID) ⇒ [<code>Hub</code>](#Hub) \| <code>null</code>
|
* [.getConnectedDeviceByUUID(uuid)](#LPF2+getConnectedDeviceByUUID) ⇒ [<code>Hub</code>](#Hub) \| <code>null</code>
|
||||||
* [.getConnectedDevices()](#LPF2+getConnectedDevices) ⇒ [<code>Array.<Hub></code>](#Hub)
|
* [.getConnectedDevices()](#LPF2+getConnectedDevices) ⇒ [<code>Array.<Hub></code>](#Hub)
|
||||||
* ["discover" (hub)](#LPF2+event_discover)
|
* ["discover" (hub)](#LPF2+event_discover)
|
||||||
@ -30,9 +30,9 @@
|
|||||||
Begin scanning for LPF2 Hub devices.
|
Begin scanning for LPF2 Hub devices.
|
||||||
|
|
||||||
**Kind**: instance method of [<code>LPF2</code>](#LPF2)
|
**Kind**: instance method of [<code>LPF2</code>](#LPF2)
|
||||||
<a name="LPF2+scan"></a>
|
<a name="LPF2+stop"></a>
|
||||||
|
|
||||||
### lpF2.scan()
|
### lpF2.stop()
|
||||||
Stop scanning for LPF2 Hub devices.
|
Stop scanning for LPF2 Hub devices.
|
||||||
|
|
||||||
**Kind**: instance method of [<code>LPF2</code>](#LPF2)
|
**Kind**: instance method of [<code>LPF2</code>](#LPF2)
|
||||||
@ -145,10 +145,10 @@ Subscribe to sensor notifications on a given port.
|
|||||||
|
|
||||||
**Kind**: instance method of [<code>BoostHub</code>](#BoostHub)
|
**Kind**: instance method of [<code>BoostHub</code>](#BoostHub)
|
||||||
|
|
||||||
| Param | Type | Default | Description |
|
| Param | Type | Description |
|
||||||
| --- | --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| port | <code>string</code> | | |
|
| port | <code>string</code> | |
|
||||||
| [mode] | <code>number</code> \| <code>boolean</code> | <code>false</code> | The sensor mode to activate. If no mode is provided, the default for that sensor will be chosen. |
|
| [mode] | <code>number</code> | The sensor mode to activate. If no mode is provided, the default for that sensor will be chosen. |
|
||||||
|
|
||||||
<a name="Hub+unsubscribe"></a>
|
<a name="Hub+unsubscribe"></a>
|
||||||
|
|
||||||
@ -302,10 +302,10 @@ Subscribe to sensor notifications on a given port.
|
|||||||
|
|
||||||
**Kind**: instance method of [<code>WeDo2Hub</code>](#WeDo2Hub)
|
**Kind**: instance method of [<code>WeDo2Hub</code>](#WeDo2Hub)
|
||||||
|
|
||||||
| Param | Type | Default | Description |
|
| Param | Type | Description |
|
||||||
| --- | --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| port | <code>string</code> | | |
|
| port | <code>string</code> | |
|
||||||
| [mode] | <code>number</code> \| <code>boolean</code> | <code>false</code> | The sensor mode to activate. If no mode is provided, the default for that sensor will be chosen. |
|
| [mode] | <code>number</code> | The sensor mode to activate. If no mode is provided, the default for that sensor will be chosen. |
|
||||||
|
|
||||||
<a name="Hub+unsubscribe"></a>
|
<a name="Hub+unsubscribe"></a>
|
||||||
|
|
||||||
@ -411,10 +411,10 @@ Subscribe to sensor notifications on a given port.
|
|||||||
|
|
||||||
**Kind**: instance method of [<code>Hub</code>](#Hub)
|
**Kind**: instance method of [<code>Hub</code>](#Hub)
|
||||||
|
|
||||||
| Param | Type | Default | Description |
|
| Param | Type | Description |
|
||||||
| --- | --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| port | <code>string</code> | | |
|
| port | <code>string</code> | |
|
||||||
| [mode] | <code>number</code> \| <code>boolean</code> | <code>false</code> | The sensor mode to activate. If no mode is provided, the default for that sensor will be chosen. |
|
| [mode] | <code>number</code> | The sensor mode to activate. If no mode is provided, the default for that sensor will be chosen. |
|
||||||
|
|
||||||
<a name="Hub+unsubscribe"></a>
|
<a name="Hub+unsubscribe"></a>
|
||||||
|
|
||||||
|
30
README.md
30
README.md
@ -59,7 +59,7 @@ Examples are available in the "examples" directory.
|
|||||||
|
|
||||||
* [LPF2](#LPF2) ⇐ <code>EventEmitter</code>
|
* [LPF2](#LPF2) ⇐ <code>EventEmitter</code>
|
||||||
* [.scan()](#LPF2+scan)
|
* [.scan()](#LPF2+scan)
|
||||||
* [.scan()](#LPF2+scan)
|
* [.stop()](#LPF2+stop)
|
||||||
* [.getConnectedDeviceByUUID(uuid)](#LPF2+getConnectedDeviceByUUID) ⇒ [<code>Hub</code>](#Hub) \| <code>null</code>
|
* [.getConnectedDeviceByUUID(uuid)](#LPF2+getConnectedDeviceByUUID) ⇒ [<code>Hub</code>](#Hub) \| <code>null</code>
|
||||||
* [.getConnectedDevices()](#LPF2+getConnectedDevices) ⇒ [<code>Array.<Hub></code>](#Hub)
|
* [.getConnectedDevices()](#LPF2+getConnectedDevices) ⇒ [<code>Array.<Hub></code>](#Hub)
|
||||||
* ["discover" (hub)](#LPF2+event_discover)
|
* ["discover" (hub)](#LPF2+event_discover)
|
||||||
@ -70,9 +70,9 @@ Examples are available in the "examples" directory.
|
|||||||
Begin scanning for LPF2 Hub devices.
|
Begin scanning for LPF2 Hub devices.
|
||||||
|
|
||||||
**Kind**: instance method of [<code>LPF2</code>](#LPF2)
|
**Kind**: instance method of [<code>LPF2</code>](#LPF2)
|
||||||
<a name="LPF2+scan"></a>
|
<a name="LPF2+stop"></a>
|
||||||
|
|
||||||
### lpF2.scan()
|
### lpF2.stop()
|
||||||
Stop scanning for LPF2 Hub devices.
|
Stop scanning for LPF2 Hub devices.
|
||||||
|
|
||||||
**Kind**: instance method of [<code>LPF2</code>](#LPF2)
|
**Kind**: instance method of [<code>LPF2</code>](#LPF2)
|
||||||
@ -185,10 +185,10 @@ Subscribe to sensor notifications on a given port.
|
|||||||
|
|
||||||
**Kind**: instance method of [<code>BoostHub</code>](#BoostHub)
|
**Kind**: instance method of [<code>BoostHub</code>](#BoostHub)
|
||||||
|
|
||||||
| Param | Type | Default | Description |
|
| Param | Type | Description |
|
||||||
| --- | --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| port | <code>string</code> | | |
|
| port | <code>string</code> | |
|
||||||
| [mode] | <code>number</code> \| <code>boolean</code> | <code>false</code> | The sensor mode to activate. If no mode is provided, the default for that sensor will be chosen. |
|
| [mode] | <code>number</code> | The sensor mode to activate. If no mode is provided, the default for that sensor will be chosen. |
|
||||||
|
|
||||||
<a name="Hub+unsubscribe"></a>
|
<a name="Hub+unsubscribe"></a>
|
||||||
|
|
||||||
@ -342,10 +342,10 @@ Subscribe to sensor notifications on a given port.
|
|||||||
|
|
||||||
**Kind**: instance method of [<code>WeDo2Hub</code>](#WeDo2Hub)
|
**Kind**: instance method of [<code>WeDo2Hub</code>](#WeDo2Hub)
|
||||||
|
|
||||||
| Param | Type | Default | Description |
|
| Param | Type | Description |
|
||||||
| --- | --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| port | <code>string</code> | | |
|
| port | <code>string</code> | |
|
||||||
| [mode] | <code>number</code> \| <code>boolean</code> | <code>false</code> | The sensor mode to activate. If no mode is provided, the default for that sensor will be chosen. |
|
| [mode] | <code>number</code> | The sensor mode to activate. If no mode is provided, the default for that sensor will be chosen. |
|
||||||
|
|
||||||
<a name="Hub+unsubscribe"></a>
|
<a name="Hub+unsubscribe"></a>
|
||||||
|
|
||||||
@ -451,10 +451,10 @@ Subscribe to sensor notifications on a given port.
|
|||||||
|
|
||||||
**Kind**: instance method of [<code>Hub</code>](#Hub)
|
**Kind**: instance method of [<code>Hub</code>](#Hub)
|
||||||
|
|
||||||
| Param | Type | Default | Description |
|
| Param | Type | Description |
|
||||||
| --- | --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| port | <code>string</code> | | |
|
| port | <code>string</code> | |
|
||||||
| [mode] | <code>number</code> \| <code>boolean</code> | <code>false</code> | The sensor mode to activate. If no mode is provided, the default for that sensor will be chosen. |
|
| [mode] | <code>number</code> | The sensor mode to activate. If no mode is provided, the default for that sensor will be chosen. |
|
||||||
|
|
||||||
<a name="Hub+unsubscribe"></a>
|
<a name="Hub+unsubscribe"></a>
|
||||||
|
|
||||||
|
12
hub.ts
12
hub.ts
@ -120,14 +120,14 @@ export class Hub extends EventEmitter {
|
|||||||
* Subscribe to sensor notifications on a given port.
|
* Subscribe to sensor notifications on a given port.
|
||||||
* @method Hub#subscribe
|
* @method Hub#subscribe
|
||||||
* @param {string} port
|
* @param {string} port
|
||||||
* @param {number|boolean} [mode=false] - The sensor mode to activate. If no mode is provided, the default for that sensor will be chosen.
|
* @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 | boolean = false, callback?: () => void) {
|
public subscribe (port: string, mode?: number) {
|
||||||
let newMode = 0x00;
|
let newMode = 0x00;
|
||||||
if (!mode) {
|
if (mode && !(typeof mode === "number")) {
|
||||||
newMode = this._getModeForDeviceType(this._ports[port].type);
|
newMode = this._getModeForDeviceType(this._ports[port].type);
|
||||||
}
|
}
|
||||||
this._activatePortDevice(this._ports[port].value, this._ports[port].type, newMode, 0x00, callback);
|
this._activatePortDevice(this._ports[port].value, this._ports[port].type, newMode, 0x00);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -135,9 +135,9 @@ export class Hub extends EventEmitter {
|
|||||||
* @method Hub#unsubscribe
|
* @method Hub#unsubscribe
|
||||||
* @param {string} port
|
* @param {string} port
|
||||||
*/
|
*/
|
||||||
public unsubscribe (port: string, callback?: () => void) {
|
public unsubscribe (port: string) {
|
||||||
const mode = this._getModeForDeviceType(this._ports[port].type);
|
const mode = this._getModeForDeviceType(this._ports[port].type);
|
||||||
this._deactivatePortDevice(this._ports[port].value, this._ports[port].type, mode, 0x00, callback);
|
this._deactivatePortDevice(this._ports[port].value, this._ports[port].type, mode, 0x00);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user