fix: start ota is now consistent across command sources

Dieser Commit ist enthalten in:
Jared Dohrman
2026-04-23 09:27:48 +10:00
Ursprung 9085265637
Commit 4b83142b9e
6 geänderte Dateien mit 23 neuen und 8 gelöschten Zeilen
+1 -1
Datei anzeigen
@@ -123,7 +123,7 @@ Notes:
- the panel still uses the repeater admin password for access - the panel still uses the repeater admin password for access
- commands run with the same care as if you typed them into the repeater CLI directly - commands run with the same care as if you typed them into the repeater CLI directly
- this is intended for local admin use on a trusted network - this is intended for local admin use on a trusted network
- `start ota` releases the local HTTP redirect listener on port `80` so the OTA HTTP listener can take over without stopping the rest of the repeater services - `start ota` releases the local HTTP redirect listener on port `80` so the OTA HTTP listener can take over without stopping the rest of the repeater services, regardless of whether the command is run from the web panel, serial CLI, or a remote companion/app CLI session
## Companion WiFi Rescue Commands ## Companion WiFi Rescue Commands
+3
Datei anzeigen
@@ -2056,6 +2056,9 @@ void MyMesh::clearStats() {
} }
void MyMesh::prepareForOTAStart() { void MyMesh::prepareForOTAStart() {
#if defined(ESP_PLATFORM) && WITH_WEB_PANEL
web.prepareForOTAStart();
#endif
} }
void MyMesh::handleCommand(uint32_t sender_timestamp, char *command, char *reply) { void MyMesh::handleCommand(uint32_t sender_timestamp, char *command, char *reply) {
+3 -5
Datei anzeigen
@@ -2816,11 +2816,6 @@ esp_err_t WebPanelServer::handleCommand(httpd_req_t* req) {
ctx->self->noteActivity(); ctx->self->noteActivity();
memset(reply, 0, kWebReplyBufferSize); memset(reply, 0, kWebReplyBufferSize);
if (strcmp(command, "start ota") == 0) {
// OTA serves its own HTTP listener on port 80, so release the
// web-panel redirect listener first or it will keep owning that port.
ctx->self->stopRedirectServer();
}
ctx->self->_runner->runWebCommand(command, reply, kWebReplyBufferSize); ctx->self->_runner->runWebCommand(command, reply, kWebReplyBufferSize);
httpd_resp_set_type(req, "text/plain; charset=utf-8"); httpd_resp_set_type(req, "text/plain; charset=utf-8");
httpd_resp_set_hdr(req, "Cache-Control", "no-store"); httpd_resp_set_hdr(req, "Cache-Control", "no-store");
@@ -2937,6 +2932,9 @@ bool WebPanelServer::start() {
void WebPanelServer::stop() { void WebPanelServer::stop() {
} }
void WebPanelServer::stopRedirectServer() {
}
bool WebPanelServer::isRunning() const { bool WebPanelServer::isRunning() const {
return false; return false;
} }
+1 -1
Datei anzeigen
@@ -41,6 +41,7 @@ public:
void setCommandRunner(WebPanelCommandRunner* runner); void setCommandRunner(WebPanelCommandRunner* runner);
bool start(); bool start();
void stop(); void stop();
void stopRedirectServer();
bool isRunning() const; bool isRunning() const;
bool hasSessionToken() const; bool hasSessionToken() const;
bool shouldAutoLock(unsigned long now_ms) const; bool shouldAutoLock(unsigned long now_ms) const;
@@ -71,7 +72,6 @@ private:
void refreshToken(); void refreshToken();
bool isAuthorized(httpd_req_t* req) const; bool isAuthorized(httpd_req_t* req) const;
void noteActivity(); void noteActivity();
void stopRedirectServer();
#else #else
WebPanelCommandRunner* _runner; WebPanelCommandRunner* _runner;
#endif #endif
+14 -1
Datei anzeigen
@@ -26,6 +26,13 @@ void WebService::suspendForOTA() {
#endif #endif
} }
void WebService::prepareForOTAStart() {
#if defined(ESP_PLATFORM) && WITH_WEB_PANEL
_suspended_for_ota = true;
_panel.stopRedirectServer();
#endif
}
void WebService::loop() { void WebService::loop() {
#if defined(ESP_PLATFORM) && WITH_WEB_PANEL #if defined(ESP_PLATFORM) && WITH_WEB_PANEL
ensureWebServer(); ensureWebServer();
@@ -91,10 +98,16 @@ void WebService::formatWebStatusReply(char* reply, size_t reply_size) const {
#if defined(ESP_PLATFORM) && WITH_WEB_PANEL #if defined(ESP_PLATFORM) && WITH_WEB_PANEL
void WebService::ensureWebServer() { void WebService::ensureWebServer() {
if (_suspended_for_ota || _runner == nullptr || _prefs.web_enabled == 0 || _network == nullptr || !_network->isWifiConnected()) { if (_runner == nullptr || _prefs.web_enabled == 0 || _network == nullptr || !_network->isWifiConnected()) {
_panel.stop(); _panel.stop();
return; return;
} }
if (_suspended_for_ota) {
if (_panel.isRunning()) {
_panel.stopRedirectServer();
}
return;
}
if (_panel.isRunning()) { if (_panel.isRunning()) {
return; return;
} }
+1
Datei anzeigen
@@ -15,6 +15,7 @@ public:
void end(); void end();
void loop(); void loop();
void suspendForOTA(); void suspendForOTA();
void prepareForOTAStart();
void setCommandRunner(WebPanelCommandRunner* runner); void setCommandRunner(WebPanelCommandRunner* runner);
void setNetworkStateProvider(NetworkStateProvider* network) { _network = network; } void setNetworkStateProvider(NetworkStateProvider* network) { _network = network; }