BLE Scanning: callback gets invoked only once on “Huawei Ascend Mate2 Phone”

对着背影说爱祢 提交于 2020-01-06 15:46:45

问题


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


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



来源:https://stackoverflow.com/questions/37802788/ble-scanning-callback-gets-invoked-only-once-on-huawei-ascend-mate2-phone

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