Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make AutoAP run only once after a reboot #159

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/aprs_is_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ extern String sixthLine;
extern String seventhLine;
extern bool modemLoggedToAPRSIS;
extern bool backUpDigiMode;
extern bool WiFiAutoAPStarted;

uint32_t lastRxTime = millis();

Expand Down Expand Up @@ -72,10 +73,14 @@ namespace APRS_IS_Utils {
wifiState = "OK";
} else {
if (backUpDigiMode) {
wifiState = "--";
} else {
wifiState = "BK";
} else if (WiFiAutoAPStarted){
wifiState = "AP";
}
}
else {
wifiState = "--";
}

if (!Config.display.alwaysOn && Config.display.timeout != 0) {
displayToggle(true);
}
Expand Down
17 changes: 12 additions & 5 deletions src/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ extern int wxModuleType;
extern bool backUpDigiMode;
extern bool shouldSleepLowVoltage;
extern bool transmitFlag;
extern bool WiFiAutoAPStarted;

bool statusAfterBoot = true;
bool beaconUpdate = true;
Expand Down Expand Up @@ -69,11 +70,16 @@ namespace Utils {
}

String getLocalIP() {
if (!WiFiConnected) {
if (!WiFiConnected && WiFiAutoAPStarted) {
return "IP : 192.168.4.1";
} else if (backUpDigiMode) {
}
else if (backUpDigiMode) {
return "- BACKUP DIGI MODE -";
} else {
}
else if (!WiFiConnected) {
return "IP : -";
}
else {
return "IP : " + String(WiFi.localIP()[0]) + "." + String(WiFi.localIP()[1]) + "." + String(WiFi.localIP()[2]) + "." + String(WiFi.localIP()[3]);
}
}
Expand Down Expand Up @@ -112,8 +118,7 @@ namespace Utils {
if (!Config.display.alwaysOn && Config.display.timeout != 0) {
displayToggle(true);
}
Utils::println("-- Sending Beacon to APRSIS --");


STATION_Utils::deleteNotHeard();

activeStations();
Expand Down Expand Up @@ -172,6 +177,7 @@ namespace Utils {
}

if (Config.aprs_is.active && Config.beacon.sendViaAPRSIS && !backUpDigiMode) {
Utils::println("-- Sending Beacon to APRSIS --");
displayShow(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, "SENDING IGATE BEACON", 0);
seventhLine = " listening...";
#ifdef HAS_A7670
Expand All @@ -182,6 +188,7 @@ namespace Utils {
}

if (Config.beacon.sendViaRF || backUpDigiMode) {
Utils::println("-- Sending Beacon to RF --");
displayShow(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, "SENDING DIGI BEACON", 0);
seventhLine = " listening...";
STATION_Utils::addToOutputPacketBuffer(secondaryBeaconPacket);
Expand Down
24 changes: 16 additions & 8 deletions src/wifi_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ bool WiFiAutoAPStarted = false;
uint32_t previousWiFiMillis = 0;
uint8_t wifiCounter = 0;
uint32_t lastBackupDigiTime = millis();
bool WiFiAutoAPFirsttime = true;


namespace WIFI_Utils {
Expand Down Expand Up @@ -62,12 +63,15 @@ namespace WIFI_Utils {

WiFiAutoAPTime = millis();
WiFiAutoAPStarted = true;
WiFiAutoAPFirsttime = false;
}

void startWiFi() {
bool startAP = false;
if (currentWiFi->ssid == "") {
if (currentWiFi->ssid == "" && WiFiAutoAPFirsttime ) {
startAP = true;
} else if (currentWiFi->ssid == "" ) {
startAP = false;
} else {
uint8_t wifiCounter = 0;
WiFi.mode(WIFI_STA);
Expand Down Expand Up @@ -114,17 +118,21 @@ namespace WIFI_Utils {
Serial.print(" / MAC Address: ");
Serial.println(WiFi.macAddress());
displayShow("", " Connected!!", "" , " loading ...", 1000);
WiFiConnected = true;
} else if (WiFi.status() != WL_CONNECTED) {
startAP = true;

Serial.println("\nNot connected to WiFi! Starting Auto AP");

Serial.println("\nNot connected to WiFi!");
displayShow("", " WiFi Not Connected!", "" , " loading ...", 1000);
WiFi.disconnect();
WiFi.mode(WIFI_MODE_NULL);
WiFiConnected = false;
startAP = true;
}
WiFiConnected = !startAP;
if (startAP) {

if (startAP && WiFiAutoAPFirsttime && !backUpDigiMode) {
Serial.println("\nNot connected to WiFi! Starting Auto AP");
displayShow("", " Starting Auto AP", " Please connect to it " , " loading ...", 1000);

WiFiConnected = false;
startAutoAP();
}
}
Expand All @@ -141,7 +149,7 @@ namespace WIFI_Utils {

WiFiAutoAPStarted = false;
WiFi.softAPdisconnect(true);

WiFi.mode(WIFI_MODE_NULL);
Serial.println("Auto AP stopped (timeout)");
}
}
Expand Down