From 2483d366423d40d7df1aa5aec2df64e0a7b2d882 Mon Sep 17 00:00:00 2001 From: jedarden Date: Fri, 5 Jun 2026 18:23:25 -0400 Subject: [PATCH] fix(provision): re-broadcast SPAXEL READY every 1s during window Previously the ready signal was sent exactly once at window open, so the browser had to have the serial port open at that exact millisecond after reboot. Now the firmware broadcasts SPAXEL READY every second for the full provisioning window (2 min fresh / 15 s reprov), giving the host ample time to open the port and catch the handshake. Co-Authored-By: Claude Sonnet 4.6 --- VERSION | 2 +- firmware/main/provision.c | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/VERSION b/VERSION index 0439141..c1d7880 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.1.355 +0.1.357 diff --git a/firmware/main/provision.c b/firmware/main/provision.c index 8f2e2df..f960da3 100644 --- a/firmware/main/provision.c +++ b/firmware/main/provision.c @@ -44,18 +44,27 @@ void provision_listen_window(void) { ? PROVISION_WINDOW_MS_REPROV : PROVISION_WINDOW_MS_FRESH; - // Signal that firmware is ready for provisioning (includes MAC for display) + // Signal that firmware is ready for provisioning (includes MAC for display). + // Broadcast every 1 s so the host can open the port at any time during + // the window — not just at the exact moment of first boot. char ready_msg[64]; snprintf(ready_msg, sizeof(ready_msg), "SPAXEL READY %s\n", mac_str); uart_write_bytes(PROVISION_UART, ready_msg, strlen(ready_msg)); ESP_LOGI(TAG, "Provisioning window open for %u ms (MAC: %s)", (unsigned)window_ms, mac_str); - TickType_t deadline = xTaskGetTickCount() + pdMS_TO_TICKS(window_ms); + TickType_t deadline = xTaskGetTickCount() + pdMS_TO_TICKS(window_ms); + TickType_t last_ready = xTaskGetTickCount(); char line[MAX_LINE_LEN]; int line_pos = 0; while (xTaskGetTickCount() < deadline) { + // Re-broadcast READY every 1 s so the host can connect at any time + if ((xTaskGetTickCount() - last_ready) >= pdMS_TO_TICKS(1000)) { + uart_write_bytes(PROVISION_UART, ready_msg, strlen(ready_msg)); + last_ready = xTaskGetTickCount(); + } + uint8_t ch; int n = uart_read_bytes(PROVISION_UART, &ch, 1, pdMS_TO_TICKS(50)); if (n <= 0) {