Restore known-good BMS connection behavior

This commit is contained in:
2026-06-04 19:58:55 -06:00
parent 330dd7cce6
commit 83254494fb
2 changed files with 7 additions and 25 deletions
+3 -25
View File
@@ -529,31 +529,8 @@ void updateBms() {
lastReadAttempt = millis(); lastReadAttempt = millis();
if (!client || !client->isConnected()) { if (!connectBms()) {
unsigned long now = millis(); return;
if (now - lastBmsConnectAttempt < bmsConnectBackoffMs) {
bmsData.connected = false;
return;
}
lastBmsConnectAttempt = now;
if (!connectBms()) {
bmsData.connected = false;
bmsConnectFailCount++;
if (bmsConnectFailCount >= 3) {
bmsConnectBackoffMs = 120000;
} else {
bmsConnectBackoffMs = 60000;
}
return;
}
bmsConnectFailCount = 0;
bmsConnectBackoffMs = 60000;
} }
if (requestPacket(JBD_STATUS_REQUEST, sizeof(JBD_STATUS_REQUEST))) { if (requestPacket(JBD_STATUS_REQUEST, sizeof(JBD_STATUS_REQUEST))) {
@@ -566,3 +543,4 @@ void updateBms() {
parseCellVoltages(); parseCellVoltages();
} }
} }
@@ -471,10 +471,14 @@ void buildStatusDocument(JsonDocument& doc) {
} else { } else {
if (appConfig.bms.enabled && appConfig.bms.address.length() > 0) { if (appConfig.bms.enabled && appConfig.bms.address.length() > 0) {
battery["source"] = "jbd_bms"; battery["source"] = "jbd_bms";
} else {
if (appConfig.bms.enabled && appConfig.bms.address.length() > 0) {
battery["source"] = "jbd_bms";
} else { } else {
battery["source"] = "unconfigured"; battery["source"] = "unconfigured";
} }
} }
}
battery["connected"] = false; battery["connected"] = false;
battery["soc"] = 0; battery["soc"] = 0;
battery["voltage"] = 0; battery["voltage"] = 0;