Android蓝牙低功耗断开请求未发送?

时间:2016-04-15 15:38:52

标签: android cordova bluetooth

我们试图断开外设,但使用蓝牙嗅探器,我们没有看到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日志“找不到上下文”中有一个错误可能与此有关?虽然在 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)

这就是蓝牙嗅探的样子(还有更多相同的东西):

Bluetooth sniffer output in Wireshark

此外围设备有可能在此时进入睡眠状态(这是出于电池寿命目的)。这对我来说有意义,为什么手机只是一直发送Empty PDU,但是我们不应该通过无线电波看到断开请求吗?

0 个答案:

没有答案