mirror of
https://github.com/richonguzman/LoRa_APRS_iGate.git
synced 2026-02-02 05:44:13 +01:00
pinpoint app support1
This commit is contained in:
parent
2d47e3b64f
commit
c791d6aebf
33
README.md
33
README.md
|
|
@ -79,23 +79,24 @@ LoRa APRS iGATE/Digirepeater working on this boards:
|
|||
- HELTEC_WIFI_LORA_32_V2 (check "pins_config.h" and "display.cpp" for aditional configuration).
|
||||
__________________________________________
|
||||
Versions:
|
||||
- 2023.02.10 First Beta (receiving LoRa Beacon/Packets and uploading to APRS-IS).
|
||||
- 2023.02.17 Receiving Feed from APRS-IS.
|
||||
- 2023.03.01 Tx Packet from APRS-IS to nearby LoRa Stations.
|
||||
- 2023.05.12 Tx Packet from APRS-IS to LoRa-RF Correction.
|
||||
- 2023.05.19 Saving Last-Heard Stations for validating Tx Responses.
|
||||
- 2023.05.23 Processing Query's from RF/LoRa or APRS-IS (Send "Help" Message to test).
|
||||
- 2023.06.06 Full repack of Code and adding _enableTx_ only for Ham Ops.
|
||||
- 2023.06.08 Adding Digirepeater Functions.
|
||||
- 2023.06.10 OTA update support for Firmware and Filesystem.
|
||||
- 2023.06.12 Syslog added.
|
||||
- 2023.06.17 Support for BME280 Module (Temperature, Humidity, Pressure) added.
|
||||
- 2023.06.18 Info on Oled Screen mayor update, added RSSI and Distance to Listened Station.
|
||||
- 2023.07.05 Adding monitor info of Battery connected.
|
||||
- 2023.07.16 Small OTA, BME module update.
|
||||
- 2023.07.31 StationMode5 added: iGate when WiFi and APRS available, DigiRepeater when not.
|
||||
- 2023.08.05 Ground Height Correction for Pressure readings added
|
||||
- 2023.10.08 Added Serial Comunication with PinPoint APRS app (https://www.pinpointaprs.com)
|
||||
- 2023.08.20 Added External Voltage Measurement (Max 15V!)
|
||||
- 2023.08.05 Ground Height Correction for Pressure readings added
|
||||
- 2023.07.31 StationMode5 added: iGate when WiFi and APRS available, DigiRepeater when not.
|
||||
- 2023.07.16 Small OTA, BME module update.
|
||||
- 2023.07.05 Adding monitor info of Battery connected.
|
||||
- 2023.06.18 Info on Oled Screen mayor update, added RSSI and Distance to Listened Station.
|
||||
- 2023.06.17 Support for BME280 Module (Temperature, Humidity, Pressure) added.
|
||||
- 2023.06.12 Syslog added.
|
||||
- 2023.06.10 OTA update support for Firmware and Filesystem.
|
||||
- 2023.06.08 Adding Digirepeater Functions.
|
||||
- 2023.06.06 Full repack of Code and adding _enableTx_ only for Ham Ops.
|
||||
- 2023.05.23 Processing Query's from RF/LoRa or APRS-IS (Send "Help" Message to test).
|
||||
- 2023.05.19 Saving Last-Heard Stations for validating Tx Responses.
|
||||
- 2023.05.12 Tx Packet from APRS-IS to LoRa-RF Correction.
|
||||
- 2023.03.01 Tx Packet from APRS-IS to nearby LoRa Stations.
|
||||
- 2023.02.17 Receiving Feed from APRS-IS.
|
||||
- 2023.02.10 First Beta (receiving LoRa Beacon/Packets and uploading to APRS-IS).
|
||||
|
||||
__________________________________________
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
Configuration Config;
|
||||
WiFiClient espClient;
|
||||
|
||||
String versionDate = "2023.09.21";
|
||||
String versionDate = "2023.10.08";
|
||||
int myWiFiAPIndex = 0;
|
||||
int myWiFiAPSize = Config.wifiAPs.size();
|
||||
WiFi_AP *currentWiFi = &Config.wifiAPs[myWiFiAPIndex];
|
||||
|
|
|
|||
|
|
@ -23,190 +23,203 @@ extern String seventhLine;
|
|||
|
||||
namespace APRS_IS_Utils {
|
||||
|
||||
void connect(){
|
||||
int count = 0;
|
||||
String aprsauth;
|
||||
Serial.print("Connecting to APRS-IS ... ");
|
||||
while (!espClient.connect(Config.aprs_is.server.c_str(), Config.aprs_is.port) && count < 20) {
|
||||
Serial.println("Didn't connect with server...");
|
||||
delay(1000);
|
||||
espClient.stop();
|
||||
espClient.flush();
|
||||
Serial.println("Run client.stop");
|
||||
Serial.println("Trying to connect with Server: " + String(Config.aprs_is.server) + " AprsServerPort: " + String(Config.aprs_is.port));
|
||||
count++;
|
||||
Serial.println("Try: " + String(count));
|
||||
}
|
||||
if (count == 20) {
|
||||
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 CD2RXU_LoRa_iGate 1.2 filter t/m/" + Config.callsign + "/" + (String)Config.aprs_is.reportingDistance + "\n\r";
|
||||
espClient.write(aprsauth.c_str());
|
||||
delay(200);
|
||||
}
|
||||
}
|
||||
|
||||
void checkStatus() {
|
||||
String wifiState, aprsisState;
|
||||
if (WiFi.status() == WL_CONNECTED) {
|
||||
wifiState = "OK";
|
||||
} else {
|
||||
wifiState = "--";
|
||||
if (!Config.display.alwaysOn) {
|
||||
display_toggle(true);
|
||||
void connect(){
|
||||
int count = 0;
|
||||
String aprsauth;
|
||||
Serial.print("Connecting to APRS-IS ... ");
|
||||
while (!espClient.connect(Config.aprs_is.server.c_str(), Config.aprs_is.port) && count < 20) {
|
||||
Serial.println("Didn't connect with server...");
|
||||
delay(1000);
|
||||
espClient.stop();
|
||||
espClient.flush();
|
||||
Serial.println("Run client.stop");
|
||||
Serial.println("Trying to connect with Server: " + String(Config.aprs_is.server) + " AprsServerPort: " + String(Config.aprs_is.port));
|
||||
count++;
|
||||
Serial.println("Try: " + String(count));
|
||||
}
|
||||
lastScreenOn = millis();
|
||||
}
|
||||
if (espClient.connected()) {
|
||||
aprsisState = "OK";
|
||||
} else {
|
||||
aprsisState = "--";
|
||||
if (!Config.display.alwaysOn) {
|
||||
display_toggle(true);
|
||||
if (count == 20) {
|
||||
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 CD2RXU_LoRa_iGate 1.2 filter t/m/" + Config.callsign + "/" + (String)Config.aprs_is.reportingDistance + "\n\r";
|
||||
espClient.write(aprsauth.c_str());
|
||||
delay(200);
|
||||
}
|
||||
lastScreenOn = millis();
|
||||
}
|
||||
secondLine = "WiFi: " + wifiState + "/ APRS-IS: " + aprsisState;
|
||||
}
|
||||
|
||||
String createPacket(String packet) {
|
||||
if (stationMode > 1) {
|
||||
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";
|
||||
void checkStatus() {
|
||||
String wifiState, aprsisState;
|
||||
if (WiFi.status() == WL_CONNECTED) {
|
||||
wifiState = "OK";
|
||||
} else {
|
||||
wifiState = "--";
|
||||
if (!Config.display.alwaysOn) {
|
||||
display_toggle(true);
|
||||
}
|
||||
lastScreenOn = millis();
|
||||
}
|
||||
if (espClient.connected()) {
|
||||
aprsisState = "OK";
|
||||
} else {
|
||||
aprsisState = "--";
|
||||
if (!Config.display.alwaysOn) {
|
||||
display_toggle(true);
|
||||
}
|
||||
lastScreenOn = millis();
|
||||
}
|
||||
secondLine = "WiFi: " + wifiState + "/ APRS-IS: " + aprsisState;
|
||||
}
|
||||
}
|
||||
|
||||
void processLoRaPacket(String packet) {
|
||||
bool queryMessage = false;
|
||||
String aprsPacket, Sender, AddresseeAndMessage, Addressee, ackMessage, receivedMessage;
|
||||
if (packet != "") {
|
||||
//Serial.print("Received Lora Packet : " + String(packet));
|
||||
Serial.println(packet.substring(3));
|
||||
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 (stationMode == 2 || stationMode == 5) {
|
||||
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 += ' ';
|
||||
String createPacket(String packet) {
|
||||
if (stationMode > 1) {
|
||||
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";
|
||||
}
|
||||
}
|
||||
|
||||
void processLoRaPacket(String packet) {
|
||||
bool queryMessage = false;
|
||||
String aprsPacket, Sender, AddresseeAndMessage, Addressee, ackMessage, receivedMessage;
|
||||
if (packet != "") {
|
||||
#ifdef PinPointApp
|
||||
Serial.println(packet.substring(3));
|
||||
#else
|
||||
Serial.print("Received Lora Packet : " + String(packet));
|
||||
#endif
|
||||
if ((packet.substring(0, 3) == "\x3c\xff\x01") && (packet.indexOf("TCPIP") == -1) && (packet.indexOf("NOGATE") == -1) && (packet.indexOf("RFONLY") == -1)) {
|
||||
#ifndef PinPointApp
|
||||
Serial.print(" ---> APRS LoRa Packet!");
|
||||
#endif
|
||||
Sender = packet.substring(3,packet.indexOf(">"));
|
||||
if (Sender != Config.callsign) { // avoid listening yourself by digirepeating
|
||||
if (stationMode == 2 || stationMode == 5) {
|
||||
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);
|
||||
}
|
||||
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);
|
||||
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"));
|
||||
lastScreenOn = millis();
|
||||
show_display(firstLine, secondLine, thirdLine, fourthLine, fifthLine, "Callsign = " + Sender, "TYPE --> QUERY", 0);
|
||||
}
|
||||
LoRa_Utils::sendNewPacket("APRS", QUERY_Utils::process(receivedMessage, Sender, "LoRa"));
|
||||
lastScreenOn = millis();
|
||||
show_display(firstLine, secondLine, thirdLine, fourthLine, fifthLine, "Callsign = " + Sender, "TYPE --> QUERY", 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!queryMessage) {
|
||||
aprsPacket = createPacket(packet);
|
||||
if (!Config.display.alwaysOn) {
|
||||
display_toggle(true);
|
||||
if (!queryMessage) {
|
||||
aprsPacket = createPacket(packet);
|
||||
if (!Config.display.alwaysOn) {
|
||||
display_toggle(true);
|
||||
}
|
||||
lastScreenOn = millis();
|
||||
espClient.write(aprsPacket.c_str());
|
||||
#ifndef PinPointApp
|
||||
Serial.println(" ---> Uploaded to APRS-IS");
|
||||
#endif
|
||||
STATION_Utils::updateLastHeard(Sender);
|
||||
Utils::typeOfPacket(aprsPacket, "LoRa-APRS");
|
||||
show_display(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, seventhLine, 0);
|
||||
}
|
||||
lastScreenOn = millis();
|
||||
espClient.write(aprsPacket.c_str());
|
||||
//Serial.println(" ---> Uploaded to APRS-IS");
|
||||
STATION_Utils::updateLastHeard(Sender);
|
||||
Utils::typeOfPacket(aprsPacket, "LoRa-APRS");
|
||||
show_display(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, seventhLine, 0);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//Serial.println(" ---> LoRa Packet Ignored (first 3 bytes or TCPIP/NOGATE/RFONLY)\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void processAPRSISPacket(String packet) {
|
||||
String Sender, AddresseeAndMessage, Addressee, receivedMessage;
|
||||
if (!packet.startsWith("#")){
|
||||
if (packet.indexOf("::")>0) {
|
||||
Sender = packet.substring(0,packet.indexOf(">"));
|
||||
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?
|
||||
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 : " + packet);
|
||||
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());
|
||||
fifthLine = "APRS-IS ----> APRS-IS";
|
||||
sixthLine = Config.callsign;
|
||||
for (int j=sixthLine.length();j<9;j++) {
|
||||
sixthLine += " ";
|
||||
}
|
||||
sixthLine += "> " + Sender;
|
||||
seventhLine = "QUERY = " + receivedMessage;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//Serial.print("Received from APRS-IS : " + packet);
|
||||
if ((stationMode==2 || stationMode==5) && STATION_Utils::wasHeard(Addressee)) {
|
||||
LoRa_Utils::sendNewPacket("APRS", LoRa_Utils::generatePacket(packet));
|
||||
display_toggle(true);
|
||||
lastScreenOn = millis();
|
||||
Utils::typeOfPacket(packet, "APRS-LoRa");
|
||||
}
|
||||
#ifndef PinPointApp
|
||||
Serial.println(" ---> LoRa Packet Ignored (first 3 bytes or TCPIP/NOGATE/RFONLY)\n");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void processAPRSISPacket(String packet) {
|
||||
String Sender, AddresseeAndMessage, Addressee, receivedMessage;
|
||||
if (!packet.startsWith("#")){
|
||||
if (packet.indexOf("::")>0) {
|
||||
Sender = packet.substring(0,packet.indexOf(">"));
|
||||
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?
|
||||
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) {
|
||||
#ifndef PinPointApp
|
||||
Serial.println("Received Query APRS-IS : " + packet);
|
||||
#endif
|
||||
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());
|
||||
fifthLine = "APRS-IS ----> APRS-IS";
|
||||
sixthLine = Config.callsign;
|
||||
for (int j=sixthLine.length();j<9;j++) {
|
||||
sixthLine += " ";
|
||||
}
|
||||
sixthLine += "> " + Sender;
|
||||
seventhLine = "QUERY = " + receivedMessage;
|
||||
}
|
||||
} else {
|
||||
#ifndef PinPointApp
|
||||
Serial.print("Received from APRS-IS : " + packet);
|
||||
#endif
|
||||
if ((stationMode==2 || stationMode==5) && STATION_Utils::wasHeard(Addressee)) {
|
||||
LoRa_Utils::sendNewPacket("APRS", LoRa_Utils::generatePacket(packet));
|
||||
display_toggle(true);
|
||||
lastScreenOn = millis();
|
||||
Utils::typeOfPacket(packet, "APRS-LoRa");
|
||||
}
|
||||
}
|
||||
show_display(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, seventhLine, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
checkStatus();
|
||||
show_display(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, seventhLine, 0);
|
||||
while (espClient.connected()) {
|
||||
Utils::checkDisplayInterval();
|
||||
Utils::checkBeaconInterval();
|
||||
processLoRaPacket(LoRa_Utils::receivePacket());
|
||||
if (espClient.available()) {
|
||||
String aprsisPacket;
|
||||
aprsisPacket.concat(espClient.readStringUntil('\r'));
|
||||
processAPRSISPacket(aprsisPacket);
|
||||
}
|
||||
show_display(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, seventhLine, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
checkStatus();
|
||||
show_display(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, seventhLine, 0);
|
||||
while (espClient.connected()) {
|
||||
Utils::checkDisplayInterval();
|
||||
Utils::checkBeaconInterval();
|
||||
processLoRaPacket(LoRa_Utils::receivePacket());
|
||||
if (espClient.available()) {
|
||||
String aprsisPacket;
|
||||
aprsisPacket.concat(espClient.readStringUntil('\r'));
|
||||
processAPRSISPacket(aprsisPacket);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -3,6 +3,8 @@
|
|||
|
||||
#include <Arduino.h>
|
||||
|
||||
//#define PinPointApp //uncomment this line when using PinPoint App ( https://www.pinpointaprs.com )
|
||||
|
||||
namespace APRS_IS_Utils {
|
||||
|
||||
void connect();
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
#include <LoRa.h>
|
||||
#include "configuration.h"
|
||||
#include "pins_config.h"
|
||||
#include "aprs_is_utils.h"
|
||||
#include "syslog_utils.h"
|
||||
#include "pins_config.h"
|
||||
#include "display.h"
|
||||
|
||||
extern Configuration Config;
|
||||
|
|
@ -12,83 +13,85 @@ float snr;
|
|||
|
||||
namespace LoRa_Utils {
|
||||
|
||||
void setup() {
|
||||
SPI.begin(LORA_SCK, LORA_MISO, LORA_MOSI, LORA_CS);
|
||||
LoRa.setPins(LORA_CS, LORA_RST, LORA_IRQ);
|
||||
long freq;
|
||||
if (stationMode == 1 || stationMode == 2) {
|
||||
freq = Config.loramodule.iGateFreq;
|
||||
} else {
|
||||
freq = Config.loramodule.digirepeaterTxFreq;
|
||||
}
|
||||
if (!LoRa.begin(freq)) {
|
||||
Serial.println("Starting LoRa failed!");
|
||||
show_display("ERROR", "Starting LoRa failed!");
|
||||
while (true) {
|
||||
delay(1000);
|
||||
void setup() {
|
||||
SPI.begin(LORA_SCK, LORA_MISO, LORA_MOSI, LORA_CS);
|
||||
LoRa.setPins(LORA_CS, LORA_RST, LORA_IRQ);
|
||||
long freq;
|
||||
if (stationMode == 1 || stationMode == 2) {
|
||||
freq = Config.loramodule.iGateFreq;
|
||||
} else {
|
||||
freq = Config.loramodule.digirepeaterTxFreq;
|
||||
}
|
||||
}
|
||||
LoRa.setSpreadingFactor(Config.loramodule.spreadingFactor);
|
||||
LoRa.setSignalBandwidth(Config.loramodule.signalBandwidth);
|
||||
LoRa.setCodingRate4(Config.loramodule.codingRate4);
|
||||
LoRa.enableCrc();
|
||||
LoRa.setTxPower(Config.loramodule.power);
|
||||
Serial.print("init : LoRa Module ... done!");
|
||||
}
|
||||
|
||||
void sendNewPacket(const String &typeOfMessage, const String &newPacket) {
|
||||
digitalWrite(greenLed,HIGH);
|
||||
LoRa.beginPacket();
|
||||
LoRa.write('<');
|
||||
if (typeOfMessage == "APRS") {
|
||||
LoRa.write(0xFF);
|
||||
} else if (typeOfMessage == "LoRa") {
|
||||
LoRa.write(0xF8);
|
||||
}
|
||||
LoRa.write(0x01);
|
||||
LoRa.write((const uint8_t *)newPacket.c_str(), newPacket.length());
|
||||
LoRa.endPacket();
|
||||
digitalWrite(greenLed,LOW);
|
||||
SYSLOG_Utils::log("LoRa Tx", newPacket,0,0,0);
|
||||
Serial.print("---> LoRa Packet Tx : ");
|
||||
Serial.println(newPacket);
|
||||
}
|
||||
|
||||
String generatePacket(String aprsisPacket) {
|
||||
String firstPart, messagePart;
|
||||
aprsisPacket.trim();
|
||||
firstPart = aprsisPacket.substring(0, aprsisPacket.indexOf(","));
|
||||
messagePart = aprsisPacket.substring(aprsisPacket.indexOf("::")+2);
|
||||
return firstPart + ",TCPIP," + Config.callsign + "::" + messagePart;
|
||||
}
|
||||
|
||||
String receivePacket() {
|
||||
String loraPacket = "";
|
||||
int packetSize = LoRa.parsePacket();
|
||||
if (packetSize) {
|
||||
while (LoRa.available()) {
|
||||
int inChar = LoRa.read();
|
||||
loraPacket += (char)inChar;
|
||||
}
|
||||
rssi = LoRa.packetRssi();
|
||||
snr = LoRa.packetSnr();
|
||||
freqError = LoRa.packetFrequencyError();
|
||||
//Serial.println("(RSSI:" +String(rssi) + " / SNR:" + String(snr) + " / FreqErr:" + String(freqError) + ")");
|
||||
if (Config.syslog.active && (stationMode==1 || stationMode==2)) {
|
||||
SYSLOG_Utils::log("LoRa Rx", loraPacket, rssi, snr, freqError);
|
||||
if (!LoRa.begin(freq)) {
|
||||
Serial.println("Starting LoRa failed!");
|
||||
show_display("ERROR", "Starting LoRa failed!");
|
||||
while (true) {
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
LoRa.setSpreadingFactor(Config.loramodule.spreadingFactor);
|
||||
LoRa.setSignalBandwidth(Config.loramodule.signalBandwidth);
|
||||
LoRa.setCodingRate4(Config.loramodule.codingRate4);
|
||||
LoRa.enableCrc();
|
||||
LoRa.setTxPower(Config.loramodule.power);
|
||||
Serial.print("init : LoRa Module ... done!");
|
||||
}
|
||||
return loraPacket;
|
||||
}
|
||||
|
||||
void changeFreqTx() {
|
||||
delay(500);
|
||||
LoRa.setFrequency(Config.loramodule.digirepeaterTxFreq);
|
||||
}
|
||||
void sendNewPacket(const String &typeOfMessage, const String &newPacket) {
|
||||
digitalWrite(greenLed,HIGH);
|
||||
LoRa.beginPacket();
|
||||
LoRa.write('<');
|
||||
if (typeOfMessage == "APRS") {
|
||||
LoRa.write(0xFF);
|
||||
} else if (typeOfMessage == "LoRa") {
|
||||
LoRa.write(0xF8);
|
||||
}
|
||||
LoRa.write(0x01);
|
||||
LoRa.write((const uint8_t *)newPacket.c_str(), newPacket.length());
|
||||
LoRa.endPacket();
|
||||
digitalWrite(greenLed,LOW);
|
||||
SYSLOG_Utils::log("LoRa Tx", newPacket,0,0,0);
|
||||
Serial.print("---> LoRa Packet Tx : ");
|
||||
Serial.println(newPacket);
|
||||
}
|
||||
|
||||
void changeFreqRx() {
|
||||
delay(500);
|
||||
LoRa.setFrequency(Config.loramodule.digirepeaterRxFreq);
|
||||
}
|
||||
String generatePacket(String aprsisPacket) {
|
||||
String firstPart, messagePart;
|
||||
aprsisPacket.trim();
|
||||
firstPart = aprsisPacket.substring(0, aprsisPacket.indexOf(","));
|
||||
messagePart = aprsisPacket.substring(aprsisPacket.indexOf("::")+2);
|
||||
return firstPart + ",TCPIP," + Config.callsign + "::" + messagePart;
|
||||
}
|
||||
|
||||
String receivePacket() {
|
||||
String loraPacket = "";
|
||||
int packetSize = LoRa.parsePacket();
|
||||
if (packetSize) {
|
||||
while (LoRa.available()) {
|
||||
int inChar = LoRa.read();
|
||||
loraPacket += (char)inChar;
|
||||
}
|
||||
rssi = LoRa.packetRssi();
|
||||
snr = LoRa.packetSnr();
|
||||
freqError = LoRa.packetFrequencyError();
|
||||
#ifndef PinPointApp
|
||||
Serial.println("(RSSI:" +String(rssi) + " / SNR:" + String(snr) + " / FreqErr:" + String(freqError) + ")");
|
||||
#endif
|
||||
if (Config.syslog.active && (stationMode==1 || stationMode==2)) {
|
||||
SYSLOG_Utils::log("LoRa Rx", loraPacket, rssi, snr, freqError);
|
||||
}
|
||||
}
|
||||
return loraPacket;
|
||||
}
|
||||
|
||||
void changeFreqTx() {
|
||||
delay(500);
|
||||
LoRa.setFrequency(Config.loramodule.digirepeaterTxFreq);
|
||||
}
|
||||
|
||||
void changeFreqRx() {
|
||||
delay(500);
|
||||
LoRa.setFrequency(Config.loramodule.digirepeaterRxFreq);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
#include "station_utils.h"
|
||||
#include "aprs_is_utils.h"
|
||||
#include "configuration.h"
|
||||
#include <vector>
|
||||
|
||||
|
|
@ -45,12 +46,13 @@ void updateLastHeard(String station) {
|
|||
}
|
||||
fourthLine += String(lastHeardStation.size());
|
||||
|
||||
//////
|
||||
Serial.print("Stations Near (last 30 minutes): ");
|
||||
#ifndef PinPointApp ////// This is just for debugging
|
||||
Serial.print("Stations Near (last " + String(Config.rememberStationTime) + " minutes): ");
|
||||
for (int k=0; k<lastHeardStation.size(); k++) {
|
||||
Serial.print(lastHeardStation[k].substring(0,lastHeardStation[k].indexOf(","))); Serial.print(" ");
|
||||
}
|
||||
Serial.println("");
|
||||
#endif
|
||||
}
|
||||
|
||||
bool wasHeard(String station) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue