mirror of
https://github.com/zjs81/meshcore-open.git
synced 2026-07-17 14:20:49 +10:00
Refactor USB permission handling and reset initial channel sync flag
This commit is contained in:
committed by
just-stuff-tm
parent
38d40ca0a4
commit
21ff765e41
@@ -82,13 +82,6 @@ class MeshcoreUsbFunctions(
|
|||||||
return
|
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)
|
val device = findUsbDevice(portName)
|
||||||
if (device == null) {
|
if (device == null) {
|
||||||
result.error(
|
result.error(
|
||||||
@@ -99,6 +92,13 @@ class MeshcoreUsbFunctions(
|
|||||||
return
|
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)
|
openUsbDevice(device, pendingConnectBaudRate, result)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1169,7 +1169,6 @@ class MeshCoreConnector extends ChangeNotifier {
|
|||||||
_pendingInitialContactsSync = false;
|
_pendingInitialContactsSync = false;
|
||||||
_bleInitialSyncStarted = false;
|
_bleInitialSyncStarted = false;
|
||||||
_pendingDeferredChannelSyncAfterContacts = false;
|
_pendingDeferredChannelSyncAfterContacts = false;
|
||||||
_webInitialHandshakeRequestSent = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool get _shouldAutoReconnect =>
|
bool get _shouldAutoReconnect =>
|
||||||
@@ -2241,6 +2240,7 @@ class MeshCoreConnector extends ChangeNotifier {
|
|||||||
(_activeTransport == MeshCoreTransportType.bluetooth ||
|
(_activeTransport == MeshCoreTransportType.bluetooth ||
|
||||||
_activeTransport == MeshCoreTransportType.usb)) {
|
_activeTransport == MeshCoreTransportType.usb)) {
|
||||||
_pendingDeferredChannelSyncAfterContacts = false;
|
_pendingDeferredChannelSyncAfterContacts = false;
|
||||||
|
_pendingInitialChannelSync = false;
|
||||||
unawaited(getChannels());
|
unawaited(getChannels());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user