From 3771a79a55e3255db12d2e9dfdc4a4c8f244a493 Mon Sep 17 00:00:00 2001 From: tablatronix Date: Fri, 13 Sep 2019 11:28:05 -0500 Subject: [PATCH] dev example country and bounce --- .../OnDemandConfigPortal.ino | 40 +++++++++++-------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/examples/DEV/OnDemandConfigPortal/OnDemandConfigPortal.ino b/examples/DEV/OnDemandConfigPortal/OnDemandConfigPortal.ino index 7c6c959..3044d8a 100644 --- a/examples/DEV/OnDemandConfigPortal/OnDemandConfigPortal.ino +++ b/examples/DEV/OnDemandConfigPortal/OnDemandConfigPortal.ino @@ -1,5 +1,7 @@ /** * This is a kind of unit test for DEV for now + * It contains many of the public methods + * */ #include // https://github.com/tzapu/WiFiManager #include @@ -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);