We have an Android application developed in Kotlin which uses the Nordic scanner library (Android-Scanner-Compat-Library) version 1.6.0. It scans for devices which use the nRF52840. Our app specifies compileSdkVersion 31, minSdkVersion 26, targetSdkVersion 31.
In our app, we periodically stop BLE scanning and restart it. When the screen is off or the app is minimized, scanning/scan callbacks continue to work until one of the periodic intervals comes around to stop and restart scanning. When scanning is restarted, we no longer receive any scan callbacks from BLE advertisements.
Nordic documentation for the Android BLE Scanner Compat Library states "Note, that for unfiltered scans, scanning is stopped on screen off to save power. Scanning is resumed when screen is turned on again. To avoid this, use scanning with desired ScanFilter." This doesn't appear to be our problem for 2 reasons:
- we are using a scan filter
- with the screen off, the scan callbacks continue to work until we explicitly stop and restart scanning
We use SCAN_MODE_LOW_LATENCY for our scanning, which we understand will be more power hungry. Nordic documentation mentions the following about SCAN_MODE_LOW_POWER: "Perform Bluetooth LE scan in low power mode...This mode may be enforced if the scanning application is not in foreground." Could our issue be that even though we are specifying SCAN_MODE_LOW_LATENCY, the system is automatically switching over to use SCAN_MODE_LOW_POWER when we restart scanning? If so, it seems surprising that we receive NO scan callbacks at all.
Thank you for your help with this issue.
John