android- ble device status shows connected for some seconds even after turning off the device

匆匆过客 提交于 2019-12-12 20:08:53

问题


I m developing a ble app that goes out of range many times or turns off, it is designed to do so.

if connected to android if i turn off my Bluetooth low energy (smart) device the Bluetooth manager still keeps that profile for some time and then removes it after calling the onClientConnectionState() method.

Even the device is visible in the list i get from getConnectedDevices(int). how can i invoke the method device removal from the android device


回答1:


There are two parameters used in ble that describes when to mark a connection as lost:

connection intervall: intervall to communicate at (on other 'ticks' the device 'sleeps') (between 7.5ms - 4s)

connection slave latency: thats the number on how many communications can be omitted without marking the connection lost (between 0-499). After this treshhold is exceeded the connection is marked as lost.

As it is not officially documented how these parameters are set in android you will not know if this is the gap you saw between turning your periheral off and getting the event that it is actually disconnected. Could be between ~7.5ms and ~2000s....

You only can use the notification in onClientConnectionState() to monitor out-of-range devices.



来源:https://stackoverflow.com/questions/26434202/android-ble-device-status-shows-connected-for-some-seconds-even-after-turning-o

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!