diff --git a/data/igate_conf.json b/data/igate_conf.json index 3393aa6..02edb31 100644 --- a/data/igate_conf.json +++ b/data/igate_conf.json @@ -1,35 +1,36 @@ { "callsign": "CD2RXU-10", - "stationMode": 4, + "stationMode": 2, "iGateComment": "LoRa_APRS_iGate", - "digirepeaterComment": "LoRa_APRS_Digirepeater" , "wifi": { "AP": [ - { "SSID": "Richon", - "Password": "k4fPnmg5qnyf", - "Latitude": -33.0338131, - "Longitude": -71.5737237 + { "ssid": "Richon", + "password": "k4fPnmg5qnyf", + "latitude": -33.0338131, + "longitude": -71.5737237 }, - { "SSID": "Jimenita", - "Password": "mg6wyMhqRnxk", - "Latitude": -33.0312492, - "Longitude": -71.5796215 + { "ssid": "Jimenita", + "password": "mg6wyMhqRnxk", + "latitude": -33.0312492, + "longitude": -71.5796215 } - ], - "checkInterval": 30 + ] + }, + "digi": { + "comment": "LoRa_APRS_Digirepeater", + "latitude": -33.0338131, + "longitude": -71.5737237 }, "aprs_is": { "passcode": "23201", "server": "soam.aprs2.net", "port": 14580, - "softwareName": "ESP32_LoRa_iGate", - "softwareVersion": "1.2", "reportingDistance": 30 }, "lora": { "iGateFreq": 433775000, - "digirepeaterTxFreq": 433900000, - "digirepeaterRxFreq": 433775000, + "digirepeaterTxFreq": 433775000, + "digirepeaterRxFreq": 433900000, "spreadingFactor": 12, "signalBandwidth": 125000, "codingRate4": 5, diff --git a/src/LoRa_APRS_iGate.cpp b/src/LoRa_APRS_iGate.cpp index 612d0ff..b264d91 100644 --- a/src/LoRa_APRS_iGate.cpp +++ b/src/LoRa_APRS_iGate.cpp @@ -69,7 +69,7 @@ void loop() { }*/ } else if (stationMode==1 || stationMode==2 ) { // iGate (1 Only Rx / 2 Rx+Tx) unsigned long currentWiFiMillis = millis(); - if ((WiFi.status() != WL_CONNECTED) && (currentWiFiMillis - previousWiFiMillis >= currentWiFi->checkInterval*1000)) { + if ((WiFi.status() != WL_CONNECTED) && (currentWiFiMillis - previousWiFiMillis >= 30*1000)) { Serial.print(millis()); Serial.println("Reconnecting to WiFi..."); WiFi.disconnect(); diff --git a/src/aprs_is_utils.cpp b/src/aprs_is_utils.cpp index 9302005..3bc7939 100644 --- a/src/aprs_is_utils.cpp +++ b/src/aprs_is_utils.cpp @@ -34,7 +34,7 @@ void connect(){ 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 " + Config.aprs_is.softwareName + " " + Config.aprs_is.softwareVersion + " filter t/m/" + Config.callsign + "/" + (String)Config.aprs_is.reportingDistance + "\n\r"; + aprsauth = "user " + Config.callsign + " pass " + Config.aprs_is.passcode + " vers CD2RXU_LoRa_iGate 1.2 filter t/m/" + Config.callsign + "/" + (String)Config.aprs_is.reportingDistance + "\n\r"; espClient.write(aprsauth.c_str()); delay(200); } @@ -80,12 +80,12 @@ void processLoRaPacket(String packet) { Serial.print(" ---> APRS LoRa Packet!"); Sender = packet.substring(3,packet.indexOf(">")); if (Sender != Config.callsign) { // avoid listening yourself by digirepeating - if (stationMode > 1) { // only answer when stationMode > 1 (with Ham Licence) + if (stationMode == 2) { if (packet.indexOf("::") > 10) { // its a Message! AddresseeAndMessage = packet.substring(packet.indexOf("::")+2); Addressee = AddresseeAndMessage.substring(0,AddresseeAndMessage.indexOf(":")); Addressee.trim(); - if (Addressee == Config.callsign) { // its for me! + if (Addressee == Config.callsign) { // its for me! if (AddresseeAndMessage.indexOf("{")>0) { // ack? ackMessage = "ack" + AddresseeAndMessage.substring(AddresseeAndMessage.indexOf("{")+1); ackMessage.trim(); @@ -113,7 +113,7 @@ void processLoRaPacket(String packet) { } } if (!queryMessage) { - aprsPacket = APRS_IS_Utils::createPacket(packet); + aprsPacket = createPacket(packet); if (!Config.display.alwaysOn) { display_toggle(true); } @@ -138,13 +138,4 @@ void processLoRaPacket(String packet) { } } -/*void processSplitedMessage(String addressee, String message1, String message2) { - espClient.write((Config.callsign + ">APRS,qAC::" + addressee + ":" + message1 + "\n").c_str()); - Serial.println("-------> " + message1); - Serial.println("(waiting for second part)"); - delay(5000); - espClient.write((Config.callsign + ">APRS,qAC::" + addressee + ":" + message2 + "\n").c_str()); - Serial.println("-------> " + message2); -}*/ - } \ No newline at end of file diff --git a/src/aprs_is_utils.h b/src/aprs_is_utils.h index a4e8984..ad37125 100644 --- a/src/aprs_is_utils.h +++ b/src/aprs_is_utils.h @@ -9,7 +9,6 @@ void connect(); String checkStatus(); String createPacket(String unprocessedPacket); void processLoRaPacket(String packet); -//void processSplitedMessage(String addressee, String message1, String message2); } diff --git a/src/configuration.cpp b/src/configuration.cpp index b4618d4..afcc7b2 100644 --- a/src/configuration.cpp +++ b/src/configuration.cpp @@ -21,11 +21,10 @@ void Configuration::readFile(fs::FS &fs, const char *fileName) { JsonArray WiFiArray = data["wifi"]["AP"]; for (int i = 0; i < WiFiArray.size(); i++) { 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(); - wifiap.checkInterval = data["wifi"]["checkInterval"].as(); + 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); } @@ -33,17 +32,18 @@ void Configuration::readFile(fs::FS &fs, const char *fileName) { callsign = data["callsign"].as(); stationMode = data["stationMode"].as(); iGateComment = data["iGateComment"].as(); - digirepeaterComment = data["digirepeaterComment"].as(); beaconInterval = data["other"]["beaconInterval"].as(); rememberStationTime = data["other"]["rememberStationTime"].as(); statusAfterBoot = data["other"]["statusAfterBoot"].as(); defaultStatus = data["other"]["defaultStatus"].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.softwareName = data["aprs_is"]["softwareName"].as(); - aprs_is.softwareVersion = data["aprs_is"]["softwareVersion"].as(); aprs_is.reportingDistance = data["aprs_is"]["reportingDistance"].as(); loramodule.iGateFreq = data["lora"]["iGateFreq"].as(); diff --git a/src/configuration.h b/src/configuration.h index 5deef77..aad2ef0 100644 --- a/src/configuration.h +++ b/src/configuration.h @@ -14,7 +14,13 @@ public: String password; double latitude; double longitude; - int checkInterval; +}; + +class DIGI { +public: + String comment; + double latitude; + double longitude; }; class APRS_IS { @@ -22,8 +28,6 @@ public: String passcode; String server; int port; - String softwareName; - String softwareVersion; int reportingDistance; }; @@ -50,12 +54,12 @@ public: String callsign; int stationMode; String iGateComment; - String digirepeaterComment; int beaconInterval; int rememberStationTime; bool statusAfterBoot; String defaultStatus; std::vector wifiAPs; + DIGI digi; APRS_IS aprs_is; LoraModule loramodule; Display display; diff --git a/src/digi_utils.cpp b/src/digi_utils.cpp index 2f30450..e59c34e 100644 --- a/src/digi_utils.cpp +++ b/src/digi_utils.cpp @@ -29,7 +29,7 @@ void typeOfPacket(String packet) { } void processPacket(String packet) { - String firstPart, lastPart; + String firstPart, lastPart, loraPacket; if (packet != "") { Serial.print("Received Lora Packet : " + String(packet)); if ((packet.substring(0, 3) == "\x3c\xff\x01") && (packet.indexOf("NOGATE") == -1) && (packet.indexOf("WIDE1-1") > 10)) { // confirmar lo de WIDE1-1 !!! @@ -37,12 +37,12 @@ void processPacket(String packet) { typeOfPacket(packet); firstPart = packet.substring(3,packet.indexOf(",")+1); lastPart = packet.substring(packet.indexOf(":")); - Serial.println(firstPart + Config.callsign + "*" + lastPart); + loraPacket = firstPart + Config.callsign + "*" + lastPart; delay(500); if (stationMode == 4) { // Digirepeating with Freq Rx != Tx LoRa_Utils::changeFreqTx(); } - LoRa_Utils::sendNewPacket("APRS", firstPart + Config.callsign + lastPart); + LoRa_Utils::sendNewPacket("APRS", loraPacket); if (stationMode == 4) { LoRa_Utils::changeFreqRx(); } diff --git a/src/gps_utils.cpp b/src/gps_utils.cpp index d12cc32..14eec6f 100644 --- a/src/gps_utils.cpp +++ b/src/gps_utils.cpp @@ -22,8 +22,8 @@ String double2string(double n, int ndec) { return r; } -String processLatitudeAPRS() { - String degrees = double2string(currentWiFi->latitude,6); +String processLatitudeAPRS(double lat) { + String degrees = double2string(lat,6); String north_south, latitude, convDeg3; float convDeg, convDeg2; @@ -46,8 +46,8 @@ String processLatitudeAPRS() { return latitude; } -String processLongitudeAPRS() { - String degrees = double2string(currentWiFi->longitude,6); +String processLongitudeAPRS(double lon) { + String degrees = double2string(lon,6); String east_west, longitude, convDeg3; float convDeg, convDeg2; @@ -73,18 +73,21 @@ String processLongitudeAPRS() { } String generateBeacon() { - String iGateLat = processLatitudeAPRS(); - String iGateLon = processLongitudeAPRS(); - String beaconPacket = Config.callsign + ">APLRG1"; - if (stationMode == 1) { - beaconPacket += ",qAC:=" +iGateLat + "L" + iGateLon + "&"; + String stationLatitude, stationLongitude, beaconPacket; + if (stationMode==1 || stationMode==2) { + stationLatitude = processLatitudeAPRS(currentWiFi->latitude); + stationLongitude = processLongitudeAPRS(currentWiFi->longitude); + beaconPacket = Config.callsign + ">APLRG1,qAC:=" + stationLatitude + "L" + stationLongitude; + if (stationMode == 1) { + beaconPacket += "&"; + } else { + beaconPacket += "a"; + } beaconPacket += Config.iGateComment; - } else if (stationMode == 2 || stationMode == 5) { - beaconPacket += ",qAC:=" + iGateLat + "L" + iGateLon + "a"; - beaconPacket += Config.iGateComment; - } else if (stationMode ==3 || stationMode == 4) { - beaconPacket += ":=" + iGateLat + "L" + iGateLon + "#"; - beaconPacket += Config.digirepeaterComment; + } else { //stationMode 3 y 4 + 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/query_utils.cpp b/src/query_utils.cpp index 4d6081a..2f44d35 100644 --- a/src/query_utils.cpp +++ b/src/query_utils.cpp @@ -13,7 +13,7 @@ String process(String query, String station, String queryOrigin) { if (query=="?APRS?" || query=="?aprs?" || query=="?Aprs?" || query=="H" || query=="h" || query=="Help" || query=="help" || query=="?") { answer = "?APRSV ?APRSP ?APRSL ?APRSH ?WHERE callsign"; } else if (query=="?APRSV" || query=="?aprsv" || query=="?Aprsv") { - answer = Config.aprs_is.softwareName + " " + Config.aprs_is.softwareVersion; + answer = "CD2RXU_LoRa_iGate 1.2"; } else if (query=="?APRSP" || query=="?aprsp" || query=="?Aprsp") { answer = "iGate QTH: " + String(currentWiFi->latitude,2) + " " + String(currentWiFi->longitude,2); } else if (query=="?APRSL" || query=="?aprsl" || query=="?Aprsl") {