Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,17 @@ Indicates that a device discovery procedure is active.
**Kind**: instance method of [<code>Adapter</code>](#Adapter)
<a name="Adapter+startDiscovery"></a>

### adapter.startDiscovery()
### adapter.startDiscovery([duplicateData])
This method starts the device discovery session.

**Kind**: instance method of [<code>Adapter</code>](#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 [<code>Adapter</code>](#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. |

<a name="Adapter+stopDiscovery"></a>

### adapter.stopDiscovery()
Expand Down
11 changes: 9 additions & 2 deletions src/Adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
}
Expand Down
2 changes: 1 addition & 1 deletion src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ declare namespace NodeBle {
getAlias(): Promise<string>;
isPowered(): Promise<boolean>;
isDiscovering(): Promise<boolean>;
startDiscovery(): Promise<void>;
startDiscovery(duplicateData?: boolean): Promise<void>;
stopDiscovery(): Promise<void>;
devices(): Promise<string[]>;
getDevice(uuid: string): Promise<Device>;
Expand Down