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

huangapple go评论62阅读模式
英文:

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

问题

我正在使用 https://pub.dev/packages/flutter_reactive_ble 在我的 Flutter 项目中。但是,如果我在服务中提供 UUID,我无法扫描 iBeacon,我认为我漏掉了什么。

另一方面,如果在服务中提供空数组,它可以正常工作。

这是我的一部分代码:

_subscription = await FlutterReactiveBle().scanForDevices(
        withServices: [Uuid.parse('11111111-1111-1111-1111-111111111111')],
        // withServices: [],//使用空数组正常工作
        scanMode: ScanMode.lowLatency,
        requireLocationServicesEnabled:
            true).listen(onDeviceFound, onError: onError);

这是模拟器截图:

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:

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

any help would be appreciated, thanks !

答案1

得分: 1

问题在于您正在使用的Flutter包没有扫描信标广告(iBeacon、AltBeacon),而是扫描BLE服务UUID广告。请注意以下代码中的withServices

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

这意味着您正在告诉库扫描具有指定服务UUID的广告BLE服务。这些与BLE信标广告完全不同。遗憾的是,您正在使用的包不会满足您的需求。

您可以尝试使用Flutter Beacon

英文:

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.

huangapple
  • 本文由 发表于 2023年6月1日 00:56:51
  • 转载请务必保留本文链接:https://go.coder-hub.com/76375788.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定