diff --git a/data/igate_conf.json b/data/igate_conf.json
index 40024b6..f1d6324 100644
--- a/data/igate_conf.json
+++ b/data/igate_conf.json
@@ -45,10 +45,15 @@
"timeout": 4,
"turn180": false
},
+ "battery": {
+ "sendBatteryVoltage": false,
+ "externalVoltageMeasurement": false,
+ "externalVoltagePin": 34
+ },
"bme": {
- "active": false,
- "heightCorrection": 0,
- "temperatureCorrection": 0.0
+ "active": false,
+ "heightCorrection": 0,
+ "temperatureCorrection": 0.0
},
"syslog": {
"active": false,
@@ -66,9 +71,6 @@
},
"other": {
"rememberStationTime": 30,
- "sendBatteryVoltage": false,
- "externalVoltageMeasurement": false,
- "externalVoltagePin": 34,
"lowPowerMode": false,
"lowVoltageCutOff": 0,
"backupDigiMode": false,
diff --git a/data_embed/index.html b/data_embed/index.html
index ce5753a..cf5c3c6 100644
--- a/data_embed/index.html
+++ b/data_embed/index.html
@@ -529,12 +529,12 @@
diff --git a/data_embed/script.js b/data_embed/script.js
index d3a285a..33b2b33 100644
--- a/data_embed/script.js
+++ b/data_embed/script.js
@@ -164,7 +164,7 @@ function loadSettings(settings) {
// Beacon
document.getElementById("beacon.interval").value = settings.beacon.interval;
document.getElementById("other.rememberStationTime").value = settings.other.rememberStationTime;
- document.getElementById("other.sendBatteryVoltage").checked = settings.other.sendBatteryVoltage;
+ document.getElementById("battery.sendBatteryVoltage").checked = settings.battery.sendBatteryVoltage;
document.getElementById("other.externalVoltageMeasurement").checked = settings.other.externalVoltageMeasurement;
document.getElementById("other.externalVoltagePin").value = settings.other.externalVoltagePin;
// document.getElementById("beacon.igateSendsLoRaBeacon").value = settings.beacon.igateSendsLoRaBeacon;
diff --git a/src/LoRa_APRS_iGate.cpp b/src/LoRa_APRS_iGate.cpp
index c5e514e..8b4c715 100644
--- a/src/LoRa_APRS_iGate.cpp
+++ b/src/LoRa_APRS_iGate.cpp
@@ -37,7 +37,7 @@ ________________________________________________________________________________
#include "A7670_utils.h"
#endif
-String versionDate = "2024.05.22";
+String versionDate = "2024.05.23";
Configuration Config;
WiFiClient espClient;
@@ -94,8 +94,8 @@ void setup() {
if (lastBeacon == 0 || time - lastBeacon >= Config.beacon.interval * 60) {
Serial.println("Sending beacon");
String comment = Config.beacon.comment;
- if (Config.sendBatteryVoltage) comment += " Batt=" + String(BATTERY_Utils::checkBattery(),2) + "V";
- if (Config.externalVoltageMeasurement) comment += " Ext=" + String(BATTERY_Utils::checkExternalVoltage(),2) + "V";
+ if (Config.battery.sendBatteryVoltage) comment += " Batt=" + String(BATTERY_Utils::checkBattery(),2) + "V";
+ if (Config.battery.externalVoltageMeasurement) comment += " Ext=" + String(BATTERY_Utils::checkExternalVoltage(),2) + "V";
STATION_Utils::addToOutputPacketBuffer(GPS_Utils::getiGateLoRaBeaconPacket() + comment);
lastBeacon = time;
}
diff --git a/src/battery_utils.cpp b/src/battery_utils.cpp
index 5b53568..6f44c5e 100644
--- a/src/battery_utils.cpp
+++ b/src/battery_utils.cpp
@@ -64,7 +64,7 @@ namespace BATTERY_Utils {
int sample;
int sampleSum = 0;
for (int i = 0; i < 100; i++) {
- sample = analogRead(Config.externalVoltagePin);
+ sample = analogRead(Config.battery.externalVoltagePin);
sampleSum += sample;
delayMicroseconds(50);
}
diff --git a/src/configuration.cpp b/src/configuration.cpp
index d6c9da1..2a49eca 100644
--- a/src/configuration.cpp
+++ b/src/configuration.cpp
@@ -17,7 +17,7 @@ void Configuration::check() {
void Configuration::writeFile() {
Serial.println("Saving config..");
- StaticJsonDocument<2048> data;
+ StaticJsonDocument<2560> data;
File configFile = SPIFFS.open("/igate_conf.json", "w");
if (wifiAPs[0].ssid != "") { // We don't want to save Auto AP empty SSID
@@ -40,9 +40,9 @@ void Configuration::writeFile() {
// data["other"]["igateSendsLoRaBeacons"] = igateSendsLoRaBeacons;
// data["other"]["igateRepeatsLoRaPackets"] = igateRepeatsLoRaPackets;
data["other"]["rememberStationTime"] = rememberStationTime;
- data["other"]["sendBatteryVoltage"] = sendBatteryVoltage;
- data["other"]["externalVoltageMeasurement"] = externalVoltageMeasurement;
- data["other"]["externalVoltagePin"] = externalVoltagePin;
+ data["battery"]["sendBatteryVoltage"] = battery.sendBatteryVoltage;
+ data["battery"]["externalVoltageMeasurement"] = battery.externalVoltageMeasurement;
+ data["battery"]["externalVoltagePin"] = battery.externalVoltagePin;
data["digi"]["mode"] = digi.mode;
// data["digi"]["comment"] = digi.comment;
@@ -123,7 +123,7 @@ bool Configuration::readFile() {
File configFile = SPIFFS.open("/igate_conf.json", "r");
if (configFile) {
- StaticJsonDocument<2048> data;
+ StaticJsonDocument<2560> data;
DeserializationError error = deserializeJson(data, configFile);
if (error) {
@@ -144,9 +144,14 @@ bool Configuration::readFile() {
callsign = data["callsign"].as();
rememberStationTime = data["other"]["rememberStationTime"].as();
- sendBatteryVoltage = data["other"]["sendBatteryVoltage"].as();
+
+ /*sendBatteryVoltage = data["other"]["sendBatteryVoltage"].as();
externalVoltageMeasurement = data["other"]["externalVoltageMeasurement"].as();
- externalVoltagePin = data["other"]["externalVoltagePin"].as();
+ externalVoltagePin = data["other"]["externalVoltagePin"].as();*/
+
+ battery.sendBatteryVoltage = data["battery"]["sendBatteryVoltage"].as();
+ battery.externalVoltageMeasurement = data["battery"]["externalVoltageMeasurement"].as();
+ battery.externalVoltagePin = data["battery"]["externalVoltagePin"].as();
aprs_is.passcode = data["aprs_is"]["passcode"].as();
aprs_is.server = data["aprs_is"]["server"].as();
@@ -357,9 +362,13 @@ void Configuration::init() {
// igateSendsLoRaBeacons = false; // deprecated
// igateRepeatsLoRaPackets = false; // deprecated
rememberStationTime = 30;
- sendBatteryVoltage = false;
+ /*sendBatteryVoltage = false;
externalVoltageMeasurement = false;
- externalVoltagePin = 34;
+ externalVoltagePin = 34;*/
+
+ battery.sendBatteryVoltage = false;
+ battery.externalVoltageMeasurement = false;
+ battery.externalVoltagePin = 34;
lowPowerMode = false;
lowVoltageCutOff = 0;
diff --git a/src/configuration.h b/src/configuration.h
index 2816876..a281677 100644
--- a/src/configuration.h
+++ b/src/configuration.h
@@ -17,7 +17,7 @@ public:
int powerOff;
};
-class Beacon {
+class BEACON {
public:
double latitude;
double longitude;
@@ -66,6 +66,13 @@ public:
bool turn180;
};
+class BATTERY {
+public:
+ bool sendBatteryVoltage;
+ bool externalVoltageMeasurement;
+ int externalVoltagePin;
+};
+
class BME {
public:
bool active;
@@ -98,9 +105,9 @@ public:
bool reload; // ?
String callsign;
int rememberStationTime;
- bool sendBatteryVoltage;
+ /*bool sendBatteryVoltage;
bool externalVoltageMeasurement;
- int externalVoltagePin;
+ int externalVoltagePin;*/
bool lowPowerMode;
double lowVoltageCutOff;
bool backupDigiMode;
@@ -108,14 +115,15 @@ public:
int rebootModeTime;
std::vector wifiAPs;
WiFi_Auto_AP wifiAutoAP;
- Beacon beacon;
- DIGI digi;
- TNC tnc;
+ BEACON beacon;
APRS_IS aprs_is;
+ DIGI digi;
LoraModule loramodule;
Display display;
- SYSLOG syslog;
+ BATTERY battery;
BME bme;
+ SYSLOG syslog;
+ TNC tnc;
OTA ota;
void init();
diff --git a/src/power_utils.cpp b/src/power_utils.cpp
index 17a382d..4b2f448 100644
--- a/src/power_utils.cpp
+++ b/src/power_utils.cpp
@@ -128,8 +128,8 @@ namespace POWER_Utils {
pinMode(INTERNAL_LED_PIN, OUTPUT);
#endif
- if (Config.externalVoltageMeasurement) {
- pinMode(Config.externalVoltagePin, INPUT);
+ if (Config.battery.externalVoltageMeasurement) {
+ pinMode(Config.battery.externalVoltagePin, INPUT);
}
#ifdef VEXT_CTRL
diff --git a/src/utils.cpp b/src/utils.cpp
index 9587af6..431a45e 100644
--- a/src/utils.cpp
+++ b/src/utils.cpp
@@ -122,7 +122,7 @@ namespace Utils {
secondaryBeaconPacket += Config.beacon.comment;
#ifdef BATTERY_PIN
- if (Config.sendBatteryVoltage) {
+ if (Config.battery.sendBatteryVoltage) {
String batteryInfo = "Batt=" + String(BATTERY_Utils::checkBattery(),2) + "V";
beaconPacket += " " + batteryInfo;
secondaryBeaconPacket += " " + batteryInfo;
@@ -130,7 +130,7 @@ namespace Utils {
}
#endif
- if (Config.externalVoltageMeasurement) {
+ if (Config.battery.externalVoltageMeasurement) {
String externalVoltage = String(BATTERY_Utils::checkExternalVoltage(),2) + "V";
beaconPacket += " Ext=" + externalVoltage;
secondaryBeaconPacket += " Ext=" + externalVoltage;
diff --git a/src/web_utils.cpp b/src/web_utils.cpp
index 27ab67a..688faf4 100644
--- a/src/web_utils.cpp
+++ b/src/web_utils.cpp
@@ -157,10 +157,10 @@ namespace WEB_Utils {
Config.ota.password = request->getParam("ota.password", true)->value();
Config.rememberStationTime = request->getParam("other.rememberStationTime", true)->value().toInt();
- Config.sendBatteryVoltage = request->hasParam("other.sendBatteryVoltage", true);
- Config.externalVoltageMeasurement = request->hasParam("other.externalVoltageMeasurement", true);
- if (Config.externalVoltageMeasurement) {
- Config.externalVoltagePin = request->getParam("other.externalVoltagePin", true)->value().toInt();
+ Config.battery.sendBatteryVoltage = request->hasParam("battery.sendBatteryVoltage", true);
+ Config.battery.externalVoltageMeasurement = request->hasParam("battery.externalVoltageMeasurement", true);
+ if (Config.battery.externalVoltageMeasurement) {
+ Config.battery.externalVoltagePin = request->getParam("battery.externalVoltagePin", true)->value().toInt();
}
Config.backupDigiMode = request->hasParam("other.backupDigiMode", true);