6 if (candidate ==
nullptr || reference ==
nullptr)
10 while (*candidate >=
'0' && *candidate <=
'9') {
11 a = a * 10 +
static_cast<uint32_t>(*candidate -
'0');
15 while (*reference >=
'0' && *reference <=
'9') {
16 b = b * 10 +
static_cast<uint32_t>(*reference -
'0');
22 const bool a_more = (*candidate ==
'.');
23 const bool b_more = (*reference ==
'.');
28 if (!a_more && !b_more)
33#ifdef USE_OTA_STATE_LISTENER
47 static_assert(
OTA_ERROR <= 0xFF,
"OTAState must fit in 8 bits for packing");
49 static_cast<uint16_t
>(progress * 100.0f);
50 this->
defer([
this, packed]() {
51 this->
notify_state_(
static_cast<OTAState>(packed >> 24),
static_cast<float>(packed & 0xFFFF) / 100.0f,
52 static_cast<uint8_t
>(packed >> 16));
58 listener->on_ota_state(
state, progress, error);
void defer(const char *name, std::function< void()> &&f)
Defer a callback to the next loop() call with a const char* name.
void notify_state_deferred_(OTAState state, float progress, uint8_t error)
Notify state with deferral to main loop (for thread safety).
std::vector< OTAStateListener * > state_listeners_
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 version_is_older(const char *candidate, const char *reference)
Compare two dotted-numeric version strings (such as "1.2.3").
OTAGlobalCallback * get_global_ota_callback()
OTAGlobalCallback * global_ota_callback