Skip to content

Commit

Permalink
Fixup this commit to copy if the original is updated in same way
Browse files Browse the repository at this point in the history
  • Loading branch information
YannLocatelli committed Feb 27, 2024
1 parent a93d9a2 commit 458a3e9
Showing 1 changed file with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -357,34 +356,37 @@ private class StateApplyingUpdate: GKState, StateEventProcessor {

private var cancellables: Set<AnyCancellable> = []

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)
Expand Down

0 comments on commit 458a3e9

Please sign in to comment.