don / cordova-plugin-ble-central

Bluetooth Low Energy (BLE) Central plugin for Apache Cordova (aka PhoneGap)
Apache License 2.0
944 stars 609 forks source link

Add duration flag (in seconds) to scan with options #967

Closed peitschie closed 1 year ago

peitschie commented 1 year ago

This allows different scan modes to be easily selected while still allowing the scan to be time-limited

mikerusso-tsi commented 1 year ago

Looks like you're cutting off the 'scan' function, which will force all consumers of that to switch. Do you normally want a deprecation period to ease people over? I.e., change 'scan' to internally call 'startScanWithOptions'.

Also, will this be available in the 'slim' variant?

BTW, here is my code to replace the 'scan' call. I believe I am seeing the same scan performance with it as before the API change you indicated! let options = { scanMode: 'lowLatency', duration: timeout }; ble.startScanWithOptions(services, options, success, failure); where timeout is a number in seconds.

peitschie commented 1 year ago

Bothscan and startScan remain fully supported. If you pay close attention to ble.js, you'll see that I've routed these to the equivalent scanWithOptions call instead, as all the native paths trace through the same code.

mikerusso-tsi commented 1 year ago

Bothscan and startScan remain fully supported. If you pay close attention to ble.js, you'll see that I've routed these to the equivalent scanWithOptions call instead, as all the native paths trace through the same code.

Ah, that's what I was expecting! Sorry. But is the @slim variant included in this PR? I'm hoping so!

peitschie commented 1 year ago

Slim runs on a different branch. I'll publish both at the same time once I merge this 🙂