mirror of
https://github.com/alexhopeoconnor/WiFiManager.git
synced 2026-10-16 07:51:36 +10:00
fix: restart portal OTA after response completion
This commit is contained in:
@@ -1003,13 +1003,15 @@ void WiFiManagerHandlers::handleUpdateDone(AsyncWebServerRequest *request) {
|
||||
return;
|
||||
}
|
||||
|
||||
// AsyncWebServer queues this response and closes the connection only after
|
||||
// it has completed the response. Restarting from this request callback—or
|
||||
// merely waiting a guessed interval—can still tear down that TCP exchange.
|
||||
// Schedule through process() after this particular response disconnects.
|
||||
request->onDisconnect([this]() {
|
||||
_wm->_rebootScheduled = true;
|
||||
_wm->_rebootTime = millis() + _wm->REBOOT_DELAY_MS;
|
||||
});
|
||||
sendApiJson(request, 200, jsonApiOtaUpdateSuccess());
|
||||
// AsyncWebServer queues this response; restarting from the request callback
|
||||
// tears down its TCP connection before the client can receive the success
|
||||
// JSON. Let the application's regular process() call perform the same
|
||||
// delayed restart path used by the other restart-capable portal endpoints.
|
||||
_wm->_rebootScheduled = true;
|
||||
_wm->_rebootTime = millis() + _wm->REBOOT_DELAY_MS;
|
||||
}
|
||||
|
||||
void WiFiManagerHandlers::sendApiJson(AsyncWebServerRequest *request, int code, const String& json) {
|
||||
|
||||
Reference in New Issue
Block a user