From eed2745dfb5d752e874052e1425603d2c8502feb Mon Sep 17 00:00:00 2001 From: Khoi Hoang <57012152+khoih-prog@users.noreply.github.com> Date: Sat, 12 Feb 2022 14:18:20 -0500 Subject: [PATCH] Fix bug --- .../AsyncHTTPRequest_ESP_WiFiManager.ino | 38 ++++++++++++++++--- 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/examples/AsyncHTTPRequest_ESP_WiFiManager/AsyncHTTPRequest_ESP_WiFiManager.ino b/examples/AsyncHTTPRequest_ESP_WiFiManager/AsyncHTTPRequest_ESP_WiFiManager.ino index 12a0371..c88421c 100644 --- a/examples/AsyncHTTPRequest_ESP_WiFiManager/AsyncHTTPRequest_ESP_WiFiManager.ino +++ b/examples/AsyncHTTPRequest_ESP_WiFiManager/AsyncHTTPRequest_ESP_WiFiManager.ino @@ -253,6 +253,8 @@ bool initialConfig = false; IPAddress dns1IP = gatewayIP; IPAddress dns2IP = IPAddress(8, 8, 8, 8); +#define USE_CUSTOM_AP_IP false + IPAddress APStaticIP = IPAddress(192, 168, 100, 1); IPAddress APStaticGW = IPAddress(192, 168, 100, 1); IPAddress APStaticSN = IPAddress(255, 255, 255, 0); @@ -260,17 +262,17 @@ IPAddress APStaticSN = IPAddress(255, 255, 255, 0); #include //https://github.com/khoih-prog/ESPAsync_WiFiManager // To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error -#include //https://github.com/khoih-prog/ESPAsync_WiFiManager +//#include //https://github.com/khoih-prog/ESPAsync_WiFiManager #define HTTP_PORT 80 -AsyncWebServer webServer(HTTP_PORT); -DNSServer dnsServer; +//AsyncWebServer webServer(HTTP_PORT); +//DNSServer dnsServer; #include // https://github.com/khoih-prog/AsyncHTTPRequest_Generic // To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error -#include // https://github.com/khoih-prog/AsyncHTTPRequest_Generic +//#include // https://github.com/khoih-prog/AsyncHTTPRequest_Generic #include @@ -624,17 +626,28 @@ void setup() // Use this to default DHCP hostname to ESP8266-XXXXXX or ESP32-XXXXXX //ESPAsync_WiFiManager ESPAsync_wifiManager(&webServer, &dnsServer); // Use this to personalize DHCP hostname (RFC952 conformed) - ESPAsync_WiFiManager ESPAsync_wifiManager(&webServer, &dnsServer, "AutoConnectAP"); + AsyncWebServer webServer(HTTP_PORT); + + //ESPAsync_WiFiManager ESPAsync_wifiManager(&webServer, &dnsServer, "AutoConnectAP"); +#if ( USING_ESP32_S2 || USING_ESP32_C3 ) + ESPAsync_WiFiManager ESPAsync_wifiManager(&webServer, NULL, "AutoConnectAP"); +#else + DNSServer dnsServer; - ESPAsync_wifiManager.setDebugOutput(true); + ESPAsync_WiFiManager ESPAsync_wifiManager(&webServer, &dnsServer, "AutoConnectAP"); +#endif + + //ESPAsync_wifiManager.setDebugOutput(true); //reset settings - for testing //ESPAsync_wifiManager.resetSettings(); +#if USE_CUSTOM_AP_IP //set custom ip for portal // New in v1.4.0 ESPAsync_wifiManager.setAPStaticIPConfig(WM_AP_IPconfig); ////// +#endif ESPAsync_wifiManager.setMinimumSignalQuality(-1); @@ -689,6 +702,19 @@ void setup() initialConfig = true; + Serial.print(F("Starting configuration portal @ ")); + +#if USE_CUSTOM_AP_IP + Serial.print(APStaticIP); +#else + Serial.print(F("192.168.4.1")); +#endif + + Serial.print(F(", SSID = ")); + Serial.print(AP_SSID); + Serial.print(F(", PASS = ")); + Serial.println(AP_PASS); + // Starts an access point //if (!ESPAsync_wifiManager.startConfigPortal((const char *) ssid.c_str(), password)) if ( !ESPAsync_wifiManager.startConfigPortal(AP_SSID.c_str(), AP_PASS.c_str()) )