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.
WRITE_NOT_ATTEMPTED (-1): cold path, no write tried yet — try write
WRITE_FAILED (-2): fast path write() returned -1 — skip retry, check errno
This avoids a redundant write() syscall when the fast path already
got EWOULDBLOCK and fell through to the slow path.
LOG_PACKET_SENDING was in write_raw_iov_ which is only called on
the slow path. Moved to write_protobuf_packet and write_protobuf_messages
so all packets are logged regardless of which write path is taken.