The options object passed into the startScanning function.

interface StartScanningOptions {
    android?: {
        callbackType?: CallbackType;
        legacy?: boolean;
        matchMode?: MatchMode;
        matchNum?: MatchNum;
        phy?: Phy;
        reportDelay?: number;
        scanMode?: ScanMode;
        useHardwareBatchingIfSupported?: boolean;
    };
    avoidDuplicates?: boolean;
    filters?: {
        deviceAddress?: string;
        deviceName?: string;
        manufacturerData?: ArrayBuffer;
        serviceUUID?: string;
    }[];
    onDiscovered?: ((data) => void);
    seconds?: number;
    skipPermissionCheck?: boolean;
}

Properties

android?: {
    callbackType?: CallbackType;
    legacy?: boolean;
    matchMode?: MatchMode;
    matchNum?: MatchNum;
    phy?: Phy;
    reportDelay?: number;
    scanMode?: ScanMode;
    useHardwareBatchingIfSupported?: boolean;
}

Android scanning specific options. The defaults should cover majority of use cases. Be sure to check documentation for the various values for Android Bluetooth.

Type declaration

  • Optional callbackType?: CallbackType

    *** Only available on Android 23+ *** The callback type flags for the scan. TODO: Add documentation on the valid values for callbackTypes.

  • Optional legacy?: boolean

    Set whether only legacy advertisements should be returned in scan results. Legacy advertisements include advertisements as specified by the Bluetooth core specification 4.2 and below. This is true by default for compatibility with older apps.

    Param: legacy

    true if only legacy advertisements will be returned

  • Optional matchMode?: MatchMode

    *** Only available on Android 23+ *** The match mode can be one of android.bluetooth.le.ScanSettings.MATCH_MODE_AGGRESSIVE (1) or android.bluetooth.le.ScanSettings.MATCH_MODE_STICKY (2) DEFAULT: MATCH_MODE_AGGRESSIVE (2).

  • Optional matchNum?: MatchNum

    *** Only available on Android 23+ *** The num of matches can be one of android.bluetooth.le.ScanSettings.MATCH_NUM_ONE_ADVERTISEMENT (1), android.bluetooth.le.ScanSettings.MATCH_NUM_FEW_ADVERTISEMENT (2), or android.bluetooth.le.ScanSettings.MATCH_NUM_MAX_ADVERTISEMENT (3) DEFAULT: MATCH_NUM_MAX_ADVERTISEMENT(3)

  • Optional phy?: Phy

    *** Only available on Android 23+ *** Set the Physical Layer to use during this scan. This is used only if ScanSettings.Builder#setLegacy is set to false and only on Android 0reo or newer. android.bluetooth.BluetoothAdapter#isLeCodedPhySupported may be used to check whether LE Coded phy is supported by calling android.bluetooth.BluetoothAdapter#isLeCodedPhySupported. Selecting an unsupported phy will result in failure to start scan.

    Param: phy

    Can be one of BluetoothDevice#PHY_LE_1M, BluetoothDevice#PHY_LE_CODED or ScanSettings#PHY_LE_ALL_SUPPORTED

  • Optional reportDelay?: number

    Set report delay timestamp for Bluetooth LE scan.

    Param: reportDelayMillis

    Delay of report in milliseconds. Set to 0 to be notified of results immediately. Values > 0 causes the scan results to be queued up and delivered after the requested delay or when the internal buffers fill up.

    Throws

    IllegalArgumentException If {@code reportDelayMillis} < 0.

  • Optional scanMode?: ScanMode

    *** Only available on Android 21+ *** The scan mode can be one of android.bluetooth.le.ScanSettings.SCAN_MODE_LOW_POWER (0), android.bluetooth.le.ScanSettings.SCAN_MODE_BALANCED (1) , or android.bluetooth.le.ScanSettings.SCAN_MODE_LOW_LATENCY (2). DEFAULT: SCAN_MODE_LOW_LATENCY (2)

  • Optional useHardwareBatchingIfSupported?: boolean

    Several phones may have some issues when it comes to offloaded filtering. Even if it should be supported, it may not work as expected. It has been observed for example, that setting 2 filters with different devices addresses on Nexus 6 with Lollipop gives no callbacks if one or both devices advertise. See https://code.google.com/p/android/issues/detail?id=181561.

    Param: use

    true to enable (default) hardware offload filtering. If false a compat software filtering will be used (uses much more resources).

avoidDuplicates?: boolean

Avoid duplicates with the same serviceUUID in "onDiscovered" callback. If true, only the first discovered peripheral with the same serviceUUID will be reported.

filters?: {
    deviceAddress?: string;
    deviceName?: string;
    manufacturerData?: ArrayBuffer;
    serviceUUID?: string;
}[]

Zero or more services which the peripheral needs to broadcast. Default: [], which matches any peripheral.

Type declaration

  • Optional deviceAddress?: string
  • Optional deviceName?: string
  • Optional manufacturerData?: ArrayBuffer
  • Optional serviceUUID?: string
onDiscovered?: ((data) => void)

This callback is invoked when a peripheral is found.

Type declaration

    • (data): void
    • This callback is invoked when a peripheral is found.

      Parameters

      Returns void

seconds?: number

The number of seconds to scan for services. Default: unlimited, which is not really recommended. You should stop scanning manually by calling 'stopScanning'.

skipPermissionCheck?: boolean

*** ANDROID ONLY *** Set this to true if you don't want the plugin to check (and request) the required Bluetooth permissions. Particularly useful if you're running this function on a non-UI thread (ie. a Worker).

Generated using TypeDoc