flutter_reactive_ble扫描的设备不包括设备UUID

6tqwzwtp  于 2023-02-09  发布在  Flutter
关注(0)|答案(1)|浏览(184)
_scanStream = flutterReactiveBle
          .scanForDevices(withServices: <Uuid>[]).listen((device) {
        _foundBleUARTDevices.add(device);
        for (var element in _foundBleUARTDevices) {
          print(
              "${element.serviceUuids}---${element.name}---${element.id}---${element.serviceData}---${element.rssi}");
        }

我使用上述代码片段扫描BLE设备,发现并打印这些设备时,UUID是空列表,当我尝试使用特定UUID扫描时,未找到任何设备。我使用ESP 32作为BLE设备,使用Android作为运行/调试应用程序的平台

bvjxkvbb

bvjxkvbb1#

在等待了几个小时后,我没有得到任何人的回答,我不得不继续尝试,我发现我实际上可以连接到BLE设备,没有服务UUID,而只是ID,我认为这是BLE设备的Mac地址。
我使用下面的代码片段来建立连接:

void _connectToDevice() {
    // We're done scanning, we can cancel it
    // _scanStream.cancel();
    // Let's listen to our connection so we can make updates on a state change
    Stream<ConnectionStateUpdate> _currentConnectionStream = flutterReactiveBle
        .connectToAdvertisingDevice(
            id: _ubiqueDevice.id,
            prescanDuration: const Duration(seconds: 3),
            withServices: <Uuid>[]);
    _currentConnectionStream.listen((event) {
      print(":::::::: ${event.connectionState.name}");
    });
  }

so I will now proceed to see how I can read and write to the characteristics, i hope someone find this helpful

相关问题