From a49fa5d95380dda904b3b28752549562de9382f9 Mon Sep 17 00:00:00 2001 From: cjkas Date: Mon, 12 Oct 2026 17:59:48 +0200 Subject: [PATCH] fix: don't hold position updates back while the radio is full processQueue stopped draining web commands whenever the radio queue was near full, including set_positions, which never transmits. Look at the command at the head and only hold it back if it needs the radio, keeping the commands in order. Co-Authored-By: Claude Opus 5.5 --- src/Web.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Web.cpp b/src/Web.cpp index c93ae66..4803d27 100644 --- a/src/Web.cpp +++ b/src/Web.cpp @@ -134,14 +134,19 @@ bool Web::queueCommand(const web_command_t &cmd) { } return true; } +// Only setting positions never goes on air. +static bool usesRadio(web_cmd_t type) { return type != web_cmd_t::set_positions; } void Web::processQueue() { if(!webCmdQueue) return; web_command_t cmd; // The client was already told the command was accepted so leave it queued // until the radio has room rather than have the radio drop it. While TX is // suspended nothing gets through anyway so don't hold anything back then. - while((somfy.transceiver.txSuspended() || somfy.transceiver.txHasRoom()) && - xQueueReceive(webCmdQueue, &cmd, 0) == pdTRUE) { + // Commands run in order, so only the one at the head can be held back. + while(xQueuePeek(webCmdQueue, &cmd, 0) == pdTRUE) { + if(usesRadio(cmd.type) && !somfy.transceiver.txSuspended() && !somfy.transceiver.txHasRoom()) break; + // loop() is the only consumer so this is the command we peeked. + xQueueReceive(webCmdQueue, &cmd, 0); bool sent = true; switch(cmd.type) { case web_cmd_t::shade_command: {