mirror of
https://github.com/zjs81/meshcore-open.git
synced 2026-07-01 22:50:37 +10:00
Refactor USB connection handling to use scheduled closure and improve error management in USB services
This commit is contained in:
committed by
just-stuff-tm
parent
4b24506310
commit
dcad5c586d
@@ -1266,14 +1266,23 @@ class MeshCoreConnector extends ChangeNotifier {
|
||||
_selfInfoRetryTimer?.cancel();
|
||||
if (PlatformInfo.isWeb &&
|
||||
_activeTransport == MeshCoreTransportType.bluetooth) {
|
||||
_selfInfoRetryTimer = Timer(const Duration(seconds: 10), () {
|
||||
var attempts = 0;
|
||||
const maxAttempts = 3;
|
||||
_selfInfoRetryTimer = Timer.periodic(const Duration(seconds: 10), (
|
||||
timer,
|
||||
) {
|
||||
if (!isConnected || !_awaitingSelfInfo) {
|
||||
timer.cancel();
|
||||
return;
|
||||
}
|
||||
if (_isLoadingContacts || _isSyncingChannels || _channelSyncInFlight) {
|
||||
return;
|
||||
}
|
||||
attempts += 1;
|
||||
unawaited(sendFrame(buildAppStartFrame()));
|
||||
if (attempts >= maxAttempts) {
|
||||
timer.cancel();
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user