adding digirepeater when not wifi available
This commit is contained in:
parent
d4f719f996
commit
1205c23d67
|
|
@ -1,14 +1,14 @@
|
||||||
{
|
{
|
||||||
"callsign": "NOCALL-10",
|
"callsign": "CD2RXU-11",
|
||||||
"stationMode": 1,
|
"stationMode": 5,
|
||||||
"iGateComment": "LoRa_APRS_iGate",
|
"iGateComment": "LoRa_APRS_iGate",
|
||||||
"wifi": {
|
"wifi": {
|
||||||
"AP": [
|
"AP": [
|
||||||
{ "ssid": "WIFI_1",
|
{ "ssid": "Richon",
|
||||||
"password": "password_1",
|
"password": "k4fPnmg5qny",
|
||||||
"latitude": 0.0000000,
|
"latitude": -33.0337313,
|
||||||
"longitude": 0.0000000
|
"longitude": -71.5737261
|
||||||
},
|
},
|
||||||
{ "ssid": "WIFI_2",
|
{ "ssid": "WIFI_2",
|
||||||
"password": "password_2",
|
"password": "password_2",
|
||||||
"latitude": 0.0000000,
|
"latitude": 0.0000000,
|
||||||
|
|
@ -18,11 +18,11 @@
|
||||||
},
|
},
|
||||||
"digi": {
|
"digi": {
|
||||||
"comment": "LoRa_APRS_Digirepeater",
|
"comment": "LoRa_APRS_Digirepeater",
|
||||||
"latitude": 0.0000000,
|
"latitude": -32.9543284,
|
||||||
"longitude": 0.0000000
|
"longitude": -71.1202063
|
||||||
},
|
},
|
||||||
"aprs_is": {
|
"aprs_is": {
|
||||||
"passcode": "VWXYZ",
|
"passcode": "23201",
|
||||||
"server": "euro.aprs2.net",
|
"server": "euro.aprs2.net",
|
||||||
"port": 14580,
|
"port": 14580,
|
||||||
"reportingDistance": 30
|
"reportingDistance": 30
|
||||||
|
|
@ -49,7 +49,8 @@
|
||||||
"other": {
|
"other": {
|
||||||
"beaconInterval": 15,
|
"beaconInterval": 15,
|
||||||
"rememberStationTime": 30,
|
"rememberStationTime": 30,
|
||||||
"sendBatteryVoltage": false
|
"sendBatteryVoltage": false,
|
||||||
|
"lastWiFiCheck": 15
|
||||||
},
|
},
|
||||||
"bme": {
|
"bme": {
|
||||||
"active": false
|
"active": false
|
||||||
|
|
|
||||||
|
|
@ -20,18 +20,21 @@
|
||||||
Configuration Config;
|
Configuration Config;
|
||||||
WiFiClient espClient;
|
WiFiClient espClient;
|
||||||
|
|
||||||
String versionDate = "2023.07.17";
|
String versionDate = "2023.07.30";
|
||||||
int myWiFiAPIndex = 0;
|
int myWiFiAPIndex = 0;
|
||||||
int myWiFiAPSize = Config.wifiAPs.size();
|
int myWiFiAPSize = Config.wifiAPs.size();
|
||||||
WiFi_AP *currentWiFi = &Config.wifiAPs[myWiFiAPIndex];
|
WiFi_AP *currentWiFi = &Config.wifiAPs[myWiFiAPIndex];
|
||||||
|
|
||||||
int stationMode = Config.stationMode;
|
int stationMode = Config.stationMode;
|
||||||
bool statusAfterBoot = true;
|
bool statusAfterBoot = true;
|
||||||
bool beaconUpdate = true;
|
bool beaconUpdate = true;
|
||||||
uint32_t lastBeaconTx = 0;
|
uint32_t lastBeaconTx = 0;
|
||||||
uint32_t previousWiFiMillis = 0;
|
uint32_t previousWiFiMillis = 0;
|
||||||
uint32_t lastScreenOn = millis();
|
uint32_t lastScreenOn = millis();
|
||||||
|
|
||||||
|
uint32_t lastWiFiCheck = 0;
|
||||||
|
bool WiFiConnect = true;
|
||||||
|
|
||||||
String batteryVoltage;
|
String batteryVoltage;
|
||||||
|
|
||||||
std::vector<String> lastHeardStation;
|
std::vector<String> lastHeardStation;
|
||||||
|
|
@ -77,5 +80,38 @@ void loop() {
|
||||||
Utils::checkBeaconInterval();
|
Utils::checkBeaconInterval();
|
||||||
show_display(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, seventhLine, 0);
|
show_display(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, seventhLine, 0);
|
||||||
DIGI_Utils::processPacket(LoRa_Utils::receivePacket());
|
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>();
|
beaconInterval = data["other"]["beaconInterval"].as<int>();
|
||||||
rememberStationTime = data["other"]["rememberStationTime"].as<int>();
|
rememberStationTime = data["other"]["rememberStationTime"].as<int>();
|
||||||
sendBatteryVoltage = data["other"]["sendBatteryVoltage"].as<bool>();
|
sendBatteryVoltage = data["other"]["sendBatteryVoltage"].as<bool>();
|
||||||
|
lastWiFiCheck = data["other"]["lastWiFiCheck"].as<int>();
|
||||||
|
|
||||||
digi.comment = data["digi"]["comment"].as<String>();
|
digi.comment = data["digi"]["comment"].as<String>();
|
||||||
digi.latitude = data["digi"]["latitude"].as<double>();
|
digi.latitude = data["digi"]["latitude"].as<double>();
|
||||||
|
|
|
||||||
|
|
@ -67,6 +67,7 @@ public:
|
||||||
int beaconInterval;
|
int beaconInterval;
|
||||||
int rememberStationTime;
|
int rememberStationTime;
|
||||||
bool sendBatteryVoltage;
|
bool sendBatteryVoltage;
|
||||||
|
int lastWiFiCheck;
|
||||||
std::vector<WiFi_AP> wifiAPs;
|
std::vector<WiFi_AP> wifiAPs;
|
||||||
DIGI digi;
|
DIGI digi;
|
||||||
APRS_IS aprs_is;
|
APRS_IS aprs_is;
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ void processPacket(String packet) {
|
||||||
String sender = packet.substring(3,packet.indexOf(">"));
|
String sender = packet.substring(3,packet.indexOf(">"));
|
||||||
STATION_Utils::updateLastHeard(sender);
|
STATION_Utils::updateLastHeard(sender);
|
||||||
Utils::typeOfPacket(packet, "Digi");
|
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 = packet.substring(3);
|
||||||
loraPacket.replace("WIDE1-1", Config.callsign + "*");
|
loraPacket.replace("WIDE1-1", Config.callsign + "*");
|
||||||
delay(500);
|
delay(500);
|
||||||
|
|
|
||||||
|
|
@ -137,21 +137,36 @@ void checkBeaconInterval() {
|
||||||
sixthLine = " (Batt=" + String(BATTERY_Utils::checkVoltages(),2) + "V)";
|
sixthLine = " (Batt=" + String(BATTERY_Utils::checkVoltages(),2) + "V)";
|
||||||
}
|
}
|
||||||
seventhLine = " listening...";
|
seventhLine = " listening...";
|
||||||
if (stationMode == 4) {
|
if (stationMode==4) {
|
||||||
LoRa_Utils::changeFreqTx();
|
LoRa_Utils::changeFreqTx();
|
||||||
}
|
}
|
||||||
LoRa_Utils::sendNewPacket("APRS", beaconPacket);
|
LoRa_Utils::sendNewPacket("APRS", beaconPacket);
|
||||||
if (stationMode == 4) {
|
if (stationMode==4) {
|
||||||
LoRa_Utils::changeFreqRx();
|
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();
|
lastBeaconTx = millis();
|
||||||
lastScreenOn = millis();
|
lastScreenOn = millis();
|
||||||
beaconUpdate = false;
|
beaconUpdate = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
if (statusAfterBoot) {
|
if (statusAfterBoot) {
|
||||||
processStatus();
|
//processStatus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ void startWiFi() {
|
||||||
delay(500);
|
delay(500);
|
||||||
unsigned long start = millis();
|
unsigned long start = millis();
|
||||||
show_display("", "", "Connecting to Wifi:", "", currentWiFi->ssid + " ...", 0);
|
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());
|
WiFi.begin(currentWiFi->ssid.c_str(), currentWiFi->password.c_str());
|
||||||
while (WiFi.status() != WL_CONNECTED) {
|
while (WiFi.status() != WL_CONNECTED) {
|
||||||
delay(500);
|
delay(500);
|
||||||
|
|
@ -59,6 +59,48 @@ void startWiFi() {
|
||||||
show_display("", "", " Connected!!", "" , " loading ...", 1000);
|
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() {
|
void setup() {
|
||||||
if (stationMode == 1 || stationMode == 2) {
|
if (stationMode == 1 || stationMode == 2) {
|
||||||
if (stationMode==1) {
|
if (stationMode==1) {
|
||||||
|
|
@ -76,10 +118,12 @@ void setup() {
|
||||||
}
|
}
|
||||||
WiFi.mode(WIFI_OFF);
|
WiFi.mode(WIFI_OFF);
|
||||||
btStop();
|
btStop();
|
||||||
|
} else if (stationMode == 5) {
|
||||||
|
Serial.println("stationMode ---> iGate when Wifi/APRS available (DigiRepeater when not)");
|
||||||
} else {
|
} else {
|
||||||
Serial.println("stationMode ---> NOT VALID, check '/data/igate_conf.json'");
|
Serial.println("stationMode ---> NOT VALID, check '/data/igate_conf.json'");
|
||||||
show_display("------- ERROR -------", "stationMode Not Valid", "change it on : /data/", "igate_conf.json", 0);
|
show_display("------- ERROR -------", "stationMode Not Valid", "change it on : /data/", "igate_conf.json", 0);
|
||||||
while (1);
|
while (1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ namespace WIFI_Utils {
|
||||||
|
|
||||||
void checkWiFi();
|
void checkWiFi();
|
||||||
void startWiFi();
|
void startWiFi();
|
||||||
|
void startWiFi2();
|
||||||
void setup();
|
void setup();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue