ESPHome 2026.1.0-dev
Loading...
Searching...
No Matches
ota_backend.cpp
Go to the documentation of this file.
1#include "ota_backend.h"
2
3namespace esphome {
4namespace ota {
5
6#ifdef USE_OTA_STATE_LISTENER
7OTAGlobalCallback *global_ota_callback{nullptr}; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
8
10 if (global_ota_callback == nullptr) {
11 global_ota_callback = new OTAGlobalCallback(); // NOLINT(cppcoreguidelines-owning-memory)
12 }
14}
15
16void OTAComponent::notify_state_(OTAState state, float progress, uint8_t error) {
17 for (auto *listener : this->state_listeners_) {
18 listener->on_ota_state(state, progress, error);
19 }
20 get_global_ota_callback()->notify_ota_state(state, progress, error, this);
21}
22#endif
23
24} // namespace ota
25} // namespace esphome
std::vector< OTAStateListener * > state_listeners_
Definition ota_backend.h:91
void notify_state_(OTAState state, float progress, uint8_t error)
Global callback that aggregates OTA state from all OTA components.
void notify_ota_state(OTAState state, float progress, uint8_t error, OTAComponent *component)
bool state
Definition fan.h:0
OTAGlobalCallback * get_global_ota_callback()
OTAGlobalCallback * global_ota_callback
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7