mirror of
https://github.com/esphome/esphome.git
synced 2026-09-11 23:37:34 +00:00
[mdns] Fold the receive branch into the onRx handler
This commit is contained in:
@@ -29,8 +29,15 @@ class GuardedMDNSResponder : public ::esp8266::MDNSImplementation::MDNSResponder
|
||||
(this->*fn)();
|
||||
return;
|
||||
}
|
||||
// Set every time: a restart replaces the context together with its stock handler
|
||||
ctx->onRx([this]() { this->on_rx_(); });
|
||||
// Set every time: a restart replaces the context together with its stock handler.
|
||||
// Runs from lwIP in the SYS context.
|
||||
ctx->onRx([this]() {
|
||||
if (this->in_loop_call_) {
|
||||
this->pending_rx_++;
|
||||
} else {
|
||||
this->_callProcess();
|
||||
}
|
||||
});
|
||||
this->pending_rx_ = 0;
|
||||
this->in_loop_call_ = true;
|
||||
(this->*fn)();
|
||||
@@ -42,15 +49,6 @@ class GuardedMDNSResponder : public ::esp8266::MDNSImplementation::MDNSResponder
|
||||
this->in_loop_call_ = false;
|
||||
}
|
||||
|
||||
// lwIP receive callback (SYS context)
|
||||
void on_rx_() {
|
||||
if (this->in_loop_call_) {
|
||||
this->pending_rx_++;
|
||||
} else {
|
||||
this->_callProcess();
|
||||
}
|
||||
}
|
||||
|
||||
volatile bool in_loop_call_{false};
|
||||
volatile uint8_t pending_rx_{0};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user