本文介绍了BLE扫描:回调仅在"Huawei Ascend Mate2 Phone"上被调用一次.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个正常工作的BLE扫描应用程序,在Nexus 5上(在4.4至6.0的各种API版本上),最近几个月一直运行良好.今天,我们在具有API 22的不同设备"Huawei Ascend Mate2"上运行了该应用程序,发现我认为是有趣或奇怪的行为:回调被连续触发(大约三次),但仅在一个回调中检测到我的iBeacon,在剩余的回调中,它会选择房屋中的其他设备(例如netgear路由器和roku等;我不知道此netgear和rouku是否甚至是BLE设备).我的BLE扫描代码与此处所述的代码非常相似 http://www.truiton.com/2015/04/android-bluetooth-low-energy-ble-example/

此线程 Android 4.4 BLE扫描缺乏稳定性表明BLE扫描是在5.0及更高版本上稳定,但在我的情况下,这是不正确的,因为我使用的是API 22

此线程在不同手机型号上进行Android BLE信标扫描表示我们需要每1.5秒打开和关闭一次扫描,这在我们的用例中不切实际,因为我们的应用每天应该运行10个小时(我们认为启动/停止系统资源是一项昂贵的操作)

我很困惑为什么在Nexus 5(在4.4和6.0 Android API上都经过测试)的连续回调中检测到相同的信标;但是在"Huawei Ascend Mate2"上运行时,尽管回调被连续调用,但同一iBeacon仅被检测到一次,而在后续回调中检测到其他非BLE设备.

这是我第一次在Nexus之外进行测试.有没有人在"Huawei Ascend Mate2"上测试过BLE扫描?任何意见和评论将不胜感激.

华为Ascend Mate2":设备型号为MT2L03,Android版本为5.1

解决方案

我在很多不同的设备上工作,我可以告诉你,不同设备上的行为有很大不同.我没有Huawei Mate2,但是我可以观察到类似的行为,即每个设备只能获得一次扫描结果.因此,如果您需要为同一设备获得多个扫描结果,则需要不时重新启动扫描.我认为1.5s太多了,但这取决于您的用例.

I have a working BLE scanning app that has been working fine for last few months on Nexus 5 (on various API versions from 4.4 to 6.0 ). Today we ran the app on different device "Huawei Ascend Mate2" that has API 22 and found what I thought was an interesting or peculiar behavior: callback gets fired continuously (about thrice a second), but my iBeacon is detected in only one callback and in remaining callbacks it picks other devices in the house (like netgear router and roku etc; I donot know if this netgear and rouku are even BLE devices).My BLE scanning code is very similar to the one described here http://www.truiton.com/2015/04/android-bluetooth-low-energy-ble-example/

This thread Android 4.4 BLE Scanning lack of stability suggests that BLE scanning is stable on 5.0+, but in my case that is not true because I am on API 22

This thread Android BLE Beacon scanning on different phone models suggests that we need to turn on and turnoff the scanning every 1.5 seconds and that is not practical in our use case because our app should run for 10 hours every day (we think starting/stopping of system resource is expensive operation)

I am puzzled on why the same beacon is getting detected in continuous callbacks on Nexus 5 (tested on both 4.4 and 6.0 Android APIs); but when running on "Huawei Ascend Mate2", though callback is continuously invoked, the same iBeacon is detected only once while other non BLE devices are detected in subsequent callbacks.

This is the first time I tested outside Nexus. Did anyone test BLE scanning on "Huawei Ascend Mate2"? Any observations and comments would be appreciated.

"Huawei Ascend Mate2": Device model number is MT2L03 and Android version is 5.1

解决方案

I worked with a lot of different devices and I can tell you, that the behaviour is very different on different devices. I don't have an Huawei Mate2, but I could observe similar behaviour, where you only get a scan result once per device. So if you need to have multiple scan result for the same device you need to restart the scan from time to time. I think 1.5s is a bit too much, but this depends on your use case.

这篇关于BLE扫描:回调仅在"Huawei Ascend Mate2 Phone"上被调用一次.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-16 14:33