From 458a3e9a62afe46a77137f2dc6cade363c55d4e0 Mon Sep 17 00:00:00 2001 From: Yann Locatelli Date: Wed, 17 Jan 2024 18:03:52 +0100 Subject: [PATCH] Fixup this commit to copy if the original is updated in same way --- .../Version/UpdateProcessV150.swift | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/Apps/LekaUpdater/Sources/Libs/UpdateProcess/Version/UpdateProcessV150.swift b/Apps/LekaUpdater/Sources/Libs/UpdateProcess/Version/UpdateProcessV150.swift index 0b613b2378..c79d7e72cb 100644 --- a/Apps/LekaUpdater/Sources/Libs/UpdateProcess/Version/UpdateProcessV150.swift +++ b/Apps/LekaUpdater/Sources/Libs/UpdateProcess/Version/UpdateProcessV150.swift @@ -336,8 +336,7 @@ private class StateApplyingUpdate: GKState, StateEventProcessor { } override func didEnter(from _: GKState?) { - DispatchQueue.main.asyncAfter(deadline: .now() + 1, execute: self.setMajorMinorRevision) - DispatchQueue.main.asyncAfter(deadline: .now() + 5, execute: self.applyUpdate) + self.setMajor() } override func willExit(to _: GKState) { @@ -357,34 +356,37 @@ private class StateApplyingUpdate: GKState, StateEventProcessor { private var cancellables: Set = [] - private func setMajorMinorRevision() { + private func setMajor() { let majorData = Data([globalFirmwareManager.major]) let majorCharacteristic = CharacteristicModelWriteOnly( characteristicUUID: BLESpecs.FirmwareUpdate.Characteristics.versionMajor, - serviceUUID: BLESpecs.FirmwareUpdate.service + serviceUUID: BLESpecs.FirmwareUpdate.service, + onWrite: self.setMinor ) Robot.shared.connectedPeripheral?.send(majorData, forCharacteristic: majorCharacteristic) + } - sleep(1) - + private func setMinor() { let minorData = Data([globalFirmwareManager.minor]) let minorCharacteristic = CharacteristicModelWriteOnly( characteristicUUID: BLESpecs.FirmwareUpdate.Characteristics.versionMinor, - serviceUUID: BLESpecs.FirmwareUpdate.service + serviceUUID: BLESpecs.FirmwareUpdate.service, + onWrite: self.setRevision ) Robot.shared.connectedPeripheral?.send(minorData, forCharacteristic: minorCharacteristic) + } - sleep(1) - + private func setRevision() { let revisionData = globalFirmwareManager.revision.data let revisionCharacteristic = CharacteristicModelWriteOnly( characteristicUUID: BLESpecs.FirmwareUpdate.Characteristics.versionRevision, - serviceUUID: BLESpecs.FirmwareUpdate.service + serviceUUID: BLESpecs.FirmwareUpdate.service, + onWrite: self.applyUpdate ) Robot.shared.connectedPeripheral?.send(revisionData, forCharacteristic: revisionCharacteristic)