Skip to content

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 containing UUIDs of Services which are registered in scanned Device. If null is passed, all available Devices will be scanned.
  • ScanOptions—Optional configuration for scanning operation.
    • allowDuplicates?: boolean—duplicate scanning records are received more frequently [iOS only—default false]. On Android the duplicates will be emitted.
  • listener—Function which will be called for every scanned Device (devices may be scanned multiple times). It's first argument is potential Error which is set to non null value when scanning failed. You have to start scanning process again if that happens. Second argument is a scanned Device

When the scan is no longer needed one must call:

bleManager.stopDeviceScan()

Notes