小编Ale*_*uki的帖子

连接关闭和应用程序终止后,BLE堆栈会重复连接到外围设备

我有一个应用程序打开与BLE设备的短暂连接,执行一些特性读取和写入,然后断开连接并关闭连接.该应用使用autoReconnect = false,设备未配对或绑定.

我看到Android的一些非常奇怪的行为,即使在连接关闭()d,应用程序被杀或甚至卸载后,它似乎反复且意外地重新连接到外围设备.

此问题之前已与Spotify触发重新连接相关联(请参阅:Android BLE意外重复连接到外围设备),但在我的情况下,即使没有安装Spotify也会发生这种情况.

可以可靠地再现的设备是:

  • Google Pixel,Android 8.1
  • LG Nexus 5X,Android 7.1.2
  • 三星Galaxy S7,Android 7.0
  • 三星Galaxy S6,Andorid 6.0

连接是短暂的,持续约3秒.我可以验证是否建立了连接,因为外围设备提供了其连接的可视指示和日志输出.

我很难理解可能导致重复重新连接的原因,因为BLE堆栈的logcat没有给出关于谁或什么原因导致连接的提示.运行7.1.2的Nexus 5X上的一个连接/断开循环的蓝牙服务(com.android.bluetooth)的logcat输出如下所示:

05-15 10:36:55.428  6397  7029 W bt_smp  : smp_br_connect_callback is called on unexpected transport 2
05-15 10:36:55.428  6397  7029 W bt_btif : bta_dm_acl_change info: 0x0
05-15 10:36:55.428  6397  7029 E bt_btif : bta_gattc_cache_load: can't open GATT cache file /data/misc/bluetooth/gatt_cache_c4be844851e9 for reading, error: No such file or directory
05-15 10:36:55.428  6397  6526 D bt_btif_dm: remote …
Run Code Online (Sandbox Code Playgroud)

android bluetooth bluetooth-lowenergy

11
推荐指数
0
解决办法
524
查看次数

标签 统计

android ×1

bluetooth ×1

bluetooth-lowenergy ×1