Add OTA support to ESP-IDF webserver (#9264)
This commit is contained in:
1 parent
e3ccb9b46c
commit
16ef5a9377
17 files changed
+788
-44
No files matched your search
@@ -110,13 +110,17 @@ class WebServerBase : public Component {
|
||||
|
||||
void add_handler(AsyncWebHandler *handler);
|
||||
|
||||
#ifdef USE_WEBSERVER_OTA
|
||||
void add_ota_handler();
|
||||
#endif
|
||||
|
||||
void set_port(uint16_t port) { port_ = port; }
|
||||
uint16_t get_port() const { return port_; }
|
||||
|
||||
protected:
|
||||
#ifdef USE_WEBSERVER_OTA
|
||||
friend class OTARequestHandler;
|
||||
#endif
|
||||
|
||||
int initialized_{0};
|
||||
uint16_t port_{80};
|
||||
@@ -125,6 +129,7 @@ class WebServerBase : public Component {
|
||||
internal::Credentials credentials_;
|
||||
};
|
||||
|
||||
#ifdef USE_WEBSERVER_OTA
|
||||
class OTARequestHandler : public AsyncWebHandler {
|
||||
public:
|
||||
OTARequestHandler(WebServerBase *parent) : parent_(parent) {}
|
||||
@@ -139,10 +144,21 @@ class OTARequestHandler : public AsyncWebHandler {
|
||||
bool isRequestHandlerTrivial() const override { return false; }
|
||||
|
||||
protected:
|
||||
void report_ota_progress_(AsyncWebServerRequest *request);
|
||||
void schedule_ota_reboot_();
|
||||
void ota_init_(const char *filename);
|
||||
|
||||
uint32_t last_ota_progress_{0};
|
||||
uint32_t ota_read_length_{0};
|
||||
WebServerBase *parent_;
|
||||
|
||||
private:
|
||||
#ifdef USE_ESP_IDF
|
||||
void *ota_backend_{nullptr};
|
||||
bool ota_success_{false};
|
||||
#endif
|
||||
};
|
||||
#endif // USE_WEBSERVER_OTA
|
||||
|
||||
} // namespace web_server_base
|
||||
} // namespace esphome
|
||||
|
||||
Reference in new issue
Block a user