Skip to content

Commit

Permalink
testing Mode5 return1
Browse files Browse the repository at this point in the history
  • Loading branch information
richonguzman committed May 22, 2024
1 parent 0921d01 commit adf4c1f
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 48 deletions.
24 changes: 8 additions & 16 deletions src/LoRa_APRS_iGate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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() {
Expand Down Expand Up @@ -121,7 +114,6 @@ void setup() {
Config.loramodule.rxActive = false;
}
#endif

WIFI_Utils::setup();
SYSLOG_Utils::setup();
BME_Utils::setup();
Expand Down Expand Up @@ -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();
Expand All @@ -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
}

Expand Down
7 changes: 6 additions & 1 deletion src/aprs_is_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ extern String fifthLine;
extern String sixthLine;
extern String seventhLine;
extern bool modemLoggedToAPRSIS;
extern bool backUpDigiMode;

uint32_t lastRxTime = millis();

Expand Down Expand Up @@ -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);
}
Expand Down
3 changes: 2 additions & 1 deletion src/digi_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ extern String fourthLine;
extern String fifthLine;
extern String sixthLine;
extern String seventhLine;
extern bool backUpDigiMode;


namespace DIGI_Utils {
Expand Down Expand Up @@ -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);
Expand Down
7 changes: 5 additions & 2 deletions src/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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]);
}
Expand Down Expand Up @@ -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
Expand All @@ -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);
Expand Down
61 changes: 33 additions & 28 deletions src/wifi_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,50 +7,55 @@

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);
}
}

/*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;
if (backupDigiModeActive) {
wifiCounter++;
}
if (wifiCounter >= 2) {
Serial.println("*** Starting BackUp Digi Mode ***");
backUpDigiMode = true;
lastWiFiCheckBackupDigiMode = millis();
}
}
}*/

}

void startAutoAP() {
WiFi.mode(WIFI_MODE_NULL);
Expand Down

0 comments on commit adf4c1f

Please sign in to comment.