mirror of
https://github.com/alexhopeoconnor/WiFiManager.git
synced 2026-10-13 23:01:20 +10:00
dev example country and bounce
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
/**
|
||||
* This is a kind of unit test for DEV for now
|
||||
* It contains many of the public methods
|
||||
*
|
||||
*/
|
||||
#include <WiFiManager.h> // https://github.com/tzapu/WiFiManager
|
||||
#include <time.h>
|
||||
@@ -167,14 +169,13 @@ void setup() {
|
||||
// wm.setAPStaticIPConfig(IPAddress(10,0,1,1), IPAddress(10,0,1,1), IPAddress(255,255,255,0));
|
||||
// wm.setAPStaticIPConfig(IPAddress(10,0,1,99), IPAddress(10,0,1,1), IPAddress(255,255,255,0));
|
||||
|
||||
// WiFi.mode(WIFI_STA);
|
||||
// const wifi_country_t COUNTRY_US{"US",1,11,WIFI_COUNTRY_POLICY_AUTO};
|
||||
// const wifi_country_t COUNTRY_CN{"CN",1,13,WIFI_COUNTRY_POLICY_AUTO};
|
||||
// const wifi_country_t COUNTRY_JP{"JP",1,14,WIFI_COUNTRY_POLICY_AUTO};
|
||||
// esp_wifi_set_country(&COUNTRY_US);
|
||||
|
||||
// wm.setCountry("US");
|
||||
// set country
|
||||
wm.setCountry("US"); // setting wifi country seems to improve OSX soft ap connectivity, may help others as well
|
||||
|
||||
// set channel
|
||||
wm.setWiFiAPChannel(13);
|
||||
|
||||
// set configrportal timeout
|
||||
wm.setConfigPortalTimeout(120);
|
||||
// wm.startConfigPortal("AutoConnectAP", "password");
|
||||
|
||||
@@ -189,6 +190,8 @@ void setup() {
|
||||
print_oled("Not Connected",2);
|
||||
}
|
||||
else if(TEST_CP) {
|
||||
delay(1000);
|
||||
Serial.println("TEST_CP ENABLED");
|
||||
// start configportal always
|
||||
wm.setConfigPortalTimeout(60);
|
||||
wm.startConfigPortal();
|
||||
@@ -204,17 +207,20 @@ void setup() {
|
||||
void loop() {
|
||||
// is configuration portal requested?
|
||||
if ( digitalRead(TRIGGER_PIN) == LOW ) {
|
||||
Serial.println("BUTTON PRESSED");
|
||||
wm.setConfigPortalTimeout(140);
|
||||
wm.setWiFiAPChannel(13);
|
||||
delay(100);
|
||||
if ( digitalRead(TRIGGER_PIN) == LOW ){
|
||||
Serial.println("BUTTON PRESSED");
|
||||
wm.setConfigPortalTimeout(140);
|
||||
|
||||
// disable captive portal redirection
|
||||
// wm.setCaptivePortalEnable(false);
|
||||
|
||||
if (!wm.startConfigPortal("OnDemandAP","12345678")) {
|
||||
Serial.println("failed to connect and hit timeout");
|
||||
delay(3000);
|
||||
} else {
|
||||
// disable captive portal redirection
|
||||
// wm.setCaptivePortalEnable(false);
|
||||
|
||||
if (!wm.startConfigPortal("OnDemandAP","12345678")) {
|
||||
Serial.println("failed to connect and hit timeout");
|
||||
delay(3000);
|
||||
}
|
||||
}
|
||||
else {
|
||||
//if you get here you have connected to the WiFi
|
||||
Serial.println("connected...yeey :)");
|
||||
print_oled("Connected\nIP: " + WiFi.localIP().toString() + "\nSSID: " + WiFi.SSID(),1);
|
||||
|
||||
Reference in New Issue
Block a user