Skip to content

Commit

Permalink
Merge pull request #143 from NordicSemiconductor/wrong-confirm-command
Browse files Browse the repository at this point in the history
Possible Fix for sending CONFIRM Command to wrong Image / Slot
  • Loading branch information
dinesharjani authored Oct 16, 2023
2 parents d520097 + 8278409 commit c3d50ae
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Source/Managers/DFU/FirmwareUpgradeManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ public class FirmwareUpgradeManager : FirmwareUpgradeController, ConnectionObser
private func confirm(_ image: FirmwareUpgradeImage) {
objc_sync_setState(.confirm)
if !paused {
log(msg: "Sending Confirm command for Image \(image.image) Slot \(image.slot)...", atLevel: .verbose)
log(msg: "Sending Confirm command to Image \(image.image) Slot \(image.slot)...", atLevel: .verbose)
imageManager.confirm(hash: [UInt8](image.hash), callback: confirmCallback)
}
}
Expand Down Expand Up @@ -931,7 +931,11 @@ extension FirmwareUpgradeManager: ImageUploadDelegate {
// If eraseAppSettings command was sent or was not requested, we can continue.
switch mode {
case .confirmOnly:
if let firstUnconfirmedImage = images.first(where: { !$0.confirmed }) {
// Note: We look for the first !uploaded image because at the time of LIST, it was
// not marked as uploaded yet, so we had to upload it. If the code reaches this point
// the Upload has finished, so it has been uploaded already, and what's missing is
// the CONFIRM Command.
if let firstUnconfirmedImage = images.first(where: { !$0.uploaded && !$0.confirmed }) {
confirm(firstUnconfirmedImage)
return
} else {
Expand Down

0 comments on commit c3d50ae

Please sign in to comment.