ESPHome 2026.1.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 {
15namespace http_request {
16
17static const uint8_t MD5_SIZE = 32;
18
24
25class OtaHttpRequestComponent : public ota::OTAComponent, public Parented<HttpRequestComponent> {
26 public:
27 void dump_config() override;
28 float get_setup_priority() const override { return setup_priority::AFTER_WIFI; }
29
30 void set_md5_url(const std::string &md5_url);
31 void set_md5(const std::string &md5) { this->md5_expected_ = md5; }
32 void set_password(const std::string &password) { this->password_ = password; }
33 void set_url(const std::string &url);
34 void set_username(const std::string &username) { this->username_ = username; }
35
36 std::string md5_computed() { return this->md5_computed_; }
37 std::string md5_expected() { return this->md5_expected_; }
38
39 void flash();
40
41 protected:
42 void cleanup_(std::unique_ptr<ota::OTABackend> backend, const std::shared_ptr<HttpContainer> &container);
43 uint8_t do_ota_();
44 std::string get_url_with_auth_(const std::string &url);
45 bool http_get_md5_();
46 bool validate_url_(const std::string &url);
47
48 std::string md5_computed_{};
49 std::string md5_expected_{};
50 std::string md5_url_{};
51 std::string password_{};
52 std::string username_{};
53 std::string url_{};
54 int status_ = -1;
55 bool update_started_ = false;
56 static const uint16_t HTTP_RECV_BUFFER = 256; // the firmware GET chunk size
57};
58
59} // namespace http_request
60} // namespace esphome
Helper class to easily give an object a parent of type T.
Definition helpers.h:1102
void cleanup_(std::unique_ptr< ota::OTABackend > backend, const std::shared_ptr< HttpContainer > &container)
void set_password(const std::string &password)
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)
const float AFTER_WIFI
For components that should be initialized after WiFi is connected.
Definition component.cpp:88
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7