Skip to content

Commit

Permalink
Add some more firmware update progress messages
Browse files Browse the repository at this point in the history
  • Loading branch information
krksgbr committed Mar 28, 2024
1 parent 766fcca commit a404d50
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/dividat-driver/firmware/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ func Update(parentCtx context.Context, image io.Reader, deviceSerial *string, co
dfuHost = *configuredAddr
} else {
ctx, cancel := context.WithTimeout(parentCtx, 60*time.Second)
onProgress("Looking for Senso in bootloader mode.")
discoveredAddr, err := discover("_sensoUpdate._udp", deviceSerial, ctx, onProgress)
cancel()
if err != nil {
Expand All @@ -111,6 +112,7 @@ func Update(parentCtx context.Context, image io.Reader, deviceSerial *string, co
cancel()
if err == nil {
dfuHost = legacyDiscoveredAddr
onProgress("Senso discovered via _sensoControl._tcp")
} else if controllerHost != "" {
onProgress(fmt.Sprintf("Could not discover update service, trying to fall back to previous discovery %s.", controllerHost))
dfuHost = controllerHost
Expand All @@ -122,9 +124,11 @@ func Update(parentCtx context.Context, image io.Reader, deviceSerial *string, co
}
} else {
dfuHost = discoveredAddr
onProgress("Senso discovered via _sensoUpdate._udp")
}
}

onProgress("Preparing to transmit firmware.")
// 4: Transmit firmware via TFTP
time.Sleep(5 * time.Second) // Wait to ensure proper TFTP startup
err := putTFTP(dfuHost, tftpPort, image, onProgress)
Expand Down
2 changes: 2 additions & 0 deletions src/dividat-driver/senso/update_firmware.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ func (handle *Handle) ProcessFirmwareUpdateRequest(command UpdateFirmware, onUpd
handle.log.Info("Processing firmware update request.")
handle.setUpdatingFirmware(true)
if handle.cancelCurrentConnection != nil {
msg := "Disconnecting from the Senso"
onUpdate(FirmwareUpdateMessage{FirmwareUpdateProgress: &msg})
handle.cancelCurrentConnection()
}
image, err := decodeImage(command.Image)
Expand Down

0 comments on commit a404d50

Please sign in to comment.