1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-30 06:33:51 +00:00

No walruses were harmed in the committing of this commit

This commit is contained in:
Keith Burzinski
2024-04-30 02:07:47 -05:00
parent 33b36425a4
commit 68cb348a8b
2 changed files with 4 additions and 2 deletions

View File

@@ -4,8 +4,9 @@ namespace esphome {
namespace ota {
#ifdef USE_OTA_STATE_CALLBACK
OTAGlobalCallback *global_ota_component =
new OTAGlobalCallback; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
OTAGlobalCallback *global_ota_component = nullptr; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
OTAGlobalCallback::OTAGlobalCallback() { global_ota_component = this; }
#endif
} // namespace ota

View File

@@ -68,6 +68,7 @@ class OTAComponent : public Component {
#ifdef USE_OTA_STATE_CALLBACK
class OTAGlobalCallback {
public:
OTAGlobalCallback();
void register_ota(OTAComponent *ota_caller) {
ota_caller->add_on_state_callback([this, ota_caller](OTAState state, float progress, uint8_t error) {
this->state_callback_.call(state, progress, error, ota_caller);