From 34606fb27a4e0ef7c827b3ae753eca235c5168be Mon Sep 17 00:00:00 2001 From: nick Date: Thu, 4 Jun 2026 17:25:35 -0600 Subject: [PATCH] Reduce blocking BMS connection timeout --- firmware/esp32/overland-controller/bms.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/firmware/esp32/overland-controller/bms.cpp b/firmware/esp32/overland-controller/bms.cpp index 5b0ddec..16afe25 100644 --- a/firmware/esp32/overland-controller/bms.cpp +++ b/firmware/esp32/overland-controller/bms.cpp @@ -21,7 +21,7 @@ static bool responseReady = false; static unsigned long lastReadAttempt = 0; static unsigned long lastBmsConnectAttempt = 0; -static unsigned long bmsConnectBackoffMs = 30000; +static unsigned long bmsConnectBackoffMs = 120000; static int bmsConnectFailCount = 0; static unsigned long bmsReconnectPausedUntil = 0; static bool bmsSetupMode = false; @@ -317,6 +317,9 @@ static bool connectBms() { client = NimBLEDevice::createClient(); + // Keep failed/out-of-range BMS attempts from freezing the web UI too long. + client->setConnectTimeout(3); + if (!client->connect(address)) { Serial.println("BMS: Connect failed"); bmsData.connected = false; @@ -536,16 +539,16 @@ void updateBms() { bmsConnectFailCount++; if (bmsConnectFailCount >= 3) { - bmsConnectBackoffMs = 60000; + bmsConnectBackoffMs = 120000; } else { - bmsConnectBackoffMs = 30000; + bmsConnectBackoffMs = 60000; } return; } bmsConnectFailCount = 0; - bmsConnectBackoffMs = 30000; + bmsConnectBackoffMs = 60000; } if (requestPacket(JBD_STATUS_REQUEST, sizeof(JBD_STATUS_REQUEST))) {