Add an atomic counter incremented when events are enqueued and
decremented when dequeued. wifi_loop_() checks this counter before
calling xQueueReceive, avoiding the FreeRTOS kernel call on every
loop iteration when no events are pending (the common case).
This matches the fast-path pattern used by the scheduler to avoid
lock overhead when there is nothing to process.
Replace the file-static s_sta_state with the shared sta_state_
member variable on WiFiComponent, matching the ESP8266 change.
All accesses are in member functions so no global_wifi_component
indirection is needed.
Replace the file-static s_sta_state with the shared sta_state_
member variable on WiFiComponent, matching the ESP8266 change.
All accesses are in member functions so no global_wifi_component
indirection is needed.
Keep the enum definition private to wifi_component_esp8266.cpp and
store as uint8_t in the class to avoid leaking platform-specific
types into the shared header.
Move these small methods to the header so the compiler can inline
them into loop(), eliminating two function call/return pairs from
every loop iteration on all platforms.
Replace the file-static s_sta_state with a member variable sta_state_
on WiFiComponent, consistent with error_from_callback_ and pending_
which are also written from the static callback via global_wifi_component.
Replace five separate boolean state variables in the ESP8266 WiFi
implementation with a single enum state machine, matching the pattern
already used by LibreTiny. This eliminates the per-loop call to
wifi_station_get_connect_status() by reading cached state from the
existing event callback instead.
Also use the cached connected_ field (set unconditionally at the top
of loop()) in the STA_CONNECTED branch instead of calling
is_connected_() a second time. This applies to all platforms.
The header padding is a compile-time constant per protocol (6 for
plaintext, 7 for noise). Using constexpr eliminates memory loads
on the hot path. The value is defined once per class with the
component breakdown in the comment.
WRITE_FAILED=-1 matches the socket write() return value directly,
so the fast path can pass sent through without remapping. Simplifies
both the inline fast path and the slow path errno check.