在Android设备上测量信标时,一段时间后(约3-5分钟)会发生错误。在此之后,测距不再看到信标。 它只能重启蓝牙。重启后,测距开始正常工作,检测到信标,但过一会儿,再次发生故障。 据我所知,客户端连接溢出。 我学习了logcat并确定了以下错误:
GATT_Register:无法注册GATT客户端,MAX客户端到了! CycledLeScannerForLollipop扫描失败:无法注册应用程序 BluetoothLeScanner onClientRegistered() - status = 133 clientIf = 0 mClientIf = 0
我理解状态应该是0。 我再次注意到,该工作的特性是一个服务,它在与应用程序本身分开的进程中运行。 当服务停止看到信标时,来自logcat的带有BluetoothLeScanner过滤器的字符串:
Debug 12591 BluetoothLeScanner onClientRegistered() - status=133 clientIf=0 mClientIf=0
Debug 12591 BluetoothLeScanner onClientRegistered() - status=133 clientIf=0 mClientIf=0
Debug 12591 BluetoothLeScanner onClientRegistered() - status=133 clientIf=0 mClientIf=0
Debug 12591 BluetoothLeScanner onClientRegistered() - status=133 clientIf=0 mClientIf=0
Debug 12591 BluetoothLeScanner onClientRegistered() - status=0 clientIf=32 mClientIf=0
Debug 12591 BluetoothLeScanner onClientRegistered() - status=0 clientIf=32 mClientIf=0
Debug 12591 BluetoothLeScanner onClientRegistered() - status=0 clientIf=31 mClientIf=0
Debug 12591 BluetoothLeScanner onClientRegistered() - status=0 clientIf=30 mClientIf=0
Debug 12591 BluetoothLeScanner onClientRegistered() - status=0 clientIf=29 mClientIf=0
Debug 12591 BluetoothLeScanner onClientRegistered() - status=0 clientIf=28 mClientIf=0
有可能解决给定的问题吗?谢谢!
修改 这是logcat:
Time Device Name Type PID Tag Message
02-19 18:49:45.395 AGM A8 Debug 13351 BluetoothLeScanner onClientRegistered() - status=133 clientIf=0 mClientIf=0
02-19 18:49:40.375 AGM A8 Debug 13351 BluetoothLeScanner onClientRegistered() - status=0 clientIf=32 mClientIf=0
02-19 18:49:35.333 AGM A8 Debug 13351 BluetoothLeScanner onClientRegistered() - status=0 clientIf=31 mClientIf=0
02-19 18:49:30.411 AGM A8 Debug 13351 BluetoothLeScanner onClientRegistered() - status=0 clientIf=30 mClientIf=0
02-19 18:49:25.256 AGM A8 Debug 13351 BluetoothLeScanner onClientRegistered() - status=0 clientIf=29 mClientIf=0
02-19 18:49:20.234 AGM A8 Debug 13351 BluetoothLeScanner onClientRegistered() - status=0 clientIf=28 mClientIf=0
02-19 18:49:15.185 AGM A8 Debug 13351 BluetoothLeScanner onClientRegistered() - status=0 clientIf=27 mClientIf=0
02-19 18:49:10.181 AGM A8 Debug 13351 BluetoothLeScanner onClientRegistered() - status=0 clientIf=5 mClientIf=0
02-19 18:49:05.170 AGM A8 Debug 13351 BluetoothLeScanner onClientRegistered() - status=0 clientIf=26 mClientIf=0
02-19 18:49:00.124 AGM A8 Debug 13351 BluetoothLeScanner onClientRegistered() - status=0 clientIf=26 mClientIf=0
02-19 18:48:55.108 AGM A8 Debug 13351 BluetoothLeScanner onClientRegistered() - status=0 clientIf=25 mClientIf=0
02-19 18:48:50.078 AGM A8 Debug 13351 BluetoothLeScanner onClientRegistered() - status=0 clientIf=25 mClientIf=0
02-19 18:48:45.028 AGM A8 Debug 13351 BluetoothLeScanner onClientRegistered() - status=0 clientIf=23 mClientIf=0
02-19 18:48:39.992 AGM A8 Debug 13351 BluetoothLeScanner onClientRegistered() - status=0 clientIf=24 mClientIf=0
02-19 18:48:39.316 AGM A8 Debug 3254 BluetoothLeScanner onClientRegistered() - status=0 clientIf=23 mClientIf=0
02-19 18:48:34.994 AGM A8 Debug 13351 BluetoothLeScanner onClientRegistered() - status=0 clientIf=22 mClientIf=0
02-19 18:48:29.927 AGM A8 Debug 13351 BluetoothLeScanner onClientRegistered() - status=0 clientIf=21 mClientIf=0
02-19 18:48:24.905 AGM A8 Debug 13351 BluetoothLeScanner onClientRegistered() - status=0 clientIf=20 mClientIf=0
02-19 18:48:19.866 AGM A8 Debug 13351 BluetoothLeScanner onClientRegistered() - status=0 clientIf=19 mClientIf=0
02-19 18:48:14.852 AGM A8 Debug 13351 BluetoothLeScanner onClientRegistered() - status=0 clientIf=18 mClientIf=0
02-19 18:48:09.825 AGM A8 Debug 13351 BluetoothLeScanner onClientRegistered() - status=0 clientIf=17 mClientIf=0
02-19 18:48:04.812 AGM A8 Debug 13351 BluetoothLeScanner onClientRegistered() - status=0 clientIf=16 mClientIf=0
02-19 18:47:59.768 AGM A8 Debug 13351 BluetoothLeScanner onClientRegistered() - status=0 clientIf=15 mClientIf=0
02-19 18:47:54.751 AGM A8 Debug 13351 BluetoothLeScanner onClientRegistered() - status=0 clientIf=14 mClientIf=0
02-19 18:47:49.708 AGM A8 Debug 13351 BluetoothLeScanner onClientRegistered() - status=0 clientIf=13 mClientIf=0
02-19 18:47:44.688 AGM A8 Debug 13351 BluetoothLeScanner onClientRegistered() - status=0 clientIf=12 mClientIf=0
02-19 18:47:39.676 AGM A8 Debug 13351 BluetoothLeScanner onClientRegistered() - status=0 clientIf=11 mClientIf=0
02-19 18:47:34.662 AGM A8 Debug 13351 BluetoothLeScanner onClientRegistered() - status=0 clientIf=10 mClientIf=0
02-19 18:47:29.603 AGM A8 Debug 13351 BluetoothLeScanner onClientRegistered() - status=0 clientIf=9 mClientIf=0
02-19 18:47:24.585 AGM A8 Debug 13351 BluetoothLeScanner onClientRegistered() - status=0 clientIf=8 mClientIf=0
02-19 18:47:19.552 AGM A8 Debug 13351 BluetoothLeScanner onClientRegistered() - status=0 clientIf=7 mClientIf=0
02-19 18:47:14.525 AGM A8 Debug 13351 BluetoothLeScanner onClientRegistered() - status=0 clientIf=7 mClientIf=0
答案 0 :(得分:1)
在某些Android设备型号上,蓝牙堆栈可能会进入不良状态,需要重新上电才能再次扫描蓝牙设备。为了自动修复此问题,Android Beacon Library中添加了BluetoothMedic,当检测到问题时,它会自动重启蓝牙。在撰写本文时,此更改仍处于拉取请求中,因此尚未合并到库的发布版本中。
虽然这是解决您问题的方法,但核心问题可能是手机上安装了太多蓝牙扫描应用。 Android使用蓝牙客户端同时限制应用程序的数量为32.如果您安装了多个试图使用蓝牙LE API的应用程序,您将收到此错误,并且只会出现蓝牙的电源循环(可能是自动化的)通过上面的BluetoothMedic)可以从问题中恢复。这将有效地杀死其他应用程序上蓝牙API的使用,因此您的应用程序有机会使用它们。
答案 1 :(得分:0)
只需关闭手机的蓝牙并干净运行系统,然后再次运行该应用程序。这也解决了我的问题和头痛。