From 9c01288fd75a0c7728d89002be14e9c294797eef Mon Sep 17 00:00:00 2001 From: richonguzman Date: Sun, 30 Jul 2023 18:57:31 -0400 Subject: [PATCH] 1.1.6 --- data/igate_conf.json | 2 +- src/LoRa_APRS_iGate.cpp | 7 +++--- src/utils.cpp | 13 ++++------ src/wifi_utils.cpp | 54 ++++++++--------------------------------- 4 files changed, 20 insertions(+), 56 deletions(-) diff --git a/data/igate_conf.json b/data/igate_conf.json index e435601..cf87c30 100644 --- a/data/igate_conf.json +++ b/data/igate_conf.json @@ -5,7 +5,7 @@ "wifi": { "AP": [ { "ssid": "Richon", - "password": "k4fPnmg5qny", + "password": "k4fPnmg5qnyf", "latitude": -32.9543284, "longitude": -71.1202063 }, diff --git a/src/LoRa_APRS_iGate.cpp b/src/LoRa_APRS_iGate.cpp index e52f140..d8f7d25 100644 --- a/src/LoRa_APRS_iGate.cpp +++ b/src/LoRa_APRS_iGate.cpp @@ -81,9 +81,9 @@ void loop() { Utils::checkBeaconInterval(); show_display(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, seventhLine, 0); DIGI_Utils::processPacket(LoRa_Utils::receivePacket()); - } else if (stationMode==5) { + } else if (stationMode==5) { // iGate when WiFi and APRS available , DigiRepeater when not (RxFreq=TxFreq) Utils::checkWiFiInterval(); - if (WiFi.status() == WL_CONNECTED) { // Modo iGate + if (WiFi.status() == WL_CONNECTED) { // iGate Mode thirdLine = Utils::getLocalIP(); if (!espClient.connected()) { APRS_IS_Utils::connect(); @@ -91,6 +91,7 @@ void loop() { if (lastStationModeState == 1) { iGateBeaconPacket = GPS_Utils::generateBeacon(); lastStationModeState = 0; + Utils::startOTAServer(); } APRS_IS_Utils::checkStatus(); show_display(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, seventhLine, 0); @@ -104,7 +105,7 @@ void loop() { APRS_IS_Utils::processAPRSISPacket(aprsisPacket); } } - } else { // Modo DigiRepeater + } else { // DigiRepeater Mode if (lastStationModeState == 0) { iGateBeaconPacket = GPS_Utils::generateBeacon(); lastStationModeState = 1; diff --git a/src/utils.cpp b/src/utils.cpp index ab34652..7289555 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -78,9 +78,6 @@ void setupDisplay() { show_display(" LoRa APRS", " ( iGate )", "", " Richonguzman", " -- CD2RXU --", "", " " + versionDate, 4000); digitalWrite(greenLed,LOW); firstLine = Config.callsign; - /*if (stationMode==3 || stationMode==4) { - thirdLine = "<< DigiRepeater >>"; - }*/ seventhLine = " listening..."; } @@ -95,7 +92,7 @@ void activeStations() { void checkBeaconInterval() { uint32_t lastTx = millis() - lastBeaconTx; String beaconPacket; - if (lastTx >= Config.beaconInterval*12*1000) { // 60!!! + if (lastTx >= Config.beaconInterval*60*1000) { beaconUpdate = true; } if (beaconUpdate) { @@ -177,7 +174,7 @@ void checkBeaconInterval() { beaconUpdate = false; } if (statusAfterBoot) { - //processStatus(); + processStatus(); } } @@ -192,12 +189,12 @@ void checkDisplayInterval() { void checkWiFiInterval() { uint32_t WiFiCheck = millis() - lastWiFiCheck; - if (WiFi.status() != WL_CONNECTED && WiFiCheck >= Config.lastWiFiCheck*4*1000) { //60!!! + if (WiFi.status() != WL_CONNECTED && WiFiCheck >= Config.lastWiFiCheck*60*1000) { WiFiConnect = true; } if (WiFiConnect) { Serial.println("\nConnecting to WiFi ..."); - WIFI_Utils::startWiFi2(); + WIFI_Utils::startWiFi(); lastWiFiCheck = millis(); WiFiConnect = false; } @@ -265,7 +262,7 @@ void typeOfPacket(String packet, String packetType) { } void startOTAServer() { - if (stationMode==1 || stationMode==2) { + if (stationMode==1 || stationMode==2 || (stationMode==5 && WiFi.status() == WL_CONNECTED)) { server.on("/", HTTP_GET, [](AsyncWebServerRequest *request) { request->send(200, "text/plain", "Hi " + Config.callsign + ", \n\nthis is your (Richonguzman/CD2RXU) LoRa iGate , version " + versionDate + ".\n\nTo update your firmware or filesystem go to: http://" + getLocalIP().substring(getLocalIP().indexOf(":")+3) + "/update\n\n\n73!"); }); diff --git a/src/wifi_utils.cpp b/src/wifi_utils.cpp index 48acf64..f7f4d4b 100644 --- a/src/wifi_utils.cpp +++ b/src/wifi_utils.cpp @@ -24,42 +24,6 @@ void checkWiFi() { } void startWiFi() { - 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) { - delay(500); - digitalWrite(greenLed,HIGH); - Serial.print('.'); - delay(500); - digitalWrite(greenLed,LOW); - if ((millis() - start) > 15000){ - delay(1000); - if(myWiFiAPIndex >= (myWiFiAPSize-1)) { - myWiFiAPIndex = 0; - } 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()); - } - } - digitalWrite(greenLed,LOW); - Serial.print("Connected as "); - Serial.println(WiFi.localIP()); - show_display("", "", " Connected!!", "" , " loading ...", 1000); -} - -void startWiFi2() { int wifiCounter = 0; int status = WL_IDLE_STATUS; WiFi.mode(WIFI_STA); @@ -79,7 +43,9 @@ void startWiFi2() { delay(1000); if(myWiFiAPIndex >= (myWiFiAPSize-1)) { myWiFiAPIndex = 0; - wifiCounter++; + if (stationMode==5) { + wifiCounter++; + } } else { myWiFiAPIndex++; } @@ -91,14 +57,14 @@ void startWiFi2() { WiFi.begin(currentWiFi->ssid.c_str(), currentWiFi->password.c_str()); } } + digitalWrite(greenLed,LOW); if (WiFi.status() == WL_CONNECTED) { - digitalWrite(greenLed,LOW); - Serial.print("Connected as "); - Serial.println(WiFi.localIP()); - show_display("", "", " Connected!!", "" , " loading ...", 1000); - } else { - Serial.println("\nNot connected to WiFi! (DigiRepeater Mode)"); - show_display("", "", " WiFi Not Connected!", " DigiRepeater MODE" , " loading ...", 2000); + Serial.print("Connected as "); + Serial.println(WiFi.localIP()); + show_display("", "", " Connected!!", "" , " loading ...", 1000); + } else if (WiFi.status() != WL_CONNECTED && stationMode==5) { + Serial.println("\nNot connected to WiFi! (DigiRepeater Mode)"); + show_display("", "", " WiFi Not Connected!", " DigiRepeater MODE" , " loading ...", 2000); } }