diff --git a/data/igate_conf.json b/data/igate_conf.json index 11fcb0d..e435601 100644 --- a/data/igate_conf.json +++ b/data/igate_conf.json @@ -5,9 +5,9 @@ "wifi": { "AP": [ { "ssid": "Richon", - "password": "k4fPnmg5qnyf", - "latitude": -33.0337313, - "longitude": -71.5737261 + "password": "k4fPnmg5qny", + "latitude": -32.9543284, + "longitude": -71.1202063 }, { "ssid": "iPhone Richon", "password": "1234poto5678", @@ -22,7 +22,7 @@ "longitude": -71.1202063 }, "aprs_is": { - "passcode": "23202", + "passcode": "23201", "server": "euro.aprs2.net", "port": 14580, "reportingDistance": 30 diff --git a/src/LoRa_APRS_iGate.cpp b/src/LoRa_APRS_iGate.cpp index d383779..e52f140 100644 --- a/src/LoRa_APRS_iGate.cpp +++ b/src/LoRa_APRS_iGate.cpp @@ -82,16 +82,7 @@ void loop() { 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*4*1000) { - WiFiConnect = true; - } - if (WiFiConnect) { - Serial.println("\n\n###############\nRevision WiFi\n###############"); - WIFI_Utils::startWiFi2(); - lastWiFiCheck = millis(); - WiFiConnect = false; - } + Utils::checkWiFiInterval(); if (WiFi.status() == WL_CONNECTED) { // Modo iGate thirdLine = Utils::getLocalIP(); if (!espClient.connected()) { @@ -117,6 +108,9 @@ void loop() { if (lastStationModeState == 0) { iGateBeaconPacket = GPS_Utils::generateBeacon(); lastStationModeState = 1; + 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)); thirdLine = "<< DigiRepeater >>"; } Utils::checkDisplayInterval(); diff --git a/src/utils.cpp b/src/utils.cpp index 3fc9e6e..ab34652 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -41,6 +41,8 @@ extern float snr; extern int freqError; extern String distance; extern String versionDate; +extern uint32_t lastWiFiCheck; +extern bool WiFiConnect; namespace Utils { @@ -147,13 +149,13 @@ void checkBeaconInterval() { LoRa_Utils::changeFreqRx(); } } else if (stationMode==5) { + if (!Config.bme.active) { + fifthLine = ""; + } + sixthLine = ""; if (WiFi.status() == WL_CONNECTED && espClient.connected()) { APRS_IS_Utils::checkStatus(); thirdLine = getLocalIP(); - if (!Config.bme.active) { - fifthLine = ""; - } - sixthLine = ""; show_display(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, "SENDING iGate BEACON", 1000); if (Config.sendBatteryVoltage) { sixthLine = " (Batt=" + String(BATTERY_Utils::checkVoltages(),2) + "V)"; @@ -162,12 +164,6 @@ void checkBeaconInterval() { espClient.write((beaconPacket + "\n").c_str()); show_display(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, seventhLine, 0); } else { - 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)); - thirdLine = "<< DigiRepeater >>"; - 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)"; @@ -194,6 +190,19 @@ void checkDisplayInterval() { } } +void checkWiFiInterval() { + uint32_t WiFiCheck = millis() - lastWiFiCheck; + if (WiFi.status() != WL_CONNECTED && WiFiCheck >= Config.lastWiFiCheck*4*1000) { //60!!! + WiFiConnect = true; + } + if (WiFiConnect) { + Serial.println("\nConnecting to WiFi ..."); + WIFI_Utils::startWiFi2(); + lastWiFiCheck = millis(); + WiFiConnect = false; + } +} + void validateDigiFreqs() { if (stationMode == 4) { if (abs(Config.loramodule.digirepeaterTxFreq - Config.loramodule.digirepeaterRxFreq) < 125000) { @@ -206,7 +215,7 @@ void validateDigiFreqs() { void typeOfPacket(String packet, String packetType) { String sender; - if (stationMode==1 || stationMode==2) { + if (stationMode==1 || stationMode==2 || (stationMode==5 && WiFi.status() == WL_CONNECTED)) { if (packetType == "LoRa-APRS") { fifthLine = "LoRa Rx ----> APRS-IS"; } else if (packetType == "APRS-LoRa") { diff --git a/src/utils.h b/src/utils.h index 9b38c75..d37e405 100644 --- a/src/utils.h +++ b/src/utils.h @@ -11,6 +11,7 @@ void setupDisplay(); void activeStations(); void checkBeaconInterval(); void checkDisplayInterval(); +void checkWiFiInterval(); void validateDigiFreqs(); void typeOfPacket(String packet, String packetType); void startOTAServer(); diff --git a/src/wifi_utils.cpp b/src/wifi_utils.cpp index a1423c8..48acf64 100644 --- a/src/wifi_utils.cpp +++ b/src/wifi_utils.cpp @@ -97,7 +97,7 @@ void startWiFi2() { Serial.println(WiFi.localIP()); show_display("", "", " Connected!!", "" , " loading ...", 1000); } else { - Serial.println("\nNot connected to WiFi! (starting DigiRepeater Mode)"); + Serial.println("\nNot connected to WiFi! (DigiRepeater Mode)"); show_display("", "", " WiFi Not Connected!", " DigiRepeater MODE" , " loading ...", 2000); } }