Add ESP32 alarms system status and debug commands

This commit is contained in:
2026-06-04 00:59:51 -06:00
parent d971afde96
commit 817db651ce
5 changed files with 111 additions and 0 deletions
+15
View File
@@ -64,9 +64,19 @@ static void handleNotify(
static bool connectBms() {
if (client && client->isConnected()) {
bmsData.connected = true;
return true;
}
if (client && !client->isConnected()) {
Serial.println("BMS: Disconnected, resetting client");
NimBLEDevice::deleteClient(client);
client = nullptr;
notifyChar = nullptr;
writeChar = nullptr;
bmsData.connected = false;
}
Serial.println("BMS: Connecting...");
NimBLEAddress address(std::string(BMS_ADDRESS), BLE_ADDR_PUBLIC);
@@ -76,6 +86,8 @@ static bool connectBms() {
if (!client->connect(address)) {
Serial.println("BMS: Connect failed");
bmsData.connected = false;
NimBLEDevice::deleteClient(client);
client = nullptr;
return false;
}
@@ -116,6 +128,9 @@ static bool requestPacket(uint8_t* command, size_t commandLength) {
if (!ok) {
Serial.println("BMS: Write failed");
bmsData.connected = false;
if (client) {
client->disconnect();
}
return false;
}