Autoconnect use with async webserver #459
Unanswered
xygax
asked this question in
How can I?
Replies: 1 comment
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
i use a Soft AP as the preferred first connection that times out after a minute (this is via wifi only) and all other connections are via ethernet unless the Wifi password and SSID are changed from default (then its wifi)
Currently i serve a web page from SPIFFS as the credentials entry point for several things and i'm having trouble replacing the async webserver with Autoconnect. Is it possible to get the auto connect working with async webserver (esp32)
Code below Auto connect commented out as is
//WebServer Server;
//AutoConnect Portal;
Setup_Wifi(); // Start Wifi as STA or AP with credentials from EE
AP_Connect:
byte count1 = 0;
while (!client_connected && count1 < 16) { // wait for connection 60 sec
delay(3750);
Serial.print(".");
lcd.print(".");
count1 ++;
//Portal.handleClient();
}
void Setup_Wifi(){
//---------------big snip AP / sta choice and setup------------------------
//----------------- set up creds access point------------------------ MODE3
Serial.println(" ");
Serial.println("Setting up config AP (Access Point)…");
WiFi.softAP(def_ssid, def_password);
IPAddress IP = WiFi.softAPIP();
Serial.print ("WiFi :- "); // if access point
Serial.print(def_ssid);
Serial.println("\t ( Mode 3 )");
Serial.print ("AP IP :- ");
Serial.println(IP);
lcd.setCursor(0, 1);
lcd.print ("AP: ");
lcd.print(IP);
//------------------the async handler for Config.html-----------------------------------------------------
// send setup web page with input fields to client
server.on("/", HTTP_GET, [](AsyncWebServerRequest * request) {
request->send(SPIFFS, "/Config.html");
});
//-----------------------------------------------------------------------
server.on("/identVer", HTTP_GET, [](AsyncWebServerRequest * request) {
String payload = String(Version);
request->send_P(200, "text/plain", payload.c_str());
});
// big snip of server.on http get statements
});
server.onNotFound(notFound);
server.begin();
//Portal.begin();
Serial.println("Webserver started: "+ WiFi.localIP().toString());
}
Beta Was this translation helpful? Give feedback.
All reactions