diff --git a/DOCS.md b/DOCS.md index 3dc42c4..9aa5d38 100644 --- a/DOCS.md +++ b/DOCS.md @@ -19,7 +19,7 @@ * [LPF2](#LPF2) ⇐ EventEmitter * [.scan()](#LPF2+scan) - * [.scan()](#LPF2+scan) + * [.stop()](#LPF2+stop) * [.getConnectedDeviceByUUID(uuid)](#LPF2+getConnectedDeviceByUUID) ⇒ [Hub](#Hub) \| null * [.getConnectedDevices()](#LPF2+getConnectedDevices) ⇒ [Array.<Hub>](#Hub) * ["discover" (hub)](#LPF2+event_discover) @@ -30,9 +30,9 @@ Begin scanning for LPF2 Hub devices. **Kind**: instance method of [LPF2](#LPF2) - + -### lpF2.scan() +### lpF2.stop() Stop scanning for LPF2 Hub devices. **Kind**: instance method of [LPF2](#LPF2) @@ -145,10 +145,10 @@ Subscribe to sensor notifications on a given port. **Kind**: instance method of [BoostHub](#BoostHub) -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| port | string | | | -| [mode] | number \| boolean | false | The sensor mode to activate. If no mode is provided, the default for that sensor will be chosen. | +| 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. | @@ -302,10 +302,10 @@ Subscribe to sensor notifications on a given port. **Kind**: instance method of [WeDo2Hub](#WeDo2Hub) -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| port | string | | | -| [mode] | number \| boolean | false | The sensor mode to activate. If no mode is provided, the default for that sensor will be chosen. | +| 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. | @@ -411,10 +411,10 @@ Subscribe to sensor notifications on a given port. **Kind**: instance method of [Hub](#Hub) -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| port | string | | | -| [mode] | number \| boolean | false | The sensor mode to activate. If no mode is provided, the default for that sensor will be chosen. | +| 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. | diff --git a/README.md b/README.md index ca709b6..2527f49 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ Examples are available in the "examples" directory. * [LPF2](#LPF2) ⇐ EventEmitter * [.scan()](#LPF2+scan) - * [.scan()](#LPF2+scan) + * [.stop()](#LPF2+stop) * [.getConnectedDeviceByUUID(uuid)](#LPF2+getConnectedDeviceByUUID) ⇒ [Hub](#Hub) \| null * [.getConnectedDevices()](#LPF2+getConnectedDevices) ⇒ [Array.<Hub>](#Hub) * ["discover" (hub)](#LPF2+event_discover) @@ -70,9 +70,9 @@ Examples are available in the "examples" directory. Begin scanning for LPF2 Hub devices. **Kind**: instance method of [LPF2](#LPF2) - + -### lpF2.scan() +### lpF2.stop() Stop scanning for LPF2 Hub devices. **Kind**: instance method of [LPF2](#LPF2) @@ -185,10 +185,10 @@ Subscribe to sensor notifications on a given port. **Kind**: instance method of [BoostHub](#BoostHub) -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| port | string | | | -| [mode] | number \| boolean | false | The sensor mode to activate. If no mode is provided, the default for that sensor will be chosen. | +| 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. | @@ -342,10 +342,10 @@ Subscribe to sensor notifications on a given port. **Kind**: instance method of [WeDo2Hub](#WeDo2Hub) -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| port | string | | | -| [mode] | number \| boolean | false | The sensor mode to activate. If no mode is provided, the default for that sensor will be chosen. | +| 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. | @@ -451,10 +451,10 @@ Subscribe to sensor notifications on a given port. **Kind**: instance method of [Hub](#Hub) -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| port | string | | | -| [mode] | number \| boolean | false | The sensor mode to activate. If no mode is provided, the default for that sensor will be chosen. | +| 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. | diff --git a/hub.ts b/hub.ts index 1b42502..d46d966 100644 --- a/hub.ts +++ b/hub.ts @@ -120,14 +120,14 @@ export class Hub extends EventEmitter { * Subscribe to sensor notifications on a given port. * @method Hub#subscribe * @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; - if (!mode) { + if (mode && !(typeof mode === "number")) { 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 * @param {string} port */ - public unsubscribe (port: string, callback?: () => void) { + public unsubscribe (port: string) { 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); } diff --git a/lpf2.ts b/lpf2.ts index d2501f8..1184563 100644 --- a/lpf2.ts +++ b/lpf2.ts @@ -101,7 +101,7 @@ export class LPF2 extends EventEmitter { /** * Stop scanning for LPF2 Hub devices. - * @method LPF2#scan + * @method LPF2#stop */ public stop () { wantScan = false;