Android Ble disable delay time

I wrote code to connect my Android phone to the device. When I turn off the device, my phone takes a few seconds (2-20 seconds) to notify me that it has lost connection with the device. Is there a way in which I can be notified immediately? can i change the connection control timeout?

+4
source share
1 answer

When the Ble device sends disconnects cmd, it is waiting for confirmation from the Android application. If an ACK is received, it will shut down immediately if it does not wait for the monitoring timeout to complete. Usually, when connecting to an Android application, the device (peripheral device) must adhere to the application settings (central) connection (connection interval, timeout, timeout control). Control timeout in Android is hard-coded up to 20 seconds, which is why we get a delay of 20 seconds. When disconnecting ( Referrence ) To solve this problem, I sent a request to update the connection settings from the BLE device 5 seconds after the connection, updating the monitoring wait time to 1 second. I tested several Android devices and found that delayed shutdowns were resolved.

0

Source: https://habr.com/ru/post/1613381/


All Articles