Reduce blocking BMS connection timeout

This commit is contained in:
2026-06-04 17:25:35 -06:00
parent 8f2481025f
commit 34606fb27a
+7 -4
View File
@@ -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))) {