From 1e087427e91e3154ca23c9a7bdc11d4f8f094321 Mon Sep 17 00:00:00 2001 From: Yann Locatelli Date: Wed, 20 Sep 2023 21:09:59 +0200 Subject: [PATCH] :zap: (LekaUpdater): Adjust delays before writing to characteristics Might lead to a disconnection --- .../UpdateProcess/Version/UpdateProcessV100.swift | 10 +++++----- .../UpdateProcess/Version/UpdateProcessV130.swift | 12 ++++++------ 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Apps/LekaUpdater/Sources/Libs/UpdateProcess/Version/UpdateProcessV100.swift b/Apps/LekaUpdater/Sources/Libs/UpdateProcess/Version/UpdateProcessV100.swift index b8be741857..ed2edd1832 100644 --- a/Apps/LekaUpdater/Sources/Libs/UpdateProcess/Version/UpdateProcessV100.swift +++ b/Apps/LekaUpdater/Sources/Libs/UpdateProcess/Version/UpdateProcessV100.swift @@ -82,7 +82,7 @@ private class StateSettingDestinationPath: GKState, StateEventProcessor { } override func didEnter(from previousState: GKState?) { - DispatchQueue.main.asyncAfter(deadline: .now() + 0.1, execute: setDestinationPath) + DispatchQueue.main.asyncAfter(deadline: .now() + 1, execute: setDestinationPath) } func process(event: UpdateEvent) { @@ -169,7 +169,7 @@ private class StateSendingFile: GKState, StateEventProcessor { } override func didEnter(from previousState: GKState?) { - DispatchQueue.main.asyncAfter(deadline: .now() + 0.1, execute: sendFile) + DispatchQueue.main.asyncAfter(deadline: .now() + 1, execute: sendFile) } override func willExit(to nextState: GKState) { @@ -198,7 +198,7 @@ private class StateSendingFile: GKState, StateEventProcessor { private func tryToSendNextPacket() { if isInCriticalSection() { - DispatchQueue.main.asyncAfter(deadline: .now() + 0.1, execute: self.tryToSendNextPacket) + DispatchQueue.main.asyncAfter(deadline: .now() + 1, execute: self.tryToSendNextPacket) return } @@ -244,8 +244,8 @@ private class StateApplyingUpdate: GKState, StateEventProcessor { override func didEnter(from previousState: GKState?) { - DispatchQueue.main.asyncAfter(deadline: .now() + 0.1, execute: setMajorMinorRevision) - DispatchQueue.main.asyncAfter(deadline: .now() + 1.0, execute: applyUpdate) + DispatchQueue.main.asyncAfter(deadline: .now() + 1, execute: setMajorMinorRevision) + DispatchQueue.main.asyncAfter(deadline: .now() + 2, execute: applyUpdate) } diff --git a/Apps/LekaUpdater/Sources/Libs/UpdateProcess/Version/UpdateProcessV130.swift b/Apps/LekaUpdater/Sources/Libs/UpdateProcess/Version/UpdateProcessV130.swift index 1dc47e2e84..82ab045ac0 100644 --- a/Apps/LekaUpdater/Sources/Libs/UpdateProcess/Version/UpdateProcessV130.swift +++ b/Apps/LekaUpdater/Sources/Libs/UpdateProcess/Version/UpdateProcessV130.swift @@ -86,7 +86,7 @@ private class StateSettingFileExchangeState: GKState, StateEventProcessor { } override func didEnter(from previousState: GKState?) { - DispatchQueue.main.asyncAfter(deadline: .now() + 0.1, execute: setFileExchangeState) + DispatchQueue.main.asyncAfter(deadline: .now() + 1, execute: setFileExchangeState) } func process(event: UpdateEvent) { @@ -123,7 +123,7 @@ private class StateSettingDestinationPath: GKState, StateEventProcessor { } override func didEnter(from previousState: GKState?) { - DispatchQueue.main.asyncAfter(deadline: .now() + 0.1, execute: setDestinationPath) + DispatchQueue.main.asyncAfter(deadline: .now() + 1, execute: setDestinationPath) } func process(event: UpdateEvent) { @@ -164,7 +164,7 @@ private class StateClearingFile: GKState, StateEventProcessor { } override func didEnter(from previousState: GKState?) { - DispatchQueue.main.asyncAfter(deadline: .now() + 0.1, execute: setClearPath) + DispatchQueue.main.asyncAfter(deadline: .now() + 1, execute: setClearPath) } func process(event: UpdateEvent) { @@ -247,7 +247,7 @@ private class StateSendingFile: GKState, StateEventProcessor { } override func didEnter(from previousState: GKState?) { - DispatchQueue.main.asyncAfter(deadline: .now() + 0.1, execute: sendFile) + DispatchQueue.main.asyncAfter(deadline: .now() + 1, execute: sendFile) } override func willExit(to nextState: GKState) { @@ -393,8 +393,8 @@ private class StateApplyingUpdate: GKState, StateEventProcessor { override func didEnter(from previousState: GKState?) { - DispatchQueue.main.asyncAfter(deadline: .now() + 0.1, execute: setMajorMinorRevision) - DispatchQueue.main.asyncAfter(deadline: .now() + 1.0, execute: applyUpdate) + DispatchQueue.main.asyncAfter(deadline: .now() + 1, execute: setMajorMinorRevision) + DispatchQueue.main.asyncAfter(deadline: .now() + 2, execute: applyUpdate) }