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) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UWZuYkHBRqNb6BZHV8sTG5
This commit is contained in:
torlando-agent[bot]
2026-06-19 22:30:11 -04:00
co-authored by Claude Opus 4.8
parent 7148859582
commit a1a5104c5b
+5
View File
@@ -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) {