checking freqs digirepeater
This commit is contained in:
parent
0a2c7ed9ee
commit
c81a04a315
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"callsign": "CD2RXU-10",
|
||||
"stationMode": 2,
|
||||
"stationMode": 4,
|
||||
"iGateComment": "LoRa_APRS_iGate",
|
||||
"digirepeaterComment": "LoRa_APRS_Digirepeater" ,
|
||||
"wifi": {
|
||||
|
|
@ -27,8 +27,9 @@
|
|||
"reportingDistance": 30
|
||||
},
|
||||
"lora": {
|
||||
"frequencyTx": 433900000,
|
||||
"frequencyRx": 433775000,
|
||||
"iGateFreq": 433775000,
|
||||
"digirepeaterTxFreq": 433900000,
|
||||
"digirepeaterRxFreq": 433775000,
|
||||
"spreadingFactor": 12,
|
||||
"signalBandwidth": 125000,
|
||||
"codingRate4": 5,
|
||||
|
|
|
|||
|
|
@ -45,9 +45,11 @@ void setup() {
|
|||
utils::setupDiplay();
|
||||
Serial.println("\nStarting iGate: " + Config.callsign + " Version: " + String(VERSION));
|
||||
show_display(" LoRa APRS iGate", " Richonguzman", " -- CD2RXU --", " " VERSION, 4000);
|
||||
WIFI_Utils::validateMode(stationMode);
|
||||
iGateBeaconPacket = GPS_Utils::generateBeacon();
|
||||
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.");
|
||||
});
|
||||
|
|
@ -62,9 +64,9 @@ void loop() {
|
|||
utils::checkBeaconInterval();
|
||||
show_display(firstLine, secondLine, thirdLine, fourthLine, 0);
|
||||
DIGI_Utils::processPacket(LoRa_Utils::receivePacket());
|
||||
if (statusAfterBoot) {
|
||||
/*if (statusAfterBoot) {
|
||||
utils::processStatus();
|
||||
}
|
||||
}*/
|
||||
} else if (stationMode==1 || stationMode==2 ) { // iGate (1 Only Rx / 2 Rx+Tx)
|
||||
unsigned long currentWiFiMillis = millis();
|
||||
if ((WiFi.status() != WL_CONNECTED) && (currentWiFiMillis - previousWiFiMillis >= currentWiFi->checkInterval*1000)) {
|
||||
|
|
@ -139,13 +141,9 @@ void loop() {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (statusAfterBoot) {
|
||||
/*if (statusAfterBoot) {
|
||||
utils::processStatus();
|
||||
}
|
||||
}*/
|
||||
}
|
||||
} else {
|
||||
Serial.println(stationMode);
|
||||
// stationMode = 5
|
||||
// this mode is only for when iGate loses Wifi and transforms into Digirepeater
|
||||
}
|
||||
}
|
||||
|
|
@ -46,8 +46,9 @@ void Configuration::readFile(fs::FS &fs, const char *fileName) {
|
|||
aprs_is.softwareVersion = data["aprs_is"]["softwareVersion"].as<String>();
|
||||
aprs_is.reportingDistance = data["aprs_is"]["reportingDistance"].as<int>();
|
||||
|
||||
loramodule.frequencyTx = data["lora"]["frequencyTx"].as<long>();
|
||||
loramodule.frequencyRx = data["lora"]["frequencyRx"].as<long>();
|
||||
loramodule.iGateFreq = data["lora"]["iGateFreq"].as<long>();
|
||||
loramodule.digirepeaterTxFreq = data["lora"]["digirepeaterTxFreq"].as<long>();
|
||||
loramodule.digirepeaterRxFreq = data["lora"]["digirepeaterRxFreq"].as<long>();
|
||||
loramodule.spreadingFactor = data["lora"]["spreadingFactor"].as<int>();
|
||||
loramodule.signalBandwidth = data["lora"]["signalBandwidth"].as<long>();
|
||||
loramodule.codingRate4 = data["lora"]["codingRate4"].as<int>();
|
||||
|
|
|
|||
|
|
@ -29,8 +29,9 @@ public:
|
|||
|
||||
class LoraModule {
|
||||
public:
|
||||
long frequencyTx;
|
||||
long frequencyRx;
|
||||
long iGateFreq;
|
||||
long digirepeaterTxFreq;
|
||||
long digirepeaterRxFreq;
|
||||
int spreadingFactor;
|
||||
long signalBandwidth;
|
||||
int codingRate4;
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ void processPacket(String packet) {
|
|||
typeOfPacket(packet);
|
||||
firstPart = packet.substring(3,packet.indexOf(",")+1);
|
||||
lastPart = packet.substring(packet.indexOf(":"));
|
||||
Serial.println(firstPart + Config.callsign + lastPart);
|
||||
Serial.println(firstPart + Config.callsign + "*" + lastPart);
|
||||
delay(500);
|
||||
if (stationMode == 4) { // Digirepeating with Freq Rx != Tx
|
||||
LoRa_Utils::changeFreqTx();
|
||||
|
|
|
|||
|
|
@ -2,14 +2,21 @@
|
|||
#include "configuration.h"
|
||||
#include "display.h"
|
||||
|
||||
extern Configuration Config;
|
||||
extern Configuration Config;
|
||||
extern int stationMode;
|
||||
|
||||
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.frequencyRx)) {
|
||||
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) {
|
||||
|
|
@ -61,14 +68,12 @@ String receivePacket() {
|
|||
|
||||
void changeFreqTx() {
|
||||
delay(500);
|
||||
LoRa.setFrequency(Config.loramodule.frequencyTx);
|
||||
//Serial.println("changing LoRa Freq to " + String(Config.loramodule.frequencyTx));
|
||||
LoRa.setFrequency(Config.loramodule.digirepeaterTxFreq);
|
||||
}
|
||||
|
||||
void changeFreqRx() {
|
||||
delay(500);
|
||||
LoRa.setFrequency(Config.loramodule.frequencyRx);
|
||||
//Serial.println("changing LoRa Freq to = " + String(Config.loramodule.frequencyRx));
|
||||
LoRa.setFrequency(Config.loramodule.digirepeaterRxFreq);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -29,7 +29,13 @@ void processStatus() {
|
|||
} else {
|
||||
delay(5000);
|
||||
status += ":>" + Config.defaultStatus;
|
||||
if (stationMode == 4) { // Digirepeating with Freq Rx != Tx
|
||||
LoRa_Utils::changeFreqTx();
|
||||
}
|
||||
LoRa_Utils::sendNewPacket("APRS", status);
|
||||
if (stationMode == 4) {
|
||||
LoRa_Utils::changeFreqRx();
|
||||
}
|
||||
}
|
||||
statusAfterBoot = false;
|
||||
}
|
||||
|
|
@ -55,20 +61,29 @@ void checkBeaconInterval() {
|
|||
display_toggle(true);
|
||||
thirdLine = "";
|
||||
Serial.println("---- Sending iGate Beacon ----");
|
||||
if (stationMode==3 || stationMode==4) {
|
||||
show_display(firstLine, secondLine, thirdLine, "SENDING iGate BEACON", 0);
|
||||
fourthLine = " listening...";
|
||||
LoRa_Utils::sendNewPacket("APRS",iGateBeaconPacket);
|
||||
} else if (stationMode==1 || stationMode==2) {
|
||||
if (stationMode==1 || stationMode==2) {
|
||||
show_display(firstLine, secondLine, thirdLine, "SENDING iGate BEACON", 1000);
|
||||
fourthLine = " listening...";
|
||||
espClient.write((iGateBeaconPacket + "\n").c_str());
|
||||
show_display(firstLine, secondLine, thirdLine, fourthLine, 0);
|
||||
} 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
|
||||
LoRa_Utils::changeFreqTx();
|
||||
}
|
||||
LoRa_Utils::sendNewPacket("APRS",iGateBeaconPacket);
|
||||
if (stationMode == 4) {
|
||||
LoRa_Utils::changeFreqRx();
|
||||
}
|
||||
}
|
||||
lastBeaconTx = millis();
|
||||
lastScreenOn = millis();
|
||||
beacon_update = false;
|
||||
}
|
||||
if (statusAfterBoot) {
|
||||
processStatus();
|
||||
}
|
||||
}
|
||||
|
||||
void checkDisplayInterval() {
|
||||
|
|
@ -80,4 +95,14 @@ void checkDisplayInterval() {
|
|||
}
|
||||
}
|
||||
|
||||
void validateDigiFreqs() {
|
||||
if (stationMode == 4) {
|
||||
if (abs(Config.loramodule.digirepeaterTxFreq - Config.loramodule.digirepeaterRxFreq) < 125000) {
|
||||
Serial.println("Tx Freq less than 125kHz from Rx Freq ---> NOT VALID, check 'data/igate_conf.json'");
|
||||
show_display("Tx Freq is less than ", "125kHz from Rx Freq", "change it on : /data/", "igate_conf.json", 0);
|
||||
while (1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -9,6 +9,7 @@ void processStatus();
|
|||
void setupDiplay();
|
||||
void checkBeaconInterval();
|
||||
void checkDisplayInterval();
|
||||
void validateDigiFreqs();
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,10 +7,11 @@ extern Configuration Config;
|
|||
extern WiFi_AP *currentWiFi;
|
||||
extern int myWiFiAPIndex;
|
||||
extern int myWiFiAPSize;
|
||||
extern int stationMode;
|
||||
|
||||
namespace WIFI_Utils {
|
||||
|
||||
void setupWiFi() {
|
||||
void startWiFi() {
|
||||
int status = WL_IDLE_STATUS;
|
||||
WiFi.mode(WIFI_STA);
|
||||
WiFi.disconnect();
|
||||
|
|
@ -39,21 +40,26 @@ void setupWiFi() {
|
|||
Serial.println(WiFi.localIP());
|
||||
}
|
||||
|
||||
void validateMode(int mode) {
|
||||
if (mode == 1 || mode == 2 || mode == 5) {
|
||||
if (mode==1) {
|
||||
void setup() {
|
||||
if (stationMode == 1 || stationMode == 2) {
|
||||
if (stationMode==1) {
|
||||
Serial.println("stationMode ---> iGate (only Rx)");
|
||||
} else {
|
||||
Serial.println("stationMode ---> iGate (Rx + Tx)");
|
||||
}
|
||||
setupWiFi();
|
||||
startWiFi();
|
||||
btStop();
|
||||
} else if (stationMode == 3 || stationMode == 4) {
|
||||
if (stationMode == 3) {
|
||||
Serial.println("stationMode ---> DigiRepeater (Rx freq == Tx freq)");
|
||||
} else {
|
||||
Serial.println("stationMode ---> DigiRepeater (Rx freq != Tx freq)");
|
||||
}
|
||||
WiFi.mode(WIFI_OFF);
|
||||
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'");
|
||||
Serial.println("stationMode ---> NOT VALID, check '/data/igate_conf.json'");
|
||||
show_display("stationMode Not Valid", "change it on : /data/", "igate_conf.json", 0);
|
||||
while (1);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@
|
|||
|
||||
namespace WIFI_Utils {
|
||||
|
||||
void setupWiFi();
|
||||
void validateMode(int mode);
|
||||
void startWiFi();
|
||||
void setup();
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue