diff --git a/data/igate_conf.json b/data/igate_conf.json index 191d053..6d32809 100644 --- a/data/igate_conf.json +++ b/data/igate_conf.json @@ -1,18 +1,18 @@ { - "callsign": "NOCALL-10", + "callsign": "CA2RXU-11", "stationMode": 2, "iGateComment": "LoRa_APRS_iGate", "wifi": { "AP": [ - { "ssid": "WIFI_1", - "password": "wifi_1_password", - "latitude": 0.0000000, - "longitude": 0.0000000 + { "ssid": "Richon", + "password": "k4fPnmg5qnyf", + "latitude": -33.0337718, + "longitude": -71.5737141 }, - { "ssid": "WIFI_2", - "password": "wifi_2_password", - "latitude": 0.0000000, - "longitude": 0.0000000 + { "ssid": "Jimenita", + "password": "mg6wyMhqRnxk", + "latitude": -33.0312492, + "longitude": -71.5796215 } ] }, @@ -22,7 +22,7 @@ "longitude": 0.0000000 }, "aprs_is": { - "passcode": "XYZVW", + "passcode": "23204", "server": "soam.aprs2.net", "port": 14580, "reportingDistance": 30 @@ -55,6 +55,8 @@ }, "other": { "beaconInterval": 15, + "igateLoRaBeacon": true, + "igateRepeatsLoRaPackets": true, "rememberStationTime": 30, "sendBatteryVoltage": false, "externalVoltageMeasurement" : false, diff --git a/src/LoRa_APRS_iGate.cpp b/src/LoRa_APRS_iGate.cpp index 6f29002..df07e69 100644 --- a/src/LoRa_APRS_iGate.cpp +++ b/src/LoRa_APRS_iGate.cpp @@ -20,7 +20,7 @@ Configuration Config; WiFiClient espClient; -String versionDate = "2024.01.05"; +String versionDate = "2024.01.11"; int myWiFiAPIndex = 0; int myWiFiAPSize = Config.wifiAPs.size(); WiFi_AP *currentWiFi = &Config.wifiAPs[myWiFiAPIndex]; @@ -43,7 +43,7 @@ std::vector lastHeardStation_temp; std::vector packetBuffer; std::vector packetBuffer_temp; -String firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, seventhLine, iGateBeaconPacket; +String firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, seventhLine, iGateBeaconPacket, iGateLoRaBeaconPacket; void setup() { Serial.begin(115200); @@ -65,6 +65,7 @@ void setup() { LoRa_Utils::setup(); Utils::validateDigiFreqs(); iGateBeaconPacket = GPS_Utils::generateBeacon(); + iGateLoRaBeaconPacket = GPS_Utils::generateiGateLoRaBeacon(); //Utils::startServer(); SYSLOG_Utils::setup(); BME_Utils::setup(); diff --git a/src/configuration.cpp b/src/configuration.cpp index a03e638..62110d7 100644 --- a/src/configuration.cpp +++ b/src/configuration.cpp @@ -35,6 +35,8 @@ void Configuration::readFile(fs::FS &fs, const char *fileName) { stationMode = data["stationMode"].as(); iGateComment = data["iGateComment"].as(); beaconInterval = data["other"]["beaconInterval"].as(); + igateLoRaBeacon = data["other"]["igateLoRaBeacon"].as(); + igateRepeatsLoRaPackets = data["other"]["igateRepeatsLoRaPackets"].as(); rememberStationTime = data["other"]["rememberStationTime"].as(); sendBatteryVoltage = data["other"]["sendBatteryVoltage"].as(); externalVoltageMeasurement = data["other"]["externalVoltageMeasurement"].as(); diff --git a/src/configuration.h b/src/configuration.h index 95dca15..56dfea3 100644 --- a/src/configuration.h +++ b/src/configuration.h @@ -73,6 +73,8 @@ public: int stationMode; String iGateComment; int beaconInterval; + bool igateLoRaBeacon; + bool igateRepeatsLoRaPackets; int rememberStationTime; bool sendBatteryVoltage; bool externalVoltageMeasurement; diff --git a/src/gps_utils.cpp b/src/gps_utils.cpp index 33544c0..a3c8eec 100644 --- a/src/gps_utils.cpp +++ b/src/gps_utils.cpp @@ -107,6 +107,19 @@ namespace GPS_Utils { 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"; + } + return beaconPacket; + } + double calculateDistanceTo(double latitude, double longitude) { return TinyGPSPlus::distanceBetween(currentWiFi->latitude,currentWiFi->longitude, latitude, longitude) / 1000.0; } diff --git a/src/gps_utils.h b/src/gps_utils.h index ea24a3e..32ed920 100644 --- a/src/gps_utils.h +++ b/src/gps_utils.h @@ -9,6 +9,7 @@ namespace GPS_Utils { String processLatitudeAPRS(); String processLongitudeAPRS(); String generateBeacon(); + String generateiGateLoRaBeacon(); double calculateDistanceCourse(double latitude, double longitude); String decodeEncodedGPS(String packet); String getReceivedGPS(String packet); diff --git a/src/utils.cpp b/src/utils.cpp index cf14ad1..7cbd9dc 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -34,6 +34,7 @@ extern uint32_t lastScreenOn; extern bool beaconUpdate; extern int stationMode; extern String iGateBeaconPacket; +extern String iGateLoRaBeaconPacket; extern std::vector lastHeardStation; extern int rssi; extern float snr; @@ -103,7 +104,7 @@ namespace Utils { void checkBeaconInterval() { uint32_t lastTx = millis() - lastBeaconTx; - String beaconPacket; + String beaconPacket, secondaryBeaconPacket; if (lastTx >= Config.beaconInterval*60*1000) { beaconUpdate = true; } @@ -113,9 +114,16 @@ namespace Utils { STATION_Utils::deleteNotHeard(); activeStations(); if (Config.bme.active) { - beaconPacket = iGateBeaconPacket.substring(0,iGateBeaconPacket.indexOf(":=")+20) + "_" + BME_Utils::readDataSensor() + iGateBeaconPacket.substring(iGateBeaconPacket.indexOf(":=")+21) + " + WX"; + String sensorData = BME_Utils::readDataSensor(); + beaconPacket = iGateBeaconPacket.substring(0,iGateBeaconPacket.indexOf(":=")+20) + "_" + sensorData + iGateBeaconPacket.substring(iGateBeaconPacket.indexOf(":=")+21) + " + WX"; + if (Config.igateLoRaBeacon) { + secondaryBeaconPacket = iGateLoRaBeaconPacket + sensorData + Config.iGateComment + " + WX"; + } } else { beaconPacket = iGateBeaconPacket; + if (Config.igateLoRaBeacon) { + secondaryBeaconPacket = iGateLoRaBeaconPacket + Config.iGateComment; + } } #if defined(TTGO_T_LORA32_V2_1) || defined(HELTEC_V2) if (Config.sendBatteryVoltage) { @@ -142,6 +150,9 @@ namespace Utils { } seventhLine = " listening..."; espClient.write((beaconPacket + "\n").c_str()); + if (Config.igateLoRaBeacon) { + 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);