ArduinoJson 7 update

This commit is contained in:
Ricardo Guzman (Richonguzman)
2026-03-10 23:10:04 -03:00
parent 3810821f45
commit f87a89213f
3 changed files with 92 additions and 93 deletions

View File

@@ -32,7 +32,7 @@ lib_deps =
adafruit/Adafruit Si7021 Library @ 1.5.3 adafruit/Adafruit Si7021 Library @ 1.5.3
arduino-libraries/NTPClient @ 3.2.1 arduino-libraries/NTPClient @ 3.2.1
ayushsharma82/ElegantOTA @ 3.1.7 ayushsharma82/ElegantOTA @ 3.1.7
bblanchon/ArduinoJson @ 6.21.3 bblanchon/ArduinoJson @ 7.4.2
jgromes/RadioLib @ 7.6.0 jgromes/RadioLib @ 7.6.0
knolleary/PubSubClient @ 2.8 knolleary/PubSubClient @ 2.8
ESP32Async/AsyncTCP @ 3.4.10 ESP32Async/AsyncTCP @ 3.4.10

View File

@@ -68,8 +68,8 @@ ___________________________________________________________________*/
#endif #endif
String versionDate = "2026-03-10"; String versionDate = "2026-03-11";
String versionNumber = "3.2.105"; String versionNumber = "3.2.107";
Configuration Config; Configuration Config;
WiFiClient aprsIsClient; WiFiClient aprsIsClient;
WiFiClient mqttClient; WiFiClient mqttClient;

View File

