Skip to content

Commit 13479da

Browse files
author
dbaba
committed
Set Powered property on and duplicate filter prior to sarting BLE scanning
1 parent 9b070f1 commit 13479da

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/noble/lib/bluez/bindings.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,23 @@ class BluezBindings extends EventEmitter {
8989
if (this._scanning) {
9090
debug(`[startScanning] Scan already ongoing...`);
9191
} else {
92-
debug(`[startScanning] Start Scanning...`);
9392
try {
93+
const powered = (
94+
await this.hciProps.Get('org.bluez.Adapter1', 'Powered')
95+
).value;
96+
if (!powered) {
97+
debug(`[startScanning] Turning the adapter on...`);
98+
await this.hciProps.Set(
99+
'org.bluez.Adapter1',
100+
'Powered',
101+
new dbus.Variant('b', true)
102+
);
103+
}
104+
debug(`[startScanning] Setting discovery filter...`);
105+
await this.hciAdapter.SetDiscoveryFilter({
106+
DuplicateData: new dbus.Variant('b', !this._scanFilterDuplicates),
107+
});
108+
debug(`[startScanning] Start Scanning...`);
94109
await this.hciAdapter.StartDiscovery();
95110
} catch (err) {
96111
debug(

0 commit comments

Comments
 (0)