diff --git a/data/igate_conf.json b/data/igate_conf.json index 85aa4f86..b68a4ec8 100644 --- a/data/igate_conf.json +++ b/data/igate_conf.json @@ -7,6 +7,16 @@ }, "AP": [] }, + "aprs_is": { + "active": false, + "passcode": "XYZVW", + "server": "rotate.aprs2.net", + "port": 14580, + "filter": "m/10", + "toRF": false, + "messagesToRF": false, + "objectsToRF": false + }, "beacon": { "latitude": 0.0, "longitude": 0.0, @@ -21,21 +31,6 @@ "digi": { "mode": 0 }, - "tnc": { - "enableServer": false, - "enableSerial": false, - "acceptOwn": false - }, - "aprs_is": { - "active": false, - "passcode": "XYZVW", - "server": "rotate.aprs2.net", - "port": 14580, - "filter": "m/10", - "toRF": false, - "messagesToRF": false, - "objectsToRF": false - }, "lora": { "txFreq": 433775000, "rxFreq": 433775000, @@ -51,20 +46,6 @@ "timeout": 4, "turn180": false }, - "syslog": { - "active": false, - "server": "192.168.0.100", - "port": 514 - }, - "bme": { - "active": false, - "heightCorrection": 0, - "temperatureCorrection": 0.0 - }, - "ota": { - "username": "", - "password": "" - }, "battery": { "sendInternalVoltage": false, "sendExternalVoltage": false, @@ -74,6 +55,25 @@ "externalMonitor": false, "externalSleepVoltage": 0.0 }, + "bme": { + "active": false, + "heightCorrection": 0, + "temperatureCorrection": 0.0 + }, + "syslog": { + "active": false, + "server": "192.168.0.100", + "port": 514 + }, + "tnc": { + "enableServer": false, + "enableSerial": false, + "acceptOwn": false + }, + "ota": { + "username": "", + "password": "" + }, "other": { "rememberStationTime": 30, "lowPowerMode": false, diff --git a/src/LoRa_APRS_iGate.cpp b/src/LoRa_APRS_iGate.cpp index a93d42ec..6c7d200b 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; @@ -109,7 +109,7 @@ void setup() { esp_light_sleep_start(); Serial.println("Waked up"); } - Config.loramodule.rxActive = false; + Config.lora.rxActive = false; } #endif @@ -155,7 +155,7 @@ void loop() { APRS_IS_Utils::checkStatus(); // Need that to update display, maybe split this and send APRSIS status to display func? String packet = ""; - if (Config.loramodule.rxActive) { + if (Config.lora.rxActive) { packet = LoRa_Utils::receivePacket(); // We need to fetch LoRa packet above APRSIS and Digi } diff --git a/src/configuration.cpp b/src/configuration.cpp index b93bfc17..1b9ea7a9 100644 --- a/src/configuration.cpp +++ b/src/configuration.cpp @@ -72,17 +72,17 @@ void Configuration::writeFile() { 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["lora"]["iGateFreq"] = lora.iGateFreq; + // data["lora"]["digirepeaterTxFreq"] = lora.digirepeaterTxFreq; + // data["lora"]["digirepeaterRxFreq"] = lora.digirepeaterRxFreq; + data["lora"]["rxFreq"] = lora.rxFreq; + data["lora"]["txFreq"] = lora.txFreq; + data["lora"]["spreadingFactor"] = lora.spreadingFactor; + data["lora"]["signalBandwidth"] = lora.signalBandwidth; + data["lora"]["codingRate4"] = lora.codingRate4; + data["lora"]["power"] = lora.power; + data["lora"]["txActive"] = lora.txActive; + data["lora"]["rxActive"] = lora.rxActive; data["display"]["alwaysOn"] = display.alwaysOn; data["display"]["timeout"] = display.timeout; @@ -154,10 +154,10 @@ bool Configuration::readFile() { aprs_is.server = data["aprs_is"]["server"].as(); aprs_is.port = data["aprs_is"]["port"].as(); - loramodule.spreadingFactor = data["lora"]["spreadingFactor"].as(); - loramodule.signalBandwidth = data["lora"]["signalBandwidth"].as(); - loramodule.codingRate4 = data["lora"]["codingRate4"].as(); - loramodule.power = data["lora"]["power"].as(); + lora.spreadingFactor = data["lora"]["spreadingFactor"].as(); + lora.signalBandwidth = data["lora"]["signalBandwidth"].as(); + lora.codingRate4 = data["lora"]["codingRate4"].as(); + lora.power = data["lora"]["power"].as(); display.alwaysOn = data["display"]["alwaysOn"].as(); display.timeout = data["display"]["timeout"].as(); @@ -219,10 +219,10 @@ bool Configuration::readFile() { aprs_is.messagesToRF = data["aprs_is"]["messagesToRF"].as(); aprs_is.objectsToRF = data["aprs_is"]["objectsToRF"].as(); - loramodule.txFreq = data["lora"]["txFreq"].as(); - loramodule.rxFreq = data["lora"]["rxFreq"].as(); - loramodule.txActive = data["lora"]["txActive"].as(); - loramodule.rxActive = data["lora"]["rxActive"].as(); + lora.txFreq = data["lora"]["txFreq"].as(); + lora.rxFreq = data["lora"]["rxFreq"].as(); + lora.txActive = data["lora"]["txActive"].as(); + lora.rxActive = data["lora"]["rxActive"].as(); } else { // Load old settings and put into new variables not actual config @@ -244,9 +244,9 @@ bool Configuration::readFile() { beacon.interval = beaconInterval; // beacon.igateSendsLoRaBeacons = igateSendsLoRaBeacons; // beacon.igateRepeatsLoRaPackets = igateRepeatsLoRaPackets; - loramodule.txFreq = digirepeaterTxFreq; - loramodule.rxFreq = digirepeaterRxFreq; - loramodule.rxActive = true; + lora.txFreq = digirepeaterTxFreq; + lora.rxFreq = digirepeaterRxFreq; + lora.rxActive = true; beacon.sendViaAPRSIS = true; beacon.sendViaRF = false; @@ -254,14 +254,14 @@ bool Configuration::readFile() { case 1: // IGate only // aprs_is.active = true; // better don't do that automatically beacon.comment = iGateComment; - loramodule.rxFreq = iGateFreq; + lora.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; + lora.rxFreq = iGateFreq; break; case 3: // Digi case 4: // Digi @@ -336,17 +336,17 @@ void Configuration::init() { aprs_is.messagesToRF = false; aprs_is.objectsToRF = false; - // 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 + // lora.iGateFreq = 433775000; // deprecated + // lora.digirepeaterTxFreq = 433775000; // deprecated + // lora.digirepeaterRxFreq = 433900000; // deprecated + lora.txFreq = 433775000; // new + lora.rxFreq = 433775000; // new + lora.spreadingFactor = 12; + lora.signalBandwidth = 125000; + lora.codingRate4 = 5; + lora.power = 20; + lora.txActive = false; // new + lora.rxActive = true; // new display.alwaysOn = true; display.timeout = 4; diff --git a/src/configuration.h b/src/configuration.h index 57f2bba9..8650f480 100644 --- a/src/configuration.h +++ b/src/configuration.h @@ -9,8 +9,6 @@ class WiFi_AP { public: String ssid; String password; - // double latitude; // deprecated - // double longitude; // deprecated }; class WiFi_Auto_AP { @@ -19,49 +17,41 @@ class WiFi_Auto_AP { int powerOff; }; -class Beacon { -public: - double latitude; // new - double longitude; // new - String comment; // new - String overlay; // new - String symbol; // new - int interval; // new - bool sendViaRF; // new - bool sendViaAPRSIS; // new - String path; // new -}; - -class DIGI { -public: - int mode; // new - // String comment; // deprecated - // double latitude; // deprecated - // double longitude; // deprecated -}; - class APRS_IS { public: - bool active; // new + bool active; String passcode; String server; int port; - // int reportingDistance; // deprecated - String filter; // new - //bool toRF; // new + String filter; bool messagesToRF; bool objectsToRF; }; -class LoraModule { +class BEACON { +public: + double latitude; + double longitude; + String comment; + String overlay; + String symbol; + int interval; + bool sendViaRF; + bool sendViaAPRSIS; + String path; +}; + +class DIGI { +public: + int mode; +}; + +class LORA { public: - // long iGateFreq; // deprecated - // long digirepeaterTxFreq; // deprecated - // long digirepeaterRxFreq; // deprecated - long txFreq; // new - long rxFreq; // new - bool txActive; // new - bool rxActive; // new + long txFreq; + long rxFreq; + bool txActive; + bool rxActive; int spreadingFactor; long signalBandwidth; int codingRate4; @@ -75,11 +65,22 @@ class Display { bool turn180; }; -class TNC { +class BATTERY { public: - bool enableServer; - bool enableSerial; - bool acceptOwn; + bool sendInternalVoltage; + bool sendExternalVoltage; + int externalVoltagePin; + bool internalMonitor; + float internalSleepVoltage; + bool externalMonitor; + float externalSleepVoltage; +}; + +class BME { +public: + bool active; + int heightCorrection; + float temperatureCorrection; }; class SYSLOG { @@ -89,11 +90,11 @@ class SYSLOG { int port; }; -class BME { +class TNC { public: - bool active; - int heightCorrection; - float temperatureCorrection; + bool enableServer; + bool enableSerial; + bool acceptOwn; }; class OTA { @@ -102,45 +103,28 @@ class OTA { String password; }; -class BATTERY { -public: - bool sendInternalVoltage; - bool sendExternalVoltage; - int externalVoltagePin; - bool internalMonitor; - float internalSleepVoltage; - bool externalMonitor; - float externalSleepVoltage; -}; - - class Configuration { public: bool reload; - String callsign; - // int stationMode; // deprecated - // String iGateComment; // deprecated - // int beaconInterval; // deprecated - // bool igateSendsLoRaBeacons; // deprecated - // bool igateRepeatsLoRaPackets; // deprecated + String callsign; int rememberStationTime; bool lowPowerMode; double lowVoltageCutOff; - bool backupDigiMode; // new - bool rebootMode; // new - int rebootModeTime; // new + bool backupDigiMode; + bool rebootMode; + int rebootModeTime; std::vector wifiAPs; WiFi_Auto_AP wifiAutoAP; - Beacon beacon; // new - DIGI digi; - TNC tnc; // new APRS_IS aprs_is; - LoraModule loramodule; + BEACON beacon; + DIGI digi; + LORA lora; Display display; - SYSLOG syslog; + BATTERY battery; BME bme; + SYSLOG syslog; + TNC tnc; OTA ota; - BATTERY battery; // new void init(); void writeFile(); diff --git a/src/lora_utils.cpp b/src/lora_utils.cpp index d27c4e93..8a93dc5a 100644 --- a/src/lora_utils.cpp +++ b/src/lora_utils.cpp @@ -42,7 +42,7 @@ namespace LoRa_Utils { void setup() { SPI.begin(RADIO_SCLK_PIN, RADIO_MISO_PIN, RADIO_MOSI_PIN); - float freq = (float)Config.loramodule.rxFreq / 1000000; + float freq = (float)Config.lora.rxFreq / 1000000; int state = radio.begin(freq); if (state == RADIOLIB_ERR_NONE) { Utils::println("Initializing LoRa Module"); @@ -60,23 +60,23 @@ namespace LoRa_Utils { #if defined(HAS_SX1278) || defined(HAS_SX1276) radio.setDio0Action(setFlag, RISING); #endif - radio.setSpreadingFactor(Config.loramodule.spreadingFactor); - float signalBandwidth = Config.loramodule.signalBandwidth/1000; + radio.setSpreadingFactor(Config.lora.spreadingFactor); + float signalBandwidth = Config.lora.signalBandwidth/1000; radio.setBandwidth(signalBandwidth); - radio.setCodingRate(Config.loramodule.codingRate4); + radio.setCodingRate(Config.lora.codingRate4); radio.setCRC(true); #if defined(ESP32_DIY_1W_LoRa) || defined(OE5HWN_MeshCom) radio.setRfSwitchPins(RADIO_RXEN, RADIO_TXEN); - state = radio.setOutputPower(Config.loramodule.power); // max value 20dB for 400M30S as it has Low Noise Amp + state = radio.setOutputPower(Config.lora.power); // max value 20dB for 400M30S as it has Low Noise Amp radio.setCurrentLimit(140); // to be validated (100 , 120, 140)? #endif #if defined(HAS_SX1278) || defined(HAS_SX1276) - state = radio.setOutputPower(Config.loramodule.power); // max value 20dB for 400M30S as it has Low Noise Amp + state = radio.setOutputPower(Config.lora.power); // max value 20dB for 400M30S as it has Low Noise Amp radio.setCurrentLimit(100); // to be validated (80 , 100)? #endif #if defined(HELTEC_V3) || defined(HELTEC_WSL_V3) || defined(HELTEC_WS) || defined(TTGO_T_Beam_V1_0_SX1268) || defined(TTGO_T_Beam_V1_2_SX1262) - state = radio.setOutputPower(Config.loramodule.power + 2); // values available: 10, 17, 22 --> if 20 in tracker_conf.json it will be updated to 22. + state = radio.setOutputPower(Config.lora.power + 2); // values available: 10, 17, 22 --> if 20 in tracker_conf.json it will be updated to 22. radio.setCurrentLimit(140); #endif @@ -94,20 +94,20 @@ namespace LoRa_Utils { void changeFreqTx() { delay(500); - float freq = (float)Config.loramodule.txFreq / 1000000; + float freq = (float)Config.lora.txFreq / 1000000; radio.setFrequency(freq); } void changeFreqRx() { delay(500); - float freq = (float)Config.loramodule.rxFreq / 1000000; + float freq = (float)Config.lora.rxFreq / 1000000; radio.setFrequency(freq); } void sendNewPacket(const String& newPacket) { - if (!Config.loramodule.txActive) return; + if (!Config.lora.txActive) return; - if (Config.loramodule.txFreq != Config.loramodule.rxFreq) { + if (Config.lora.txFreq != Config.lora.rxFreq) { changeFreqTx(); } @@ -129,7 +129,7 @@ namespace LoRa_Utils { #ifdef INTERNAL_LED_PIN digitalWrite(INTERNAL_LED_PIN, LOW); #endif - if (Config.loramodule.txFreq != Config.loramodule.rxFreq) { + if (Config.lora.txFreq != Config.lora.rxFreq) { changeFreqRx(); } } diff --git a/src/utils.cpp b/src/utils.cpp index 6fcef6fa..5d0db2aa 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -186,10 +186,10 @@ namespace Utils { } void validateFreqs() { - if (Config.loramodule.txFreq != Config.loramodule.rxFreq && abs(Config.loramodule.txFreq - Config.loramodule.rxFreq) < 125000) { + if (Config.lora.txFreq != Config.lora.rxFreq && abs(Config.lora.txFreq - Config.lora.rxFreq) < 125000) { Serial.println("Tx Freq less than 125kHz from Rx Freq ---> NOT VALID"); show_display("Tx Freq is less than ", "125kHz from Rx Freq", "device will autofix", "and then reboot", 1000); - Config.loramodule.txFreq = Config.loramodule.rxFreq; // Inform about that but then change the TX QRG to RX QRG and reset the device + Config.lora.txFreq = Config.lora.rxFreq; // Inform about that but then change the TX QRG to RX QRG and reset the device Config.writeFile(); ESP.restart(); } diff --git a/src/web_utils.cpp b/src/web_utils.cpp index 9d309839..0e2ff795 100644 --- a/src/web_utils.cpp +++ b/src/web_utils.cpp @@ -119,22 +119,22 @@ namespace WEB_Utils { Config.aprs_is.messagesToRF = request->hasParam("aprs_is.messagesToRF", true); Config.aprs_is.objectsToRF = request->hasParam("aprs_is.objectsToRF", true); - // Config.loramodule.iGateFreq = request->getParam("lora.iGateFreq", true)->value().toInt(); + // Config.lora.iGateFreq = request->getParam("lora.iGateFreq", true)->value().toInt(); // if (request->hasParam("lora.digirepeaterTxFreq", true)) { - // Config.loramodule.digirepeaterTxFreq = request->getParam("lora.digirepeaterTxFreq", true)->value().toInt(); + // Config.lora.digirepeaterTxFreq = request->getParam("lora.digirepeaterTxFreq", true)->value().toInt(); // } // if (request->hasParam("lora.digirepeaterRxFreq", true)) { - // Config.loramodule.digirepeaterRxFreq = request->getParam("lora.digirepeaterRxFreq", true)->value().toInt(); + // Config.lora.digirepeaterRxFreq = request->getParam("lora.digirepeaterRxFreq", true)->value().toInt(); // } - Config.loramodule.txFreq = request->getParam("lora.txFreq", true)->value().toInt(); - Config.loramodule.rxFreq = request->getParam("lora.rxFreq", true)->value().toInt(); - Config.loramodule.spreadingFactor = request->getParam("lora.spreadingFactor", true)->value().toInt(); - Config.loramodule.signalBandwidth = request->getParam("lora.signalBandwidth", true)->value().toInt(); - Config.loramodule.codingRate4 = request->getParam("lora.codingRate4", true)->value().toInt(); - Config.loramodule.power = request->getParam("lora.power", true)->value().toInt(); - Config.loramodule.txActive = request->hasParam("lora.txActive", true); - Config.loramodule.rxActive = request->hasParam("lora.rxActive", true); + Config.lora.txFreq = request->getParam("lora.txFreq", true)->value().toInt(); + Config.lora.rxFreq = request->getParam("lora.rxFreq", true)->value().toInt(); + Config.lora.spreadingFactor = request->getParam("lora.spreadingFactor", true)->value().toInt(); + Config.lora.signalBandwidth = request->getParam("lora.signalBandwidth", true)->value().toInt(); + Config.lora.codingRate4 = request->getParam("lora.codingRate4", true)->value().toInt(); + Config.lora.power = request->getParam("lora.power", true)->value().toInt(); + Config.lora.txActive = request->hasParam("lora.txActive", true); + Config.lora.rxActive = request->hasParam("lora.rxActive", true); Config.display.alwaysOn = request->hasParam("display.alwaysOn", true);