ESPHome 2026.6.0-dev
Loading...
Searching...
No Matches
ota_http_request.h
Go to the documentation of this file.
1#pragma once
2
7
8#include <memory>
9#include <string>
10#include <utility>
11
12#include "../http_request.h"
13
14namespace esphome::http_request {
15
16static const uint8_t MD5_SIZE = 32;
17
23
24class OtaHttpRequestComponent final : public ota::OTAComponent, public Parented<HttpRequestComponent> {
25 public:
26 void dump_config() override;
27 float get_setup_priority() const override { return setup_priority::AFTER_WIFI; }
28
29 void set_md5_url(const std::string &md5_url);
30 void set_md5(const std::string &md5) { this->md5_expected_ = md5; }
31 void set_password(const std::string &password);
32 void set_url(const std::string &url);
33 void set_username(const std::string &username);
34
35 std::string md5_computed() { return this->md5_computed_; }
36 std::string md5_expected() { return this->md5_expected_; }
37
38 void flash();
39
40 protected:
41 void cleanup_(ota::OTABackendPtr backend, const std::shared_ptr<HttpContainer> &container);
42 uint8_t do_ota_();
43 std::string get_url_with_auth_(const std::string &url);
44 bool http_get_md5_();
45 bool validate_url_(const std::string &url);
46
47 std::string md5_computed_{};
48 std::string md5_expected_{};
49 std::string md5_url_{};
50 std::string password_{};
51 std::string username_{};
52 std::string url_{};
53 int status_ = -1;
54 bool update_started_ = false;
55 static const uint16_t HTTP_RECV_BUFFER = 256; // the firmware GET chunk size
56};
57
58} // namespace esphome::http_request
Helper class to easily give an object a parent of type T.
Definition helpers.h:1861
void set_password(const std::string &password)
void cleanup_(ota::OTABackendPtr backend, const std::shared_ptr< HttpContainer > &container)
void set_username(const std::string &username)
std::string get_url_with_auth_(const std::string &url)
void set_md5_url(const std::string &md5_url)
decltype(make_ota_backend()) OTABackendPtr
constexpr float AFTER_WIFI
For components that should be initialized after WiFi is connected.
Definition component.h:53