diff --git a/android/app/src/main/kotlin/com/meshcore/meshcore_open/MeshcoreUsbFunctions.kt b/android/app/src/main/kotlin/com/meshcore/meshcore_open/MeshcoreUsbFunctions.kt index d6c09b7..b8ee645 100644 --- a/android/app/src/main/kotlin/com/meshcore/meshcore_open/MeshcoreUsbFunctions.kt +++ b/android/app/src/main/kotlin/com/meshcore/meshcore_open/MeshcoreUsbFunctions.kt @@ -82,13 +82,6 @@ class MeshcoreUsbFunctions( return } - val granted = - intent.getBooleanExtra(UsbManager.EXTRA_PERMISSION_GRANTED, false) - if (!granted) { - result.error("usb_permission_denied", "USB permission denied", null) - return - } - val device = findUsbDevice(portName) if (device == null) { result.error( @@ -99,6 +92,13 @@ class MeshcoreUsbFunctions( return } + val granted = + intent.getBooleanExtra(UsbManager.EXTRA_PERMISSION_GRANTED, false) + if (!granted || !usbManager.hasPermission(device)) { + result.error("usb_permission_denied", "USB permission denied", null) + return + } + openUsbDevice(device, pendingConnectBaudRate, result) } } diff --git a/lib/connector/meshcore_connector.dart b/lib/connector/meshcore_connector.dart index 2bdc033..606b870 100644 --- a/lib/connector/meshcore_connector.dart +++ b/lib/connector/meshcore_connector.dart @@ -1169,7 +1169,6 @@ class MeshCoreConnector extends ChangeNotifier { _pendingInitialContactsSync = false; _bleInitialSyncStarted = false; _pendingDeferredChannelSyncAfterContacts = false; - _webInitialHandshakeRequestSent = false; } bool get _shouldAutoReconnect => @@ -2241,6 +2240,7 @@ class MeshCoreConnector extends ChangeNotifier { (_activeTransport == MeshCoreTransportType.bluetooth || _activeTransport == MeshCoreTransportType.usb)) { _pendingDeferredChannelSyncAfterContacts = false; + _pendingInitialChannelSync = false; unawaited(getChannels()); } break;