ESPHome 2026.11.0b6
Loading...
Searching...
No Matches
ota_web_server.h
Go to the documentation of this file.
1#pragma once
2
4#ifdef USE_WEBSERVER_OTA
5
9
10namespace esphome::web_server {
11
12class WebServerOTAComponent final : public AsyncWebHandler, public ota::OTAComponent {
13 public:
14 void setup() override;
15 void dump_config() override;
16 float get_setup_priority() const override { return setup_priority::AFTER_WIFI; }
17
18 void handleRequest(AsyncWebServerRequest *request) override;
19 void handleUpload(AsyncWebServerRequest *request, const PlatformString &filename, size_t index, uint8_t *data,
20 size_t len, bool final) override;
21 bool canHandle(AsyncWebServerRequest *request) const override;
22
23 // NOLINTNEXTLINE(readability-identifier-naming)
24 bool isRequestHandlerTrivial() const override { return false; }
25
26 protected:
27 void report_ota_progress_(AsyncWebServerRequest *request);
29 void ota_init_(const char *filename);
31 void abort_session_();
33 void refuse_(AsyncWebServerRequest *request);
34
37 bool ota_success_{false};
38
39 private:
40 ota::OTABackendPtr ota_backend_{nullptr};
42 const AsyncWebServerRequest *ota_request_{nullptr};
43 const AsyncWebServerRequest *refused_request_{nullptr};
44};
45
46} // namespace esphome::web_server
47
48#endif // USE_WEBSERVER_OTA
void handleRequest(AsyncWebServerRequest *request) override
void report_ota_progress_(AsyncWebServerRequest *request)
bool canHandle(AsyncWebServerRequest *request) const override
void refuse_(AsyncWebServerRequest *request)
Reply "busy" without touching the running upload.
void abort_session_()
Abort and drop the backend, releasing the lock.
void handleUpload(AsyncWebServerRequest *request, const PlatformString &filename, size_t index, uint8_t *data, size_t len, bool final) override
decltype(make_ota_backend()) OTABackendPtr
constexpr float AFTER_WIFI
For components that should be initialized after WiFi is connected.
Definition component.h:55
const void size_t len
Definition hal.h:68
static void uint32_t
std::string PlatformString