Replies: 2 comments
|
Hi, |
0 replies
|
Wow, what a swift answer! Thanks! |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Hi,
I have a code to check periodically if we are connected on wifi and to try to reconnect in case of disconnection:
if (WiFi.status() != WL_CONNECTED) { SerialAndTelnetPrintln("Trying to (re)connect to WiFi."); WiFi.setHostname(Hostname.data()); // https://github.com/espressif/arduino-esp32/issues/6700 WiFi.mode(WIFI_MODE_NULL); WiFi.mode(WIFI_MODE_STA); wifiMulti.run(Clock.Params.WiFiConnectTimeout * 1000); }Once WiFi.status() == WL_CONNECTED, I start a server with
Clock.ws.onEvent(onAsyncEvent); Clock.server->addHandler(&Clock.ws); Clock.server->on("/", HTTP_GET, [](AsyncWebServerRequest *request) { SerialAndTelnetPrintln("HTTP_GET request."); request->send(LittleFS, "/index.html", "text/html", false, TemplateProcessorCallback); }); Clock.server->on("/", HTTP_POST, [](AsyncWebServerRequest *request) { HTTP_POST_request_handler(request); }); // Start server Clock.server->begin();The question is : Should I call again server->begin(); after a wifi disconnection/reconnection? Should I re-run the full server configuration sequence I've posted above?
Anyway...is it a decent way to handle disconnection/automatic reconnection?
All reactions