Beacons not detected when scanning regularly

Hi. I’m creating an Android app which does regular scans for beacons. I use a background service to start ranging, allow a short time (around five seconds) then stop scanning. The scan is repeated every minute or so.

It generally works fine, and although I allow five seconds, it usually picks up all four of my test beacons in the first second or two. Sometimes however, it simply won’t detect any beacons at all. This may happen once or twice randomly, and then suddenly it will detect them all again immediately.

I’m trying to work out why this is, and would appreciate any ideas. Is it the device restricting availability or the network or bluetooth? If so is there any code I can call to wake these features up? I know bluetooth is on, but for example it may be somehow put to sleep after the last scan. I’m just guessing, so any clues welcome! Thanks.

Beacons broadcast continuously, all the time, so the gaps you’re seeing are usually/probably on the receiver (here: the smartphone) side. For example, my test Huaweii P9 Lite sometimes experiences 10-15 gaps in Bluetooth scanning, for reasons unknown to me.

Yes, exactly. My feeling is it’s the bluetooth being restricted by the device - with each new version of android there seem to be more and more restrictions on what you can do in the background, and how often.

I was hoping someone else had experienced this and knew of a way to make bluetooth kick in again.

I was hoping someone else had experienced this and knew of a way to make bluetooth kick in again.

This is pretty much what we want our Android Proximity SDK (GitHub - Estimote/Android-Proximity-SDK: Estimote Proximity SDK for Android) to be. A ready-made lib which includes all of our experience/know-how, so that things “just work”. From the first post, it sounds like you’re using some other lib, have you tried the Proximity SDK yet?

e.g., We switched to a foreground service because they’re more reliable for scanning when the app is not on screen. We do RSSI processing/smoothing to mitigate signal strength fluctuations. We configure BluetoothLeScanner settings based on experiments we’ve run in our lab on different Android devices, to see which settings provide best results on what devices (it generally differs per manufacturer, and sometimes per generation). etc. etc.

Hi Poitr, apologies I’d missed this reponse and am now back on the case.

No, I hadn’t seen the Proximity SDK. What are the essential differences between this and the standard Estimote SDK I am using already?

I just want to scan at a given moment and find out what beacons are nearby, I’m not actually interested in being notified of entering or exiting a range. Is this SDK still recommended for me?