ESPHome 2025.9.0
Loading...
Searching...
No Matches
ota_esphome.h
Go to the documentation of this file.
1#pragma once
2
4#ifdef USE_OTA
8#include "esphome/core/log.h"
10
11namespace esphome {
12
15 public:
16#ifdef USE_OTA_PASSWORD
17 void set_auth_password(const std::string &password) { password_ = password; }
18#endif // USE_OTA_PASSWORD
19
21 void set_port(uint16_t port);
22
23 void setup() override;
24 void dump_config() override;
25 float get_setup_priority() const override;
26 void loop() override;
27
28 uint16_t get_port() const;
29
30 protected:
31 void handle_handshake_();
32 void handle_data_();
33 bool readall_(uint8_t *buf, size_t len);
34 bool writeall_(const uint8_t *buf, size_t len);
35 void log_socket_error_(const LogString *msg);
36 void log_read_error_(const LogString *what);
37 void log_start_(const LogString *phase);
40
41#ifdef USE_OTA_PASSWORD
42 std::string password_;
43#endif // USE_OTA_PASSWORD
44
45 std::unique_ptr<socket::Socket> server_;
46 std::unique_ptr<socket::Socket> client_;
47
49 uint16_t port_;
50 uint8_t magic_buf_[5];
51 uint8_t magic_buf_pos_{0};
52};
53
54} // namespace esphome
55#endif
ESPHomeOTAComponent provides a simple way to integrate Over-the-Air updates into your app using Ardui...
Definition ota_esphome.h:14
bool writeall_(const uint8_t *buf, size_t len)
void set_auth_password(const std::string &password)
Definition ota_esphome.h:17
float get_setup_priority() const override
void log_read_error_(const LogString *what)
bool readall_(uint8_t *buf, size_t len)
void set_port(uint16_t port)
Manually set the port OTA should listen on.
std::unique_ptr< socket::Socket > server_
Definition ota_esphome.h:45
std::unique_ptr< socket::Socket > client_
Definition ota_esphome.h:46
void log_start_(const LogString *phase)
void log_socket_error_(const LogString *msg)
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7
std::string size_t len
Definition helpers.h:280