Skip to content

Commit fea094f

Browse files
committed
add parameter to control BlueZ data duplication while scanning
1 parent 2eddf23 commit fea094f

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

docs/api.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,17 @@ Indicates that a device discovery procedure is active.
110110
**Kind**: instance method of [<code>Adapter</code>](#Adapter)
111111
<a name="Adapter+startDiscovery"></a>
112112

113-
### adapter.startDiscovery()
113+
### adapter.startDiscovery([duplicateData])
114114
This method starts the device discovery session.
115115

116-
**Kind**: instance method of [<code>Adapter</code>](#Adapter)
116+
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).
117+
118+
**Kind**: instance method of [<code>Adapter</code>](#Adapter)
119+
120+
| Param | Type | Default | Description |
121+
| --- | --- | --- | --- |
122+
| [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. |
123+
117124
<a name="Adapter+stopDiscovery"></a>
118125

119126
### adapter.stopDiscovery()

src/Adapter.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,22 @@ class Adapter {
7373

7474
/**
7575
* This method starts the device discovery session.
76+
* @param {boolean} duplicateData - Disables duplicate detection of
77+
* advertisement data.
78+
*
79+
* When enabled PropertiesChanged signals will be generated for either
80+
* ManufacturerData and ServiceData everytime they are discovered.
81+
*
7682
* @async
7783
*/
78-
async startDiscovery () {
84+
async startDiscovery (duplicateData = true) {
7985
if (await this.isDiscovering()) {
8086
throw new Error('Discovery already in progress')
8187
}
8288

8389
await this.helper.callMethod('SetDiscoveryFilter', {
84-
Transport: buildTypedValue('string', 'le')
90+
Transport: buildTypedValue('string', 'le'),
91+
DuplicateData: buildTypedValue('boolean', duplicateData)
8592
})
8693
await this.helper.callMethod('StartDiscovery')
8794
}

src/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ declare namespace NodeBle {
6262
getAlias(): Promise<string>;
6363
isPowered(): Promise<boolean>;
6464
isDiscovering(): Promise<boolean>;
65-
startDiscovery(): Promise<void>;
65+
startDiscovery(duplicateData?: boolean): Promise<void>;
6666
stopDiscovery(): Promise<void>;
6767
devices(): Promise<string[]>;
6868
getDevice(uuid: string): Promise<Device>;

0 commit comments

Comments
 (0)