使用 Flutter Blue 连接到 BLE 设备时出现问题

hei*_*ter 7 android bluetooth-lowenergy flutter

我是 Flutter 新手,想测试 Flutter Blue 提供的一些 BLE 功能。我已经启动并运行了示例应用程序,它发现我周围有很多设备。问题是我无法连接到其中任何一个。我目前正在使用第二部手机来模拟 BLE 外设,所有其他软件(例如 nRF Connect for Mobile)都能够连接到外设并读取其提供的数据。Flutter Blue 示例应用程序在尝试连接到设备时卡在断开连接状态。

以下是尝试连接时的典型控制台输出:

D/BluetoothGatt( 6359): connect() - device: 73:B9:9F:25:67:DC, auto: true
D/BluetoothGatt( 6359): registerApp()
D/BluetoothGatt( 6359): registerApp() - UUID=44fdc1ff-3804-4ae2-ab52-3f3b6eb31e17
D/BluetoothGatt( 6359): onClientRegistered() - status=0 clientIf=7
D/BluetoothGatt( 6359): onAutoConnectionStatusCb()status =10
D/BluetoothGatt( 6359): close()
Run Code Online (Sandbox Code Playgroud)

我已经成功地连接到模拟外围设备几次,首先通过不同的应用程序连接,然后与 Flutter 应用程序“连接”。这是输出:

D/BluetoothGatt( 6359): connect() - device: 73:B9:9F:25:67:DC, auto: true
D/BluetoothGatt( 6359): registerApp()
D/BluetoothGatt( 6359): registerApp() - UUID=201eaf3d-ab8a-402e-9cbf-232527fa53a8
D/BluetoothGatt( 6359): onClientRegistered() - status=0 clientIf=8
D/BluetoothGatt( 6359): onAutoConnectionStatusCb()status =10
D/BluetoothGatt( 6359): onClientConnectionState() - status=0 clientIf=8 device=73:B9:9F:25:67:DC
D/FlutterBluePlugin( 6359): [onConnectionStateChange] status: 0 newState: 2
D/BluetoothGatt( 6359): discoverServices() - device: 73:B9:9F:25:67:DC
I/flutter ( 6359): connected!
D/BluetoothGatt( 6359): onSearchComplete() = Device=73:B9:9F:25:67:DC Status=0
D/FlutterBluePlugin( 6359): [onServicesDiscovered] count: 3 status: 0
Run Code Online (Sandbox Code Playgroud)

我已阅读有关退出其他应用程序后连接未正确关闭的信息,并且我已确保打开/关闭蓝牙和位置服务以及卸载可能干扰 Flutter 应用程序的其他应用程序。我尝试过允许更长的连接超时时间,以确保应用程序在能够实际连接之前不会关闭连接,除此之外,我有点迷失,无法完全弄清楚可能会发生什么是错的。

编辑:只是想补充一点,这似乎是与模拟 BLE 外设相关的问题。从那时起,我就能够毫无问题地使其与 AT-09 模块和 ESP32 板一起使用!