我们正在尝试与外围设备断开连接,但是使用蓝牙嗅探器时,我们没有看到LL_TERMINATE_IND
数据包。相反,电话似乎会继续向外围设备发送Empty PDU
大约20秒钟。
我们正在使用以下Cordova BLE插件:https://github.com/don/cordova-plugin-ble-central
断开方法在这里:https://github.com/don/cordova-plugin-ble-central#/L74
我们还尝试过在gatt.disconnect()
之前添加一个显式的gatt.close()
,如下所示,但似乎没有任何区别:
public void disconnect() {
connectCallback = null;
connected = false;
if (gatt != null) {
gatt.disconnect();
gatt.close();
gatt = null;
}
}
这里是相关的adb
日志。 adb日志“找不到上下文”中存在错误,可能与之相关?尽管那似乎只是after onDisconnected()。
04-15 16:25:34.931 24199 24199 I chromium: [INFO:CONSOLE(79263)] "ble:store > Handle dispatch DOOR_DISCONNECT", source: file:///android_asset/www/js/bundle.js (79263)
04-15 16:25:34.931 24199 24199 I chromium: [INFO:CONSOLE(79263)] "ble:connecting > § 20", source: file:///android_asset/www/js/bundle.js (79263)
04-15 16:25:34.932 24199 24274 D BluetoothGatt: close()
04-15 16:25:34.932 24199 24274 D BluetoothGatt: unregisterApp() - mClientIf=5
04-15 16:25:34.933 1886 9721 D BtGatt.GattService: unregisterClient() - clientIf=5
04-15 16:25:34.934 1886 2019 W bt_btif : bta_gattc_conn_cback() - cif=3 connected=0 conn_id=3 reason=0x0016
04-15 16:25:34.934 1886 2019 W bt_btif : bta_gattc_conn_cback() - cif=4 connected=0 conn_id=4 reason=0x0016
04-15 16:25:34.934 1886 2019 W bt_btif : bta_gattc_conn_cback() - cif=5 connected=0 conn_id=5 reason=0x0016
04-15 16:25:34.944 1886 1924 D BtGatt.GattService: onDisconnected() - clientIf=5, connId=5, address=00:A0:00:00:00:14
04-15 16:25:34.944 1886 1924 E BtGatt.ContextMap: Context not found for ID 5
04-15 16:25:34.948 24199 24199 I chromium: [INFO:CONSOLE(79270)] "ble:connecting > _disconnectFromDoor success", source: file:///android_asset/www/js/bundle.js (79270)
04-15 16:25:34.952 24199 24199 I chromium: [INFO:CONSOLE(79263)] "ble:store > Handle dispatch DOOR_DISCONNECT_SUCCESS", source: file:///android_asset/www/js/bundle.js (79263)
这是蓝牙嗅探的样子(有很多相同的地方:):
此时外设可能已经进入睡眠状态(这样做是为了延长电池寿命)。这对我来说很有意义,为什么电话只继续发送Empty PDU
,但我们是否不应该仍然通过电波看到断开请求?
您找到根了吗?我也遇到这个问题。