mirror of
https://github.com/richonguzman/LoRa_APRS_iGate.git
synced 2026-04-06 06:55:07 +00:00
feat: stationMode removed
This commit is contained in:
parent
8a7d91a7f6
commit
a46a97691d
22 changed files with 991 additions and 700 deletions
|
|
@ -3,6 +3,15 @@
|
|||
#include "configuration.h"
|
||||
#include "display.h"
|
||||
|
||||
void Configuration::check() {
|
||||
if (reload) {
|
||||
show_display("------- UPDATE ------", "config is old", "device will update", "and then reboot", 1000);
|
||||
|
||||
writeFile();
|
||||
|
||||
ESP.restart();
|
||||
}
|
||||
}
|
||||
|
||||
void Configuration::writeFile() {
|
||||
Serial.println("Saving config..");
|
||||
|
|
@ -14,8 +23,8 @@ void Configuration::writeFile() {
|
|||
for (int i = 0; i < wifiAPs.size(); i++) {
|
||||
data["wifi"]["AP"][i]["ssid"] = wifiAPs[i].ssid;
|
||||
data["wifi"]["AP"][i]["password"] = wifiAPs[i].password;
|
||||
data["wifi"]["AP"][i]["latitude"] = wifiAPs[i].latitude;
|
||||
data["wifi"]["AP"][i]["longitude"] = wifiAPs[i].longitude;
|
||||
// data["wifi"]["AP"][i]["latitude"] = wifiAPs[i].latitude;
|
||||
// data["wifi"]["AP"][i]["longitude"] = wifiAPs[i].longitude;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -23,33 +32,52 @@ void Configuration::writeFile() {
|
|||
data["wifi"]["autoAP"]["powerOff"] = wifiAutoAP.powerOff;
|
||||
|
||||
data["callsign"] = callsign;
|
||||
data["stationMode"] = stationMode;
|
||||
data["iGateComment"] = iGateComment;
|
||||
// data["stationMode"] = stationMode; // only check for config version
|
||||
// data["iGateComment"] = iGateComment;
|
||||
|
||||
data["other"]["beaconInterval"] = beaconInterval;
|
||||
data["other"]["igateSendsLoRaBeacons"] = igateSendsLoRaBeacons;
|
||||
data["other"]["igateRepeatsLoRaPackets"] = igateRepeatsLoRaPackets;
|
||||
// data["other"]["beaconInterval"] = beaconInterval;
|
||||
// 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["digi"]["comment"] = digi.comment;
|
||||
data["digi"]["latitude"] = digi.latitude;
|
||||
data["digi"]["longitude"] = digi.longitude;
|
||||
data["digi"]["mode"] = digi.mode;
|
||||
// data["digi"]["comment"] = digi.comment;
|
||||
// data["digi"]["latitude"] = digi.latitude;
|
||||
// data["digi"]["longitude"] = digi.longitude;
|
||||
|
||||
data["aprs_is"]["active"] = aprs_is.active;
|
||||
data["aprs_is"]["passcode"] = aprs_is.passcode;
|
||||
data["aprs_is"]["server"] = aprs_is.server;
|
||||
data["aprs_is"]["port"] = aprs_is.port;
|
||||
data["aprs_is"]["reportingDistance"] = aprs_is.reportingDistance;
|
||||
data["aprs_is"]["filter"] = aprs_is.filter;
|
||||
data["aprs_is"]["toRF"] = aprs_is.toRF;
|
||||
|
||||
data["lora"]["iGateFreq"] = loramodule.iGateFreq;
|
||||
data["lora"]["digirepeaterTxFreq"] = loramodule.digirepeaterTxFreq;
|
||||
data["lora"]["digirepeaterRxFreq"] = loramodule.digirepeaterRxFreq;
|
||||
data["beacon"]["comment"] = beacon.comment;
|
||||
// data["beacon"]["igateRepeatsLoRaPackets"] = beacon.igateRepeatsLoRaPackets;
|
||||
// data["beacon"]["igateSendsLoRaBeacons"] = beacon.igateSendsLoRaBeacons;
|
||||
data["beacon"]["interval"] = beacon.interval;
|
||||
data["beacon"]["latitude"] = beacon.latitude;
|
||||
data["beacon"]["longitude"] = beacon.longitude;
|
||||
data["beacon"]["overlay"] = beacon.overlay;
|
||||
data["beacon"]["symbol"] = beacon.symbol;
|
||||
data["beacon"]["sendViaAPRSIS"] = beacon.sendViaAPRSIS;
|
||||
data["beacon"]["sendViaRF"] = beacon.sendViaRF;
|
||||
data["beacon"]["path"] = beacon.path;
|
||||
|
||||
// data["lora"]["iGateFreq"] = loramodule.iGateFreq;
|
||||
// data["lora"]["digirepeaterTxFreq"] = loramodule.digirepeaterTxFreq;
|
||||
// data["lora"]["digirepeaterRxFreq"] = loramodule.digirepeaterRxFreq;
|
||||
data["lora"]["rxFreq"] = loramodule.rxFreq;
|
||||
data["lora"]["txFreq"] = loramodule.txFreq;
|
||||
data["lora"]["spreadingFactor"] = loramodule.spreadingFactor;
|
||||
data["lora"]["signalBandwidth"] = loramodule.signalBandwidth;
|
||||
data["lora"]["codingRate4"] = loramodule.codingRate4;
|
||||
data["lora"]["power"] = loramodule.power;
|
||||
data["lora"]["txActive"] = loramodule.txActive;
|
||||
data["lora"]["rxActive"] = loramodule.rxActive;
|
||||
|
||||
data["display"]["alwaysOn"] = display.alwaysOn;
|
||||
data["display"]["timeout"] = display.timeout;
|
||||
|
|
@ -63,7 +91,7 @@ void Configuration::writeFile() {
|
|||
|
||||
data["ota"]["username"] = ota.username;
|
||||
data["ota"]["password"] = ota.password;
|
||||
|
||||
|
||||
serializeJson(data, configFile);
|
||||
|
||||
configFile.close();
|
||||
|
|
@ -89,8 +117,6 @@ bool Configuration::readFile() {
|
|||
WiFi_AP wifiap;
|
||||
wifiap.ssid = WiFiArray[i]["ssid"].as<String>();
|
||||
wifiap.password = WiFiArray[i]["password"].as<String>();
|
||||
wifiap.latitude = WiFiArray[i]["latitude"].as<double>();
|
||||
wifiap.longitude = WiFiArray[i]["longitude"].as<double>();
|
||||
|
||||
wifiAPs.push_back(wifiap);
|
||||
}
|
||||
|
|
@ -99,28 +125,15 @@ bool Configuration::readFile() {
|
|||
wifiAutoAP.powerOff = data["wifi"]["autoAP"]["powerOff"].as<int>();
|
||||
|
||||
callsign = data["callsign"].as<String>();
|
||||
stationMode = data["stationMode"].as<int>();
|
||||
iGateComment = data["iGateComment"].as<String>();
|
||||
beaconInterval = data["other"]["beaconInterval"].as<int>();
|
||||
igateSendsLoRaBeacons = data["other"]["igateSendsLoRaBeacons"].as<bool>();
|
||||
igateRepeatsLoRaPackets = data["other"]["igateRepeatsLoRaPackets"].as<bool>();
|
||||
rememberStationTime = data["other"]["rememberStationTime"].as<int>();
|
||||
sendBatteryVoltage = data["other"]["sendBatteryVoltage"].as<bool>();
|
||||
externalVoltageMeasurement = data["other"]["externalVoltageMeasurement"].as<bool>();
|
||||
externalVoltagePin = data["other"]["externalVoltagePin"].as<int>();
|
||||
|
||||
digi.comment = data["digi"]["comment"].as<String>();
|
||||
digi.latitude = data["digi"]["latitude"].as<double>();
|
||||
digi.longitude = data["digi"]["longitude"].as<double>();
|
||||
|
||||
aprs_is.passcode = data["aprs_is"]["passcode"].as<String>();
|
||||
aprs_is.server = data["aprs_is"]["server"].as<String>();
|
||||
aprs_is.port = data["aprs_is"]["port"].as<int>();
|
||||
aprs_is.reportingDistance = data["aprs_is"]["reportingDistance"].as<int>();
|
||||
|
||||
loramodule.iGateFreq = data["lora"]["iGateFreq"].as<long>();
|
||||
loramodule.digirepeaterTxFreq = data["lora"]["digirepeaterTxFreq"].as<long>();
|
||||
loramodule.digirepeaterRxFreq = data["lora"]["digirepeaterRxFreq"].as<long>();
|
||||
loramodule.spreadingFactor = data["lora"]["spreadingFactor"].as<int>();
|
||||
loramodule.signalBandwidth = data["lora"]["signalBandwidth"].as<long>();
|
||||
loramodule.codingRate4 = data["lora"]["codingRate4"].as<int>();
|
||||
|
|
@ -139,12 +152,87 @@ bool Configuration::readFile() {
|
|||
ota.username = data["ota"]["username"].as<String>();
|
||||
ota.password = data["ota"]["password"].as<String>();
|
||||
|
||||
int stationMode = data["stationMode"].as<int>(); // deprecated but need to specify config version
|
||||
|
||||
if (stationMode == 0) {
|
||||
// Load new settings
|
||||
|
||||
beacon.latitude = data["beacon"]["latitude"].as<double>();
|
||||
beacon.longitude = data["beacon"]["longitude"].as<double>();
|
||||
beacon.comment = data["beacon"]["comment"].as<String>();
|
||||
beacon.overlay = data["beacon"]["overlay"].as<String>();
|
||||
beacon.symbol = data["beacon"]["symbol"].as<String>();
|
||||
beacon.interval = data["beacon"]["interval"].as<int>();
|
||||
// beacon.igateSendsLoRaBeacons = data["beacon"]["igateSendsLoRaBeacons"].as<bool>();
|
||||
// beacon.igateRepeatsLoRaPackets = data["beacon"]["igateRepeatsLoRaPackets"].as<bool>();
|
||||
beacon.sendViaAPRSIS = data["beacon"]["sendViaAPRSIS"].as<bool>();
|
||||
beacon.sendViaRF = data["beacon"]["sendViaRF"].as<bool>();
|
||||
beacon.path = data["beacon"]["path"].as<String>();
|
||||
|
||||
digi.mode = data["digi"]["mode"].as<int>();
|
||||
|
||||
aprs_is.active = data["aprs_is"]["active"].as<bool>();
|
||||
aprs_is.filter = data["aprs_is"]["filter"].as<String>();
|
||||
aprs_is.toRF = data["aprs_is"]["toRF"].as<bool>();
|
||||
|
||||
loramodule.txFreq = data["lora"]["txFreq"].as<long>();
|
||||
loramodule.rxFreq = data["lora"]["rxFreq"].as<long>();
|
||||
loramodule.txActive = data["lora"]["txActive"].as<bool>();
|
||||
loramodule.rxActive = data["lora"]["rxActive"].as<bool>();
|
||||
} else {
|
||||
// Load old settings and put into new variables not actual config
|
||||
|
||||
String iGateComment = data["iGateComment"].as<String>();
|
||||
int beaconInterval = data["other"]["beaconInterval"].as<int>();
|
||||
// bool igateSendsLoRaBeacons = data["other"]["igateSendsLoRaBeacons"].as<bool>();
|
||||
// bool igateRepeatsLoRaPackets = data["other"]["igateRepeatsLoRaPackets"].as<bool>();
|
||||
|
||||
long iGateFreq = data["lora"]["iGateFreq"].as<long>();
|
||||
long digirepeaterTxFreq = data["lora"]["digirepeaterTxFreq"].as<long>();
|
||||
long digirepeaterRxFreq = data["lora"]["digirepeaterRxFreq"].as<long>();
|
||||
|
||||
String digiComment = data["digi"]["comment"].as<String>();
|
||||
double digiLatitude = data["digi"]["latitude"].as<double>();
|
||||
double digiLongitude = data["digi"]["longitude"].as<double>();
|
||||
|
||||
beacon.latitude = digiLatitude;
|
||||
beacon.longitude = digiLongitude;
|
||||
beacon.interval = beaconInterval;
|
||||
// beacon.igateSendsLoRaBeacons = igateSendsLoRaBeacons;
|
||||
// beacon.igateRepeatsLoRaPackets = igateRepeatsLoRaPackets;
|
||||
loramodule.txFreq = digirepeaterTxFreq;
|
||||
loramodule.rxFreq = digirepeaterRxFreq;
|
||||
loramodule.rxActive = true;
|
||||
beacon.sendViaAPRSIS = true;
|
||||
beacon.sendViaRF = false;
|
||||
|
||||
switch (stationMode) {
|
||||
case 1: // IGate only
|
||||
// aprs_is.active = true; // better don't do that automatically
|
||||
beacon.comment = iGateComment;
|
||||
loramodule.rxFreq = iGateFreq;
|
||||
break;
|
||||
case 5: // Digi + IGate
|
||||
case 2: // Digi + IGate
|
||||
// aprs_is.active = true; // better don't do that automatically
|
||||
// digi.mode = 2; // better don't do that automatically
|
||||
beacon.comment = digiComment;
|
||||
loramodule.rxFreq = iGateFreq;
|
||||
break;
|
||||
case 3: // Digi
|
||||
case 4: // Digi
|
||||
// digi.mode = 2; // better don't do that automatically
|
||||
beacon.comment = digiComment;
|
||||
break;
|
||||
}
|
||||
|
||||
reload = true;
|
||||
}
|
||||
|
||||
if (wifiAPs.size() == 0) { // If we don't have any WiFi's from config we need to add "empty" SSID for AUTO AP
|
||||
WiFi_AP wifiap;
|
||||
wifiap.ssid = "";
|
||||
wifiap.password = "";
|
||||
wifiap.latitude = 0.0;
|
||||
wifiap.longitude = 0.0;
|
||||
|
||||
wifiAPs.push_back(wifiap);
|
||||
}
|
||||
|
|
@ -158,36 +246,57 @@ bool Configuration::readFile() {
|
|||
}
|
||||
|
||||
void Configuration::init() {
|
||||
reload = false;
|
||||
|
||||
WiFi_AP wifiap;
|
||||
wifiap.ssid = "";
|
||||
wifiap.password = "";
|
||||
wifiap.latitude = 0.0;
|
||||
wifiap.longitude = 0.0;
|
||||
// wifiap.latitude = 0.0; // deprecated
|
||||
// wifiap.longitude = 0.0; // deprecated
|
||||
wifiAPs.push_back(wifiap);
|
||||
|
||||
wifiAutoAP.password = "1234567890";
|
||||
wifiAutoAP.powerOff = 15;
|
||||
|
||||
callsign = "N0CALL";
|
||||
stationMode = 1;
|
||||
iGateComment = "LoRa_APRS_iGate Development";
|
||||
// stationMode = 1; // deprecated
|
||||
// iGateComment = "LoRa_APRS_iGate Development"; // deprecated
|
||||
|
||||
digi.comment = "LoRa_APRS_iGate Development";
|
||||
digi.latitude = 0.0;
|
||||
digi.longitude = 0.0;
|
||||
beacon.comment = "LoRa APRS"; // new
|
||||
beacon.latitude = 0.0; // new
|
||||
beacon.longitude = 0.0; // new
|
||||
beacon.interval = 15; // new
|
||||
// beacon.igateRepeatsLoRaPackets = false; // new
|
||||
// beacon.igateSendsLoRaBeacons = false; // new
|
||||
beacon.overlay = "L"; // new
|
||||
beacon.symbol = "#"; // new
|
||||
beacon.sendViaAPRSIS = true; // new
|
||||
beacon.sendViaRF = false; // new
|
||||
beacon.path = "WIDE1-1"; // new
|
||||
|
||||
digi.mode = 0; // new
|
||||
// digi.comment = "LoRa_APRS_iGate Development"; // deprecated
|
||||
// digi.latitude = 0.0; // deprecated
|
||||
// digi.longitude = 0.0; // deprecated
|
||||
|
||||
aprs_is.active = false; // new
|
||||
aprs_is.passcode = "XYZVW";
|
||||
aprs_is.server = "rotate.aprs2.net";
|
||||
aprs_is.port = 14580;
|
||||
aprs_is.reportingDistance = 30;
|
||||
aprs_is.filter = ""; // new
|
||||
aprs_is.toRF = false; // new
|
||||
|
||||
loramodule.iGateFreq = 433775000;
|
||||
loramodule.digirepeaterTxFreq = 433775000;
|
||||
loramodule.digirepeaterRxFreq = 433900000;
|
||||
// loramodule.iGateFreq = 433775000; // deprecated
|
||||
// loramodule.digirepeaterTxFreq = 433775000; // deprecated
|
||||
// loramodule.digirepeaterRxFreq = 433900000; // deprecated
|
||||
loramodule.txFreq = 433775000; // new
|
||||
loramodule.rxFreq = 433775000; // new
|
||||
loramodule.spreadingFactor = 12;
|
||||
loramodule.signalBandwidth = 125000;
|
||||
loramodule.codingRate4 = 5;
|
||||
loramodule.power = 20;
|
||||
loramodule.txActive = false; // new
|
||||
loramodule.rxActive = true; // new
|
||||
|
||||
display.alwaysOn = true;
|
||||
display.timeout = 4;
|
||||
|
|
@ -202,9 +311,9 @@ void Configuration::init() {
|
|||
ota.username = "";
|
||||
ota.password = "";
|
||||
|
||||
beaconInterval = 15;
|
||||
igateSendsLoRaBeacons = false;
|
||||
igateRepeatsLoRaPackets = false;
|
||||
// beaconInterval = 15; // deprecated
|
||||
// igateSendsLoRaBeacons = false; // deprecated
|
||||
// igateRepeatsLoRaPackets = false; // deprecated
|
||||
rememberStationTime = 30;
|
||||
sendBatteryVoltage = false;
|
||||
externalVoltageMeasurement = false;
|
||||
|
|
@ -218,13 +327,15 @@ Configuration::Configuration() {
|
|||
Serial.println("SPIFFS Mount Failed");
|
||||
return;
|
||||
} else {
|
||||
Serial.println("montado");
|
||||
Serial.println("SPIFFS Mounted");
|
||||
}
|
||||
|
||||
bool exists = SPIFFS.exists("/igate_conf.json");
|
||||
if (!exists) {
|
||||
init();
|
||||
writeFile();
|
||||
ESP.restart();
|
||||
}
|
||||
|
||||
readFile();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue