Tune BMS reconnect timing

This commit is contained in:
2026-06-04 19:49:26 -06:00
parent abb197b36d
commit 330dd7cce6
2 changed files with 11 additions and 2 deletions
+7 -2
View File
@@ -21,7 +21,7 @@ static bool responseReady = false;
static unsigned long lastReadAttempt = 0; static unsigned long lastReadAttempt = 0;
static unsigned long lastBmsConnectAttempt = 0; static unsigned long lastBmsConnectAttempt = 0;
static unsigned long bmsConnectBackoffMs = 120000; static unsigned long bmsConnectBackoffMs = 0;
static int bmsConnectFailCount = 0; static int bmsConnectFailCount = 0;
static unsigned long bmsReconnectPausedUntil = 0; static unsigned long bmsReconnectPausedUntil = 0;
static bool bmsSetupMode = false; static bool bmsSetupMode = false;
@@ -318,7 +318,7 @@ static bool connectBms() {
client = NimBLEDevice::createClient(); client = NimBLEDevice::createClient();
// Keep failed/out-of-range BMS attempts from freezing the web UI too long. // Keep failed/out-of-range BMS attempts from freezing the web UI too long.
client->setConnectTimeout(3); client->setConnectTimeout(10);
if (!client->connect(address)) { if (!client->connect(address)) {
Serial.println("BMS: Connect failed"); Serial.println("BMS: Connect failed");
@@ -507,6 +507,11 @@ void initBms() {
NimBLEDevice::init("OverlandController"); NimBLEDevice::init("OverlandController");
NimBLEDevice::setPower(ESP_PWR_LVL_P9); NimBLEDevice::setPower(ESP_PWR_LVL_P9);
resetResponseBuffer(); resetResponseBuffer();
lastReadAttempt = 0;
lastBmsConnectAttempt = 0;
bmsConnectBackoffMs = 0;
bmsConnectFailCount = 0;
} }
void updateBms() { void updateBms() {
@@ -468,9 +468,13 @@ 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;