From e635d5757fbe40c2a3d0064058152ea59b6afc6c Mon Sep 17 00:00:00 2001 From: richonguzman Date: Tue, 28 Nov 2023 00:57:15 -0300 Subject: [PATCH] syslog fix for stationMode5 --- src/aprs_is_utils.cpp | 4 ++-- src/digi_utils.cpp | 6 +++--- src/gps_utils.cpp | 4 ++-- src/lora_utils.cpp | 2 +- src/syslog_utils.cpp | 4 ++-- src/utils.cpp | 10 +++++----- src/wifi_utils.cpp | 12 ++++++------ 7 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/aprs_is_utils.cpp b/src/aprs_is_utils.cpp index 278f05c..0f1bb30 100644 --- a/src/aprs_is_utils.cpp +++ b/src/aprs_is_utils.cpp @@ -71,7 +71,7 @@ namespace APRS_IS_Utils { } String createPacket(String packet) { - if (stationMode > 1) { + if (stationMode>1) { 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"; @@ -93,7 +93,7 @@ namespace APRS_IS_Utils { #endif Sender = packet.substring(3,packet.indexOf(">")); if (Sender != Config.callsign) { // avoid listening yourself by digirepeating - if (stationMode == 2 || stationMode == 5) { + if (stationMode==2 || stationMode==5) { if (packet.indexOf("::") > 10) { // its a Message! AddresseeAndMessage = packet.substring(packet.indexOf("::")+2); Addressee = AddresseeAndMessage.substring(0,AddresseeAndMessage.indexOf(":")); diff --git a/src/digi_utils.cpp b/src/digi_utils.cpp index 4d1d779..6fbb271 100644 --- a/src/digi_utils.cpp +++ b/src/digi_utils.cpp @@ -51,18 +51,18 @@ namespace DIGI_Utils { LoRa_Utils::sendNewPacket("APRS", loraPacket); display_toggle(true); lastScreenOn = millis(); - } else if (stationMode ==4){ + } else if (stationMode==4){ if (packet.indexOf("WIDE1-1") == -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) { + if (stationMode==4) { LoRa_Utils::changeFreqTx(); } LoRa_Utils::sendNewPacket("APRS", loraPacket); - if (stationMode == 4) { + if (stationMode==4) { LoRa_Utils::changeFreqRx(); } display_toggle(true); diff --git a/src/gps_utils.cpp b/src/gps_utils.cpp index 83efc9e..61d91fa 100644 --- a/src/gps_utils.cpp +++ b/src/gps_utils.cpp @@ -80,7 +80,7 @@ String processLongitudeAPRS(double lon) { String generateBeacon() { String stationLatitude, stationLongitude, beaconPacket; - if (stationMode==1 || stationMode==2 || (stationMode==5 && WiFi.status() == WL_CONNECTED && espClient.connected()) || stationMode==6) { + if (stationMode==1 || stationMode==2 || (stationMode==5 && WiFi.status()==WL_CONNECTED && espClient.connected()) || stationMode==6) { stationLatitude = processLatitudeAPRS(currentWiFi->latitude); stationLongitude = processLongitudeAPRS(currentWiFi->longitude); beaconPacket = Config.callsign + ">APLRG1,WIDE1-1"; @@ -88,7 +88,7 @@ String generateBeacon() { beaconPacket += ",qAC"; } beaconPacket += ":=" + stationLatitude + "L" + stationLongitude; - if (stationMode == 1) { + if (stationMode==1) { beaconPacket += "&"; } else { beaconPacket += "a"; diff --git a/src/lora_utils.cpp b/src/lora_utils.cpp index 833249d..421c160 100644 --- a/src/lora_utils.cpp +++ b/src/lora_utils.cpp @@ -18,7 +18,7 @@ namespace LoRa_Utils { 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) { + if (stationMode==1 || stationMode==2) { freq = Config.loramodule.iGateFreq; } else { freq = Config.loramodule.digirepeaterTxFreq; diff --git a/src/syslog_utils.cpp b/src/syslog_utils.cpp index 818e2fd..aea5459 100644 --- a/src/syslog_utils.cpp +++ b/src/syslog_utils.cpp @@ -13,7 +13,7 @@ namespace SYSLOG_Utils { void log(String type, String packet, int rssi, float snr, int freqError) { String syslogPacket = "ESP32 LoRa [APRS] - " + Config.callsign + " - "; - if (Config.syslog.active && (stationMode==1 || stationMode==2 || stationMode==5)) { + if (Config.syslog.active && (stationMode==1 || stationMode==2 || (stationMode==5 && WiFi.status()==WL_CONNECTED))) { if (type == "APRSIS Tx") { if (packet.indexOf(":>") > 10) { syslogPacket += type + " - StartUp STATUS - " + packet.substring(packet.indexOf(":>")+2); @@ -50,7 +50,7 @@ void log(String type, String packet, int rssi, float snr, int freqError) { } void setup() { - if (Config.syslog.active && (stationMode==1 || stationMode==2 || stationMode==5)) { + if (Config.syslog.active && (stationMode==1 || stationMode==2 || (stationMode==5 && 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 9b8f8b0..98e4518 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -63,11 +63,11 @@ namespace Utils { } else { delay(5000); status += ":>https://github.com/richonguzman/LoRa_APRS_iGate " + versionDate; - if (stationMode == 4) { + if (stationMode==4) { LoRa_Utils::changeFreqTx(); } LoRa_Utils::sendNewPacket("APRS", status); - if (stationMode == 4) { + if (stationMode==4) { LoRa_Utils::changeFreqRx(); } } @@ -247,7 +247,7 @@ namespace Utils { } void validateDigiFreqs() { - if (stationMode == 4) { + if (stationMode==4) { if (abs(Config.loramodule.digirepeaterTxFreq - Config.loramodule.digirepeaterRxFreq) < 125000) { Serial.println("Tx Freq less than 125kHz from Rx Freq ---> NOT VALID, check 'data/igate_conf.json'"); show_display("Tx Freq is less than ", "125kHz from Rx Freq", "change it on : /data/", "igate_conf.json", 0); @@ -258,7 +258,7 @@ namespace Utils { void typeOfPacket(String packet, String packetType) { String sender; - if (stationMode==1 || stationMode==2 || (stationMode==5 && WiFi.status() == WL_CONNECTED)) { + if (stationMode==1 || stationMode==2 || (stationMode==5 && WiFi.status()==WL_CONNECTED)) { if (packetType == "LoRa-APRS") { fifthLine = "LoRa Rx ----> APRS-IS"; } else if (packetType == "APRS-LoRa") { @@ -308,7 +308,7 @@ namespace Utils { } void startServer() { - if (stationMode==1 || stationMode==2 || (stationMode==5 && WiFi.status() == WL_CONNECTED)) { + if (stationMode==1 || stationMode==2 || (stationMode==5 && WiFi.status()==WL_CONNECTED)) { server.on("/", HTTP_GET, [](AsyncWebServerRequest *request) { request->send(200, "text/plain", "Hi " + Config.callsign + ", \n\nthis is your (Richonguzman/CA2RXU) LoRa iGate , version " + versionDate + ".\n\nTo update your firmware or filesystem go to: http://" + getLocalIP().substring(getLocalIP().indexOf(":")+3) + "/update\n\n\n73!"); }); diff --git a/src/wifi_utils.cpp b/src/wifi_utils.cpp index cd333fd..b06f763 100644 --- a/src/wifi_utils.cpp +++ b/src/wifi_utils.cpp @@ -26,7 +26,7 @@ void checkWiFi() { void startWiFi() { int wifiCounter = 0; int status = WL_IDLE_STATUS; - if (stationMode != 6) { + if (stationMode!=6) { WiFi.mode(WIFI_STA); WiFi.disconnect(); delay(500); @@ -71,7 +71,7 @@ void startWiFi() { } void setup() { - if (stationMode == 1 || stationMode == 2) { + if (stationMode==1 || stationMode==2) { if (stationMode==1) { Serial.println("stationMode ---> iGate (only Rx)"); } else { @@ -79,17 +79,17 @@ void setup() { } startWiFi(); btStop(); - } else if (stationMode == 3 || stationMode == 4) { - if (stationMode == 3) { + } 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)"); } WiFi.mode(WIFI_OFF); btStop(); - } else if (stationMode == 5) { + } else if (stationMode==5) { Serial.println("stationMode ---> iGate when Wifi/APRS available (DigiRepeater when not)"); - } else if (stationMode == 6) { + } else if (stationMode==6) { Serial.println("stationMode ---> Digirepeater with iGate capabilities (when WiFi available)"); WiFi.mode(WIFI_STA); WiFi.disconnect();