From ae1ea71f58f0914f3f995b1b306634cb09b3b037 Mon Sep 17 00:00:00 2001 From: Janez T Date: Mon, 9 Mar 2026 19:39:14 +0100 Subject: [PATCH] Analyze MeshCore BLE scan logs --- lib/providers/connection_provider.dart | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/providers/connection_provider.dart b/lib/providers/connection_provider.dart index fccdcfc..c284d37 100644 --- a/lib/providers/connection_provider.dart +++ b/lib/providers/connection_provider.dart @@ -486,6 +486,14 @@ class ConnectionProvider with ChangeNotifier { /// Start scanning for MeshCore devices Future startScan() async { debugPrint('🔍 [Provider] startScan() called'); + if (_deviceInfo.connectionState == ConnectionState.connecting || + _deviceInfo.connectionState == ConnectionState.connected) { + debugPrint( + '⏭️ [Provider] Ignoring scan request while connection is active: ${_deviceInfo.connectionState}', + ); + return; + } + _isScanning = true; _scannedDevices.clear(); _error = null; @@ -559,6 +567,11 @@ class ConnectionProvider with ChangeNotifier { '🔵 [Provider] connect() called for device: ${device.platformName}', ); + if (_isScanning) { + debugPrint('🔵 [Provider] Stopping active scan before connect()'); + await stopScan(); + } + _deviceInfo = _deviceInfo.copyWith( deviceId: device.remoteId.toString(), deviceName: device.platformName.isNotEmpty