diff --git a/docs/api.md b/docs/api.md index 3cac351..c8e250e 100644 --- a/docs/api.md +++ b/docs/api.md @@ -110,10 +110,17 @@ Indicates that a device discovery procedure is active. **Kind**: instance method of [Adapter](#Adapter) -### adapter.startDiscovery() +### adapter.startDiscovery([duplicateData]) This method starts the device discovery session. -**Kind**: instance method of [Adapter](#Adapter) +The `duplicateData` parameter can be used to control [BlueZ duplicate detection](https://web.git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc/org.bluez.Adapter.rst). + +**Kind**: instance method of [Adapter](#Adapter) + +| Param | Type | Default | Description | +| --- | --- | --- | --- | +| [duplicateData] | `boolean` | `true` | Disables duplicate detection of advertisement data. When enabled PropertiesChanged signals will be generated for either ManufacturerData and ServiceData everytime they are discovered. | + ### adapter.stopDiscovery() diff --git a/src/Adapter.js b/src/Adapter.js index 3cc8fe8..944c44f 100644 --- a/src/Adapter.js +++ b/src/Adapter.js @@ -73,15 +73,22 @@ class Adapter { /** * This method starts the device discovery session. + * @param {boolean} duplicateData - Disables duplicate detection of + * advertisement data. + * + * When enabled PropertiesChanged signals will be generated for either + * ManufacturerData and ServiceData everytime they are discovered. + * * @async */ - async startDiscovery () { + async startDiscovery (duplicateData = true) { if (await this.isDiscovering()) { throw new Error('Discovery already in progress') } await this.helper.callMethod('SetDiscoveryFilter', { - Transport: buildTypedValue('string', 'le') + Transport: buildTypedValue('string', 'le'), + DuplicateData: buildTypedValue('boolean', duplicateData) }) await this.helper.callMethod('StartDiscovery') } diff --git a/src/index.d.ts b/src/index.d.ts index c6fcf0f..086ae37 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -62,7 +62,7 @@ declare namespace NodeBle { getAlias(): Promise; isPowered(): Promise; isDiscovering(): Promise; - startDiscovery(): Promise; + startDiscovery(duplicateData?: boolean): Promise; stopDiscovery(): Promise; devices(): Promise; getDevice(uuid: string): Promise;