我的 Android 应用程序在中央设备连接到外围设备时运行,启用通知并且外围设备开始发送。
我的问题是连接在大约 13 秒后终止。
下面我有logcat信息。
Android 中蓝牙 LE 的状态 59 是什么?
BluetoothGatt: connect() - device: C5:7F:B0:8E:AA:91, auto: false
BluetoothGatt: registerApp()
BluetoothGatt: registerApp() - UUID=3a9c080d-ae20-47ea-b34c-7ea7798204cc
BluetoothGatt: onClientRegistered() - status=0 clientIf=5
BluetoothGatt: onClientConnectionState() - status=0 clientIf=5 device=C5:7F:B0:8E:AA:91
BluetoothGatt: discoverServices() - device: C5:7F:B0:8E:AA:91
BluetoothGatt: onSearchComplete() = Device=C5:7F:B0:8E:AA:91 Status=0
BluetoothGatt: setCharacteristicNotification() - uuid: 00002a05-0000-1000-8000-00805f9b34fb enable: true
BluetoothGatt: setCharacteristicNotification() - uuid: 00001625-1212-efde-1523-785feabcd123 enable: true
BluetoothGatt: cancelOpen() - device: C5:7F:B0:8E:AA:91
BluetoothGatt: onClientConnectionState() - status=59 clientIf=5 device=C5:7F:B0:8E:AA:91
BluetoothGatt: close()
BluetoothGatt: unregisterApp() - mClientIf=5
最佳答案
我也遇到过同样的问题。经过一番挖掘,我发现我们的案例状态代码 59(或十六进制 0x3B)指向 HCI_ERR_UNACCEPT_CONN_INTERVAL
。
通过检查手机中的蓝牙 HCI 监听日志,我发现 ble 设备正在与手机协商连接参数。设备请求 7.5 毫秒的连接间隔,但手机拒绝了此请求。三次(15ms)后设备断开连接并重置。
我找到了this post据说Android 6.0中的最小连接间隔已更改为12.5ms。因此,如果您调整设备请求的连接间隔,您可能会保持连接。
关于Android 蓝牙低功耗状态 = 59,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35892288/