From b211a92a3ab96a2c7bd864f5d8b9a001ba2077f3 Mon Sep 17 00:00:00 2001 From: Niel Nielsen Date: Wed, 2 Sep 2026 14:24:29 +0200 Subject: [PATCH] Add BWM_CMD_GET_UART_BAUD definition Added a new command to get the current UART baud rate from the ESP. Signed-off-by: Niel Nielsen --- armsrc/bwm_forward.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/armsrc/bwm_forward.h b/armsrc/bwm_forward.h index 505c63581..5ef6cf71e 100644 --- a/armsrc/bwm_forward.h +++ b/armsrc/bwm_forward.h @@ -51,6 +51,7 @@ // SET is a HOST_CMD carrying u32 LE baud; the ESP replies with a SLAVE_RESP // echoing this cmd (len 0) at the OLD baud, then commits to the new baud. #define BWM_CMD_SET_UART_BAUD 1011 +#define BWM_CMD_GET_UART_BAUD 1009 // read back the ESP's live baud (negotiation verify) // Flow control (ack window) - ARM-side only, no BWM firmware change required. // The ESP already replies to every forward frame with a SLAVE_RESP echoing // cmd=SEND_FORWARD_DATA, and it sends that ack only *after* app_ble_send() has @@ -66,8 +67,12 @@ // keep enough headroom to ride out delayed acks. Only ~1 response is ever // really in flight during an upload, so this does not risk an ESP overrun. #define BWM_FC_WINDOW 16 // max un-acked forward frames in flight -#ifndef BWM_FC_ACK_TIMEOUT_SPINS -#define BWM_FC_ACK_TIMEOUT_SPINS 200000 // safety valve: proceed if an ack is lost (avoid hard hang) +#ifndef BWM_FC_ACK_TIMEOUT_MS +// Hard cap (ms) on how long a forward write may block the main loop waiting for +// acks. A spin COUNT was unbounded in wall-clock time and could hang the main +// loop long enough that the client gives up and the device looks dead (USB still +// enumerates on interrupts). Time-bounded => the main loop is always serviced. +#define BWM_FC_ACK_TIMEOUT_MS 50 // safety valve: proceed if acks stall, never hard-hang #endif // safety valve: give up waiting for credit (avoid hard hang) #define BWM_CRC16_POLY 0x1021