Skip to content

Commit

Permalink
Allow Discovery and GetStatus commands while updating firmware
Browse files Browse the repository at this point in the history
The do not interfere with the firmware update, but can be relevant for
the client.
  • Loading branch information
krksgbr committed Apr 3, 2024
1 parent cc30906 commit 723caeb
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/dividat-driver/senso/websocket.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,12 +265,13 @@ func (handle *Handle) ServeHTTP(w http.ResponseWriter, r *http.Request) {
return
}

if handle.isUpdatingFirmware() {
handle.log.Info("Firmware update in progress, ignoring websocket message.")
continue
}

if messageType == websocket.BinaryMessage {

if handle.isUpdatingFirmware() {
handle.log.Info("Firmware update in progress, ignoring Senso command.")
continue
}

handle.broker.TryPub(msg, "tx")

} else if messageType == websocket.TextMessage {
Expand All @@ -283,6 +284,11 @@ func (handle *Handle) ServeHTTP(w http.ResponseWriter, r *http.Request) {
}
log.WithField("command", prettyPrintCommand(command)).Debug("Received command.")

if handle.isUpdatingFirmware() && (command.GetStatus == nil || command.Discover == nil) {
handle.log.Info("Firmware update in progress, ignoring UpdateFirmware command.")
continue
}

err := handle.dispatchCommand(ctx, log, command, sendMessage)
if err != nil {
return
Expand Down

0 comments on commit 723caeb

Please sign in to comment.