Skip to content

Commit

Permalink
check if bluetooth is on before scanning
Browse files Browse the repository at this point in the history
  • Loading branch information
Codel1417 committed Dec 21, 2024
1 parent ec618d0 commit 60def20
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/Backend/Bluetooth/bluetooth_manager_plus.dart
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ enum ScanReason { background, addGear, manual, notScanning }
ScanReason _scanReason = ScanReason.notScanning;

Future<void> beginScan({required ScanReason scanReason, Duration? timeout}) async {
if (_didInitFlutterBluePlus && !flutterBluePlus.isScanningNow) {
if (_didInitFlutterBluePlus && !flutterBluePlus.isScanningNow && isBluetoothEnabled.value) {
_bluetoothPlusLogger.info("Starting scan");
_scanReason = scanReason;
await flutterBluePlus.startScan(withServices: DeviceRegistry.getAllIds().map(Guid.new).toList(), continuousUpdates: timeout == null, androidScanMode: AndroidScanMode.lowPower, timeout: timeout);
Expand Down

0 comments on commit 60def20

Please sign in to comment.