Skip to content

Commit 723caeb

Browse files
committed
Allow Discovery and GetStatus commands while updating firmware
The do not interfere with the firmware update, but can be relevant for the client.
1 parent cc30906 commit 723caeb

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

src/dividat-driver/senso/websocket.go

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -265,12 +265,13 @@ func (handle *Handle) ServeHTTP(w http.ResponseWriter, r *http.Request) {
265265
return
266266
}
267267

268-
if handle.isUpdatingFirmware() {
269-
handle.log.Info("Firmware update in progress, ignoring websocket message.")
270-
continue
271-
}
272-
273268
if messageType == websocket.BinaryMessage {
269+
270+
if handle.isUpdatingFirmware() {
271+
handle.log.Info("Firmware update in progress, ignoring Senso command.")
272+
continue
273+
}
274+
274275
handle.broker.TryPub(msg, "tx")
275276

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

287+
if handle.isUpdatingFirmware() && (command.GetStatus == nil || command.Discover == nil) {
288+
handle.log.Info("Firmware update in progress, ignoring UpdateFirmware command.")
289+
continue
290+
}
291+
286292
err := handle.dispatchCommand(ctx, log, command, sendMessage)
287293
if err != nil {
288294
return

0 commit comments

Comments
 (0)