diff --git a/src/LoRa_APRS_iGate.cpp b/src/LoRa_APRS_iGate.cpp index c83f4a2..755b350 100644 --- a/src/LoRa_APRS_iGate.cpp +++ b/src/LoRa_APRS_iGate.cpp @@ -131,7 +131,7 @@ void setup() { } void loop() { - if (stationMode==3 || stationMode==4) { // DigiRepeater Mode / No backUpMode + if (stationMode==3 || stationMode==4) { // DigiRepeater (3 RxFreq=TxFreq / 4 RxFreq!=TxFreq ) secondLine = ""; uint32_t lastBeaconTx = millis() - lastTxTime; if (lastBeaconTx >= Config.beaconInterval*60*1000) { @@ -143,7 +143,7 @@ void loop() { fourthLine = " listening..."; Serial.println("---- Sending iGate Beacon ----"); //Serial.println(iGateBeaconPacket); - //LoRa_Utils::sendNewPacket("APRS",iGateBeaconPacket); + LoRa_Utils::sendNewPacket("APRS",iGateBeaconPacket); lastTxTime = millis(); beacon_update = false; } diff --git a/src/digi_utils.cpp b/src/digi_utils.cpp index 7ef881c..d7941d0 100644 --- a/src/digi_utils.cpp +++ b/src/digi_utils.cpp @@ -37,85 +37,18 @@ void process(String packet) { firstPart = packet.substring(3,packet.indexOf(",")+1); lastPart = packet.substring(packet.indexOf(":")); Serial.println(firstPart + Config.callsign + lastPart); - if (stationMode == 3) { - delay(8000);// quizas no es necesario esperar tanto? - //LoRa_Utils::sendNewPacket("APRS", firstPart + Config.callsign + lastPart); - Serial.println("repitiendo/Tx mensaje truncado"); - LoRa_Utils::sendNewPacket("APRS", firstPart + Config.callsign + lastPart + Config.iGateComment); // test porque esta truncado - } else { // enviar con != freq - delay(8000); - Serial.println("repitiendo/Tx mensaje otra frecuencia"); + delay(500); + if (stationMode == 4) { // Digirepeating with Freq Rx != Tx LoRa_Utils::changeFreqTx(); - LoRa_Utils::sendNewPacket("APRS", firstPart + Config.callsign + lastPart + "1"); + } + LoRa_Utils::sendNewPacket("APRS", firstPart + Config.callsign + lastPart); + if (stationMode == 4) { LoRa_Utils::changeFreqRx(); } } else { Serial.println(" ---> LoRa Packet Ignored (first 3 bytes or NOGATE)\n"); } } - /*void checkReceivedPacket(String packet) { - bool queryMessage = false; - String aprsPacket, Sender, AddresseeAndMessage, Addressee, ackMessage, receivedMessage; - - if ((packet.substring(0, 3) == "\x3c\xff\x01") && (packet.indexOf("TCPIP") == -1) && (packet.indexOf("NOGATE") == -1) && (packet.indexOf("RFONLY") == -1)) { - Serial.print(" ---> APRS LoRa Packet!"); - Sender = packet.substring(3,packet.indexOf(">")); - if (Sender != Config.callsign) { // avoid listening yourself by digirepeating - if (Config.loramodule.enableTx) { - 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 (AddresseeAndMessage.indexOf("{")>0) { // ack? - ackMessage = "ack" + AddresseeAndMessage.substring(AddresseeAndMessage.indexOf("{")+1); - ackMessage.trim(); - delay(4000); - Serial.println(ackMessage); - for(int i = Sender.length(); i < 9; i++) { - Sender += ' '; - } - LoRa_Utils::sendNewPacket("APRS", Config.callsign + ">APLRG1,RFONLY::" + Sender + ":" + ackMessage); - receivedMessage = AddresseeAndMessage.substring(AddresseeAndMessage.indexOf(":")+1, AddresseeAndMessage.indexOf("{")); - } else { - receivedMessage = AddresseeAndMessage.substring(AddresseeAndMessage.indexOf(":")+1); - } - if (receivedMessage.indexOf("?") == 0) { - queryMessage = true; - delay(2000); - if (!Config.display.alwaysOn) { - display_toggle(true); - } - LoRa_Utils::sendNewPacket("APRS", QUERY_Utils::process(receivedMessage, Sender, "LoRa")); - lastRxTxTime = millis(); - show_display(firstLine, secondLine, "Callsign = " + Sender, "TYPE --> QUERY", 1000); - } - } - } - } - if (!queryMessage) { - aprsPacket = APRS_IS_Utils::createPacket(packet); - if (!Config.display.alwaysOn) { - display_toggle(true); - } - lastRxTxTime = millis(); - espClient.write(aprsPacket.c_str()); - Serial.println(" ---> Uploaded to APRS-IS"); - STATION_Utils::updateLastHeard(Sender); - if (aprsPacket.indexOf("::") >= 10) { - show_display(firstLine, secondLine, "Callsign = " + Sender, "TYPE --> MESSAGE", 1000); - } else if (aprsPacket.indexOf(":>") >= 10) { - show_display(firstLine, secondLine, "Callsign = " + Sender, "TYPE --> NEW STATUS", 1000); - } else if (aprsPacket.indexOf(":!") >= 10 || aprsPacket.indexOf(":=") >= 10) { - show_display(firstLine, secondLine, "Callsign = " + Sender, "TYPE --> GPS BEACON", 1000); - } else { - show_display(firstLine, secondLine, "Callsign = " + Sender, "TYPE --> ??????????", 1000); - } - } - } - } else { - Serial.println(" ---> Not APRS Packet (Ignore)\n"); - }*/ } } \ No newline at end of file diff --git a/src/lora_utils.cpp b/src/lora_utils.cpp index 32c9593..e1f6c51 100644 --- a/src/lora_utils.cpp +++ b/src/lora_utils.cpp @@ -60,29 +60,15 @@ String receivePacket() { } void changeFreqTx() { - if (!LoRa.begin(Config.loramodule.frequencyTx)) { - Serial.println("Starting LoRa failed!"); - show_display("ERROR", "Starting LoRa failed!"); - while (true) { - delay(1000); - } - } else { - delay(500); //borrar? - Serial.println("cambiando frecuencia Tx = " + String(Config.loramodule.frequencyTx)); - } + delay(500); + LoRa.setFrequency(Config.loramodule.frequencyTx); + //Serial.println("changing LoRa Freq to " + String(Config.loramodule.frequencyTx)); } void changeFreqRx() { - if (!LoRa.begin(Config.loramodule.frequencyRx)) { - Serial.println("Starting LoRa failed!"); - show_display("ERROR", "Starting LoRa failed!"); - while (true) { - delay(1000); - } - } else { - delay(500); //borrar? - Serial.println("cambiando frecuencia Rx = " + String(Config.loramodule.frequencyRx)); - } + delay(500); + LoRa.setFrequency(Config.loramodule.frequencyRx); + //Serial.println("changing LoRa Freq to = " + String(Config.loramodule.frequencyRx)); } } \ No newline at end of file