mirror of
https://github.com/esphome/esphome.git
synced 2025-08-07 02:47:47 +00:00
tweak
This commit is contained in:
parent
727161f1db
commit
9f1fae0955
@ -63,6 +63,7 @@ void WebServerBase::add_handler(AsyncWebHandler *handler) {
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef USE_WEBSERVER_OTA
|
||||
void report_ota_error() {
|
||||
#ifdef USE_ARDUINO
|
||||
StreamString ss;
|
||||
@ -70,10 +71,8 @@ void report_ota_error() {
|
||||
ESP_LOGW(TAG, "OTA Update failed! Error: %s", ss.c_str());
|
||||
#endif
|
||||
}
|
||||
|
||||
void OTARequestHandler::handleUpload(AsyncWebServerRequest *request, const String &filename, size_t index,
|
||||
uint8_t *data, size_t len, bool final) {
|
||||
#ifdef USE_WEBSERVER_OTA
|
||||
#ifdef USE_ARDUINO
|
||||
bool success;
|
||||
if (index == 0) {
|
||||
@ -160,10 +159,9 @@ void OTARequestHandler::handleUpload(AsyncWebServerRequest *request, const Strin
|
||||
this->ota_backend_ = nullptr;
|
||||
}
|
||||
#endif // USE_ESP_IDF
|
||||
#endif // USE_WEBSERVER_OTA
|
||||
}
|
||||
|
||||
void OTARequestHandler::handleRequest(AsyncWebServerRequest *request) {
|
||||
#ifdef USE_WEBSERVER_OTA
|
||||
ESP_LOGV(TAG, "OTA handleRequest called");
|
||||
AsyncWebServerResponse *response;
|
||||
#ifdef USE_ARDUINO
|
||||
@ -183,8 +181,8 @@ void OTARequestHandler::handleRequest(AsyncWebServerRequest *request) {
|
||||
#endif // USE_ESP_IDF
|
||||
response->addHeader("Connection", "close");
|
||||
request->send(response);
|
||||
#endif // USE_WEBSERVER_OTA
|
||||
}
|
||||
#endif // USE_WEBSERVER_OTA
|
||||
|
||||
#ifdef USE_WEBSERVER_OTA
|
||||
void WebServerBase::add_ota_handler() {
|
||||
|
@ -118,7 +118,9 @@ class WebServerBase : public Component {
|
||||
uint16_t get_port() const { return port_; }
|
||||
|
||||
protected:
|
||||
#ifdef USE_WEBSERVER_OTA
|
||||
friend class OTARequestHandler;
|
||||
#endif
|
||||
|
||||
int initialized_{0};
|
||||
uint16_t port_{80};
|
||||
@ -127,6 +129,7 @@ class WebServerBase : public Component {
|
||||
internal::Credentials credentials_;
|
||||
};
|
||||
|
||||
#ifdef USE_WEBSERVER_OTA
|
||||
class OTARequestHandler : public AsyncWebHandler {
|
||||
public:
|
||||
OTARequestHandler(WebServerBase *parent) : parent_(parent) {}
|
||||
@ -141,22 +144,21 @@ class OTARequestHandler : public AsyncWebHandler {
|
||||
bool isRequestHandlerTrivial() const override { return false; }
|
||||
|
||||
protected:
|
||||
#ifdef USE_WEBSERVER_OTA
|
||||
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};
|
||||
#endif
|
||||
WebServerBase *parent_;
|
||||
|
||||
private:
|
||||
#if defined(USE_ESP_IDF) && defined(USE_WEBSERVER_OTA)
|
||||
#ifdef USE_ESP_IDF
|
||||
void *ota_backend_{nullptr};
|
||||
bool ota_success_{false};
|
||||
#endif
|
||||
};
|
||||
#endif // USE_WEBSERVER_OTA
|
||||
|
||||
} // namespace web_server_base
|
||||
} // namespace esphome
|
||||
|
Loading…
x
Reference in New Issue
Block a user