cargo: fix BMS reconnect backoff helper order
This commit is contained in:
@@ -290,7 +290,34 @@ int scanBleDevices(uint32_t scanSeconds) {
|
|||||||
return bleScanResultCount;
|
return bleScanResultCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool connectBms() {
|
static static void scheduleBmsReconnectBackoff();
|
||||||
|
static void clearBmsReconnectBackoff();
|
||||||
|
|
||||||
|
static void scheduleBmsReconnectBackoff() {
|
||||||
|
bmsConnectFailCount++;
|
||||||
|
|
||||||
|
if (bmsConnectBackoffMs == 0) {
|
||||||
|
bmsConnectBackoffMs = BMS_CONNECT_BACKOFF_INITIAL_MS;
|
||||||
|
} else {
|
||||||
|
bmsConnectBackoffMs = min(bmsConnectBackoffMs * 2, BMS_CONNECT_BACKOFF_MAX_MS);
|
||||||
|
}
|
||||||
|
|
||||||
|
bmsReconnectPausedUntil = millis() + bmsConnectBackoffMs;
|
||||||
|
|
||||||
|
Serial.print("BMS: reconnect backoff ");
|
||||||
|
Serial.print(bmsConnectBackoffMs / 1000);
|
||||||
|
Serial.print("s after ");
|
||||||
|
Serial.print(bmsConnectFailCount);
|
||||||
|
Serial.println(" failed attempt(s)");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void clearBmsReconnectBackoff() {
|
||||||
|
bmsConnectFailCount = 0;
|
||||||
|
bmsConnectBackoffMs = 0;
|
||||||
|
bmsReconnectPausedUntil = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool connectBms() {
|
||||||
if (client && client->isConnected()) {
|
if (client && client->isConnected()) {
|
||||||
bmsData.connected = true;
|
bmsData.connected = true;
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define FIRMWARE_VERSION "0.5.2-bms-missing-backoff"
|
#define FIRMWARE_VERSION "0.5.3-bms-backoff-compile-fix"
|
||||||
#define FIRMWARE_NAME "overland-controller"
|
#define FIRMWARE_NAME "overland-controller"
|
||||||
|
|||||||
Reference in New Issue
Block a user