@@ -29,7 +29,7 @@ bool shouldSleepStop = true;
bool Configuration::writeFile() { bool Configuration::writeFile() {
Serial.println("Saving configuration..."); Serial.println("Saving configuration...");
DynamicJsonDocument data(3584); JsonDocument data;
File configFile = SPIFFS.open("/igate_conf.json", "w"); File configFile = SPIFFS.open("/igate_conf.json", "w");
if (!configFile) { if (!configFile) {
@@ -196,8 +196,7 @@ bool Configuration::readFile() {
if (configFile) { if (configFile) {
bool needsRewrite = false; bool needsRewrite = false;
StaticJsonDocument<3584> data; JsonDocument data;
DeserializationError error = deserializeJson(data, configFile); DeserializationError error = deserializeJson(data, configFile);
if (error) { if (error) {
Serial.println("Failed to read file, using default configuration"); Serial.println("Failed to read file, using default configuration");
@@ -212,28 +211,28 @@ bool Configuration::readFile() {
wifiAPs.push_back(wifiap); wifiAPs.push_back(wifiap);
} }
if (!data["other"].containsKey("startupDelay")) needsRewrite = true; if (data["other"]["startupDelay"].isNull()) needsRewrite = true;
startupDelay = data["other"]["startupDelay"] | 0; startupDelay = data["other"]["startupDelay"] | 0;
if (!data["wifi"]["autoAP"].containsKey("enabled") || if (data["wifi"]["autoAP"]["enabled"].isNull() ||
!data["wifi"]["autoAP"].containsKey("password") || data["wifi"]["autoAP"]["password"].isNull() ||
!data["wifi"]["autoAP"].containsKey("timeout")) needsRewrite = true; data["wifi"]["autoAP"]["timeout"].isNull()) needsRewrite = true;
wifiAutoAP.enabled = data["wifi"]["autoAP"]["enabled"] | true; wifiAutoAP.enabled = data["wifi"]["autoAP"]["enabled"] | true;
wifiAutoAP.password = data["wifi"]["autoAP"]["password"] | "1234567890"; wifiAutoAP.password = data["wifi"]["autoAP"]["password"] | "1234567890";
wifiAutoAP.timeout = data["wifi"]["autoAP"]["timeout"] | 10; wifiAutoAP.timeout = data["wifi"]["autoAP"]["timeout"] | 10;
if (!data.containsKey("callsign")) needsRewrite = true; if (data["callsign"].isNull()) needsRewrite = true;
callsign = data["callsign"] | "NOCALL-10"; callsign = data["callsign"] | "NOCALL-10";
if (!data.containsKey("tacticalCallsign")) needsRewrite = true; if (data["tacticalCallsign"].isNull()) needsRewrite = true;
tacticalCallsign = data["tacticalCallsign"] | ""; tacticalCallsign = data["tacticalCallsign"] | "";
if (!data["aprs_is"].containsKey("active") || if (data["aprs_is"]["active"].isNull() ||
!data["aprs_is"].containsKey("passcode") || data["aprs_is"]["passcode"].isNull() ||
!data["aprs_is"].containsKey("server") || data["aprs_is"]["server"].isNull() ||
!data["aprs_is"].containsKey("port") || data["aprs_is"]["port"].isNull() ||
!data["aprs_is"].containsKey("filter") || data["aprs_is"]["filter"].isNull() ||
!data["aprs_is"].containsKey("messagesToRF") || data["aprs_is"]["messagesToRF"].isNull() ||
!data["aprs_is"].containsKey("objectsToRF")) needsRewrite = true; data["aprs_is"]["objectsToRF"].isNull()) needsRewrite = true;
aprs_is.active = data["aprs_is"]["active"] | false; aprs_is.active = data["aprs_is"]["active"] | false;
aprs_is.passcode = data["aprs_is"]["passcode"] | "XYZWV"; aprs_is.passcode = data["aprs_is"]["passcode"] | "XYZWV";
aprs_is.server = data["aprs_is"]["server"] | "rotate.aprs2.net"; aprs_is.server = data["aprs_is"]["server"] | "rotate.aprs2.net";
@@ -242,20 +241,20 @@ bool Configuration::readFile() {
aprs_is.messagesToRF = data["aprs_is"]["messagesToRF"] | false; aprs_is.messagesToRF = data["aprs_is"]["messagesToRF"] | false;
aprs_is.objectsToRF = data["aprs_is"]["objectsToRF"] | false; aprs_is.objectsToRF = data["aprs_is"]["objectsToRF"] | false;
if (!data["beacon"].containsKey("latitude") || if (data["beacon"]["latitude"].isNull() ||
!data["beacon"].containsKey("longitude") || data["beacon"]["longitude"].isNull() ||
!data["beacon"].containsKey("comment") || data["beacon"]["comment"].isNull() ||
!data["beacon"].containsKey("interval") || data["beacon"]["interval"].isNull() ||
!data["beacon"].containsKey("overlay") || data["beacon"]["overlay"].isNull() ||
!data["beacon"].containsKey("symbol") || data["beacon"]["symbol"].isNull() ||
!data["beacon"].containsKey("path") || data["beacon"]["path"].isNull() ||
!data["beacon"].containsKey("sendViaAPRSIS") || data["beacon"]["sendViaAPRSIS"].isNull() ||
!data["beacon"].containsKey("sendViaRF") || data["beacon"]["sendViaRF"].isNull() ||
!data["beacon"].containsKey("beaconFreq") || data["beacon"]["beaconFreq"].isNull() ||
!data["beacon"].containsKey("statusActive") || data["beacon"]["statusActive"].isNull() ||
!data["beacon"].containsKey("statusPacket") || data["beacon"]["statusPacket"].isNull() ||
!data["beacon"].containsKey("gpsActive") || data["beacon"]["gpsActive"].isNull() ||
!data["beacon"].containsKey("ambiguityLevel")) needsRewrite = true; data["beacon"]["ambiguityLevel"].isNull()) needsRewrite = true;
beacon.latitude = data["beacon"]["latitude"] | 0.0; beacon.latitude = data["beacon"]["latitude"] | 0.0;
beacon.longitude = data["beacon"]["longitude"] | 0.0; beacon.longitude = data["beacon"]["longitude"] | 0.0;
beacon.comment = data["beacon"]["comment"] | "LoRa APRS"; beacon.comment = data["beacon"]["comment"] | "LoRa APRS";
@@ -271,15 +270,15 @@ bool Configuration::readFile() {
beacon.gpsActive = data["beacon"]["gpsActive"] | false; beacon.gpsActive = data["beacon"]["gpsActive"] | false;
beacon.ambiguityLevel = data["beacon"]["ambiguityLevel"] | 0; beacon.ambiguityLevel = data["beacon"]["ambiguityLevel"] | 0;
if (!data.containsKey("personalNote")) needsRewrite = true; if (data["personalNote"].isNull()) needsRewrite = true;
personalNote = data["personalNote"] | "personal note here"; personalNote = data["personalNote"] | "personal note here";
if (!data.containsKey("blacklist")) needsRewrite = true; if (data["blacklist"].isNull()) needsRewrite = true;
blacklist = data["blacklist"] | "station callsign"; blacklist = data["blacklist"] | "station callsign";
if (!data["digi"].containsKey("mode") || if (data["digi"]["mode"].isNull() ||
!data["digi"].containsKey("ecoMode") || data["digi"]["ecoMode"].isNull() ||
!data["digi"].containsKey("backupDigiMode")) needsRewrite = true; data["digi"]["backupDigiMode"].isNull()) needsRewrite = true;
digi.mode = data["digi"]["mode"] | 0; digi.mode = data["digi"]["mode"] | 0;
digi.ecoMode = data["digi"]["ecoMode"] | 0; digi.ecoMode = data["digi"]["ecoMode"] | 0;
if (digi.ecoMode == 1) shouldSleepStop = false; if (digi.ecoMode == 1) shouldSleepStop = false;
@@ -289,17 +288,17 @@ bool Configuration::readFile() {
digi.backupDigiMode = data["digi"]["backupDigiMode"] | false; digi.backupDigiMode = data["digi"]["backupDigiMode"] | false;
if (!data["lora"].containsKey("rxActive") || if (data["lora"]["rxActive"].isNull() ||
!data["lora"].containsKey("rxFreq") || data["lora"]["rxFreq"].isNull() ||
!data["lora"].containsKey("rxSpreadingFactor") || data["lora"]["rxSpreadingFactor"].isNull() ||
!data["lora"].containsKey("rxCodingRate4") || data["lora"]["rxCodingRate4"].isNull() ||
!data["lora"].containsKey("rxSignalBandwidth") || data["lora"]["rxSignalBandwidth"].isNull() ||
!data["lora"].containsKey("txActive") || data["lora"]["txActive"].isNull() ||
!data["lora"].containsKey("txFreq") || data["lora"]["txFreq"].isNull() ||
!data["lora"].containsKey("txSpreadingFactor") || data["lora"]["txSpreadingFactor"].isNull() ||
!data["lora"].containsKey("txCodingRate4") || data["lora"]["txCodingRate4"].isNull() ||
!data["lora"].containsKey("txSignalBandwidth") || data["lora"]["txSignalBandwidth"].isNull() ||
!data["lora"].containsKey("power")) needsRewrite = true; data["lora"]["power"].isNull()) needsRewrite = true;
loramodule.rxActive = data["lora"]["rxActive"] | true; loramodule.rxActive = data["lora"]["rxActive"] | true;
loramodule.rxFreq = data["lora"]["rxFreq"] | 433775000; loramodule.rxFreq = data["lora"]["rxFreq"] | 433775000;
loramodule.rxSpreadingFactor = data["lora"]["rxSpreadingFactor"] | 12; loramodule.rxSpreadingFactor = data["lora"]["rxSpreadingFactor"] | 12;
@@ -312,9 +311,9 @@ bool Configuration::readFile() {
loramodule.txSignalBandwidth = data["lora"]["txSignalBandwidth"] | 125000; loramodule.txSignalBandwidth = data["lora"]["txSignalBandwidth"] | 125000;
loramodule.power = data["lora"]["power"] | 20; loramodule.power = data["lora"]["power"] | 20;
if (!data["display"].containsKey("alwaysOn") || if (data["display"]["alwaysOn"].isNull() ||
!data["display"].containsKey("timeout") || data["display"]["timeout"].isNull() ||
!data["display"].containsKey("turn180")) needsRewrite = true; data["display"]["turn180"].isNull()) needsRewrite = true;
#ifdef HAS_EPAPER #ifdef HAS_EPAPER
display.alwaysOn = true; display.alwaysOn = true;
#else #else
@@ -323,17 +322,17 @@ bool Configuration::readFile() {
display.timeout = data["display"]["timeout"] | 4; display.timeout = data["display"]["timeout"] | 4;
display.turn180 = data["display"]["turn180"] | false; display.turn180 = data["display"]["turn180"] | false;
if (!data["battery"].containsKey("sendInternalVoltage") || if (data["battery"]["sendInternalVoltage"].isNull() ||
!data["battery"].containsKey("monitorInternalVoltage") || data["battery"]["monitorInternalVoltage"].isNull() ||
!data["battery"].containsKey("internalSleepVoltage") || data["battery"]["internalSleepVoltage"].isNull() ||
!data["battery"].containsKey("sendExternalVoltage") || data["battery"]["sendExternalVoltage"].isNull() ||
!data["battery"].containsKey("monitorExternalVoltage") || data["battery"]["monitorExternalVoltage"].isNull() ||
!data["battery"].containsKey("externalSleepVoltage") || data["battery"]["externalSleepVoltage"].isNull() ||
!data["battery"].containsKey("useExternalI2CSensor") || data["battery"]["useExternalI2CSensor"].isNull() ||
!data["battery"].containsKey("voltageDividerR1") || data["battery"]["voltageDividerR1"].isNull() ||
!data["battery"].containsKey("voltageDividerR2") || data["battery"]["voltageDividerR2"].isNull() ||
!data["battery"].containsKey("externalVoltagePin") || data["battery"]["externalVoltagePin"].isNull() ||
!data["battery"].containsKey("sendVoltageAsTelemetry")) needsRewrite = true; data["battery"]["sendVoltageAsTelemetry"].isNull()) needsRewrite = true;
battery.sendInternalVoltage = data["battery"]["sendInternalVoltage"] | false; battery.sendInternalVoltage = data["battery"]["sendInternalVoltage"] | false;
battery.monitorInternalVoltage = data["battery"]["monitorInternalVoltage"] | false; battery.monitorInternalVoltage = data["battery"]["monitorInternalVoltage"] | false;
battery.internalSleepVoltage = data["battery"]["internalSleepVoltage"] | 2.9; battery.internalSleepVoltage = data["battery"]["internalSleepVoltage"] | 2.9;
@@ -346,38 +345,38 @@ bool Configuration::readFile() {
battery.externalVoltagePin = data["battery"]["externalVoltagePin"] | 34; battery.externalVoltagePin = data["battery"]["externalVoltagePin"] | 34;
battery.sendVoltageAsTelemetry = data["battery"]["sendVoltageAsTelemetry"] | false; battery.sendVoltageAsTelemetry = data["battery"]["sendVoltageAsTelemetry"] | false;
if (!data["wxsensor"].containsKey("active") || if (data["wxsensor"]["active"].isNull() ||
!data["wxsensor"].containsKey("heightCorrection") || data["wxsensor"]["heightCorrection"].isNull() ||
!data["wxsensor"].containsKey("temperatureCorrection")) needsRewrite = true; data["wxsensor"]["temperatureCorrection"].isNull()) needsRewrite = true;
wxsensor.active = data["wxsensor"]["active"] | false; wxsensor.active = data["wxsensor"]["active"] | false;
wxsensor.heightCorrection = data["wxsensor"]["heightCorrection"] | 0; wxsensor.heightCorrection = data["wxsensor"]["heightCorrection"] | 0;
wxsensor.temperatureCorrection = data["wxsensor"]["temperatureCorrection"] | 0.0; wxsensor.temperatureCorrection = data["wxsensor"]["temperatureCorrection"] | 0.0;
if (!data["syslog"].containsKey("active") || if (data["syslog"]["active"].isNull() ||
!data["syslog"].containsKey("server") || data["syslog"]["server"].isNull() ||
!data["syslog"].containsKey("port") || data["syslog"]["port"].isNull() ||
!data["syslog"].containsKey("logBeaconOverTCPIP")) needsRewrite = true; data["syslog"]["logBeaconOverTCPIP"].isNull()) needsRewrite = true;
syslog.active = data["syslog"]["active"] | false; syslog.active = data["syslog"]["active"] | false;
syslog.server = data["syslog"]["server"] | "lora.link9.net"; syslog.server = data["syslog"]["server"] | "lora.link9.net";
syslog.port = data["syslog"]["port"] | 1514; syslog.port = data["syslog"]["port"] | 1514;
syslog.logBeaconOverTCPIP = data["syslog"]["logBeaconOverTCPIP"] | false; syslog.logBeaconOverTCPIP = data["syslog"]["logBeaconOverTCPIP"] | false;
if (!data["tnc"].containsKey("enableServer") || if (data["tnc"]["enableServer"].isNull() ||
!data["tnc"].containsKey("enableSerial") || data["tnc"]["enableSerial"].isNull() ||
!data["tnc"].containsKey("acceptOwn") || data["tnc"]["acceptOwn"].isNull() ||
!data["tnc"].containsKey("aprsBridgeActive")) needsRewrite = true; data["tnc"]["aprsBridgeActive"].isNull()) needsRewrite = true;
tnc.enableServer = data["tnc"]["enableServer"] | false; tnc.enableServer = data["tnc"]["enableServer"] | false;
tnc.enableSerial = data["tnc"]["enableSerial"] | false; tnc.enableSerial = data["tnc"]["enableSerial"] | false;
tnc.acceptOwn = data["tnc"]["acceptOwn"] | false; tnc.acceptOwn = data["tnc"]["acceptOwn"] | false;
tnc.aprsBridgeActive = data["tnc"]["aprsBridgeActive"] | false; tnc.aprsBridgeActive = data["tnc"]["aprsBridgeActive"] | false;
if (!data["mqtt"].containsKey("active") || if (data["mqtt"]["active"].isNull() ||
!data["mqtt"].containsKey("server") || data["mqtt"]["server"].isNull() ||
!data["mqtt"].containsKey("topic") || data["mqtt"]["topic"].isNull() ||
!data["mqtt"].containsKey("username") || data["mqtt"]["username"].isNull() ||
!data["mqtt"].containsKey("password") || data["mqtt"]["password"].isNull() ||
!data["mqtt"].containsKey("port") || data["mqtt"]["port"].isNull() ||
!data["mqtt"].containsKey("beaconOverMqtt")) needsRewrite = true; data["mqtt"]["beaconOverMqtt"].isNull()) needsRewrite = true;
mqtt.active = data["mqtt"]["active"] | false; mqtt.active = data["mqtt"]["active"] | false;
mqtt.server = data["mqtt"]["server"] | ""; mqtt.server = data["mqtt"]["server"] | "";
mqtt.topic = data["mqtt"]["topic"] | "aprs-igate"; mqtt.topic = data["mqtt"]["topic"] | "aprs-igate";
@@ -386,34 +385,34 @@ bool Configuration::readFile() {
mqtt.port = data["mqtt"]["port"] | 1883; mqtt.port = data["mqtt"]["port"] | 1883;
mqtt.beaconOverMqtt = data["mqtt"]["beaconOverMqtt"] | false; mqtt.beaconOverMqtt = data["mqtt"]["beaconOverMqtt"] | false;
if (!data["ota"].containsKey("username") || if (data["ota"]["username"].isNull() ||
!data["ota"].containsKey("password")) needsRewrite = true; data["ota"]["password"].isNull()) needsRewrite = true;
ota.username = data["ota"]["username"] | ""; ota.username = data["ota"]["username"] | "";
ota.password = data["ota"]["password"] | ""; ota.password = data["ota"]["password"] | "";
if (!data["webadmin"].containsKey("active") || if (data["webadmin"]["active"].isNull() ||
!data["webadmin"].containsKey("username") || data["webadmin"]["username"].isNull() ||
!data["webadmin"].containsKey("password")) needsRewrite = true; data["webadmin"]["password"].isNull()) needsRewrite = true;
webadmin.active = data["webadmin"]["active"] | false; webadmin.active = data["webadmin"]["active"] | false;
webadmin.username = data["webadmin"]["username"] | "admin"; webadmin.username = data["webadmin"]["username"] | "admin";
webadmin.password = data["webadmin"]["password"] | ""; webadmin.password = data["webadmin"]["password"] | "";
if (!data["remoteManagement"].containsKey("managers") || if (data["remoteManagement"]["managers"].isNull() ||
!data["remoteManagement"].containsKey("rfOnly")) needsRewrite = true; data["remoteManagement"]["rfOnly"].isNull()) needsRewrite = true;
remoteManagement.managers = data["remoteManagement"]["managers"] | ""; remoteManagement.managers = data["remoteManagement"]["managers"] | "";
remoteManagement.rfOnly = data["remoteManagement"]["rfOnly"] | true; remoteManagement.rfOnly = data["remoteManagement"]["rfOnly"] | true;
if (!data["ntp"].containsKey("server") || if (data["ntp"]["server"].isNull() ||
!data["ntp"].containsKey("gmtCorrection")) needsRewrite = true; data["ntp"]["gmtCorrection"].isNull()) needsRewrite = true;
ntp.server = data["ntp"]["server"] | "pool.ntp.org"; ntp.server = data["ntp"]["server"] | "pool.ntp.org";
ntp.gmtCorrection = data["ntp"]["gmtCorrection"] | 0.0; ntp.gmtCorrection = data["ntp"]["gmtCorrection"] | 0.0;
if (!data["other"].containsKey("rebootMode") || if (data["other"]["rebootMode"].isNull() ||
!data["other"].containsKey("rebootModeTime")) needsRewrite = true; data["other"]["rebootModeTime"].isNull()) needsRewrite = true;
rebootMode = data["other"]["rebootMode"] | false; rebootMode = data["other"]["rebootMode"] | false;
rebootModeTime = data["other"]["rebootModeTime"] | 6; rebootModeTime = data["other"]["rebootModeTime"] | 6;
if (!data["other"].containsKey("rememberStationTime")) needsRewrite = true; if (data["other"]["rememberStationTime"].isNull()) needsRewrite = true;
rememberStationTime = data["other"]["rememberStationTime"] | 30; rememberStationTime = data["other"]["rememberStationTime"] | 30;
if (wifiAPs.size() == 0) { // If we don't have any WiFi's from config we need to add "empty" SSID for AUTO AP if (wifiAPs.size() == 0) { // If we don't have any WiFi's from config we need to add "empty" SSID for AUTO AP