mirror of
https://github.com/richonguzman/LoRa_APRS_iGate.git
synced 2026-03-06 13:33:52 +01:00
adding digirepeater when not wifi available
This commit is contained in:
parent
d4f719f996
commit
1205c23d67
|
|
@ -1,14 +1,14 @@
|
|||
{
|
||||
"callsign": "NOCALL-10",
|
||||
"stationMode": 1,
|
||||
"iGateComment": "LoRa_APRS_iGate",
|
||||
"wifi": {
|
||||
"AP": [
|
||||
{ "ssid": "WIFI_1",
|
||||
"password": "password_1",
|
||||
"latitude": 0.0000000,
|
||||
"longitude": 0.0000000
|
||||
},
|
||||
"callsign": "CD2RXU-11",
|
||||
"stationMode": 5,
|
||||
"iGateComment": "LoRa_APRS_iGate",
|
||||
"wifi": {
|
||||
"AP": [
|
||||
{ "ssid": "Richon",
|
||||
"password": "k4fPnmg5qny",
|
||||
"latitude": -33.0337313,
|
||||
"longitude": -71.5737261
|
||||
},
|
||||
{ "ssid": "WIFI_2",
|
||||
"password": "password_2",
|
||||
"latitude": 0.0000000,
|
||||
|
|
@ -18,11 +18,11 @@
|
|||
},
|
||||
"digi": {
|
||||
"comment": "LoRa_APRS_Digirepeater",
|
||||
"latitude": 0.0000000,
|
||||
"longitude": 0.0000000
|
||||
"latitude": -32.9543284,
|
||||
"longitude": -71.1202063
|
||||
},
|
||||
"aprs_is": {
|
||||
"passcode": "VWXYZ",
|
||||
"passcode": "23201",
|
||||
"server": "euro.aprs2.net",
|
||||
"port": 14580,
|
||||
"reportingDistance": 30
|
||||
|
|
@ -49,7 +49,8 @@
|
|||
"other": {
|
||||
"beaconInterval": 15,
|
||||
"rememberStationTime": 30,
|
||||
"sendBatteryVoltage": false
|
||||
"sendBatteryVoltage": false,
|
||||
"lastWiFiCheck": 15
|
||||
},
|
||||
"bme": {
|
||||
"active": false
|
||||
|
|
|
|||
|
|
@ -20,18 +20,21 @@
|
|||
Configuration Config;
|
||||
WiFiClient espClient;
|
||||
|
||||
String versionDate = "2023.07.17";
|
||||
String versionDate = "2023.07.30";
|
||||
int myWiFiAPIndex = 0;
|
||||
int myWiFiAPSize = Config.wifiAPs.size();
|
||||
WiFi_AP *currentWiFi = &Config.wifiAPs[myWiFiAPIndex];
|
||||
|
||||
int stationMode = Config.stationMode;
|
||||
bool statusAfterBoot = true;
|
||||
bool beaconUpdate = true;
|
||||
bool beaconUpdate = true;
|
||||
uint32_t lastBeaconTx = 0;
|
||||
uint32_t previousWiFiMillis = 0;
|
||||
uint32_t lastScreenOn = millis();
|
||||
|
||||
uint32_t lastWiFiCheck = 0;
|
||||
bool WiFiConnect = true;
|
||||
|
||||
String batteryVoltage;
|
||||
|
||||
std::vector<String> lastHeardStation;
|
||||
|
|
@ -77,5 +80,38 @@ void loop() {
|
|||
Utils::checkBeaconInterval();
|
||||
show_display(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, seventhLine, 0);
|
||||
DIGI_Utils::processPacket(LoRa_Utils::receivePacket());
|
||||
} else if (stationMode==5) {
|
||||
uint32_t WiFiCheck = millis() - lastWiFiCheck;
|
||||
if (WiFi.status() != WL_CONNECTED && WiFiCheck >= Config.lastWiFiCheck*33*1000) {
|
||||
WiFiConnect = true;
|
||||
}
|
||||
if (WiFiConnect) {
|
||||
Serial.println("\n\n###############\ncomenzando nueva revision\n###############");
|
||||
WIFI_Utils::startWiFi2();
|
||||
lastWiFiCheck = millis();
|
||||
WiFiConnect = false;
|
||||
}
|
||||
|
||||
if (WiFi.status() == WL_CONNECTED) { // Modo iGate
|
||||
Serial.println("conectado");
|
||||
} else { // Modo DigiRepeater
|
||||
Utils::checkDisplayInterval();
|
||||
Utils::checkBeaconInterval();
|
||||
show_display(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, seventhLine, 0);
|
||||
DIGI_Utils::processPacket(LoRa_Utils::receivePacket());
|
||||
}
|
||||
|
||||
/* si wifi
|
||||
si aprs --> igate
|
||||
else --> digi/exit
|
||||
else--> be digi
|
||||
*/
|
||||
|
||||
/*if (!espClient.connected()) {
|
||||
APRS_IS_Utils::connect();
|
||||
|
||||
// if aprsis ok --> be igate
|
||||
// else --> be digirepeater
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
|
@ -37,6 +37,7 @@ void Configuration::readFile(fs::FS &fs, const char *fileName) {
|
|||
beaconInterval = data["other"]["beaconInterval"].as<int>();
|
||||
rememberStationTime = data["other"]["rememberStationTime"].as<int>();
|
||||
sendBatteryVoltage = data["other"]["sendBatteryVoltage"].as<bool>();
|
||||
lastWiFiCheck = data["other"]["lastWiFiCheck"].as<int>();
|
||||
|
||||
digi.comment = data["digi"]["comment"].as<String>();
|
||||
digi.latitude = data["digi"]["latitude"].as<double>();
|
||||
|
|
|
|||
|
|
@ -67,6 +67,7 @@ public:
|
|||
int beaconInterval;
|
||||
int rememberStationTime;
|
||||
bool sendBatteryVoltage;
|
||||
int lastWiFiCheck;
|
||||
std::vector<WiFi_AP> wifiAPs;
|
||||
DIGI digi;
|
||||
APRS_IS aprs_is;
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ void processPacket(String packet) {
|
|||
String sender = packet.substring(3,packet.indexOf(">"));
|
||||
STATION_Utils::updateLastHeard(sender);
|
||||
Utils::typeOfPacket(packet, "Digi");
|
||||
if ((stationMode==3) && (packet.indexOf("WIDE1-1") > 10)) {
|
||||
if ((stationMode==3 || stationMode==5) && (packet.indexOf("WIDE1-1") > 10)) {
|
||||
loraPacket = packet.substring(3);
|
||||
loraPacket.replace("WIDE1-1", Config.callsign + "*");
|
||||
delay(500);
|
||||
|
|
|
|||
|
|
@ -137,21 +137,36 @@ void checkBeaconInterval() {
|
|||
sixthLine = " (Batt=" + String(BATTERY_Utils::checkVoltages(),2) + "V)";
|
||||
}
|
||||
seventhLine = " listening...";
|
||||
if (stationMode == 4) {
|
||||
if (stationMode==4) {
|
||||
LoRa_Utils::changeFreqTx();
|
||||
}
|
||||
LoRa_Utils::sendNewPacket("APRS", beaconPacket);
|
||||
if (stationMode == 4) {
|
||||
if (stationMode==4) {
|
||||
LoRa_Utils::changeFreqRx();
|
||||
}
|
||||
}
|
||||
} else if (stationMode==5) {
|
||||
if (WiFi.status() != WL_CONNECTED) {
|
||||
String Tx = String(Config.loramodule.digirepeaterTxFreq);
|
||||
secondLine = "Rx:" + String(Tx.substring(0,3)) + "." + String(Tx.substring(3,6));
|
||||
secondLine += " Tx:" + String(Tx.substring(0,3)) + "." + String(Tx.substring(3,6));
|
||||
fifthLine = "";
|
||||
sixthLine = "";
|
||||
show_display(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, "SENDING iGate BEACON", 0);
|
||||
if (Config.sendBatteryVoltage) {
|
||||
sixthLine = " (Batt=" + String(BATTERY_Utils::checkVoltages(),2) + "V)";
|
||||
}
|
||||
seventhLine = " listening...";
|
||||
LoRa_Utils::sendNewPacket("APRS", beaconPacket);
|
||||
} else {
|
||||
Serial.println("enviando beacon por APRS WIFI");
|
||||
}
|
||||
}
|
||||
lastBeaconTx = millis();
|
||||
lastScreenOn = millis();
|
||||
beaconUpdate = false;
|
||||
|
||||
}
|
||||
if (statusAfterBoot) {
|
||||
processStatus();
|
||||
//processStatus();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ void startWiFi() {
|
|||
delay(500);
|
||||
unsigned long start = millis();
|
||||
show_display("", "", "Connecting to Wifi:", "", currentWiFi->ssid + " ...", 0);
|
||||
Serial.print("\nConnecting to '"); Serial.print(currentWiFi->ssid); Serial.println("' WiFi ...");
|
||||
Serial.print("\nConnecting to WiFi '"); Serial.print(currentWiFi->ssid); Serial.println("' ...");
|
||||
WiFi.begin(currentWiFi->ssid.c_str(), currentWiFi->password.c_str());
|
||||
while (WiFi.status() != WL_CONNECTED) {
|
||||
delay(500);
|
||||
|
|
@ -59,6 +59,48 @@ void startWiFi() {
|
|||
show_display("", "", " Connected!!", "" , " loading ...", 1000);
|
||||
}
|
||||
|
||||
void startWiFi2() {
|
||||
int wifiCounter = 0;
|
||||
int status = WL_IDLE_STATUS;
|
||||
WiFi.mode(WIFI_STA);
|
||||
WiFi.disconnect();
|
||||
delay(500);
|
||||
unsigned long start = millis();
|
||||
show_display("", "", "Connecting to Wifi:", "", currentWiFi->ssid + " ...", 0);
|
||||
Serial.print("\nConnecting to WiFi '"); Serial.print(currentWiFi->ssid); Serial.println("' ...");
|
||||
WiFi.begin(currentWiFi->ssid.c_str(), currentWiFi->password.c_str());
|
||||
while (WiFi.status() != WL_CONNECTED && wifiCounter<2) {
|
||||
delay(500);
|
||||
digitalWrite(greenLed,HIGH);
|
||||
Serial.print('.');
|
||||
delay(500);
|
||||
digitalWrite(greenLed,LOW);
|
||||
if ((millis() - start) > 10000){
|
||||
delay(1000);
|
||||
if(myWiFiAPIndex >= (myWiFiAPSize-1)) {
|
||||
myWiFiAPIndex = 0;
|
||||
wifiCounter++;
|
||||
} else {
|
||||
myWiFiAPIndex++;
|
||||
}
|
||||
currentWiFi = &Config.wifiAPs[myWiFiAPIndex];
|
||||
start = millis();
|
||||
Serial.print("\nConnecting to WiFi '"); Serial.print(currentWiFi->ssid); Serial.println("' ...");
|
||||
show_display("", "", "Connecting to Wifi:", "", currentWiFi->ssid + " ...", 0);
|
||||
WiFi.disconnect();
|
||||
WiFi.begin(currentWiFi->ssid.c_str(), currentWiFi->password.c_str());
|
||||
}
|
||||
}
|
||||
if (WiFi.status() == WL_CONNECTED) {
|
||||
digitalWrite(greenLed,LOW);
|
||||
Serial.print("Connected as ");
|
||||
Serial.println(WiFi.localIP());
|
||||
show_display("", "", " Connected!!", "" , " loading ...", 1000);
|
||||
} else {
|
||||
show_display("", "", " WiFi Not Connected!", " DigiRepeater MODE" , " loading ...", 2000);
|
||||
}
|
||||
}
|
||||
|
||||
void setup() {
|
||||
if (stationMode == 1 || stationMode == 2) {
|
||||
if (stationMode==1) {
|
||||
|
|
@ -76,10 +118,12 @@ void setup() {
|
|||
}
|
||||
WiFi.mode(WIFI_OFF);
|
||||
btStop();
|
||||
} else if (stationMode == 5) {
|
||||
Serial.println("stationMode ---> iGate when Wifi/APRS available (DigiRepeater when not)");
|
||||
} else {
|
||||
Serial.println("stationMode ---> NOT VALID, check '/data/igate_conf.json'");
|
||||
show_display("------- ERROR -------", "stationMode Not Valid", "change it on : /data/", "igate_conf.json", 0);
|
||||
while (1);
|
||||
Serial.println("stationMode ---> NOT VALID, check '/data/igate_conf.json'");
|
||||
show_display("------- ERROR -------", "stationMode Not Valid", "change it on : /data/", "igate_conf.json", 0);
|
||||
while (1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ namespace WIFI_Utils {
|
|||
|
||||
void checkWiFi();
|
||||
void startWiFi();
|
||||
void startWiFi2();
|
||||
void setup();
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue