且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

即使关闭设备,Android设备的状态也会显示已连接几秒钟

更新时间:2022-12-01 20:51:23

ble中使用了两个参数来描述何时将连接标记为丢失:

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

连接intervall :间隔(在7.5ms-4s之间)(在其他滴答声"中,设备睡眠")进行通信

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

连接从设备等待时间:即在不标记连接丢失的情况下可以省略多少个通信的数字(介于0-499之间).超过此限制后,连接将标记为丢失.

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.

由于尚未正式记录如何在android中设置这些参数,因此您将不知道这是否是关闭周围神经鞘与实际断开连接之间的间隙.可能在〜7.5ms到〜2000s之间....

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....

您只能使用onClientConnectionState()中的通知来监视超出范围的设备.

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