statusMode 3 ready
This commit is contained in:
parent
b48bc0a461
commit
54af00d357
|
|
@ -1,7 +1,8 @@
|
|||
{
|
||||
"callsign": "CD2RXU-10",
|
||||
"stationMode": 1,
|
||||
"comment": "LoRa_APRS_iGate",
|
||||
"stationMode": 3,
|
||||
"iGateComment": "LoRa_APRS_iGate",
|
||||
"digirepeaterComment": "LoRa_APRS_Digirepeater" ,
|
||||
"wifi": {
|
||||
"AP": [
|
||||
{ "SSID": "Richon",
|
||||
|
|
@ -26,7 +27,7 @@
|
|||
"reportingDistance": 30
|
||||
},
|
||||
"lora": {
|
||||
"frequencyTx": 433775000,
|
||||
"frequencyTx": 433900000,
|
||||
"frequencyRx": 433775000,
|
||||
"spreadingFactor": 12,
|
||||
"signalBandwidth": 125000,
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ void checkReceivedPacket(String packet) {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
Serial.println(" ---> LoRa Packet Ignored (by first 3 bytes of by TCPIP/NOGATE/RFONLY)\n");
|
||||
Serial.println(" ---> LoRa Packet Ignored (first 3 bytes or TCPIP/NOGATE/RFONLY)\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -112,7 +112,7 @@ void setup() {
|
|||
setup_display();
|
||||
Serial.println("\nStarting iGate: " + Config.callsign + " Version: " + String(VERSION));
|
||||
show_display(" LoRa APRS iGate", " Richonguzman", " -- CD2RXU --", " " VERSION, 4000);
|
||||
utils::validateMode(stationMode);
|
||||
WIFI_Utils::validateMode(stationMode);
|
||||
iGateBeaconPacket = GPS_Utils::generateBeacon();
|
||||
LoRa_Utils::setup();
|
||||
|
||||
|
|
@ -133,6 +133,20 @@ void setup() {
|
|||
void loop() {
|
||||
if (stationMode==3 || stationMode==4) { // DigiRepeater Mode / No backUpMode
|
||||
secondLine = "<DigiRepeater Active>";
|
||||
uint32_t lastBeaconTx = millis() - lastTxTime;
|
||||
if (lastBeaconTx >= Config.beaconInterval*60*1000) {
|
||||
beacon_update = true;
|
||||
}
|
||||
if (beacon_update) {
|
||||
thirdLine = "";
|
||||
show_display(firstLine, secondLine, thirdLine, "SENDING iGate BEACON", 0);
|
||||
fourthLine = " listening...";
|
||||
Serial.println("---- Sending iGate Beacon ----");
|
||||
//Serial.println(iGateBeaconPacket);
|
||||
//LoRa_Utils::sendNewPacket("APRS",iGateBeaconPacket);
|
||||
lastTxTime = millis();
|
||||
beacon_update = false;
|
||||
}
|
||||
show_display(firstLine, secondLine, thirdLine, fourthLine, 0);
|
||||
DIGI_Utils::process(LoRa_Utils::receivePacket());
|
||||
} else if (stationMode==1 || stationMode==2 ) { // standard iGate Mode (No DigiRepeater)
|
||||
|
|
@ -157,8 +171,6 @@ void loop() {
|
|||
display_toggle(false);
|
||||
}
|
||||
}
|
||||
thirdLine = "";
|
||||
fourthLine = "";
|
||||
if (!Config.display.keepLastPacketOnScreen) {
|
||||
show_display(firstLine, secondLine, thirdLine, fourthLine, 0);
|
||||
}
|
||||
|
|
@ -175,6 +187,8 @@ void loop() {
|
|||
lastTxTime = millis();
|
||||
lastRxTxTime = millis();
|
||||
show_display(firstLine, secondLine, thirdLine, "SENDING iGate BEACON", 1000);
|
||||
thirdLine = "";
|
||||
fourthLine = " listening...";
|
||||
show_display(firstLine, secondLine, thirdLine, fourthLine, 0);
|
||||
beacon_update = false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,8 @@ void Configuration::readFile(fs::FS &fs, const char *fileName) {
|
|||
|
||||
callsign = data["callsign"].as<String>();
|
||||
stationMode = data["stationMode"].as<int>();
|
||||
comment = data["comment"].as<String>();
|
||||
iGateComment = data["iGateComment"].as<String>();
|
||||
digirepeaterComment = data["digirepeaterComment"].as<String>();
|
||||
beaconInterval = data["other"]["beaconInterval"].as<int>();
|
||||
rememberStationTime = data["other"]["rememberStationTime"].as<int>();
|
||||
statusAfterBoot = data["other"]["statusAfterBoot"].as<bool>();
|
||||
|
|
|
|||
|
|
@ -49,7 +49,8 @@ public:
|
|||
|
||||
String callsign;
|
||||
int stationMode;
|
||||
String comment;
|
||||
String iGateComment;
|
||||
String digirepeaterComment;
|
||||
int beaconInterval;
|
||||
int rememberStationTime;
|
||||
bool statusAfterBoot;
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
#include "digi_utils.h"
|
||||
#include "configuration.h"
|
||||
/*#include <LoRa.h>
|
||||
#include "lora_utils.h"
|
||||
|
||||
#include "display.h"*/
|
||||
|
||||
extern Configuration Config;
|
||||
extern String thirdLine;
|
||||
|
|
@ -31,29 +30,27 @@ void typeOfPacket(String packet) {
|
|||
void process(String packet) {
|
||||
String firstPart, lastPart;
|
||||
if (packet != "") {
|
||||
Serial.println("Received Lora Packet : " + String(packet));
|
||||
if (packet.substring(0, 3) == "\x3c\xff\x01") {
|
||||
if ((packet.indexOf("TCPIP") == -1) && (packet.indexOf("NOGATE") == -1) && (packet.indexOf("RFONLY") == -1) && (packet.indexOf("WIDE1-1") > 10)) {
|
||||
Serial.println("---> APRS LoRa Packet: Tracker --> iGate");
|
||||
typeOfPacket(packet);
|
||||
firstPart = packet.substring(0,packet.indexOf(",")+1);
|
||||
lastPart = packet.substring(packet.indexOf(":"));
|
||||
|
||||
//Serial.println(firstPart);
|
||||
//Serial.println(lastPart);
|
||||
Serial.println(firstPart + Config.callsign + lastPart);
|
||||
|
||||
} else if ((packet.indexOf("TCPIP") == -1) && (packet.indexOf("NOGATE") == -1) && (packet.indexOf("RFONLY") > 10)) {
|
||||
Serial.println("---> APRS LoRa Packet: iGate --> Tracker");
|
||||
typeOfPacket(packet);
|
||||
} else if ((packet.indexOf("TCPIP") > 5) && (packet.indexOf("NOGATE") == -1) && (packet.indexOf("RFONLY") == -1)) {
|
||||
Serial.println("---> APRS LoRa Packet: APRSIS (iGate) --> Tracker");
|
||||
typeOfPacket(packet);
|
||||
} else {
|
||||
Serial.println("Packet ignored because iGate Configuration(.json)");
|
||||
Serial.print("Received Lora Packet : " + String(packet));
|
||||
if ((packet.substring(0, 3) == "\x3c\xff\x01") && (packet.indexOf("NOGATE") == -1) && (packet.indexOf("WIDE1-1") > 10)) { // confirmar lo de WIDE1-1 !!!
|
||||
Serial.println(" ---> APRS LoRa Packet");
|
||||
typeOfPacket(packet);
|
||||
firstPart = packet.substring(3,packet.indexOf(",")+1);
|
||||
lastPart = packet.substring(packet.indexOf(":"));
|
||||
Serial.println(firstPart + Config.callsign + lastPart);
|
||||
if (stationMode == 3) {
|
||||
delay(8000);// quizas no es necesario esperar tanto?
|
||||
//LoRa_Utils::sendNewPacket("APRS", firstPart + Config.callsign + lastPart);
|
||||
Serial.print("repitiendo/Tx mensaje truncado");
|
||||
LoRa_Utils::sendNewPacket("APRS", firstPart + Config.callsign + lastPart + Config.iGateComment); // test porque esta truncado
|
||||
} else { // enviar con != freq
|
||||
delay(8000);
|
||||
Serial.print("repitiendo/Tx mensaje otra frecuencia");
|
||||
LoRa_Utils::changeFreqTx();
|
||||
LoRa_Utils::sendNewPacket("APRS", firstPart + Config.callsign + lastPart + "1");
|
||||
LoRa_Utils::changeFreqRx();
|
||||
}
|
||||
} else {
|
||||
Serial.println("---> Not APRS Packet (Ignore)\n");
|
||||
Serial.println(" ---> LoRa Packet Ignored (first 3 bytes or NOGATE)\n");
|
||||
}
|
||||
}
|
||||
/*void checkReceivedPacket(String packet) {
|
||||
|
|
|
|||
|
|
@ -75,15 +75,17 @@ String processLongitudeAPRS() {
|
|||
String generateBeacon() {
|
||||
String iGateLat = processLatitudeAPRS();
|
||||
String iGateLon = processLongitudeAPRS();
|
||||
String beaconPacket = Config.callsign + ">APLRG1,qAC:=";
|
||||
String beaconPacket = Config.callsign + ">APLRG1";
|
||||
if (stationMode == 1) {
|
||||
beaconPacket += iGateLat + "L" + iGateLon + "&";
|
||||
beaconPacket += ",qAC:=" +iGateLat + "L" + iGateLon + "&";
|
||||
beaconPacket += Config.iGateComment;
|
||||
} else if (stationMode == 2 || stationMode == 5) {
|
||||
beaconPacket += iGateLat + "L" + iGateLon + "a";
|
||||
} else if (stationMode >=3 && stationMode <= 4) {
|
||||
beaconPacket += iGateLat + "L" + iGateLon + "#";
|
||||
beaconPacket += ",qAC:=" + iGateLat + "L" + iGateLon + "a";
|
||||
beaconPacket += Config.iGateComment;
|
||||
} else if (stationMode ==3 || stationMode == 4) {
|
||||
beaconPacket += ":=" + iGateLat + "L" + iGateLon + "#";
|
||||
beaconPacket += Config.digirepeaterComment;
|
||||
}
|
||||
beaconPacket += Config.comment;
|
||||
return beaconPacket;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ namespace LoRa_Utils {
|
|||
void setup() {
|
||||
SPI.begin(LORA_SCK, LORA_MISO, LORA_MOSI, LORA_CS);
|
||||
LoRa.setPins(LORA_CS, LORA_RST, LORA_IRQ);
|
||||
if (!LoRa.begin(Config.loramodule.frequencyTx)) {
|
||||
if (!LoRa.begin(Config.loramodule.frequencyRx)) {
|
||||
Serial.println("Starting LoRa failed!");
|
||||
show_display("ERROR", "Starting LoRa failed!");
|
||||
while (true) {
|
||||
|
|
@ -59,4 +59,28 @@ String receivePacket() {
|
|||
return loraPacket;
|
||||
}
|
||||
|
||||
void changeFreqTx() {
|
||||
if (!LoRa.begin(Config.loramodule.frequencyTx)) {
|
||||
Serial.println("Starting LoRa failed!");
|
||||
show_display("ERROR", "Starting LoRa failed!");
|
||||
while (true) {
|
||||
delay(1000);
|
||||
}
|
||||
} else {
|
||||
Serial.println("cambiando frecuencia Tx = " + String(Config.loramodule.frequencyTx));
|
||||
}
|
||||
}
|
||||
|
||||
void changeFreqRx() {
|
||||
if (!LoRa.begin(Config.loramodule.frequencyRx)) {
|
||||
Serial.println("Starting LoRa failed!");
|
||||
show_display("ERROR", "Starting LoRa failed!");
|
||||
while (true) {
|
||||
delay(1000);
|
||||
}
|
||||
} else {
|
||||
Serial.println("cambiando frecuencia Rx = " + String(Config.loramodule.frequencyRx));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -9,6 +9,8 @@ void setup();
|
|||
void sendNewPacket(const String &typeOfMessage, const String &newPacket);
|
||||
String generatePacket(String aprsisPacket);
|
||||
String receivePacket();
|
||||
void changeFreqTx();
|
||||
void changeFreqRx();
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,30 +10,9 @@ extern bool statusAfterBoot;
|
|||
|
||||
namespace utils {
|
||||
|
||||
void validateMode(int mode) {
|
||||
if (mode == 1 || mode == 2 || mode == 5) {
|
||||
if (mode==1) {
|
||||
Serial.println("stationMode ---> iGate (only Rx)");
|
||||
} else {
|
||||
Serial.println("stationMode ---> iGate (Rx + Tx)");
|
||||
}
|
||||
WIFI_Utils::setup();
|
||||
btStop();
|
||||
} else if (mode == 3) {
|
||||
Serial.println("stationMode ---> DigiRepeater Rx freq = Tx freq");
|
||||
} else if (mode == 4) {
|
||||
Serial.println("stationMode ---> DigiRepeater Rx freq = Tx freq");
|
||||
} else {
|
||||
Serial.println("stationMode ---> NOT VALID, check 'data/igate_conf.json'");
|
||||
while (1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void processStatus() {
|
||||
delay(1000);
|
||||
String startupStatus = Config.callsign + ">APLRG1,qAC:>" + Config.defaultStatus;
|
||||
espClient.write((startupStatus + "\n").c_str());
|
||||
espClient.write((Config.callsign + ">APLRG1,qAC:>" + Config.defaultStatus + "\n").c_str());
|
||||
statusAfterBoot = false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@
|
|||
|
||||
namespace utils {
|
||||
|
||||
void validateMode(int mode);
|
||||
void processStatus();
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ extern int myWiFiAPSize;
|
|||
|
||||
namespace WIFI_Utils {
|
||||
|
||||
void setup() {
|
||||
void setupWiFi() {
|
||||
int status = WL_IDLE_STATUS;
|
||||
WiFi.mode(WIFI_STA);
|
||||
WiFi.disconnect();
|
||||
|
|
@ -39,4 +39,23 @@ void setup() {
|
|||
Serial.println(WiFi.localIP());
|
||||
}
|
||||
|
||||
void validateMode(int mode) {
|
||||
if (mode == 1 || mode == 2 || mode == 5) {
|
||||
if (mode==1) {
|
||||
Serial.println("stationMode ---> iGate (only Rx)");
|
||||
} else {
|
||||
Serial.println("stationMode ---> iGate (Rx + Tx)");
|
||||
}
|
||||
setupWiFi();
|
||||
btStop();
|
||||
} else if (mode == 3) {
|
||||
Serial.println("stationMode ---> DigiRepeater (Rx freq == Tx freq)");
|
||||
} else if (mode == 4) {
|
||||
Serial.println("stationMode ---> DigiRepeater (Rx freq != Tx freq)");
|
||||
} else {
|
||||
Serial.println("stationMode ---> NOT VALID, check 'data/igate_conf.json'");
|
||||
while (1);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -5,7 +5,8 @@
|
|||
|
||||
namespace WIFI_Utils {
|
||||
|
||||
void setup();
|
||||
void setupWiFi();
|
||||
void validateMode(int mode);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue