Skip to content
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

[Help] Android: UNKNOWN_SCAN_ERROR when scanning in background #925

Closed
1 task done
summeryi opened this issue Jul 4, 2024 · 4 comments
Closed
1 task done

[Help] Android: UNKNOWN_SCAN_ERROR when scanning in background #925

summeryi opened this issue Jul 4, 2024 · 4 comments
Labels
help Questions, help, observations, or possible bugs

Comments

@summeryi
Copy link

summeryi commented Jul 4, 2024

Requirements

  • I've looked at the README 'Common Problems' section

Have you checked this problem on the example app?

Yes

FlutterBluePlus Version

1.32.8

Flutter Version

3.19.5

What OS?

Android

OS Version

Android 13

Bluetooth Module

null

What is your problem?

When my phone turns off the screen and triggers a startScan(), it will report an error(UNKNOWN_SCAN_ERROR). If I search again, it will report an error(SCAN_FAILED_ALREADY_STARTED)

Logs

error1:
I/flutter ( 9962): [FBP] <startScan> result: true
E/[FBP-Android]( 9962): [FBP] onScanFailed: UNKNOWN_SCAN_ERROR (100)
I/flutter ( 9962): [FBP] [[ OnScanResponse ]] result: {error_string: UNKNOWN_SCAN_ERROR (100), advertisements: [], success: 0, error_code: 100}


error2:
I/flutter ( 9962): [FBP] <startScan> args: {with_services: [], with_remote_ids: [], with_names: [], with_keywords: [], with_msd: [], with_service_data: [], continuous_updates: false, continuous_divisor: 1, android_scan_mode: 2, android_uses_fine_location: false}
D/[FBP-Android]( 9962): [FBP] onMethodCall: startScan
D/BluetoothAdapter( 9962): isLeEnabled(): ON
E/[FBP-Android]( 9962): [FBP] onScanFailed: SCAN_FAILED_ALREADY_STARTED
I/flutter ( 9962): [FBP] <startScan> result: true
I/flutter ( 9962): [FBP] [[ OnScanResponse ]] result: {error_string: SCAN_FAILED_ALREADY_STARTED, advertisements: [], success: 0, error_code: 1}
@summeryi summeryi added the help Questions, help, observations, or possible bugs label Jul 4, 2024
@chipweinberger chipweinberger changed the title When my phone turns off the screen and triggers a startScan(), it will report an error(UNKNOWN_SCAN_ERROR). If I search again, it will report an error(SCAN_FAILED_ALREADY_STARTED) [Help] Android: UNKNOWN_SCAN_ERROR when scanning in background Jul 4, 2024
@chipweinberger
Copy link
Owner

chipweinberger commented Jul 4, 2024

how are you triggering the scan when the screen is off? this is not something FBP really supports

but this sounds like an android bug, not FBP

@summeryi
Copy link
Author

summeryi commented Jul 5, 2024

After turning off the screen on my end, I wrote a timer that triggered it in 1 second. The problem occurred 100% of the time, and after the problem occurred, the search continued to fail

@summeryi
Copy link
Author

summeryi commented Jul 5, 2024

Future onScanPressed() async {
Future.delayed(Duration(seconds: 1),() async {
try {
_systemDevices = await FlutterBluePlus.systemDevices;
} catch (e) {
Snackbar.show(ABC.b, prettyException("System Devices Error:", e), success: false);
}
try {
await FlutterBluePlus.startScan(timeout: const Duration(seconds: 15));
} catch (e) {
Snackbar.show(ABC.b, prettyException("Start Scan Error:", e), success: false);
}
if (mounted) {
setState(() {});
}
});
}

@chipweinberger
Copy link
Owner

closing in favor of new issue

#930

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help Questions, help, observations, or possible bugs
Projects
None yet
Development

No branches or pull requests

2 participants