-
Notifications
You must be signed in to change notification settings - Fork 516
Bluetooth Scanning
Dariusz Seweryn edited this page Feb 2, 2018
·
3 revisions
react-native-ble-plx
supports scanning of BLE peripherals.
To perform a scan one must use:
bleManager.startDeviceScan(
UUIDs: ?Array<UUID>,
options: ?ScanOptions,
listener: (error: ?Error, scannedDevice: ?Device) => void
)
-
UUIDs
—Array of strings containingUUID
s ofService
s which are registered in scannedDevice
. Ifnull
is passed, all availableDevice
s will be scanned. -
ScanOptions
—Optional configuration for scanning operation.-
allowDuplicates?: boolean
—duplicate scanning records are received more frequently [iOS only—defaultfalse
]. On Android the duplicates will be emitted.
-
-
listener
—Function which will be called for every scannedDevice
(devices may be scanned multiple times). It's first argument is potentialError
which is set to nonnull
value when scanning failed. You have to start scanning process again if that happens. Second argument is a scannedDevice
When the scan is no longer needed one must call:
bleManager.stopDeviceScan()
- iOS:
- Background scanning—one must provide a non-empty
UUIDs
array and be aware of how the app behaviour will change.
- Background scanning—one must provide a non-empty
- Android:
- Background scanning—the OS may kill the application on arbitrary moment once in the background. There are native ways of waking/keeping the app
- Performing other BLE actions while scan is active may cause problems on some devices.