Android: Catching BLE Connection Fails/Disconnects?

后端 未结 3 754
旧巷少年郎
旧巷少年郎 2021-02-06 09:17

So I\'m able to connect to a BLE device just fine under normal circumstances. What I want to do is handle abnormal circumstances, like when the connection to a device fails or a

3条回答
  •  你的背包
    2021-02-06 09:58

    I think what you are looking for is Bluetooth Supervision timeout which is according to Bluetooth LE specifications :

    a parameter that defines the maximum time between two received Data Packet PDUs before the connection is considered lost

    Default Supervision timeoout is set to 20 seconds on Android (depending on Android version & device). For instance, here is the value of Supervision Timeout on Android 5.1.

    There is no API to set this parameter, so you will have to wait 20 seconds (depending on your Android version & device) to get onConnectionStateChange callback with status BluetoothGatt.STATE_DISCONNECTED after you power off your BLE module

提交回复
热议问题