From a1a5104c5b97b7d8a3e423cd9e13316199319342 Mon Sep 17 00:00:00 2001 From: "torlando-agent[bot]" <281092095+torlando-agent[bot]@users.noreply.github.com> Date: Fri, 19 Jun 2026 22:30:11 -0400 Subject: [PATCH] fix(tcp): seed _last_connect_attempt so the initial connect isn't delayed (greptile) With _last_connect_attempt == 0, task_loop()'s first `now - _last_connect_attempt >= RECONNECT_WAIT_MS` check only passes once millis() >= RECONNECT_WAIT_MS, delaying the very first connect up to 15s after boot. Seed it to millis() - RECONNECT_WAIT_MS in start() so the first attempt fires immediately (unsigned wraparound keeps it correct when millis() < the wait). Co-Authored-By: Claude Opus 4.8 (1M context) Claude-Session: https://claude.ai/code/session_01UWZuYkHBRqNb6BZHV8sTG5 --- src/TCPClientInterface.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/TCPClientInterface.cpp b/src/TCPClientInterface.cpp index 85d9220e..6aff3b10 100644 --- a/src/TCPClientInterface.cpp +++ b/src/TCPClientInterface.cpp @@ -50,6 +50,11 @@ TCPClientInterface::TCPClientInterface(const char* name /*= "TCPClientInterface" #ifdef ARDUINO // The blocking connect() runs on its own task so it never stalls the main // loop. read/write/frame stay on the main loop (see loop()). + // Seed _last_connect_attempt so the task's first reconnect-wait check passes + // immediately; otherwise the initial connect could be delayed up to + // RECONNECT_WAIT_MS. Unsigned wraparound keeps this correct when + // millis() < RECONNECT_WAIT_MS. + _last_connect_attempt = millis() - RECONNECT_WAIT_MS; _task_running = true; BaseType_t r = xTaskCreatePinnedToCore(tcp_task, "tcp", 6144, this, 1, &_task_handle, 0); if (r != pdPASS) {