From d392483bea0234585a48c9b67c4e161dd105d9b0 Mon Sep 17 00:00:00 2001 From: richonguzman Date: Fri, 9 Jun 2023 20:20:39 -0400 Subject: [PATCH] test it --- src/LoRa_APRS_iGate.cpp | 5 +++-- src/aprs_is_utils.cpp | 16 ++++++---------- src/digi_utils.cpp | 13 +++++-------- src/lora_utils.cpp | 3 +++ src/pins_config.h | 6 ++++-- src/utils.cpp | 3 +++ src/wifi_utils.cpp | 4 ++++ 7 files changed, 28 insertions(+), 22 deletions(-) diff --git a/src/LoRa_APRS_iGate.cpp b/src/LoRa_APRS_iGate.cpp index 5902e75..fe24616 100644 --- a/src/LoRa_APRS_iGate.cpp +++ b/src/LoRa_APRS_iGate.cpp @@ -21,7 +21,7 @@ Configuration Config; WiFiClient espClient; //AsyncWebServer server(80); -String versionDate = "2023.06.08"; +String versionDate = "2023.06.09"; int myWiFiAPIndex = 0; int myWiFiAPSize = Config.wifiAPs.size(); WiFi_AP *currentWiFi = &Config.wifiAPs[myWiFiAPIndex]; @@ -40,6 +40,7 @@ String firstLine, secondLine, thirdLine, fourthLine, iGateBeaconPacket; void setup() { Serial.begin(115200); + pinMode(greenLed, OUTPUT); delay(1000); utils::setupDiplay(); WIFI_Utils::setup(); @@ -51,7 +52,7 @@ void setup() { }); AsyncElegantOTA.begin(&server); // Start ElegantOTA server.begin(); - Serial.println("HTTP server started");*/ + Serial.println("HTTP server started");*/ } void loop() { diff --git a/src/aprs_is_utils.cpp b/src/aprs_is_utils.cpp index 46d0ea0..645ab61 100644 --- a/src/aprs_is_utils.cpp +++ b/src/aprs_is_utils.cpp @@ -171,16 +171,12 @@ void processAPRSISPacket(String packet) { } } else { Serial.print("Received from APRS-IS : " + packet); - if (stationMode == 1) { - Serial.println(" ---> Cant Tx without Ham Lincence"); - } else if (stationMode > 1) { - if (STATION_Utils::wasHeard(Addressee)) { - LoRa_Utils::sendNewPacket("APRS", LoRa_Utils::generatePacket(packet)); - display_toggle(true); - lastScreenOn = millis(); - receivedMessage = AddresseeAndMessage.substring(AddresseeAndMessage.indexOf(":")+1); - show_display(firstLine, secondLine, Sender + " -> " + Addressee, receivedMessage, 0); - } + if (stationMode == 2 && STATION_Utils::wasHeard(Addressee)) { + LoRa_Utils::sendNewPacket("APRS", LoRa_Utils::generatePacket(packet)); + display_toggle(true); + lastScreenOn = millis(); + utils::typeOfPacket(packet); + show_display(firstLine, secondLine, Sender + " -> " + Addressee, fourthLine, 0); } } } diff --git a/src/digi_utils.cpp b/src/digi_utils.cpp index 49c6443..be039d6 100644 --- a/src/digi_utils.cpp +++ b/src/digi_utils.cpp @@ -11,25 +11,22 @@ extern uint32_t lastScreenOn; namespace DIGI_Utils { void processPacket(String packet) { - String firstPart, lastPart, loraPacket; + String loraPacket; if (packet != "") { Serial.print("Received Lora Packet : " + String(packet)); if ((packet.substring(0, 3) == "\x3c\xff\x01") && (packet.indexOf("NOGATE") == -1)) { Serial.println(" ---> APRS LoRa Packet"); if ((stationMode==3) && (packet.indexOf("WIDE1-1") > 10)) { utils::typeOfPacket(packet); - firstPart = packet.substring(3,packet.indexOf(",")+1); - lastPart = packet.substring(packet.indexOf(":")); - loraPacket = firstPart + Config.callsign + "*" + lastPart; + loraPacket = packet.substring(3); + loraPacket.replace("WIDE1-1", Config.callsign + "*"); delay(500); LoRa_Utils::sendNewPacket("APRS", loraPacket); display_toggle(true); lastScreenOn = millis(); - } else { + } else if (stationMode ==4){ utils::typeOfPacket(packet); - firstPart = packet.substring(3,packet.indexOf(",")+1); - lastPart = packet.substring(packet.indexOf(",")+1); - loraPacket = firstPart + Config.callsign + lastPart; // se agrega "*"" ??? + loraPacket = packet.substring(3,packet.indexOf(",")+1) + Config.callsign + "*" + packet.substring(packet.indexOf(",")+1); delay(500); if (stationMode == 4) { LoRa_Utils::changeFreqTx(); diff --git a/src/lora_utils.cpp b/src/lora_utils.cpp index b1a3556..ee1db59 100644 --- a/src/lora_utils.cpp +++ b/src/lora_utils.cpp @@ -1,5 +1,6 @@ #include #include "configuration.h" +#include "pins_config.h" #include "display.h" extern Configuration Config; @@ -32,6 +33,7 @@ void setup() { } void sendNewPacket(const String &typeOfMessage, const String &newPacket) { + digitalWrite(greenLed,HIGH); LoRa.beginPacket(); LoRa.write('<'); if (typeOfMessage == "APRS") { @@ -42,6 +44,7 @@ void sendNewPacket(const String &typeOfMessage, const String &newPacket) { LoRa.write(0x01); LoRa.write((const uint8_t *)newPacket.c_str(), newPacket.length()); LoRa.endPacket(); + digitalWrite(greenLed,LOW); Serial.print("---> LoRa Packet Tx : "); Serial.println(newPacket); } diff --git a/src/pins_config.h b/src/pins_config.h index a27f6ba..15fcdd0 100644 --- a/src/pins_config.h +++ b/src/pins_config.h @@ -10,8 +10,10 @@ #define LORA_RST 23 // GPIO14 - SX1276 RST #define LORA_IRQ 26 // GPIO26 - SX1276 IRQ ---->DIO0 -#define OLED_SDA 21 -#define OLED_SCL 22 +#define OLED_SDA 21 +#define OLED_SCL 22 + +#define greenLed 25 // Green Led /* (Same pins for LILYGO LoRa32 and ESP32 Wroom Dev ) SX1278-------------------> ESP32 ttgo-lora32-v21 and ESP32 WROOM Dev diff --git a/src/utils.cpp b/src/utils.cpp index d64f599..9b47a3b 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -1,5 +1,6 @@ #include #include "configuration.h" +#include "pins_config.h" #include "wifi_utils.h" #include "lora_utils.h" #include "display.h" @@ -43,8 +44,10 @@ void processStatus() { void setupDiplay() { setup_display(); + digitalWrite(greenLed,HIGH); Serial.println("\nStarting iGate: " + Config.callsign + " Version: " + versionDate); show_display(" LoRa APRS iGate", " Richonguzman", " -- CD2RXU --", " " + versionDate, 4000); + digitalWrite(greenLed,LOW); firstLine = "LoRa iGate: " + Config.callsign; if (stationMode==3 || stationMode==4) { secondLine = ""; diff --git a/src/wifi_utils.cpp b/src/wifi_utils.cpp index 7cbd08f..fd6a1b0 100644 --- a/src/wifi_utils.cpp +++ b/src/wifi_utils.cpp @@ -1,5 +1,6 @@ #include #include "configuration.h" +#include "pins_config.h" #include "wifi_utils.h" #include "display.h" @@ -32,8 +33,10 @@ void startWiFi() { Serial.print("\nConnecting to '"); Serial.print(currentWiFi->ssid); Serial.println("' WiFi ..."); WiFi.begin(currentWiFi->ssid.c_str(), currentWiFi->password.c_str()); while (WiFi.status() != WL_CONNECTED) { + digitalWrite(greenLed,HIGH); Serial.print('.'); delay(1000); + digitalWrite(greenLed,LOW); if ((millis() - start) > 15000){ if(myWiFiAPIndex >= (myWiFiAPSize-1)) { myWiFiAPIndex = 0; @@ -47,6 +50,7 @@ void startWiFi() { WiFi.begin(currentWiFi->ssid.c_str(), currentWiFi->password.c_str()); } } + digitalWrite(greenLed,LOW); Serial.print("Connected as "); Serial.println(WiFi.localIP()); }