Add configurable system defaults
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
#include "bms.h"
|
||||
#include "alarms.h"
|
||||
#include "system_status.h"
|
||||
#include "app_config.h"
|
||||
|
||||
WebServer server(80);
|
||||
HardwareSerial DashboardSerial(2);
|
||||
@@ -131,6 +132,33 @@ void buildStatusDocument(JsonDocument& doc) {
|
||||
system["build_date"] = __DATE__;
|
||||
system["build_time"] = __TIME__;
|
||||
system["uptime_seconds"] = millis() / 1000;
|
||||
|
||||
JsonObject configObj = doc.createNestedObject("config");
|
||||
configObj["device_name"] = appConfig.deviceName;
|
||||
|
||||
JsonArray configRelays = configObj.createNestedArray("relays");
|
||||
for (int i = 0; i < MAX_RELAYS; i++) {
|
||||
JsonObject relayConfig = configRelays.createNestedObject();
|
||||
relayConfig["id"] = appConfig.relays[i].id;
|
||||
relayConfig["name"] = appConfig.relays[i].name;
|
||||
relayConfig["pin"] = appConfig.relays[i].pin;
|
||||
relayConfig["enabled"] = appConfig.relays[i].enabled;
|
||||
}
|
||||
|
||||
JsonObject bmsConfig = configObj.createNestedObject("bms");
|
||||
bmsConfig["enabled"] = appConfig.bms.enabled;
|
||||
bmsConfig["name"] = appConfig.bms.name;
|
||||
bmsConfig["address"] = appConfig.bms.address;
|
||||
bmsConfig["address_type"] = appConfig.bms.addressType;
|
||||
|
||||
JsonArray tempConfigs = configObj.createNestedArray("temperature_sensors");
|
||||
for (int i = 0; i < MAX_TEMP_SENSORS; i++) {
|
||||
JsonObject tempConfig = tempConfigs.createNestedObject();
|
||||
tempConfig["id"] = appConfig.tempSensors[i].id;
|
||||
tempConfig["name"] = appConfig.tempSensors[i].name;
|
||||
tempConfig["address"] = appConfig.tempSensors[i].address;
|
||||
tempConfig["enabled"] = appConfig.tempSensors[i].enabled;
|
||||
}
|
||||
}
|
||||
|
||||
void sendStatus(Stream& output, bool pretty = false) {
|
||||
@@ -333,9 +361,15 @@ void setup() {
|
||||
|
||||
Serial.println();
|
||||
Serial.println("==================================");
|
||||
|
||||
loadDefaultConfig();
|
||||
printConfig();
|
||||
Serial.println("Xterra Controller Booting");
|
||||
Serial.println("==================================");
|
||||
|
||||
loadDefaultConfig();
|
||||
printConfig();
|
||||
|
||||
pinMode(IGNITION_PIN, INPUT);
|
||||
|
||||
initRelays();
|
||||
|
||||
Reference in New Issue
Block a user