mirror of
https://github.com/richonguzman/LoRa_APRS_iGate.git
synced 2026-02-03 22:35:06 +01:00
finalBetaDigi
This commit is contained in:
parent
7b3d6d93a3
commit
0ec1778c1b
|
|
@ -17,12 +17,11 @@
|
|||
#include <ESPAsyncWebServer.h>
|
||||
#include <AsyncElegantOTA.h>*/
|
||||
|
||||
#define VERSION "2023.06.08"
|
||||
|
||||
Configuration Config;
|
||||
WiFiClient espClient;
|
||||
//AsyncWebServer server(80);
|
||||
|
||||
String versionDate = "2023.06.08";
|
||||
int myWiFiAPIndex = 0;
|
||||
int myWiFiAPSize = Config.wifiAPs.size();
|
||||
WiFi_AP *currentWiFi = &Config.wifiAPs[myWiFiAPIndex];
|
||||
|
|
@ -43,13 +42,10 @@ void setup() {
|
|||
Serial.begin(115200);
|
||||
delay(1000);
|
||||
utils::setupDiplay();
|
||||
Serial.println("\nStarting iGate: " + Config.callsign + " Version: " + String(VERSION));
|
||||
show_display(" LoRa APRS iGate", " Richonguzman", " -- CD2RXU --", " " VERSION, 4000);
|
||||
WIFI_Utils::setup();
|
||||
LoRa_Utils::setup();
|
||||
utils::validateDigiFreqs();
|
||||
iGateBeaconPacket = GPS_Utils::generateBeacon();
|
||||
|
||||
/*server.on("/", HTTP_GET, [](AsyncWebServerRequest *request) {
|
||||
request->send(200, "text/plain", "Hi! I am ESP32.");
|
||||
});
|
||||
|
|
@ -65,14 +61,6 @@ void loop() {
|
|||
show_display(firstLine, secondLine, thirdLine, fourthLine, 0);
|
||||
DIGI_Utils::processPacket(LoRa_Utils::receivePacket());
|
||||
} else if (stationMode==1 || stationMode==2 ) { // iGate (1 Only Rx / 2 Rx+Tx)
|
||||
/*unsigned long currentWiFiMillis = millis();
|
||||
if ((WiFi.status() != WL_CONNECTED) && (millis() - previousWiFiMillis >= 30*1000)) {
|
||||
Serial.print(millis());
|
||||
Serial.println("Reconnecting to WiFi...");
|
||||
WiFi.disconnect();
|
||||
WiFi.reconnect();
|
||||
previousWiFiMillis = millis();
|
||||
}*/
|
||||
WIFI_Utils::checkWiFi();
|
||||
if (!espClient.connected()) {
|
||||
APRS_IS_Utils::connect();
|
||||
|
|
@ -85,61 +73,9 @@ void loop() {
|
|||
utils::checkBeaconInterval();
|
||||
APRS_IS_Utils::processLoRaPacket(LoRa_Utils::receivePacket());
|
||||
if (espClient.available()) {
|
||||
String aprsisPacket;//aprsisData, ;//, Sender, AddresseeAndMessage, Addressee, receivedMessage;
|
||||
/*bool validHeardStation = false;
|
||||
aprsisData = espClient.readStringUntil('\r'); // or '\n'
|
||||
aprsisPacket.concat(aprsisData);*/
|
||||
String aprsisPacket;
|
||||
aprsisPacket.concat(espClient.readStringUntil('\r'));
|
||||
APRS_IS_Utils::processAPRSISPacket(aprsisPacket);
|
||||
/*if (!aprsisPacket.startsWith("#")){
|
||||
if (aprsisPacket.indexOf("::")>0) {
|
||||
Sender = aprsisPacket.substring(0,aprsisPacket.indexOf(">"));
|
||||
AddresseeAndMessage = aprsisPacket.substring(aprsisPacket.indexOf("::")+2);
|
||||
Addressee = AddresseeAndMessage.substring(0, AddresseeAndMessage.indexOf(":"));
|
||||
Addressee.trim();
|
||||
if (Addressee == Config.callsign) { // its for me!
|
||||
if (AddresseeAndMessage.indexOf("{")>0) { // ack?
|
||||
String ackMessage = "ack" + AddresseeAndMessage.substring(AddresseeAndMessage.indexOf("{")+1);
|
||||
ackMessage.trim();
|
||||
delay(4000);
|
||||
Serial.println(ackMessage);
|
||||
for(int i = Sender.length(); i < 9; i++) {
|
||||
Sender += ' ';
|
||||
}
|
||||
String ackPacket = Config.callsign + ">APLRG1,TCPIP,qAC::" + Sender + ":" + ackMessage + "\n";
|
||||
espClient.write(ackPacket.c_str());
|
||||
receivedMessage = AddresseeAndMessage.substring(AddresseeAndMessage.indexOf(":")+1, AddresseeAndMessage.indexOf("{"));
|
||||
} else {
|
||||
receivedMessage = AddresseeAndMessage.substring(AddresseeAndMessage.indexOf(":")+1);
|
||||
}
|
||||
if (receivedMessage.indexOf("?") == 0) {
|
||||
Serial.println("Received Query APRS-IS : " + aprsisPacket);
|
||||
String queryAnswer = QUERY_Utils::process(receivedMessage, Sender, "APRSIS");
|
||||
Serial.println("---> QUERY Answer : " + queryAnswer.substring(0,queryAnswer.indexOf("\n")));
|
||||
if (!Config.display.alwaysOn) {
|
||||
display_toggle(true);
|
||||
}
|
||||
lastScreenOn = millis();
|
||||
delay(500);
|
||||
espClient.write(queryAnswer.c_str());
|
||||
show_display(firstLine, secondLine, "Callsign = " + Sender, "TYPE --> QUERY", 1000);
|
||||
}
|
||||
} else {
|
||||
Serial.print("Received from APRS-IS : " + aprsisPacket);
|
||||
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(aprsisPacket));
|
||||
display_toggle(true);
|
||||
lastScreenOn = millis();
|
||||
receivedMessage = AddresseeAndMessage.substring(AddresseeAndMessage.indexOf(":")+1);
|
||||
show_display(firstLine, secondLine, Sender + " -> " + Addressee, receivedMessage, 1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -126,16 +126,6 @@ void processLoRaPacket(String packet) {
|
|||
STATION_Utils::updateLastHeard(Sender);
|
||||
utils::typeOfPacket(aprsPacket);
|
||||
show_display(firstLine, secondLine, thirdLine, fourthLine, 0);
|
||||
/*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 {
|
||||
|
|
|
|||
|
|
@ -5,30 +5,11 @@
|
|||
#include "utils.h"
|
||||
|
||||
extern Configuration Config;
|
||||
//extern String thirdLine;
|
||||
//extern String fourthLine;
|
||||
extern int stationMode;
|
||||
extern uint32_t lastScreenOn;
|
||||
|
||||
namespace DIGI_Utils {
|
||||
|
||||
/*void typeOfPacket(String packet) {
|
||||
String Sender = packet.substring(3,packet.indexOf(">"));
|
||||
if (packet.indexOf("::") >= 10) {
|
||||
thirdLine = "Callsign = " + Sender;
|
||||
fourthLine = "TYPE ----> MESSAGE";
|
||||
} else if (packet.indexOf(":>") >= 10) {
|
||||
thirdLine = "Callsign = " + Sender;
|
||||
fourthLine = "TYPE ----> NEW STATUS";
|
||||
} else if (packet.indexOf(":!") >= 10 || packet.indexOf(":=") >= 10) {
|
||||
thirdLine = "Callsign = " + Sender;
|
||||
fourthLine = "TYPE ----> GPS BEACON";
|
||||
} else {
|
||||
thirdLine = "Callsign = " + Sender;
|
||||
fourthLine = "TYPE ----> ??????????";
|
||||
}
|
||||
}*/
|
||||
|
||||
void processPacket(String packet) {
|
||||
String firstPart, lastPart, loraPacket;
|
||||
if (packet != "") {
|
||||
|
|
@ -44,13 +25,13 @@ void processPacket(String packet) {
|
|||
LoRa_Utils::sendNewPacket("APRS", loraPacket);
|
||||
display_toggle(true);
|
||||
lastScreenOn = millis();
|
||||
} else { // stationMode = 4
|
||||
} else {
|
||||
utils::typeOfPacket(packet);
|
||||
firstPart = packet.substring(3,packet.indexOf(",")+1);
|
||||
lastPart = packet.substring(packet.indexOf(",")+1);
|
||||
loraPacket = firstPart + Config.callsign + lastPart; // se agrega "*"" ???
|
||||
delay(500);
|
||||
if (stationMode == 4) { // Digirepeating with Freq Rx != Tx
|
||||
if (stationMode == 4) {
|
||||
LoRa_Utils::changeFreqTx();
|
||||
}
|
||||
LoRa_Utils::sendNewPacket("APRS", loraPacket);
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@
|
|||
|
||||
namespace DIGI_Utils {
|
||||
|
||||
//void typeOfPacket(String packet);
|
||||
void processPacket(String packet);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ String generatePacket(String aprsisPacket) {
|
|||
|
||||
String receivePacket() {
|
||||
String loraPacket = "";
|
||||
int packetSize = LoRa.parsePacket(); // Listening for LoRa Packets
|
||||
int packetSize = LoRa.parsePacket();
|
||||
if (packetSize) {
|
||||
while (LoRa.available()) {
|
||||
int inChar = LoRa.read();
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ extern Configuration Config;
|
|||
extern WiFi_AP *currentWiFi;
|
||||
extern std::vector<String> lastHeardStation;
|
||||
extern std::vector<String> lastHeardStation_temp;
|
||||
extern String versionDate;
|
||||
|
||||
namespace QUERY_Utils {
|
||||
|
||||
|
|
@ -13,14 +14,18 @@ String process(String query, String station, String queryOrigin) {
|
|||
if (query=="?APRS?" || query=="?aprs?" || query=="?Aprs?" || query=="H" || query=="h" || query=="Help" || query=="help" || query=="?") {
|
||||
answer = "?APRSV ?APRSP ?APRSL ?APRSH ?WHERE callsign";
|
||||
} else if (query=="?APRSV" || query=="?aprsv" || query=="?Aprsv") {
|
||||
answer = "CD2RXU_LoRa_iGate 1.2";
|
||||
answer = "CD2RXU_LoRa_iGate 1.2 v" + versionDate;
|
||||
} else if (query=="?APRSP" || query=="?aprsp" || query=="?Aprsp") {
|
||||
answer = "iGate QTH: " + String(currentWiFi->latitude,2) + " " + String(currentWiFi->longitude,2);
|
||||
} else if (query=="?APRSL" || query=="?aprsl" || query=="?Aprsl") {
|
||||
for (int i=0; i<lastHeardStation.size(); i++) {
|
||||
answer += lastHeardStation[i].substring(0,lastHeardStation[i].indexOf(",")) + " ";
|
||||
if (lastHeardStation.size() == 0) {
|
||||
answer = "No Station Listened in the last " + String(Config.rememberStationTime) + "min.";
|
||||
} else {
|
||||
for (int i=0; i<lastHeardStation.size(); i++) {
|
||||
answer += lastHeardStation[i].substring(0,lastHeardStation[i].indexOf(",")) + " ";
|
||||
}
|
||||
answer.trim();
|
||||
}
|
||||
answer.trim();
|
||||
} else if (query.indexOf("?APRSH") == 0 || query.indexOf("?aprsv") == 0 || query.indexOf("?Aprsv") == 0) {
|
||||
// sacar callsign despues de ?APRSH
|
||||
Serial.println("escuchaste a X estacion? en las ultimas 24 o 8 horas?");
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
extern WiFiClient espClient;
|
||||
extern Configuration Config;
|
||||
extern String versionDate;
|
||||
extern bool statusAfterBoot;
|
||||
extern String firstLine;
|
||||
extern String secondLine;
|
||||
|
|
@ -42,6 +43,8 @@ void processStatus() {
|
|||
|
||||
void setupDiplay() {
|
||||
setup_display();
|
||||
Serial.println("\nStarting iGate: " + Config.callsign + " Version: " + versionDate);
|
||||
show_display(" LoRa APRS iGate", " Richonguzman", " -- CD2RXU --", " " + versionDate, 4000);
|
||||
firstLine = "LoRa iGate: " + Config.callsign;
|
||||
if (stationMode==3 || stationMode==4) {
|
||||
secondLine = "<DigiRepeater Active>";
|
||||
|
|
@ -69,7 +72,7 @@ void checkBeaconInterval() {
|
|||
} else if (stationMode==3 || stationMode==4) {
|
||||
show_display(firstLine, secondLine, thirdLine, "SENDING iGate BEACON", 0);
|
||||
fourthLine = " listening...";
|
||||
if (stationMode == 4) { // Digirepeating with Freq Rx != Tx
|
||||
if (stationMode == 4) {
|
||||
LoRa_Utils::changeFreqTx();
|
||||
}
|
||||
LoRa_Utils::sendNewPacket("APRS",iGateBeaconPacket);
|
||||
|
|
@ -106,7 +109,11 @@ void validateDigiFreqs() {
|
|||
}
|
||||
|
||||
void typeOfPacket(String packet) {
|
||||
thirdLine = "Callsign = " + packet.substring(3,packet.indexOf(">"));
|
||||
if (stationMode==1 || stationMode==2) {
|
||||
thirdLine = "Callsign = " + packet.substring(0,packet.indexOf(">"));
|
||||
} else {
|
||||
thirdLine = "Callsign = " + packet.substring(3,packet.indexOf(">"));
|
||||
}
|
||||
if (packet.indexOf("::") >= 10) {
|
||||
fourthLine = "TYPE ----> MESSAGE";
|
||||
} else if (packet.indexOf(":>") >= 10) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue