From 5f5a5cf7aee22429cb17c8614c2cfd42ed883507 Mon Sep 17 00:00:00 2001 From: richonguzman Date: Fri, 17 Feb 2023 13:26:35 -0300 Subject: [PATCH] first read from APRS-IS --- src/Lora_APRS_iGate_DIY.cpp | 41 +++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/src/Lora_APRS_iGate_DIY.cpp b/src/Lora_APRS_iGate_DIY.cpp index b1bbf34..4e4ce33 100644 --- a/src/Lora_APRS_iGate_DIY.cpp +++ b/src/Lora_APRS_iGate_DIY.cpp @@ -109,6 +109,43 @@ void valida_y_procesa_packet(String mensaje) { } } +void APRS_IS_READ(){ + int count = 0; + String aprsauth; + Serial.println("Conectando a APRS-IS"); + while (!espClient.connect(SERVER.c_str(), APRSPORT) && count < 20) { + Serial.println("Didn't connect with server: " + String(SERVER) + " APRSPORT: " + String(APRSPORT)); + delay(1000); + espClient.stop(); + espClient.flush(); + Serial.println("Run client.stop"); + Serial.println("Trying to connect with server: " + String(SERVER) + " APRSPORT: " + String(APRSPORT)); + count++; + Serial.println("Try: " + String(count)); + } + if (count == 20) { + Serial.println("Tried: " + String(count) + " don't send the packet!"); + } else { + Serial.println("Connected with server: " + String(SERVER) + " APRSPORT: " + String(APRSPORT)); + + String aprsisData; + while (espClient.connected()) { + aprsauth = "user " + iGate_Callsign + " pass " + passcode_igate + "\n"; //info igate + espClient.write(aprsauth.c_str()); + delay(200); + char c = espClient.read(); + //if (c == '\r') continue; + if (c == '\n') { + Serial.println(aprsisData); + aprsisData = ""; + } + aprsisData += c; + + } + + } +} + void setup() { Serial.begin(115200); setup_wifi(); @@ -118,6 +155,9 @@ void setup() { } void loop() { + //APRS_IS_READ(); + + /* String receivedPacket = ""; static bool beacon_update = true; @@ -141,4 +181,5 @@ void loop() { lastTxTime = millis(); beacon_update = false; } + */ } \ No newline at end of file