testing Mode5 return1

This commit is contained in:
richonguzman 2024-05-22 15:29:00 -04:00
parent 0921d01340
commit adf4c1fcb8
5 changed files with 54 additions and 48 deletions

View file

@ -37,10 +37,14 @@ ________________________________________________________________________________
#include "A7670_utils.h"
#endif
String versionDate = "2024.05.20";
String versionDate = "2024.05.22";
Configuration Config;
WiFiClient espClient;
uint8_t myWiFiAPIndex = 0;
int myWiFiAPSize = Config.wifiAPs.size();
WiFi_AP *currentWiFi = &Config.wifiAPs[myWiFiAPIndex];
bool isUpdatingOTA = false;
uint32_t lastScreenOn = millis();
@ -49,22 +53,11 @@ String batteryVoltage;
std::vector<ReceivedPacket> receivedPackets;
bool backUpDigiMode = false;
bool modemLoggedToAPRSIS = false;
String firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, seventhLine;
/*uint8_t myWiFiAPIndex = 0;
int myWiFiAPSize = Config.wifiAPs.size();
WiFi_AP *currentWiFi = &Config.wifiAPs[myWiFiAPIndex];*/
//uint32_t previousWiFiMillis = 0;
//uint32_t lastWiFiCheck = 0;
//bool WiFiConnect = true;
//bool WiFiConnected = false;
//bool WiFiAutoAPStarted = false;
//long WiFiAutoAPTime = false;
//#define STARTUP_DELAY 5 //min
void setup() {
@ -121,7 +114,6 @@ void setup() {
Config.loramodule.rxActive = false;
}
#endif
WIFI_Utils::setup();
SYSLOG_Utils::setup();
BME_Utils::setup();
@ -152,7 +144,7 @@ void loop() {
#ifdef ESP32_DIY_LoRa_A7670
if (Config.aprs_is.active && !modemLoggedToAPRSIS) A7670_Utils::APRS_IS_connect();
#else
if (Config.aprs_is.active && !espClient.connected()) APRS_IS_Utils::connect();
if (Config.aprs_is.active && (WiFi.status() == WL_CONNECTED) && !espClient.connected()) APRS_IS_Utils::connect();
#endif
TNC_Utils::loop();
@ -172,7 +164,7 @@ void loop() {
APRS_IS_Utils::processLoRaPacket(packet); // Send received packet to APRSIS
}
if (Config.digi.mode == 2) { // If Digi enabled
if (Config.digi.mode == 2 || backUpDigiMode) { // If Digi enabled
DIGI_Utils::processLoRaPacket(packet); // Send received packet to Digi
}

View file

@ -20,6 +20,7 @@ extern String fifthLine;
extern String sixthLine;
extern String seventhLine;
extern bool modemLoggedToAPRSIS;
extern bool backUpDigiMode;
uint32_t lastRxTime = millis();
@ -67,7 +68,11 @@ namespace APRS_IS_Utils {
if (WiFi.status() == WL_CONNECTED) {
wifiState = "OK";
} else {
wifiState = "AP";
if (backUpDigiMode) {
wifiState = "DI";
} else {
wifiState = "AP";
}
if (!Config.display.alwaysOn && Config.display.timeout != 0) {
display_toggle(true);
}

View file

@ -19,6 +19,7 @@ extern String fourthLine;
extern String fifthLine;
extern String sixthLine;
extern String seventhLine;
extern bool backUpDigiMode;
namespace DIGI_Utils {
@ -71,7 +72,7 @@ namespace DIGI_Utils {
if (packet.indexOf("::") > 10 && Addressee == Config.callsign) { // its a message for me!
queryMessage = APRS_IS_Utils::processReceivedLoRaMessage(Sender, AddresseeAndMessage);
}
if (!queryMessage && packet.indexOf("WIDE1-") > 10 && Config.digi.mode == 2) { // If should repeat packet (WIDE1 Digi)
if (!queryMessage && packet.indexOf("WIDE1-") > 10 && (Config.digi.mode == 2 || backUpDigiMode)) { // If should repeat packet (WIDE1 Digi)
loraPacket = generateDigiRepeatedPacket(packet.substring(3));
if (loraPacket != "") {
STATION_Utils::addToOutputPacketBuffer(loraPacket);

View file

@ -34,6 +34,7 @@ extern uint32_t lastWiFiCheck;
extern bool WiFiConnect;
extern bool WiFiConnected;
extern int wxModuleType;
extern bool backUpDigiMode;
bool statusAfterBoot = true;
bool beaconUpdate = true;
@ -63,6 +64,8 @@ namespace Utils {
String getLocalIP() {
if (!WiFiConnected) {
return "IP : 192.168.4.1";
} else if (backUpDigiMode) {
return "- BackUp Digi Mode -";
} else {
return "IP : " + String(WiFi.localIP()[0]) + "." + String(WiFi.localIP()[1]) + "." + String(WiFi.localIP()[2]) + "." + String(WiFi.localIP()[3]);
}
@ -136,7 +139,7 @@ namespace Utils {
sixthLine = " (Ext V=" + externalVoltage;
}
if (Config.aprs_is.active && Config.beacon.sendViaAPRSIS) {
if (Config.aprs_is.active && Config.beacon.sendViaAPRSIS && !backUpDigiMode) {
show_display(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, "SENDING IGATE BEACON", 0);
seventhLine = " listening...";
#ifdef ESP32_DIY_LoRa_A7670
@ -146,7 +149,7 @@ namespace Utils {
#endif
}
if (Config.beacon.sendViaRF) {
if (Config.beacon.sendViaRF || backUpDigiMode) {
show_display(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, "SENDING DIGI BEACON", 0);
seventhLine = " listening...";
STATION_Utils::addToOutputPacketBuffer(secondaryBeaconPacket);

View file

@ -7,51 +7,56 @@
extern Configuration Config;
//extern WiFi_AP *currentWiFi;
//extern uint8_t myWiFiAPIndex;
//extern int myWiFiAPSize;
//extern uint32_t previousWiFiMillis;
extern uint8_t myWiFiAPIndex;
extern int myWiFiAPSize;
extern WiFi_AP *currentWiFi;
uint8_t myWiFiAPIndex = 0;
int myWiFiAPSize = Config.wifiAPs.size();
WiFi_AP *currentWiFi = &Config.wifiAPs[myWiFiAPIndex];
uint8_t wifiCounter = 0;
bool WiFiConnected = false;
uint32_t WiFiAutoAPTime = millis();
bool WiFiAutoAPStarted = false;
uint32_t previousWiFiMillis = 0;
//
uint8_t wifiCounter = 0;
bool backupDigiModeActive = true;
extern bool backUpDigiMode;
uint32_t lastWiFiCheckBackupDigiMode = millis();
//
namespace WIFI_Utils {
void checkWiFi() {
if ((WiFi.status() != WL_CONNECTED) && ((millis() - previousWiFiMillis) >= 30 * 1000) && !WiFiAutoAPStarted) {
if (backUpDigiMode) {
uint32_t WiFiCheck = millis() - lastWiFiCheckBackupDigiMode;
if (WiFi.status() != WL_CONNECTED && WiFiCheck >= 15 * 60 * 1000) {
Serial.println("*** Stoping BackUp Digi Mode ***");
backUpDigiMode = false;
wifiCounter = 0;
} else if (WiFi.status() == WL_CONNECTED) {
Serial.println("*** WiFi Reconnect Success (Stoping Backup Digi Mode) ***");
backUpDigiMode = false;
wifiCounter = 0;
}
}
if (!backUpDigiMode && (WiFi.status() != WL_CONNECTED) && ((millis() - previousWiFiMillis) >= 30 * 1000) && !WiFiAutoAPStarted) {
Serial.print(millis());
Serial.println("Reconnecting to WiFi...");
WiFi.disconnect();
WiFi.reconnect();
previousWiFiMillis = millis();
wifiCounter++;
} else if (WiFi.status() == WL_CONNECTED) {
wifiCounter = 0;
Serial.println(wifiCounter);
if (backupDigiModeActive) {
wifiCounter++;
}
if (wifiCounter >= 2) {
Serial.println("*** Starting BackUp Digi Mode ***");
backUpDigiMode = true;
lastWiFiCheckBackupDigiMode = millis();
}
}
}
/*void checkWiFiInterval() {
uint32_t WiFiCheck = millis() - lastWiFiCheck;
if (WiFi.status() != WL_CONNECTED && WiFiCheck >= 15 * 60 * 1000) {
WiFiConnect = true;
}
if (WiFiConnect) {
Serial.println("\nConnecting to WiFi ...");
WIFI_Utils::startWiFi();
lastWiFiCheck = millis();
WiFiConnect = false;
}
}*/
void startAutoAP() {
WiFi.mode(WIFI_MODE_NULL);