Skip to content

Commit

Permalink
adds button func tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tablatronix committed Oct 10, 2023
1 parent 5a663db commit 99f770c
Showing 1 changed file with 24 additions and 15 deletions.
39 changes: 24 additions & 15 deletions examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ bool ALLOWONDEMAND = true; // enable on demand
int ONDDEMANDPIN = 0; // gpio for button
bool WMISBLOCKING = true; // use blocking or non blocking mode, non global params wont work in non blocking

uint8_t BUTTONFUNC = 1; // 0 resetsettings, 1 configportal, 2 autoconnect

// char ssid[] = "*************"; // your network SSID (name)
// char pass[] = "********"; // your network password

Expand Down Expand Up @@ -102,9 +104,9 @@ void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
delay(3000);
Serial.setDebugOutput(true);
// Serial.setDebugOutput(true);

WiFi.setTxPower(WIFI_POWER_8_5dBm);
// WiFi.setTxPower(WIFI_POWER_8_5dBm);

Serial.println("\n Starting");
// WiFi.setSleepMode(WIFI_NONE_SLEEP); // disable sleep, can improve ap stability
Expand Down Expand Up @@ -329,7 +331,7 @@ void wifiInfo(){
Serial.println("[WIFI] SAVED: " + (String)(wm.getWiFiIsSaved() ? "YES" : "NO"));
Serial.println("[WIFI] SSID: " + (String)wm.getWiFiSSID());
Serial.println("[WIFI] PASS: " + (String)wm.getWiFiPass());
Serial.println("[WIFI] HOSTNAME: " + (String)WiFi.getHostname());
// Serial.println("[WIFI] HOSTNAME: " + (String)WiFi.getHostname());
}

void loop() {
Expand All @@ -348,21 +350,28 @@ void loop() {
Serial.println("BUTTON PRESSED");

// button reset/reboot
// wm.resetSettings();
// wm.reboot();
// delay(200);
// return;
if(BUTTONFUNC == 0){
wm.resetSettings();
wm.reboot();
delay(200);
return;
}

wm.setConfigPortalTimeout(140);
wm.setParamsPage(false); // move params to seperate page, not wifi, do not combine with setmenu!
// start configportal
if(BUTTONFUNC == 1)
if (!wm.startConfigPortal("OnDemandAP","12345678")) {
Serial.println("failed to connect and hit timeout");
delay(3000);
}
}

// disable captive portal redirection
// wm.setCaptivePortalEnable(false);

if (!wm.startConfigPortal("OnDemandAP","12345678")) {
Serial.println("failed to connect and hit timeout");
delay(3000);
//test autoconnect as reconnect etc.
if(BUTTONFUNC == 2){
wm.setConfigPortalTimeout(20);
wm.autoConnect();
return;
}

}
else {
//if you get here you have connected to the WiFi
Expand Down

0 comments on commit 99f770c

Please sign in to comment.