fix(provision): re-broadcast SPAXEL READY every 1s during window
Some checks are pending
CI Benchmark - Fusion Loop Timing / Fusion Loop Timing Benchmark (push) Waiting to run

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 <noreply@anthropic.com>
This commit is contained in:
jedarden 2026-06-05 18:23:25 -04:00
parent cc65ae690f
commit 2483d36642
2 changed files with 12 additions and 3 deletions

View file

@ -1 +1 @@
0.1.355
0.1.357

View file

@ -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) {