mirror of
https://github.com/esphome/esphome.git
synced 2025-08-04 09:27:47 +00:00
[api] Fix OTA progress updates not being sent when main loop is blocked (#10049)
This commit is contained in:
parent
b1b0638fab
commit
d69e98e15d
@ -703,10 +703,16 @@ class APIConnection : public APIServerConnection {
|
|||||||
bool send_message_smart_(EntityBase *entity, MessageCreatorPtr creator, uint8_t message_type,
|
bool send_message_smart_(EntityBase *entity, MessageCreatorPtr creator, uint8_t message_type,
|
||||||
uint8_t estimated_size) {
|
uint8_t estimated_size) {
|
||||||
// Try to send immediately if:
|
// Try to send immediately if:
|
||||||
// 1. We should try to send immediately (should_try_send_immediately = true)
|
// 1. It's an UpdateStateResponse (always send immediately to handle cases where
|
||||||
// 2. Batch delay is 0 (user has opted in to immediate sending)
|
// the main loop is blocked, e.g., during OTA updates)
|
||||||
// 3. Buffer has space available
|
// 2. OR: We should try to send immediately (should_try_send_immediately = true)
|
||||||
if (this->flags_.should_try_send_immediately && this->get_batch_delay_ms_() == 0 &&
|
// AND Batch delay is 0 (user has opted in to immediate sending)
|
||||||
|
// 3. AND: Buffer has space available
|
||||||
|
if ((
|
||||||
|
#ifdef USE_UPDATE
|
||||||
|
message_type == UpdateStateResponse::MESSAGE_TYPE ||
|
||||||
|
#endif
|
||||||
|
(this->flags_.should_try_send_immediately && this->get_batch_delay_ms_() == 0)) &&
|
||||||
this->helper_->can_write_without_blocking()) {
|
this->helper_->can_write_without_blocking()) {
|
||||||
// Now actually encode and send
|
// Now actually encode and send
|
||||||
if (creator(entity, this, MAX_BATCH_PACKET_SIZE, true) &&
|
if (creator(entity, this, MAX_BATCH_PACKET_SIZE, true) &&
|
||||||
|
Loading…
x
Reference in New Issue
Block a user