3

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 sometimes also occurs if no stopScan()/startScan() has 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.

matdev
  • 4,115
  • 6
  • 35
  • 56
  • 1
    Also have this problem, does anyone find a solution? – ininmm May 19 '21 at 05:30
  • Actually, since I've ensured that startScan() is not called more frequently than the OS autorizes i.e. keeping at least 6 seconds between each stopScan()/startScan() I no longer notice the problem. Are you sure that your app does not scan too frequently ? – matdev May 19 '21 at 09:07
  • hi @matdev, do you have any source for this 6 Second Period that should exist between stopScan() and startScan()? – Lars Mar 29 '22 at 15:37

1 Answers1

0

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.