react-native-ble-plx icon indicating copy to clipboard operation
react-native-ble-plx copied to clipboard

Android devices filter out peripheral if it contains unique UUID and manufacturer's data

Open budget-coder opened this issue 4 years ago • 0 comments

Expected Behavior

We have set up a unique UUID in a peripheral such that we can use manager.startDeviceScan(uuids, options) to only scan peripherals whose advertisement data contains this UUID. This works on both iOS and Android. Now, we update the peripheral's firmware to also broadcast manufacturer's data with type 0xFF. We once again expect both platforms to scan the same peripheral.

Current Behavior

Upon adding manufacturer's data, only iOS devices scan our peripheral. Android devices seem to stop scanning it.

Steps to Reproduce

  1. Customize a peripheral advertisement data to contain a 128-bit UUID and manufacturer data.
  2. Use the manager.startDeviceScan(uuids, options) with a one-element list containing the UUID.
  3. Scan for ~20 seconds on an Android 8 or 10 and on an iOS 13 or 14 device.

Context

Currently, I don't have JS nor platform logs. If need be, I'll set the log level and use adb logcat to get some logs.

Passing null to the method causes both devices to scan all BLE devices, including our peripheral. This is our workaround, but it's by no means efficient in performance and power consumption.

  • Library version: 2.0.1 and 2.0.2
  • Platform:
    • Nokia 7.1, Android 10
    • Samsung Galaxy S, Android 8
    • iPhone 8, iOS 13/14.
  • Platform logs (logcat/XCode):

While not a log, here's a snippet from nRF Connect running on an Android device. The part underlined with red is the manufacturer data. The field above it, "Incomplete List (...)" has the correct UUID.

billede

  • JS logs:
  • Contents of the package.json file:
{
  "dependencies": {
    "react-native": "0.63.3",
    "react-native-ble-plx": "2.0.2"
  }
}
  • Formatted code sample or link to a repository:
import { BleError, BleManager, Device, ScanMode, ScanOptions,  } from 'react-native-ble-plx'

const manager = new BleManager();
const uuids = ["xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"];

const initScan = () => {
  const options: ScanOptions = {
    allowDuplicates: false,
    scanMode: ScanMode.LowLatency
  }

  manager.startDeviceScan(
	uuids,
	options,
	async (error: BleError | null, scannedDevice: Device | null) => {
		if (error || !scannedDevice) {
			// Error handling omitted
			return;
		}

		if (scannedDevice && scannedDevice.serviceUUIDs) {
			// Device handling omitted
		}
	}
  );
}

initScan();

budget-coder avatar Apr 18 '21 12:04 budget-coder