Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k views
in Technique[技术] by (71.8m points)

bluetooth lowenergy - Android: Why is BluetoothLeScanner sometimes not discovering any BLE device?

I'm using BluetoothLeScanner to scan for BLE devices, which I start using:

startScan(null, settings.getScanSettings(), scanCallback);

Every once in a while, a call to startScan() does not discover any BLE device, even though some devices are actually advertizing (They are discovered using nRF Connect app).

When this happens, the next call to stopScan() and startScan() does discover devices.

I know that since Android 7, the number of start and stop scans is restricted to 5 times in a window of 30 seconds. However, I've noticed the problem occurs also if no stopScan()/startScan() has not been called for more than 30 secs.

Has anyone experienced such issue ? Could it be something else my app is doing while starting the scanner that could the scanning to fail ?

I have this problem using Android 10 and lower versions.

question from:https://stackoverflow.com/questions/65941190/android-why-is-bluetoothlescanner-sometimes-not-discovering-any-ble-device

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Android phone limited BLE scan duration to save energy. So you can not scan BLE advertising for a long time. It is system limitation so APP layer have no way to change that.

In older phone (maybe under 4.4) do not set the limitation, but it will make the phone getting hot.

If you want to scan BLE advertisement for a long time, change your design is a better way.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...