diff --git a/README.md b/README.md index ea58b47..965cd24 100644 --- a/README.md +++ b/README.md @@ -93,6 +93,7 @@ Versions: - 2023.06.18 Info on Oled Screen mayor update, added RSSI and Distance to Listened Station. - 2023.07.05 Adding monitor info of Battery connected. - 2023.07.16 Small OTA, BME module update. +- 2023.07.31 StationMode5 added: iGate when WiFi and APRS available, DigiRepeater when not. __________________________________________ diff --git a/data/igate_conf.json b/data/igate_conf.json index cf87c30..a40de57 100644 --- a/data/igate_conf.json +++ b/data/igate_conf.json @@ -1,29 +1,29 @@ { - "callsign": "CD2RXU-11", - "stationMode": 5, + "callsign": "CD2RXU-10", + "stationMode": 2, "iGateComment": "LoRa_APRS_iGate", "wifi": { "AP": [ { "ssid": "Richon", "password": "k4fPnmg5qnyf", - "latitude": -32.9543284, - "longitude": -71.1202063 + "latitude": -33.0337313, + "longitude": -71.5737261 }, - { "ssid": "iPhone Richon", - "password": "1234poto5678", - "latitude": -32.9543284, - "longitude": -71.1202063 - } + { "ssid": "Jimenita", + "password": "mg6wyMhqRnxk", + "latitude": -33.0312492, + "longitude": -71.5796215 + } ] }, "digi": { "comment": "LoRa_APRS_Digirepeater", - "latitude": -32.9543284, - "longitude": -71.1202063 + "latitude": -33.0338131, + "longitude": -71.5737237 }, "aprs_is": { "passcode": "23201", - "server": "euro.aprs2.net", + "server": "soam.aprs2.net", "port": 14580, "reportingDistance": 30 }, @@ -37,7 +37,7 @@ "power": 20 }, "display": { - "alwaysOn": true, + "alwaysOn": false, "timeout": 4, "turn180" : false }, @@ -49,8 +49,7 @@ "other": { "beaconInterval": 15, "rememberStationTime": 30, - "sendBatteryVoltage": false, - "lastWiFiCheck": 15 + "sendBatteryVoltage": false }, "bme": { "active": false diff --git a/firmware/LoRa_APRS_iGate_Richonguzman-2023-07-06.bin b/firmware/LoRa_APRS_iGate_Richonguzman-2023-07-31.bin similarity index 54% rename from firmware/LoRa_APRS_iGate_Richonguzman-2023-07-06.bin rename to firmware/LoRa_APRS_iGate_Richonguzman-2023-07-31.bin index 06b34d7..87725af 100644 Binary files a/firmware/LoRa_APRS_iGate_Richonguzman-2023-07-06.bin and b/firmware/LoRa_APRS_iGate_Richonguzman-2023-07-31.bin differ diff --git a/src/LoRa_APRS_iGate.cpp b/src/LoRa_APRS_iGate.cpp index d8f7d25..d6b5db3 100644 --- a/src/LoRa_APRS_iGate.cpp +++ b/src/LoRa_APRS_iGate.cpp @@ -20,7 +20,7 @@ Configuration Config; WiFiClient espClient; -String versionDate = "2023.07.30"; +String versionDate = "2023.07.31"; int myWiFiAPIndex = 0; int myWiFiAPSize = Config.wifiAPs.size(); WiFi_AP *currentWiFi = &Config.wifiAPs[myWiFiAPIndex]; @@ -64,23 +64,9 @@ void loop() { if (!espClient.connected()) { APRS_IS_Utils::connect(); } - APRS_IS_Utils::checkStatus(); - show_display(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, seventhLine, 0); - while (espClient.connected()) { - Utils::checkDisplayInterval(); - Utils::checkBeaconInterval(); - APRS_IS_Utils::processLoRaPacket(LoRa_Utils::receivePacket()); - if (espClient.available()) { - String aprsisPacket; - aprsisPacket.concat(espClient.readStringUntil('\r')); - APRS_IS_Utils::processAPRSISPacket(aprsisPacket); - } - } + APRS_IS_Utils::loop(); } else if (stationMode==3 || stationMode==4) { // DigiRepeater (3 RxFreq=TxFreq / 4 RxFreq!=TxFreq) - Utils::checkDisplayInterval(); - Utils::checkBeaconInterval(); - show_display(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, seventhLine, 0); - DIGI_Utils::processPacket(LoRa_Utils::receivePacket()); + DIGI_Utils::loop(); } else if (stationMode==5) { // iGate when WiFi and APRS available , DigiRepeater when not (RxFreq=TxFreq) Utils::checkWiFiInterval(); if (WiFi.status() == WL_CONNECTED) { // iGate Mode @@ -93,31 +79,9 @@ void loop() { lastStationModeState = 0; Utils::startOTAServer(); } - APRS_IS_Utils::checkStatus(); - show_display(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, seventhLine, 0); - while (espClient.connected()) { - Utils::checkDisplayInterval(); - Utils::checkBeaconInterval(); - APRS_IS_Utils::processLoRaPacket(LoRa_Utils::receivePacket()); - if (espClient.available()) { - String aprsisPacket; - aprsisPacket.concat(espClient.readStringUntil('\r')); - APRS_IS_Utils::processAPRSISPacket(aprsisPacket); - } - } + APRS_IS_Utils::loop(); } else { // DigiRepeater Mode - if (lastStationModeState == 0) { - 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); - DIGI_Utils::processPacket(LoRa_Utils::receivePacket()); + DIGI_Utils::loop(); } } } \ No newline at end of file diff --git a/src/aprs_is_utils.cpp b/src/aprs_is_utils.cpp index d511294..f5486db 100644 --- a/src/aprs_is_utils.cpp +++ b/src/aprs_is_utils.cpp @@ -193,4 +193,19 @@ void processAPRSISPacket(String packet) { } } +void loop() { + checkStatus(); + show_display(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, seventhLine, 0); + while (espClient.connected()) { + Utils::checkDisplayInterval(); + Utils::checkBeaconInterval(); + processLoRaPacket(LoRa_Utils::receivePacket()); + if (espClient.available()) { + String aprsisPacket; + aprsisPacket.concat(espClient.readStringUntil('\r')); + processAPRSISPacket(aprsisPacket); + } + } +} + } \ No newline at end of file diff --git a/src/aprs_is_utils.h b/src/aprs_is_utils.h index 6a2e428..8a41938 100644 --- a/src/aprs_is_utils.h +++ b/src/aprs_is_utils.h @@ -10,6 +10,7 @@ void checkStatus(); String createPacket(String unprocessedPacket); void processLoRaPacket(String packet); void processAPRSISPacket(String packet); +void loop(); } diff --git a/src/configuration.cpp b/src/configuration.cpp index d6fe8b2..2d90496 100644 --- a/src/configuration.cpp +++ b/src/configuration.cpp @@ -37,7 +37,6 @@ void Configuration::readFile(fs::FS &fs, const char *fileName) { beaconInterval = data["other"]["beaconInterval"].as(); rememberStationTime = data["other"]["rememberStationTime"].as(); sendBatteryVoltage = data["other"]["sendBatteryVoltage"].as(); - lastWiFiCheck = data["other"]["lastWiFiCheck"].as(); digi.comment = data["digi"]["comment"].as(); digi.latitude = data["digi"]["latitude"].as(); diff --git a/src/configuration.h b/src/configuration.h index f0779c8..6d439de 100644 --- a/src/configuration.h +++ b/src/configuration.h @@ -67,7 +67,6 @@ public: int beaconInterval; int rememberStationTime; bool sendBatteryVoltage; - int lastWiFiCheck; std::vector wifiAPs; DIGI digi; APRS_IS aprs_is; diff --git a/src/digi_utils.cpp b/src/digi_utils.cpp index 1821012..d55065d 100644 --- a/src/digi_utils.cpp +++ b/src/digi_utils.cpp @@ -2,12 +2,22 @@ #include "station_utils.h" #include "lora_utils.h" #include "digi_utils.h" +#include "gps_utils.h" #include "display.h" #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; +extern String thirdLine; +extern String fourthLine; +extern String fifthLine; +extern String sixthLine; +extern String seventhLine; namespace DIGI_Utils { @@ -49,8 +59,9 @@ void processPacket(String packet) { } } } + void loop() { - if (lastStationModeState == 0) { + if (lastStationModeState==0 && stationMode==5) { iGateBeaconPacket = GPS_Utils::generateBeacon(); lastStationModeState = 1; String Tx = String(Config.loramodule.digirepeaterTxFreq); diff --git a/src/gps_utils.cpp b/src/gps_utils.cpp index 8b1faeb..1956f4a 100644 --- a/src/gps_utils.cpp +++ b/src/gps_utils.cpp @@ -90,9 +90,14 @@ String generateBeacon() { beaconPacket += "a"; } beaconPacket += Config.iGateComment; - } else { //stationMode 3 y 4 - stationLatitude = processLatitudeAPRS(Config.digi.latitude); - stationLongitude = processLongitudeAPRS(Config.digi.longitude); + } 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:=" + stationLatitude + "L" + stationLongitude + "#" + Config.digi.comment; } return beaconPacket; diff --git a/src/utils.cpp b/src/utils.cpp index 7289555..d9b0be3 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -48,7 +48,7 @@ namespace Utils { void processStatus() { String status = Config.callsign + ">APLRG1"; - if (stationMode==1 || stationMode==2) { + if (stationMode==1 || stationMode==2 || (stationMode==5 && WiFi.status() == WL_CONNECTED)) { delay(1000); status += ",qAC:>https://github.com/richonguzman/LoRa_APRS_iGate " + versionDate ; espClient.write((status + "\n").c_str()); @@ -189,7 +189,7 @@ void checkDisplayInterval() { void checkWiFiInterval() { uint32_t WiFiCheck = millis() - lastWiFiCheck; - if (WiFi.status() != WL_CONNECTED && WiFiCheck >= Config.lastWiFiCheck*60*1000) { + if (WiFi.status() != WL_CONNECTED && WiFiCheck >= 15*60*1000) { WiFiConnect = true; } if (WiFiConnect) {