Tune BMS reconnect timing
This commit is contained in:
@@ -21,7 +21,7 @@ static bool responseReady = false;
|
||||
static unsigned long lastReadAttempt = 0;
|
||||
|
||||
static unsigned long lastBmsConnectAttempt = 0;
|
||||
static unsigned long bmsConnectBackoffMs = 120000;
|
||||
static unsigned long bmsConnectBackoffMs = 0;
|
||||
static int bmsConnectFailCount = 0;
|
||||
static unsigned long bmsReconnectPausedUntil = 0;
|
||||
static bool bmsSetupMode = false;
|
||||
@@ -318,7 +318,7 @@ static bool connectBms() {
|
||||
client = NimBLEDevice::createClient();
|
||||
|
||||
// Keep failed/out-of-range BMS attempts from freezing the web UI too long.
|
||||
client->setConnectTimeout(3);
|
||||
client->setConnectTimeout(10);
|
||||
|
||||
if (!client->connect(address)) {
|
||||
Serial.println("BMS: Connect failed");
|
||||
@@ -507,6 +507,11 @@ void initBms() {
|
||||
NimBLEDevice::init("OverlandController");
|
||||
NimBLEDevice::setPower(ESP_PWR_LVL_P9);
|
||||
resetResponseBuffer();
|
||||
|
||||
lastReadAttempt = 0;
|
||||
lastBmsConnectAttempt = 0;
|
||||
bmsConnectBackoffMs = 0;
|
||||
bmsConnectFailCount = 0;
|
||||
}
|
||||
|
||||
void updateBms() {
|
||||
|
||||
@@ -468,9 +468,13 @@ void buildStatusDocument(JsonDocument& doc) {
|
||||
} else {
|
||||
if (appConfig.bms.enabled && appConfig.bms.address.length() > 0) {
|
||||
battery["source"] = "jbd_bms";
|
||||
} else {
|
||||
if (appConfig.bms.enabled && appConfig.bms.address.length() > 0) {
|
||||
battery["source"] = "jbd_bms";
|
||||
} else {
|
||||
battery["source"] = "unconfigured";
|
||||
}
|
||||
}
|
||||
battery["connected"] = false;
|
||||
battery["soc"] = 0;
|
||||
battery["voltage"] = 0;
|
||||
|
||||
Reference in New Issue
Block a user