flutterbluetooth-lowenergyibeacon

Why I am unable to scan iBeacon with UUID provided inside services using flutter_reactive_ble in my flutter project?


I am using https://pub.dev/packages/flutter_reactive_ble inside my flutter project. But I am unable to scan ibeacon if I provide UUID inside services, I think I am missing something.

On the other hand, it's working fine if the empty array is provided inside with services.

here's my piece of code :

 _subscription = await FlutterReactiveBle().scanForDevices(
        withServices: [Uuid.parse('11111111-1111-1111-1111-111111111111')],
        // withServices: [],//working fine with empty array
        scanMode: ScanMode.lowLatency,
        requireLocationServicesEnabled:
            true).listen(onDeviceFound, onError: onError);

Here's the simulator screenshot:

enter image description here

any help would be appreciated, thanks !


Solution

  • The problem is that the Flutter package you are using is not scanning for beacon advertisements (iBeacon, AltBeacon) but for BLE Service UUID advertisements. Note the withServices in this line of code:

    FlutterReactiveBle().scanForDevices(
            withServices: [Uuid.parse('11111111-1111-1111-1111-111111111111')],
    

    This means you are telling the library to scan for advertised BLE Services with the given Service UUIDs. These are completely different kinds of BLE advertisements than BLE Beacon advertisements. Unfortunately, the package you are using won't do what you want.

    You might try Flutter Beacon.