Restore known-good BMS connection behavior
This commit is contained in:
@@ -529,33 +529,10 @@ void updateBms() {
|
|||||||
|
|
||||||
lastReadAttempt = millis();
|
lastReadAttempt = millis();
|
||||||
|
|
||||||
if (!client || !client->isConnected()) {
|
|
||||||
unsigned long now = millis();
|
|
||||||
|
|
||||||
if (now - lastBmsConnectAttempt < bmsConnectBackoffMs) {
|
|
||||||
bmsData.connected = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
lastBmsConnectAttempt = now;
|
|
||||||
|
|
||||||
if (!connectBms()) {
|
if (!connectBms()) {
|
||||||
bmsData.connected = false;
|
|
||||||
bmsConnectFailCount++;
|
|
||||||
|
|
||||||
if (bmsConnectFailCount >= 3) {
|
|
||||||
bmsConnectBackoffMs = 120000;
|
|
||||||
} else {
|
|
||||||
bmsConnectBackoffMs = 60000;
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bmsConnectFailCount = 0;
|
|
||||||
bmsConnectBackoffMs = 60000;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (requestPacket(JBD_STATUS_REQUEST, sizeof(JBD_STATUS_REQUEST))) {
|
if (requestPacket(JBD_STATUS_REQUEST, sizeof(JBD_STATUS_REQUEST))) {
|
||||||
parseBasicInfo();
|
parseBasicInfo();
|
||||||
}
|
}
|
||||||
@@ -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;
|
||||||
|
|||||||
Reference in New Issue
Block a user