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