diff --git a/firmware/esp32/overland-controller/bms.cpp b/firmware/esp32/overland-controller/bms.cpp index 16afe25..8056754 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 = 120000; +static unsigned long bmsConnectBackoffMs = 0; static int bmsConnectFailCount = 0; static unsigned long bmsReconnectPausedUntil = 0; static bool bmsSetupMode = false; @@ -318,7 +318,7 @@ static bool connectBms() { client = NimBLEDevice::createClient(); // Keep failed/out-of-range BMS attempts from freezing the web UI too long. - client->setConnectTimeout(3); + client->setConnectTimeout(10); if (!client->connect(address)) { Serial.println("BMS: Connect failed"); @@ -507,6 +507,11 @@ void initBms() { NimBLEDevice::init("OverlandController"); NimBLEDevice::setPower(ESP_PWR_LVL_P9); resetResponseBuffer(); + + lastReadAttempt = 0; + lastBmsConnectAttempt = 0; + bmsConnectBackoffMs = 0; + bmsConnectFailCount = 0; } void updateBms() { diff --git a/firmware/esp32/overland-controller/overland-controller.ino b/firmware/esp32/overland-controller/overland-controller.ino index ef248fa..482da37 100644 --- a/firmware/esp32/overland-controller/overland-controller.ino +++ b/firmware/esp32/overland-controller/overland-controller.ino @@ -468,9 +468,13 @@ void buildStatusDocument(JsonDocument& doc) { } else { if (appConfig.bms.enabled && appConfig.bms.address.length() > 0) { battery["source"] = "jbd_bms"; + } else { + if (appConfig.bms.enabled && appConfig.bms.address.length() > 0) { + battery["source"] = "jbd_bms"; } else { battery["source"] = "unconfigured"; } + } battery["connected"] = false; battery["soc"] = 0; battery["voltage"] = 0;