@@ -333,6 +306,77 @@ document.querySelector(".new button").addEventListener("click", function () {
document.querySelector(".new").before(networkElement);
});
+document
+ .getElementById("action.symbol")
+ .addEventListener("change", function () {
+ const value = document.getElementById("action.symbol").value;
+
+ document.getElementById("beacon.overlay").value = value[0];
+ document.getElementById("beacon.symbol").value = value[1];
+
+ updateImage();
+ });
+
+const speedStandards = {
+ 300: [125, 5, 12],
+ 244: [125, 6, 12],
+ 209: [125, 7, 12],
+ 183: [125, 8, 12],
+ 610: [125, 8, 10],
+ 1200: [125, 7, 9],
+};
+
+function refreshSpeedStandard() {
+ const bw = Number(document.getElementById("lora.signalBandwidth").value);
+ const cr4 = Number(document.getElementById("lora.codingRate4").value);
+ const sf = Number(document.getElementById("lora.spreadingFactor").value);
+
+ let found = false;
+
+ for (const speed in speedStandards) {
+ const standard = speedStandards[speed];
+
+ if (standard[0] !== bw / 1000) continue;
+ if (standard[1] !== cr4) continue;
+ if (standard[2] !== sf) continue;
+
+ document.getElementById("action.speed").value = speed;
+ found = true;
+
+ break;
+ }
+
+ if (!found) {
+ document.getElementById("action.speed").value = "";
+ }
+}
+
+document
+ .getElementById("lora.signalBandwidth")
+ .addEventListener("focusout", refreshSpeedStandard);
+document
+ .getElementById("lora.codingRate4")
+ .addEventListener("focusout", refreshSpeedStandard);
+document
+ .getElementById("lora.spreadingFactor")
+ .addEventListener("focusout", refreshSpeedStandard);
+
+document.getElementById("action.speed").addEventListener("change", function () {
+ const speed = document.getElementById("action.speed").value;
+
+ if (speed !== "") {
+ const value = speedStandards[Number(speed)];
+
+ const bw = value[0];
+ const cr4 = value[1];
+ const sf = value[2];
+
+ document.getElementById("lora.signalBandwidth").value = bw * 1000;
+ document.getElementById("lora.codingRate4").value = cr4;
+ document.getElementById("lora.spreadingFactor").value = sf;
+ }
+});
+
toggleFields();
const form = document.querySelector("form");
@@ -382,7 +426,7 @@ form.addEventListener("submit", async (event) => {
saveModal.show();
- setTimeout(checkConnection, 0);
+ setTimeout(checkConnection, 2000);
});
fetchSettings();
diff --git a/src/LoRa_APRS_iGate.cpp b/src/LoRa_APRS_iGate.cpp
index b1730a4..83e71b1 100644
--- a/src/LoRa_APRS_iGate.cpp
+++ b/src/LoRa_APRS_iGate.cpp
@@ -16,17 +16,18 @@
#include "web_utils.h"
#include "display.h"
#include "utils.h"
+#include
Configuration Config;
WiFiClient espClient;
-String versionDate = "2024.02.25";
+String versionDate = "2024.03.07";
int myWiFiAPIndex = 0;
int myWiFiAPSize = Config.wifiAPs.size();
WiFi_AP *currentWiFi = &Config.wifiAPs[myWiFiAPIndex];
-int stationMode = Config.stationMode;
+bool isUpdatingOTA = false;
bool statusAfterBoot = true;
bool beaconUpdate = true;
uint32_t lastBeaconTx = 0;
@@ -36,7 +37,6 @@ uint32_t lastScreenOn = millis();
uint32_t lastWiFiCheck = 0;
bool WiFiConnect = true;
bool WiFiConnected = false;
-int lastStationModeState = 1;
bool WiFiAutoAPStarted = false;
long WiFiAutoAPTime = false;
@@ -69,47 +69,56 @@ void setup() {
#endif
delay(1000);
Utils::setupDisplay();
+
+ Config.check();
+
WIFI_Utils::setup();
LoRa_Utils::setup();
- Utils::validateDigiFreqs();
+ Utils::validateFreqs();
+
iGateBeaconPacket = GPS_Utils::generateBeacon();
iGateLoRaBeaconPacket = GPS_Utils::generateiGateLoRaBeacon();
+
SYSLOG_Utils::setup();
BME_Utils::setup();
WEB_Utils::setup();
}
void loop() {
- WEB_Utils::loop();
-
WIFI_Utils::checkIfAutoAPShouldPowerOff();
- if (stationMode==1 || stationMode==2 ) { // iGate (1 Only Rx / 2 Rx+Tx)
- if (!WiFiConnected) {
- thirdLine = Utils::getLocalIP();
- }
-
- WIFI_Utils::checkWiFi();
- if (!espClient.connected()) {
- APRS_IS_Utils::connect();
- }
- APRS_IS_Utils::loop();
- } else if (stationMode==3 || stationMode==4) { // DigiRepeater (3 RxFreq=TxFreq / 4 RxFreq!=TxFreq)
- DIGI_Utils::loop();
- } else if (stationMode==5) { // iGate when WiFi and APRS available , DigiRepeater when not (RxFreq=TxFreq)
- Utils::checkWiFiInterval();
- thirdLine = Utils::getLocalIP();
- if (WiFi.status() == WL_CONNECTED) { // iGate Mode
- if (!espClient.connected()) {
- APRS_IS_Utils::connect();
- }
- if (lastStationModeState == 1) {
- iGateBeaconPacket = GPS_Utils::generateBeacon();
- lastStationModeState = 0;
- }
- APRS_IS_Utils::loop();
- } else { // DigiRepeater Mode
- DIGI_Utils::loop();
- }
+ if (isUpdatingOTA) {
+ ElegantOTA.loop();
+ return; // Don't process IGate and Digi during OTA update
}
+
+ thirdLine = Utils::getLocalIP();
+
+ WIFI_Utils::checkWiFi(); // Always use WiFi, not related to IGate/Digi mode
+ // Utils::checkWiFiInterval();
+
+ if (Config.aprs_is.active && !espClient.connected()) {
+ APRS_IS_Utils::connect();
+ }
+
+ Utils::checkDisplayInterval();
+ Utils::checkBeaconInterval();
+
+ String packet;
+
+ if (Config.loramodule.rxActive) {
+ packet = LoRa_Utils::receivePacket(); // We need to fetch LoRa packet above APRSIS and Digi
+ }
+
+ APRS_IS_Utils::checkStatus(); // Need that to update display, maybe split this and send APRSIS status to display func?
+
+ if (Config.aprs_is.active) { // If APRSIS enabled
+ APRS_IS_Utils::loop(packet); // Send received packet to APRSIS
+ }
+
+ if (Config.digi.mode == 2) { // If Digi enabled
+ DIGI_Utils::loop(packet); // Send received packet to Digi
+ }
+
+ show_display(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, seventhLine, 0);
}
\ No newline at end of file
diff --git a/src/aprs_is_utils.cpp b/src/aprs_is_utils.cpp
index efff8c3..75f60be 100644
--- a/src/aprs_is_utils.cpp
+++ b/src/aprs_is_utils.cpp
@@ -1,4 +1,3 @@
-#include
#include
#include "configuration.h"
#include "aprs_is_utils.h"
@@ -14,7 +13,6 @@ extern Configuration Config;
extern WiFiClient espClient;
extern int internalLedPin;
extern uint32_t lastScreenOn;
-extern int stationMode;
extern String firstLine;
extern String secondLine;
extern String thirdLine;
@@ -48,7 +46,10 @@ namespace APRS_IS_Utils {
Serial.println("Tried: " + String(count) + " FAILED!");
} else {
Serial.println("Connected!\n(Server: " + String(Config.aprs_is.server) + " / Port: " + String(Config.aprs_is.port) +")");
- aprsauth = "user " + Config.callsign + " pass " + Config.aprs_is.passcode + " vers CA2RXU_LoRa_iGate 1.3 filter t/m/" + Config.callsign + "/" + (String)Config.aprs_is.reportingDistance;// + "\r\n";
+
+ // String filter = "t/m/" + Config.callsign + "/" + (String)Config.aprs_is.reportingDistance;
+
+ aprsauth = "user " + Config.callsign + " pass " + Config.aprs_is.passcode + " vers CA2RXU_LoRa_iGate 1.3 filter " + Config.aprs_is.filter;// + "\r\n";
upload(aprsauth);
delay(200);
}
@@ -60,25 +61,33 @@ namespace APRS_IS_Utils {
wifiState = "OK";
} else {
wifiState = "AP";
+
if (!Config.display.alwaysOn) {
display_toggle(true);
}
+
lastScreenOn = millis();
}
- if (espClient.connected()) {
+
+ if (!Config.aprs_is.active) {
+ aprsisState = "OFF";
+ } else if (espClient.connected()) {
aprsisState = "OK";
} else {
aprsisState = "--";
+
if (!Config.display.alwaysOn) {
display_toggle(true);
}
+
lastScreenOn = millis();
}
- secondLine = "WiFi: " + wifiState + " APRS-IS: " + aprsisState;
+
+ secondLine = "WiFi: " + wifiState + " APRS-IS: " + aprsisState;
}
String createPacket(String packet) {
- if (stationMode>1) {
+ if (!(Config.aprs_is.active && Config.digi.mode == 0)) { // Check if NOT only IGate
return packet.substring(3, packet.indexOf(":")) + ",qAR," + Config.callsign + packet.substring(packet.indexOf(":"));// + "\n";
} else {
return packet.substring(3, packet.indexOf(":")) + ",qAO," + Config.callsign + packet.substring(packet.indexOf(":"));// + "\n";
@@ -103,14 +112,6 @@ namespace APRS_IS_Utils {
AddresseeAndMessage = packet.substring(packet.indexOf("::")+2);
Addressee = AddresseeAndMessage.substring(0,AddresseeAndMessage.indexOf(":"));
Addressee.trim();
-
- if (stationMode!=1 && Config.igateRepeatsLoRaPackets && Addressee != Config.callsign) { // if its not for me
- String digiRepeatedPacket = DIGI_Utils::generateDigiRepeatedPacket(packet.substring(3), Config.callsign);
- if (digiRepeatedPacket != "X") {
- delay(500);
- LoRa_Utils::sendNewPacket("APRS", digiRepeatedPacket);
- }
- }
if (packet.indexOf("::") > 10 && Addressee == Config.callsign) { // its a message for me!
if (AddresseeAndMessage.indexOf("{")>0) { // ack?
@@ -208,7 +209,8 @@ namespace APRS_IS_Utils {
#ifndef TextSerialOutputForApp
Serial.print("Received from APRS-IS : " + packet);
#endif
- if ((stationMode==2 || stationMode==5) && STATION_Utils::wasHeard(Addressee)) {
+
+ if (Config.aprs_is.toRF && STATION_Utils::wasHeard(Addressee)) {
LoRa_Utils::sendNewPacket("APRS", LoRa_Utils::generatePacket(packet));
display_toggle(true);
lastScreenOn = millis();
@@ -220,19 +222,17 @@ namespace APRS_IS_Utils {
}
}
- void loop() {
- checkStatus();
- show_display(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, seventhLine, 0);
- while (espClient.connected()) {
- Utils::checkDisplayInterval();
- Utils::checkBeaconInterval();
- processLoRaPacket(LoRa_Utils::receivePacket());
+ void loop(String packet) {
+ if (espClient.connected()) {
+ processLoRaPacket(packet);
+
if (espClient.available()) {
- String aprsisPacket;
- aprsisPacket.concat(espClient.readStringUntil('\r'));
+ String aprsisPacket = espClient.readStringUntil('\r');
+
+ // Serial.println(aprsisPacket);
+
processAPRSISPacket(aprsisPacket);
}
- ElegantOTA.loop();
}
}
diff --git a/src/aprs_is_utils.h b/src/aprs_is_utils.h
index 814419f..b192a13 100644
--- a/src/aprs_is_utils.h
+++ b/src/aprs_is_utils.h
@@ -19,7 +19,7 @@ namespace APRS_IS_Utils {
String createPacket(String unprocessedPacket);
void processLoRaPacket(String packet);
void processAPRSISPacket(String packet);
- void loop();
+ void loop(String packet);
}
diff --git a/src/configuration.cpp b/src/configuration.cpp
index ccc32c1..a6d2514 100644
--- a/src/configuration.cpp
+++ b/src/configuration.cpp
@@ -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();
wifiap.password = WiFiArray[i]["password"].as();
- wifiap.latitude = WiFiArray[i]["latitude"].as();
- wifiap.longitude = WiFiArray[i]["longitude"].as();
wifiAPs.push_back(wifiap);
}
@@ -99,28 +125,15 @@ bool Configuration::readFile() {
wifiAutoAP.powerOff = data["wifi"]["autoAP"]["powerOff"].as();
callsign = data["callsign"].as();
- stationMode = data["stationMode"].as();
- iGateComment = data["iGateComment"].as();
- beaconInterval = data["other"]["beaconInterval"].as();
- igateSendsLoRaBeacons = data["other"]["igateSendsLoRaBeacons"].as();
- igateRepeatsLoRaPackets = data["other"]["igateRepeatsLoRaPackets"].as();
rememberStationTime = data["other"]["rememberStationTime"].as();
sendBatteryVoltage = data["other"]["sendBatteryVoltage"].as();
externalVoltageMeasurement = data["other"]["externalVoltageMeasurement"].as();
externalVoltagePin = data["other"]["externalVoltagePin"].as();
- digi.comment = data["digi"]["comment"].as();
- digi.latitude = data["digi"]["latitude"].as();
- digi.longitude = data["digi"]["longitude"].as();
-
aprs_is.passcode = data["aprs_is"]["passcode"].as();
aprs_is.server = data["aprs_is"]["server"].as();
aprs_is.port = data["aprs_is"]["port"].as();
- aprs_is.reportingDistance = data["aprs_is"]["reportingDistance"].as();
- loramodule.iGateFreq = data["lora"]["iGateFreq"].as();
- loramodule.digirepeaterTxFreq = data["lora"]["digirepeaterTxFreq"].as();
- loramodule.digirepeaterRxFreq = data["lora"]["digirepeaterRxFreq"].as();
loramodule.spreadingFactor = data["lora"]["spreadingFactor"].as();
loramodule.signalBandwidth = data["lora"]["signalBandwidth"].as();
loramodule.codingRate4 = data["lora"]["codingRate4"].as();
@@ -139,12 +152,87 @@ bool Configuration::readFile() {
ota.username = data["ota"]["username"].as();
ota.password = data["ota"]["password"].as();
+ int stationMode = data["stationMode"].as(); // deprecated but need to specify config version
+
+ if (stationMode == 0) {
+ // Load new settings
+
+ beacon.latitude = data["beacon"]["latitude"].as();
+ beacon.longitude = data["beacon"]["longitude"].as();
+ beacon.comment = data["beacon"]["comment"].as();
+ beacon.overlay = data["beacon"]["overlay"].as();
+ beacon.symbol = data["beacon"]["symbol"].as();
+ beacon.interval = data["beacon"]["interval"].as();
+ // beacon.igateSendsLoRaBeacons = data["beacon"]["igateSendsLoRaBeacons"].as();
+ // beacon.igateRepeatsLoRaPackets = data["beacon"]["igateRepeatsLoRaPackets"].as();
+ beacon.sendViaAPRSIS = data["beacon"]["sendViaAPRSIS"].as();
+ beacon.sendViaRF = data["beacon"]["sendViaRF"].as();
+ beacon.path = data["beacon"]["path"].as();
+
+ digi.mode = data["digi"]["mode"].as();
+
+ aprs_is.active = data["aprs_is"]["active"].as();
+ aprs_is.filter = data["aprs_is"]["filter"].as();
+ aprs_is.toRF = data["aprs_is"]["toRF"].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();
+ } else {
+ // Load old settings and put into new variables not actual config
+
+ String iGateComment = data["iGateComment"].as();
+ int beaconInterval = data["other"]["beaconInterval"].as();
+ // bool igateSendsLoRaBeacons = data["other"]["igateSendsLoRaBeacons"].as();
+ // bool igateRepeatsLoRaPackets = data["other"]["igateRepeatsLoRaPackets"].as();
+
+ long iGateFreq = data["lora"]["iGateFreq"].as();
+ long digirepeaterTxFreq = data["lora"]["digirepeaterTxFreq"].as();
+ long digirepeaterRxFreq = data["lora"]["digirepeaterRxFreq"].as();
+
+ String digiComment = data["digi"]["comment"].as();
+ double digiLatitude = data["digi"]["latitude"].as();
+ double digiLongitude = data["digi"]["longitude"].as();
+
+ 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();
}
\ No newline at end of file
diff --git a/src/configuration.h b/src/configuration.h
index d7011be..4b2d138 100644
--- a/src/configuration.h
+++ b/src/configuration.h
@@ -9,8 +9,8 @@ class WiFi_AP {
public:
String ssid;
String password;
- double latitude;
- double longitude;
+ // double latitude; // deprecated
+ // double longitude; // deprecated
};
class WiFi_Auto_AP {
@@ -19,27 +19,47 @@ public:
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:
- String comment;
- double latitude;
- double longitude;
+ int mode; // new
+ // String comment; // deprecated
+ // double latitude; // deprecated
+ // double longitude; // deprecated
};
class APRS_IS {
public:
+ bool active; // new
String passcode;
String server;
int port;
- int reportingDistance;
+ // int reportingDistance; // deprecated
+ String filter; // new
+ bool toRF; // new
};
class LoraModule {
public:
- long iGateFreq;
- long digirepeaterTxFreq;
- long digirepeaterRxFreq;
+ // long iGateFreq; // deprecated
+ // long digirepeaterTxFreq; // deprecated
+ // long digirepeaterRxFreq; // deprecated
+ long txFreq; // new
+ long rxFreq; // new
+ bool txActive; // new
+ bool rxActive; // new
int spreadingFactor;
long signalBandwidth;
int codingRate4;
@@ -76,18 +96,20 @@ public:
class Configuration {
public:
+ bool reload;
String callsign;
- int stationMode;
- String iGateComment;
- int beaconInterval;
- bool igateSendsLoRaBeacons;
- bool igateRepeatsLoRaPackets;
+ // int stationMode; // deprecated
+ // String iGateComment; // deprecated
+ // int beaconInterval; // deprecated
+ // bool igateSendsLoRaBeacons; // deprecated
+ // bool igateRepeatsLoRaPackets; // deprecated
int rememberStationTime;
bool sendBatteryVoltage;
bool externalVoltageMeasurement;
int externalVoltagePin;
std::vector wifiAPs;
WiFi_Auto_AP wifiAutoAP;
+ Beacon beacon; // new
DIGI digi;
APRS_IS aprs_is;
LoraModule loramodule;
@@ -98,6 +120,7 @@ public:
void init();
void writeFile();
+ void check();
Configuration();
private:
diff --git a/src/digi_utils.cpp b/src/digi_utils.cpp
index b51cc2e..44f7ff9 100644
--- a/src/digi_utils.cpp
+++ b/src/digi_utils.cpp
@@ -10,9 +10,7 @@
#include "utils.h"
extern Configuration Config;
-extern int stationMode;
extern uint32_t lastScreenOn;
-extern int lastStationModeState;
extern String iGateBeaconPacket;
extern String firstLine;
extern String secondLine;
@@ -43,13 +41,13 @@ namespace DIGI_Utils {
String repeatedPacket = sender + ">" + tocall + "," + path + packet.substring(packet.indexOf(":"));
return repeatedPacket;
} else {
- return "X";
+ return "";
}
} else {
- return "X";
+ return "";
}
} else {
- return "X";
+ return "";
}
}
@@ -62,32 +60,16 @@ namespace DIGI_Utils {
String sender = packet.substring(3,packet.indexOf(">"));
STATION_Utils::updateLastHeard(sender);
STATION_Utils::updatePacketBuffer(packet);
- Utils::typeOfPacket(packet, "Digi");
- if ((stationMode==3 || stationMode==5) && (packet.indexOf("WIDE1-") > 10)) {
+ Utils::typeOfPacket(packet.substring(3), "Digi");
+ if (packet.indexOf("WIDE1-") > 10 && Config.digi.mode == 2) { // If should repeat packet (WIDE1 Digi)
loraPacket = generateDigiRepeatedPacket(packet.substring(3), Config.callsign);
- if (loraPacket != "X") {
+ if (loraPacket != "") {
delay(500);
Serial.println(loraPacket);
LoRa_Utils::sendNewPacket("APRS", loraPacket);
display_toggle(true);
lastScreenOn = millis();
}
- } else if (stationMode==4){
- if (packet.indexOf("WIDE1-") == -1) {
- loraPacket = packet.substring(3,packet.indexOf(":")) + "," + Config.callsign + "*" + packet.substring(packet.indexOf(":"));
- } else {
- loraPacket = packet.substring(3,packet.indexOf(",")+1) + Config.callsign + "*" + packet.substring(packet.indexOf(","));
- }
- delay(500);
- if (stationMode==4) {
- LoRa_Utils::changeFreqTx();
- }
- LoRa_Utils::sendNewPacket("APRS", loraPacket);
- if (stationMode==4) {
- LoRa_Utils::changeFreqRx();
- }
- display_toggle(true);
- lastScreenOn = millis();
}
} else {
Serial.println(" ---> LoRa Packet Ignored (first 3 bytes or NOGATE)\n");
@@ -95,21 +77,8 @@ namespace DIGI_Utils {
}
}
- void loop() {
- if (stationMode==3 || stationMode==4 || stationMode==5) {
- if (lastStationModeState==0 && stationMode==5) {
- iGateBeaconPacket = GPS_Utils::generateBeacon();
- lastStationModeState = 1;
- String Tx = String(Config.loramodule.digirepeaterTxFreq);
- secondLine = "Rx:" + String(Tx.substring(0,3)) + "." + String(Tx.substring(3,6));
- secondLine += " Tx:" + String(Tx.substring(0,3)) + "." + String(Tx.substring(3,6));
- thirdLine = "<< DigiRepeater >>";
- }
- Utils::checkDisplayInterval();
- Utils::checkBeaconInterval();
- show_display(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, seventhLine, 0);
- processPacket(LoRa_Utils::receivePacket());
- }
+ void loop(String packet) {
+ processPacket(packet);
}
}
\ No newline at end of file
diff --git a/src/digi_utils.h b/src/digi_utils.h
index 2a5d8b6..4aff04a 100644
--- a/src/digi_utils.h
+++ b/src/digi_utils.h
@@ -8,7 +8,7 @@ namespace DIGI_Utils {
String generateDigiRepeatedPacket(String packet, String callsign);
void processPacket(String packet);
- void loop();
+ void loop(String packet);
}
diff --git a/src/gps_utils.cpp b/src/gps_utils.cpp
index 9120881..9fd2d53 100644
--- a/src/gps_utils.cpp
+++ b/src/gps_utils.cpp
@@ -4,9 +4,7 @@
#include "gps_utils.h"
extern Configuration Config;
-extern WiFi_AP *currentWiFi;
extern WiFiClient espClient;
-extern int stationMode;
String distance;
@@ -80,49 +78,32 @@ namespace GPS_Utils {
}
String generateBeacon() {
- String stationLatitude, stationLongitude, beaconPacket;
- if (stationMode==1 || stationMode==2 || (stationMode==5 && WiFi.status()==WL_CONNECTED && espClient.connected())) {
- stationLatitude = processLatitudeAPRS(currentWiFi->latitude);
- stationLongitude = processLongitudeAPRS(currentWiFi->longitude);
- beaconPacket = Config.callsign + ">APLRG1,WIDE1-1";
- if (stationMode!=6) {
- beaconPacket += ",qAC";
- }
- beaconPacket += ":=" + stationLatitude + "L" + stationLongitude;
- if (stationMode==1) {
- beaconPacket += "&";
- } else {
- beaconPacket += "a";
- }
- beaconPacket += Config.iGateComment;
- } else { //stationMode 3, 4 and 5
- if (stationMode==5) {
- stationLatitude = processLatitudeAPRS(currentWiFi->latitude);
- stationLongitude = processLongitudeAPRS(currentWiFi->longitude);
- } else {
- stationLatitude = processLatitudeAPRS(Config.digi.latitude);
- stationLongitude = processLongitudeAPRS(Config.digi.longitude);
- }
- beaconPacket = Config.callsign + ">APLRG1,WIDE1-1:=" + stationLatitude + "L" + stationLongitude + "#" + Config.digi.comment;
- }
+ String stationLatitude = processLatitudeAPRS(Config.beacon.latitude);
+ String stationLongitude = processLongitudeAPRS(Config.beacon.longitude);
+
+ String beaconPacket = Config.callsign + ">APLRG1," + Config.beacon.path;
+
+ if (Config.aprs_is.active && Config.digi.mode == 0) { // If APRSIS enabled and Digi disabled
+ beaconPacket += ",qAC";
+ } else {}
+
+ beaconPacket += ":=" + stationLatitude + Config.beacon.overlay + stationLongitude + Config.beacon.symbol;
+ beaconPacket += Config.beacon.comment;
+
return beaconPacket;
}
String generateiGateLoRaBeacon() {
- String stationLatitude, stationLongitude, beaconPacket;
- stationLatitude = processLatitudeAPRS(currentWiFi->latitude);
- stationLongitude = processLongitudeAPRS(currentWiFi->longitude);
- beaconPacket = Config.callsign + ">APLRG1,RFONLY:=" + stationLatitude + "L" + stationLongitude;
- if (Config.bme.active) {
- beaconPacket += "_";
- } else {
- beaconPacket += "a";
- }
+ String stationLatitude = processLatitudeAPRS(Config.beacon.latitude);
+ String stationLongitude = processLongitudeAPRS(Config.beacon.longitude);
+
+ String beaconPacket = Config.callsign + ">APLRG1," + Config.beacon.path + ":=" + stationLatitude + Config.beacon.overlay + stationLongitude + Config.beacon.symbol;
+
return beaconPacket;
}
double calculateDistanceTo(double latitude, double longitude) {
- return TinyGPSPlus::distanceBetween(currentWiFi->latitude,currentWiFi->longitude, latitude, longitude) / 1000.0;
+ return TinyGPSPlus::distanceBetween(Config.beacon.latitude,Config.beacon.longitude, latitude, longitude) / 1000.0;
}
String decodeEncodedGPS(String packet) {
diff --git a/src/lora_utils.cpp b/src/lora_utils.cpp
index c6642e6..45c35be 100644
--- a/src/lora_utils.cpp
+++ b/src/lora_utils.cpp
@@ -8,7 +8,6 @@
#include "display.h"
extern Configuration Config;
-extern int stationMode;
#if defined(HELTEC_V3) || defined(TTGO_T_Beam_V1_2_SX1262)
SX1262 radio = new Module(RADIO_CS_PIN, RADIO_DIO1_PIN, RADIO_RST_PIN, RADIO_BUSY_PIN);
@@ -37,12 +36,7 @@ namespace LoRa_Utils {
#ifdef HAS_SX127X
SPI.begin(LORA_SCK, LORA_MISO, LORA_MOSI, LORA_CS);
LoRa.setPins(LORA_CS, LORA_RST, LORA_IRQ);
- long freq;
- if (stationMode==1 || stationMode==2) {
- freq = Config.loramodule.iGateFreq;
- } else {
- freq = Config.loramodule.digirepeaterTxFreq;
- }
+ long freq = Config.loramodule.rxFreq;
if (!LoRa.begin(freq)) {
Serial.println("Starting LoRa failed!");
show_display("ERROR", "Starting LoRa failed!");
@@ -59,7 +53,7 @@ namespace LoRa_Utils {
#endif
#ifdef HAS_SX126X
SPI.begin(RADIO_SCLK_PIN, RADIO_MISO_PIN, RADIO_MOSI_PIN);
- float freq = (float)Config.loramodule.iGateFreq/1000000;
+ float freq = (float)Config.loramodule.rxFreq/1000000;
int state = radio.begin(freq);
if (state == RADIOLIB_ERR_NONE) {
Serial.print("Initializing SX126X LoRa Module");
@@ -90,7 +84,35 @@ namespace LoRa_Utils {
#endif
}
+ void changeFreqTx() {
+ delay(500);
+ #ifdef HAS_SX127X
+ LoRa.setFrequency(Config.loramodule.txFreq);
+ #endif
+ #ifdef HAS_SX126X
+ float freq = (float)Config.loramodule.txFreq/1000000;
+ radio.setFrequency(freq);
+ #endif
+ }
+
+ void changeFreqRx() {
+ delay(500);
+ #ifdef HAS_SX127X
+ LoRa.setFrequency(Config.loramodule.rxFreq);
+ #endif
+ #ifdef HAS_SX126X
+ float freq = (float)Config.loramodule.rxFreq/1000000;
+ radio.setFrequency(freq);
+ #endif
+ }
+
void sendNewPacket(const String &typeOfMessage, const String &newPacket) {
+ if (!Config.loramodule.txActive) return;
+
+ if (Config.loramodule.txFreq != Config.loramodule.rxFreq) {
+ changeFreqTx();
+ }
+
#if defined(TTGO_T_LORA32_V2_1) || defined(HELTEC_V2) || defined(HELTEC_V3) || defined(ESP32_DIY_LoRa) || defined(ESP32_DIY_1W_LoRa)
digitalWrite(internalLedPin,HIGH);
#endif
@@ -125,6 +147,10 @@ namespace LoRa_Utils {
SYSLOG_Utils::log("Tx", newPacket,0,0,0);
Serial.print("---> LoRa Packet Tx : ");
Serial.println(newPacket);
+
+ if (Config.loramodule.txFreq != Config.loramodule.rxFreq) {
+ changeFreqRx();
+ }
}
String generatePacket(String aprsisPacket) {
@@ -194,32 +220,10 @@ namespace LoRa_Utils {
}
#endif
- if (Config.syslog.active && (stationMode==1 || stationMode==2 || (stationMode==5 && WiFi.status()==WL_CONNECTED)) && loraPacket!="") {
+ if (Config.syslog.active && WiFi.status() == WL_CONNECTED && loraPacket != "") {
SYSLOG_Utils::log("Rx", loraPacket, rssi, snr, freqError);
}
return loraPacket;
}
- void changeFreqTx() {
- delay(500);
- #ifdef HAS_SX127X
- LoRa.setFrequency(Config.loramodule.digirepeaterTxFreq);
- #endif
- #ifdef HAS_SX126X
- float freq = (float)Config.loramodule.digirepeaterTxFreq/1000000;
- radio.setFrequency(freq);
- #endif
- }
-
- void changeFreqRx() {
- delay(500);
- #ifdef HAS_SX127X
- LoRa.setFrequency(Config.loramodule.digirepeaterRxFreq);
- #endif
- #ifdef HAS_SX126X
- float freq = (float)Config.loramodule.digirepeaterRxFreq/1000000;
- radio.setFrequency(freq);
- #endif
- }
-
}
\ No newline at end of file
diff --git a/src/ota_utils.cpp b/src/ota_utils.cpp
index dfa00c0..4822213 100644
--- a/src/ota_utils.cpp
+++ b/src/ota_utils.cpp
@@ -7,6 +7,7 @@
extern Configuration Config;
extern uint32_t lastScreenOn;
+extern bool isUpdatingOTA;
unsigned long ota_progress_millis = 0;
@@ -31,6 +32,7 @@ namespace OTA_Utils {
display_toggle(true);
lastScreenOn = millis();
show_display("", "", "", " OTA update started!", "", "", "", 1000);
+ isUpdatingOTA = true;
}
void onOTAProgress(size_t current, size_t final) {
@@ -53,6 +55,7 @@ namespace OTA_Utils {
Serial.println("There was an error during OTA update!");
show_display("", "", " OTA update fail!", "", "", "", "", 4000);
}
+ isUpdatingOTA = false;
}
}
\ No newline at end of file
diff --git a/src/power_utils.cpp b/src/power_utils.cpp
index 2a3ddee..12ec140 100644
--- a/src/power_utils.cpp
+++ b/src/power_utils.cpp
@@ -127,14 +127,4 @@ namespace POWER_Utils {
#endif
}
- /*void lowerCpuFrequency() {
- #if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_0_SX1268) || defined(TTGO_T_Beam_V1_2) || defined(ESP32_DIY_LoRa_GPS) || defined(TTGO_T_LORA32_V2_1_GPS) || defined(TTGO_T_LORA32_V2_1_TNC) || defined(ESP32_DIY_1W_LoRa_GPS) || defined(TTGO_T_Beam_V1_2_SX1262)
- if (setCpuFrequencyMhz(80)) {
- logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "Main", "CPU frequency set to 80MHz");
- } else {
- logger.log(logging::LoggerLevel::LOGGER_LEVEL_WARN, "Main", "CPU frequency unchanged");
- }
- #endif
- }*/
-
}
\ No newline at end of file
diff --git a/src/power_utils.h b/src/power_utils.h
index f7b5427..c057bee 100644
--- a/src/power_utils.h
+++ b/src/power_utils.h
@@ -12,7 +12,6 @@ namespace POWER_Utils {
void deactivateLoRa();
bool begin(TwoWire &port);
void setup();
- //void lowerCpuFrequency();
}
diff --git a/src/query_utils.cpp b/src/query_utils.cpp
index cc42fe0..75f1ca6 100644
--- a/src/query_utils.cpp
+++ b/src/query_utils.cpp
@@ -2,11 +2,9 @@
#include "query_utils.h"
extern Configuration Config;
-extern WiFi_AP *currentWiFi;
extern std::vector lastHeardStation;
extern std::vector lastHeardStation_temp;
extern String versionDate;
-extern int stationMode;
namespace QUERY_Utils {
@@ -16,9 +14,9 @@ namespace QUERY_Utils {
if (query=="?APRS?" || query=="?aprs?" || query=="?Aprs?" || query=="H" || query=="h" || query=="HELP" || query=="Help" || query=="help" || query=="?") {
answer = "?APRSV ?APRSP ?APRSL ?APRSH ?WHERE callsign";
} else if (query=="?APRSV" || query=="?aprsv" || query=="?Aprsv") {
- answer = "CA2RXU_LoRa_iGate 1.3 v" + versionDate + " sM" + String(stationMode);
+ answer = "CA2RXU_LoRa_iGate 1.3 v" + versionDate;
} else if (query=="?APRSP" || query=="?aprsp" || query=="?Aprsp") {
- answer = "iGate QTH: " + String(currentWiFi->latitude,2) + " " + String(currentWiFi->longitude,2);
+ answer = "iGate QTH: " + String(Config.beacon.latitude,2) + " " + String(Config.beacon.longitude,2);
} else if (query=="?APRSL" || query=="?aprsl" || query=="?Aprsl") {
if (lastHeardStation.size() == 0) {
answer = "No Station Listened in the last " + String(Config.rememberStationTime) + "min.";
diff --git a/src/syslog_utils.cpp b/src/syslog_utils.cpp
index 5e74768..01b5daa 100644
--- a/src/syslog_utils.cpp
+++ b/src/syslog_utils.cpp
@@ -5,7 +5,6 @@
#include "gps_utils.h"
extern Configuration Config;
-extern int stationMode;
WiFiUDP udpClient;
@@ -14,7 +13,7 @@ namespace SYSLOG_Utils {
void log(String type, String packet, int rssi, float snr, int freqError) {
String syslogPacket = "<165>1 - " + Config.callsign + " CA2RXU_LoRa_iGate_1.2" + " - - - "; //RFC5424 The Syslog Protocol
- if (Config.syslog.active && (stationMode==1 || stationMode==2 || (stationMode==5 && WiFi.status()==WL_CONNECTED))) {
+ if (Config.syslog.active && WiFi.status() == WL_CONNECTED) {
if (type == "APRSIS Tx") {
if (packet.indexOf(":>") > 10) {
syslogPacket += type + " / StartUp_Status / " + packet.substring(packet.indexOf(":>")+2);
@@ -67,7 +66,7 @@ namespace SYSLOG_Utils {
}
void setup() {
- if (Config.syslog.active && (stationMode==1 || stationMode==2 || (stationMode==5 && WiFi.status()==WL_CONNECTED))) {
+ if (Config.syslog.active && WiFi.status() == WL_CONNECTED) {
udpClient.begin(WiFi.localIP(), 0);
Serial.println("init : Syslog Server ... done! (at " + Config.syslog.server + ")");
}
diff --git a/src/utils.cpp b/src/utils.cpp
index 33b51ac..f4667a6 100644
--- a/src/utils.cpp
+++ b/src/utils.cpp
@@ -26,7 +26,6 @@ extern String seventhLine;
extern uint32_t lastBeaconTx;
extern uint32_t lastScreenOn;
extern bool beaconUpdate;
-extern int stationMode;
extern String iGateBeaconPacket;
extern String iGateLoRaBeaconPacket;
extern std::vector lastHeardStation;
@@ -42,23 +41,21 @@ extern bool WiFiConnected;
namespace Utils {
void processStatus() {
- String status = Config.callsign + ">APLRG1,WIDE1-1";
- if (stationMode==1 || stationMode==2 || (stationMode==5 && WiFi.status() == WL_CONNECTED)) {
+ String status = Config.callsign + ">APLRG1," + Config.beacon.path;
+
+ if (Config.aprs_is.active && Config.digi.mode == 0) { // If only IGate
delay(1000);
status += ",qAC:>https://github.com/richonguzman/LoRa_APRS_iGate " + versionDate;
APRS_IS_Utils::upload(status);
SYSLOG_Utils::log("APRSIS Tx", status,0,0,0);
- } else {
- delay(5000);
- status += ":>https://github.com/richonguzman/LoRa_APRS_iGate " + versionDate;
- if (stationMode==4) {
- LoRa_Utils::changeFreqTx();
- }
- LoRa_Utils::sendNewPacket("APRS", status);
- if (stationMode==4) {
- LoRa_Utils::changeFreqRx();
- }
}
+ // Comment this for now we will need this in the future
+ // } else if (Config.digi.mode == 2) {
+ // delay(5000);
+ // status += ":>https://github.com/richonguzman/LoRa_APRS_iGate " + versionDate;
+ // LoRa_Utils::sendNewPacket("APRS", status);
+ // }
+
statusAfterBoot = false;
}
@@ -95,125 +92,60 @@ namespace Utils {
void checkBeaconInterval() {
uint32_t lastTx = millis() - lastBeaconTx;
String beaconPacket, secondaryBeaconPacket;
- if (lastTx >= Config.beaconInterval*60*1000) {
+
+ if (lastTx >= Config.beacon.interval*60*1000) {
beaconUpdate = true;
}
+
if (beaconUpdate) {
display_toggle(true);
- Serial.println("---- Sending iGate Beacon ----");
+ Serial.println("-- Sending Beacon to APRSIS --");
STATION_Utils::deleteNotHeard();
+
activeStations();
+
if (Config.bme.active) {
String sensorData = BME_Utils::readDataSensor();
- beaconPacket = iGateBeaconPacket.substring(0,iGateBeaconPacket.indexOf(":=")+20) + "_" + sensorData + iGateBeaconPacket.substring(iGateBeaconPacket.indexOf(":=")+21) + " + WX";
- if (Config.igateSendsLoRaBeacons && stationMode!=1) {
- secondaryBeaconPacket = iGateLoRaBeaconPacket + sensorData + Config.iGateComment + " + WX";
- }
+ beaconPacket = iGateBeaconPacket.substring(0,iGateBeaconPacket.indexOf(":=")+20) + "_" + sensorData + iGateBeaconPacket.substring(iGateBeaconPacket.indexOf(":=")+21);
+ secondaryBeaconPacket = iGateLoRaBeaconPacket + sensorData + Config.beacon.comment;
} else {
beaconPacket = iGateBeaconPacket;
- if (Config.igateSendsLoRaBeacons && stationMode!=1) {
- secondaryBeaconPacket = iGateLoRaBeaconPacket + Config.iGateComment;
- }
+ secondaryBeaconPacket = iGateLoRaBeaconPacket + Config.beacon.comment;
}
+
#if defined(TTGO_T_LORA32_V2_1) || defined(HELTEC_V2)
if (Config.sendBatteryVoltage) {
beaconPacket += " (Batt=" + String(BATTERY_Utils::checkBattery(),2) + "V)";
+ sixthLine = " (Batt=" + String(BATTERY_Utils::checkBattery(),2) + "V)";
}
#endif
+
if (Config.externalVoltageMeasurement) {
beaconPacket += " (Ext V=" + String(BATTERY_Utils::checkExternalVoltage(),2) + "V)";
+ sixthLine = " (Ext V=" + String(BATTERY_Utils::checkExternalVoltage(),2) + "V)";
}
- if (stationMode==1 || stationMode==2) {
- thirdLine = getLocalIP();
- if (!Config.bme.active) {
- fifthLine = "";
- }
- sixthLine = "";
- show_display(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, "SENDING iGate BEACON", 1000);
- #if defined(TTGO_T_LORA32_V2_1) || defined(HELTEC_V2)
- if (Config.sendBatteryVoltage) {
- sixthLine = " (Batt=" + String(BATTERY_Utils::checkBattery(),2) + "V)";
- }
- #endif
- if (Config.externalVoltageMeasurement) {
- sixthLine = " (Ext V=" + String(BATTERY_Utils::checkExternalVoltage(),2) + "V)";
- }
+
+ if (Config.aprs_is.active && Config.beacon.sendViaAPRSIS) {
+ show_display(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, "SENDING IGATE BEACON", 0);
+
seventhLine = " listening...";
+
APRS_IS_Utils::upload(beaconPacket);
- if (Config.igateSendsLoRaBeacons && stationMode==2) {
- LoRa_Utils::sendNewPacket("APRS", secondaryBeaconPacket);
- }
- show_display(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, seventhLine, 0);
- } else if (stationMode==3 || stationMode==4) {
- String Rx = String(Config.loramodule.digirepeaterRxFreq);
- String Tx = String(Config.loramodule.digirepeaterTxFreq);
- if (stationMode==3) {
- secondLine = "Rx:" + String(Tx.substring(0,3)) + "." + String(Tx.substring(3,6));
- } else {
- secondLine = "Rx:" + String(Rx.substring(0,3)) + "." + String(Rx.substring(3,6));
- }
- secondLine += " Tx:" + String(Tx.substring(0,3)) + "." + String(Tx.substring(3,6));
- thirdLine = "<< DigiRepeater >>";
- fifthLine = "";
- sixthLine = "";
- show_display(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, "SENDING iGate BEACON", 0);
- #if defined(TTGO_T_LORA32_V2_1) || defined(HELTEC_V2)
- if (Config.sendBatteryVoltage) {
- sixthLine = " (Batt=" + String(BATTERY_Utils::checkBattery(),2) + "V)";
- }
- #endif
- if (Config.externalVoltageMeasurement) {
- sixthLine = " (Ext V=" + String(BATTERY_Utils::checkExternalVoltage(),2) + "V)";
- }
- seventhLine = " listening...";
- if (stationMode==4) {
- LoRa_Utils::changeFreqTx();
- }
- LoRa_Utils::sendNewPacket("APRS", beaconPacket);
- if (stationMode==4) {
- LoRa_Utils::changeFreqRx();
- }
- } else if (stationMode==5) {
- if (!Config.bme.active) {
- fifthLine = "";
- }
- sixthLine = "";
- if (WiFi.status() == WL_CONNECTED && espClient.connected()) {
- APRS_IS_Utils::checkStatus();
- thirdLine = getLocalIP();
- show_display(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, "SENDING iGate BEACON", 1000);
- #if defined(TTGO_T_LORA32_V2_1) || defined(HELTEC_V2)
- if (Config.sendBatteryVoltage) {
- sixthLine = " (Batt=" + String(BATTERY_Utils::checkBattery(),2) + "V)";
- }
- #endif
- if (Config.externalVoltageMeasurement) {
- sixthLine = " (Ext V=" + String(BATTERY_Utils::checkExternalVoltage(),2) + "V)";
- }
- seventhLine = " listening...";
- APRS_IS_Utils::upload(beaconPacket);
- if (Config.igateSendsLoRaBeacons) {
- LoRa_Utils::sendNewPacket("APRS", secondaryBeaconPacket);
- }
- show_display(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, seventhLine, 0);
- } else {
- show_display(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, "SENDING iGate BEACON", 0);
- #if defined(TTGO_T_LORA32_V2_1) || defined(HELTEC_V2)
- if (Config.sendBatteryVoltage) {
- sixthLine = " (Batt=" + String(BATTERY_Utils::checkBattery(),2) + "V)";
- }
- #endif
- if (Config.externalVoltageMeasurement) {
- sixthLine = " (Ext V=" + String(BATTERY_Utils::checkExternalVoltage(),2) + "V)";
- }
- seventhLine = " listening...";
- LoRa_Utils::sendNewPacket("APRS", beaconPacket);
- }
}
+
+ if (Config.beacon.sendViaRF) {
+ show_display(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, "SENDING DIGI BEACON", 0);
+
+ seventhLine = " listening...";
+
+ LoRa_Utils::sendNewPacket("APRS", secondaryBeaconPacket);
+ }
+
lastBeaconTx = millis();
lastScreenOn = millis();
beaconUpdate = false;
}
+
if (statusAfterBoot) {
processStatus();
}
@@ -241,21 +173,19 @@ namespace Utils {
}
}
- void validateDigiFreqs() {
- if (stationMode==4) {
- if (abs(Config.loramodule.digirepeaterTxFreq - Config.loramodule.digirepeaterRxFreq) < 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.digirepeaterTxFreq = Config.loramodule.digirepeaterRxFreq; // Inform about that but then change the digirepeaterTxFreq to digirepeaterRxFreq and reset the device
- Config.writeFile();
- ESP.restart();
- }
+ void validateFreqs() {
+ if (Config.loramodule.txFreq != Config.loramodule.rxFreq && abs(Config.loramodule.txFreq - Config.loramodule.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.writeFile();
+ ESP.restart();
}
}
void typeOfPacket(String packet, String packetType) {
String sender;
- if (stationMode==1 || stationMode==2 || (stationMode==5 && WiFi.status()==WL_CONNECTED)) {
+ if (WiFi.status() == WL_CONNECTED) { // If mode 1 2 5
if (packetType == "LoRa-APRS") {
fifthLine = "LoRa Rx ----> APRS-IS";
} else if (packetType == "APRS-LoRa") {
diff --git a/src/utils.h b/src/utils.h
index bee195c..adbc609 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -13,7 +13,7 @@ namespace Utils {
void checkBeaconInterval();
void checkDisplayInterval();
void checkWiFiInterval();
- void validateDigiFreqs();
+ void validateFreqs();
void typeOfPacket(String packet, String packetType);
void onOTAStart();
void onOTAProgress(size_t current, size_t final);
diff --git a/src/web_utils.cpp b/src/web_utils.cpp
index 6f90220..a299b57 100644
--- a/src/web_utils.cpp
+++ b/src/web_utils.cpp
@@ -29,10 +29,6 @@ namespace WEB_Utils {
AsyncWebServer server(80);
- void loop() {
-
- }
-
void handleNotFound(AsyncWebServerRequest *request) {
AsyncWebServerResponse *response = request->beginResponse(404, "text/plain", "Not found");
response->addHeader("Cache-Control", "max-age=3600");
@@ -71,42 +67,47 @@ namespace WEB_Utils {
WiFi_AP wifiap;
wifiap.ssid = request->getParam("wifi.AP." + String(i) + ".ssid", true)->value();
wifiap.password = request->getParam("wifi.AP." + String(i) + ".password", true)->value();
- wifiap.latitude = request->getParam("wifi.AP." + String(i) + ".latitude", true)->value().toDouble();
- wifiap.longitude = request->getParam("wifi.AP." + String(i) + ".longitude", true)->value().toDouble();
+ // wifiap.latitude = request->getParam("wifi.AP." + String(i) + ".latitude", true)->value().toDouble();
+ // wifiap.longitude = request->getParam("wifi.AP." + String(i) + ".longitude", true)->value().toDouble();
Config.wifiAPs.push_back(wifiap);
}
Config.callsign = request->getParam("callsign", true)->value();
- Config.stationMode = request->getParam("stationMode", true)->value().toInt();
- Config.iGateComment = request->getParam("iGateComment", true)->value();
+ // Config.iGateComment = request->getParam("iGateComment", true)->value();
Config.wifiAutoAP.password = request->getParam("wifi.autoAP.password", true)->value();
Config.wifiAutoAP.powerOff = request->getParam("wifi.autoAP.powerOff", true)->value().toInt();
- Config.digi.comment = request->getParam("digi.comment", true)->value();
- Config.digi.latitude = request->getParam("digi.latitude", true)->value().toDouble();
- Config.digi.longitude = request->getParam("digi.longitude", true)->value().toDouble();
+ Config.digi.mode = request->getParam("digi.mode", true)->value().toInt();
+ // Config.digi.comment = request->getParam("digi.comment", true)->value();
+ // Config.digi.latitude = request->getParam("digi.latitude", true)->value().toDouble();
+ // Config.digi.longitude = request->getParam("digi.longitude", true)->value().toDouble();
+ Config.aprs_is.active = request->hasParam("aprs_is.active", true);
Config.aprs_is.passcode = request->getParam("aprs_is.passcode", true)->value();
Config.aprs_is.server = request->getParam("aprs_is.server", true)->value();
Config.aprs_is.port = request->getParam("aprs_is.port", true)->value().toInt();
- Config.aprs_is.reportingDistance = request->getParam("aprs_is.reportingDistance", true)->value().toInt();
-
- Config.loramodule.iGateFreq = request->getParam("lora.iGateFreq", true)->value().toInt();
-
- if (request->hasParam("lora.digirepeaterTxFreq", true)) {
- Config.loramodule.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.aprs_is.reportingDistance = request->getParam("aprs_is.reportingDistance", true)->value().toInt();
+ Config.aprs_is.filter = request->getParam("aprs_is.filter", true)->value();
+ Config.aprs_is.toRF = request->hasParam("aprs_is.toRF", true);
+
+ // Config.loramodule.iGateFreq = request->getParam("lora.iGateFreq", true)->value().toInt();
+ // if (request->hasParam("lora.digirepeaterTxFreq", true)) {
+ // Config.loramodule.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.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.display.alwaysOn = request->hasParam("display.alwaysOn", true);
@@ -128,9 +129,19 @@ namespace WEB_Utils {
Config.ota.username = request->getParam("ota.username", true)->value();
Config.ota.password = request->getParam("ota.password", true)->value();
- Config.beaconInterval = request->getParam("other.beaconInterval", true)->value().toInt();
- Config.igateSendsLoRaBeacons = request->hasParam("other.igateSendsLoRaBeacons", true);
- Config.igateRepeatsLoRaPackets = request->hasParam("other.igateRepeatsLoRaPackets", true);
+ Config.beacon.interval = request->getParam("beacon.interval", true)->value().toInt();
+ Config.beacon.sendViaAPRSIS = request->hasParam("beacon.sendViaAPRSIS", true);
+ Config.beacon.sendViaRF = request->hasParam("beacon.sendViaRF", true);
+ Config.beacon.latitude = request->getParam("beacon.latitude", true)->value().toDouble();
+ Config.beacon.longitude = request->getParam("beacon.longitude", true)->value().toDouble();
+ Config.beacon.comment = request->getParam("beacon.comment", true)->value();
+ Config.beacon.overlay = request->getParam("beacon.overlay", true)->value();
+ Config.beacon.symbol = request->getParam("beacon.symbol", true)->value();
+ Config.beacon.path = request->getParam("beacon.path", true)->value();
+
+ // Config.beaconInterval = request->getParam("other.beaconInterval", true)->value().toInt();
+ // Config.igateSendsLoRaBeacons = request->hasParam("other.igateSendsLoRaBeacons", true);
+ // Config.igateRepeatsLoRaPackets = request->hasParam("other.igateRepeatsLoRaPackets", true);
Config.rememberStationTime = request->getParam("other.rememberStationTime", true)->value().toInt();
Config.sendBatteryVoltage = request->hasParam("other.sendBatteryVoltage", true);
Config.externalVoltageMeasurement = request->hasParam("other.externalVoltageMeasurement", true);
diff --git a/src/web_utils.h b/src/web_utils.h
index c9dd7b4..02f170a 100644
--- a/src/web_utils.h
+++ b/src/web_utils.h
@@ -9,8 +9,6 @@
namespace WEB_Utils {
-
- void loop();
void handleNotFound(AsyncWebServerRequest *request);
void handleStatus(AsyncWebServerRequest *request);
diff --git a/src/wifi_utils.cpp b/src/wifi_utils.cpp
index 4a192ad..698b013 100644
--- a/src/wifi_utils.cpp
+++ b/src/wifi_utils.cpp
@@ -9,7 +9,6 @@ extern Configuration Config;
extern WiFi_AP *currentWiFi;
extern int myWiFiAPIndex;
extern int myWiFiAPSize;
-extern int stationMode;
extern uint32_t previousWiFiMillis;
extern bool WiFiConnected;
extern long WiFiAutoAPTime;
@@ -32,7 +31,7 @@ namespace WIFI_Utils {
WiFi.mode(WIFI_MODE_NULL);
WiFi.mode(WIFI_AP);
- WiFi.softAP(Config.callsign + " AP", "1234567890");
+ WiFi.softAP(Config.callsign + " AP", Config.wifiAutoAP.password);
WiFiAutoAPTime = millis();
WiFiAutoAPStarted = true;
@@ -65,9 +64,7 @@ namespace WIFI_Utils {
delay(1000);
if(myWiFiAPIndex >= (myWiFiAPSize-1)) {
myWiFiAPIndex = 0;
- if (stationMode==5) {
- wifiCounter++;
- }
+ wifiCounter++;
} else {
myWiFiAPIndex++;
}
@@ -123,36 +120,8 @@ namespace WIFI_Utils {
}
void setup() {
- if (stationMode==1 || stationMode==2) {
- if (stationMode==1) {
- Serial.println("stationMode ---> iGate (only Rx)");
- } else {
- Serial.println("stationMode ---> iGate (Rx + Tx)");
- }
- startWiFi();
- btStop();
- } else if (stationMode==3 || stationMode==4) {
- if (stationMode==3) {
- Serial.println("stationMode ---> DigiRepeater (Rx freq == Tx freq)");
- } else {
- Serial.println("stationMode ---> DigiRepeater (Rx freq != Tx freq)");
- }
- startAutoAP();
- btStop();
- } else if (stationMode==5) {
- Serial.println("stationMode ---> iGate when Wifi/APRS available (DigiRepeater when not)");
- startWiFi();
- btStop();
- } else {
- Serial.println("stationMode ---> NOT VALID");
- show_display("------- ERROR -------", "stationMode Not Valid", "device will autofix", "and then reboot", 1000);
-
- Config.stationMode = 1; // Inform about that but then change the station mode to 1 and reset the device
- Config.writeFile();
-
- ESP.restart();
- }
-
+ startWiFi();
+ btStop();
}
}
\ No newline at end of file