mirror of
https://github.com/esphome/esphome.git
synced 2026-09-09 14:28:46 +00:00
[noise] Keep only the slot flag test inline in the api loop
The per tick check is a byte load and branch now; the network check, client scan and refill live in prepare_spare_ephemeral_slow_(), called only while the slot is empty.
This commit is contained in:
@@ -199,8 +199,8 @@ void APIServer::loop() {
|
||||
#ifdef USE_API_NOISE
|
||||
// Refill only while no api client is still connecting; an OTA handshake is
|
||||
// not visible here and just pays the refill it triggered.
|
||||
void APIServer::prepare_spare_ephemeral_() {
|
||||
if (noise::has_spare_ephemeral() || !network::is_connected()) {
|
||||
void APIServer::prepare_spare_ephemeral_slow_() {
|
||||
if (!network::is_connected()) {
|
||||
return;
|
||||
}
|
||||
const uint32_t now = App.get_loop_component_start_time();
|
||||
|
||||
@@ -364,7 +364,13 @@ class APIServer final : public Component,
|
||||
#endif
|
||||
|
||||
#ifdef USE_API_NOISE
|
||||
void prepare_spare_ephemeral_();
|
||||
// Polled every loop tick: only the flag test stays inline
|
||||
void prepare_spare_ephemeral_() {
|
||||
if (!noise::has_spare_ephemeral()) {
|
||||
this->prepare_spare_ephemeral_slow_();
|
||||
}
|
||||
}
|
||||
void prepare_spare_ephemeral_slow_();
|
||||
noise::NoiseContext noise_ctx_;
|
||||
#ifndef USE_API_NOISE_PSK_FROM_YAML
|
||||
SavedNoisePsk saved_psk_{}; // backs noise_ctx_ for a runtime provisioned key
|
||||
|
||||
Reference in New Issue
Block a user