-
Notifications
You must be signed in to change notification settings - Fork 836
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Scan failed: a BLE scan with the same settings is already started by the app #944
Comments
I believe this log line is harmless, but it does create log noise. There is logic in the CycledLeScanner to not stop a scan at the end of a cycle because Android now restricts the number of times scans can be started and stopped. Instead the scan is left on. Some path in the code causes a scan to be commanded again with the exact same settings, which leads to this logged error from the operating system. This log line really should be a warning, not an error, as there are no consequences to my knowledge. The bug is simply that the log line gets sent out at all. If your goal is to get an android O background scan to be called, then you must (a) use BackgroundPowerSaver and put the app to the background or set background mode to true (b) use a backgroundBetweenScanPeriod that is nonzero. (c) Typically this will be triggered when when using Scan Jobs and not a foreground service (this is the default library setting). Only when the library goes into background mode like this will the o scan be triggered. |
Your reference app shows setting I set that to 6200 and it does seem to actually work now. My fork of your reference app is at: The diff is: I have changed very little effective code, only notably:
|
It works with the app backgrounded, but not with the screen off. |
And a breakpoint that I set on the first line of Does AltBeacon's |
The simplest explanation for why you would not detect beacons with the screen off is because the scan filter required by Samsung does not match your beacon packet. It is common for this to happen with custom beacon formats for one of three reasons:
|
(Sorry if my comments are straying from the point of the issue. Should I open a separate issue on my "issue"? Is there a better way to converse than via issues? A forum? I didn't see one). I am clearing the beacon parsers at startup:
Perhaps I should not be doing that? |
In order to get any callbacks from the library for didRangeBeaconsInRegion, didEnterRegion, you must have at least on BeaconParser active. Otherwise here will be zero beacons detected that can fire these events. The entire design of the library is centered around detecting beacons, which requires at least one BeaconParser active -- without beacon detections, the library cannot serve its purpose. |
I am using setNonBeaconLeScanCallback and clearing all beacon parsers. I can and will create a parser for my own BLE device, which isn't always a beacon, but thought I would avoid that for now and just try to prove out if this library meets my requirements. |
Yes, a BeaconParser is a requirement for getting background detections with this library. The |
Expected behavior
No error in logs about scan already started
Actual behavior
@paulpv: "I am confused by the behavior that I am seeing when I background the app while a scan is active. With a scan active/started, I background the app and almost immediately get this..."
The log says it isn't going to stop the scan, but what it does is start a scan while a scan is already scanning, which results in onScanFailed SCAN_FAILED_ALREADY_STARTED the the following log:
I have yet to find a way to get startAndroidOBackgroundScan to be called. :/
Steps to reproduce this behavior
Run the reference app on a Samsung device with the screen on
Mobile device model and OS version
Samsung
Android Beacon Library version
2.16.4
The text was updated successfully, but these errors were encountered: