diff --git a/src/aprs_is_utils.cpp b/src/aprs_is_utils.cpp index 63ae1e5..5e28572 100644 --- a/src/aprs_is_utils.cpp +++ b/src/aprs_is_utils.cpp @@ -26,6 +26,10 @@ extern String seventhLine; namespace APRS_IS_Utils { + void upload(String line) { + espClient.write((line + "\r\n").c_str()); + } + void connect(){ int count = 0; String aprsauth; @@ -44,8 +48,9 @@ namespace APRS_IS_Utils { 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 CA2RXU_LoRa_iGate 1.2 filter t/m/" + Config.callsign + "/" + (String)Config.aprs_is.reportingDistance + "\n\r"; - espClient.write(aprsauth.c_str()); + aprsauth = "user " + Config.callsign + " pass " + Config.aprs_is.passcode + " vers CA2RXU_LoRa_iGate 1.2 filter t/m/" + Config.callsign + "/" + (String)Config.aprs_is.reportingDistance;// + "\r\n"; + upload(aprsauth); + //espClient.write(aprsauth.c_str()); delay(200); } } @@ -75,9 +80,9 @@ namespace APRS_IS_Utils { String createPacket(String packet) { if (stationMode>1) { - return packet.substring(3, packet.indexOf(":")) + ",qAR," + Config.callsign + packet.substring(packet.indexOf(":")) + "\n"; + 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"; + return packet.substring(3, packet.indexOf(":")) + ",qAO," + Config.callsign + packet.substring(packet.indexOf(":"));// + "\n"; } } @@ -139,7 +144,8 @@ namespace APRS_IS_Utils { display_toggle(true); } lastScreenOn = millis(); - espClient.write(aprsPacket.c_str()); + upload(aprsPacket); + //espClient.write(aprsPacket.c_str()); #ifndef TextSerialOutputForApp Serial.println(" ---> Uploaded to APRS-IS"); #endif @@ -173,8 +179,9 @@ namespace APRS_IS_Utils { for(int i = Sender.length(); i < 9; i++) { Sender += ' '; } - String ackPacket = Config.callsign + ">APLRG1,TCPIP,qAC::" + Sender + ":" + ackMessage + "\n"; - espClient.write(ackPacket.c_str()); + String ackPacket = Config.callsign + ">APLRG1,TCPIP,qAC::" + Sender + ":" + ackMessage;// + "\n"; + upload(ackPacket); + //espClient.write(ackPacket.c_str()); receivedMessage = AddresseeAndMessage.substring(AddresseeAndMessage.indexOf(":")+1, AddresseeAndMessage.indexOf("{")); } else { receivedMessage = AddresseeAndMessage.substring(AddresseeAndMessage.indexOf(":")+1); @@ -190,7 +197,8 @@ namespace APRS_IS_Utils { } lastScreenOn = millis(); delay(500); - espClient.write(queryAnswer.c_str()); + upload(queryAnswer); + //espClient.write(queryAnswer.c_str()); SYSLOG_Utils::log("APRSIS Tx", queryAnswer,0,0,0); fifthLine = "APRS-IS ----> APRS-IS"; sixthLine = Config.callsign; diff --git a/src/aprs_is_utils.h b/src/aprs_is_utils.h index 47c64cc..a647800 100644 --- a/src/aprs_is_utils.h +++ b/src/aprs_is_utils.h @@ -12,6 +12,7 @@ namespace APRS_IS_Utils { + void upload(String line); void connect(); void checkStatus(); String createPacket(String unprocessedPacket); diff --git a/src/digi_utils.cpp b/src/digi_utils.cpp index fe2e9a1..4a226e2 100644 --- a/src/digi_utils.cpp +++ b/src/digi_utils.cpp @@ -10,7 +10,7 @@ #include "utils.h" extern Configuration Config; -extern WiFiClient espClient; +//extern WiFiClient espClient; extern int stationMode; extern uint32_t lastScreenOn; extern int lastStationModeState; diff --git a/src/query_utils.cpp b/src/query_utils.cpp index 4d689ec..fe093f4 100644 --- a/src/query_utils.cpp +++ b/src/query_utils.cpp @@ -40,7 +40,7 @@ namespace QUERY_Utils { station += ' '; } if (queryOrigin == "APRSIS") { - return Config.callsign + ">APLRG1,TCPIP,qAC::" + station + ":" + answer + "\n"; + return Config.callsign + ">APLRG1,TCPIP,qAC::" + station + ":" + answer;// + "\n"; } else { //} if (queryOrigin == "LoRa") { return Config.callsign + ">APLRG1,RFONLY,WIDE1-1::" + station + ":" + answer; } diff --git a/src/utils.cpp b/src/utils.cpp index e0faf5a..7f20f70 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -60,7 +60,8 @@ namespace Utils { 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()); + APRS_IS_Utils::upload(status); + //espClient.write((status + "\n").c_str()); SYSLOG_Utils::log("APRSIS Tx", status,0,0,0); } else { delay(5000); @@ -149,7 +150,8 @@ namespace Utils { sixthLine = " (Ext V=" + String(BATTERY_Utils::checkExternalVoltage(),2) + "V)"; } seventhLine = " listening..."; - espClient.write((beaconPacket + "\n").c_str()); + APRS_IS_Utils::upload(beaconPacket); + //espClient.write((beaconPacket + "\n").c_str()); if (Config.igateSendsLoRaBeacons && stationMode==2) { LoRa_Utils::sendNewPacket("APRS", secondaryBeaconPacket); } @@ -201,7 +203,8 @@ namespace Utils { sixthLine = " (Ext V=" + String(BATTERY_Utils::checkExternalVoltage(),2) + "V)"; } seventhLine = " listening..."; - espClient.write((beaconPacket + "\n").c_str()); + APRS_IS_Utils::upload(beaconPacket); + //espClient.write((beaconPacket + "\n").c_str()); if (Config.igateSendsLoRaBeacons) { LoRa_Utils::sendNewPacket("APRS", secondaryBeaconPacket); }