Commit Graph
26234 Commits
Author SHA1 Message Date
J. Nick Koston 4e255ffe0d Merge branch 'wifi-idf-fast-path-queue' into integration
# Conflicts:
#	esphome/components/wifi/wifi_component_esp_idf.cpp
2026-03-29 19:17:06 -10:00
J. Nick Koston ac2f837c7f Use relaxed memory ordering for event pending flag
The flag is just a hint — xQueueReceive with its own internal
synchronization is the source of truth. Relaxed ordering avoids
unnecessary fence cost on ESP targets. Worst case is missing an
event for one loop iteration.
2026-03-29 19:16:03 -10:00
J. Nick Koston 5d2f568565 Switch to atomic uint8_t flag, fix race condition
Replace atomic counter with a simple flag to avoid underflow race
where consumer could decrement before producer increments. Use
uint8_t instead of bool to avoid GCC Xtensa indirect call issue.

Clear flag before draining — if a new event arrives between clear
and xQueueReceive, the flag is set again and caught next iteration.
2026-03-29 19:15:34 -10:00
J. Nick Koston b799a53add Switch to atomic uint8_t flag, fix race condition
Replace atomic counter with a simple flag to avoid underflow race
where consumer could decrement before producer increments. Use
uint8_t instead of bool to avoid GCC Xtensa indirect call issue.

Clear flag before draining — if a new event arrives between clear
and xQueueReceive, the flag is set again and caught next iteration.
2026-03-29 19:15:24 -10:00
J. Nick Koston e494b2aa85 Merge branch 'wifi-idf-fast-path-queue' into integration 2026-03-29 19:11:20 -10:00
J. Nick Koston 641289915f [wifi] Skip xQueueReceive when no WiFi events pending on ESP-IDF
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.
2026-03-29 19:09:03 -10:00
J. Nick Koston 67ccf374e9 Merge remote-tracking branch 'upstream/wifi-libretiny-state-member' into integration 2026-03-29 18:55:56 -10:00
J. Nick Koston 16aa0bf1a2 [wifi] Move LibreTiny WiFi STA state to member variable
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.
2026-03-29 18:53:27 -10:00
J. Nick Koston 57e192543f Add atomicity comment for sta_state_ member variable 2026-03-29 18:52:58 -10:00
J. Nick Koston 534ee66082 Merge remote-tracking branch 'upstream/wifi-libretiny-state-member' into integration 2026-03-29 18:48:36 -10:00
J. Nick Koston fc0625c0f7 [wifi] Move LibreTiny WiFi STA state to member variable
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.
2026-03-29 18:46:37 -10:00
J. Nick Koston 37e181a797 Move ESP8266WiFiSTAState enum to cpp, use uint8_t in header
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.
2026-03-29 18:38:04 -10:00
J. Nick Koston 7086cf3392 Fix comment: if statements with early returns, not if-else 2026-03-29 18:33:15 -10:00
J. Nick Koston f19792df8c Revert wifi_sta_connect_status_ header inline attempt
GCC doesn't inline it into loop() due to code size heuristics,
so the #ifdef complexity isn't worth it. Keep it out-of-line.
2026-03-29 18:32:28 -10:00
J. Nick Koston 96a23e5d3d Inline is_connected_ and update_connected_state_ into 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.
2026-03-29 18:29:03 -10:00
J. Nick Koston d52d5bbda3 Move ESP8266 WiFi STA state enum to member variable
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.
2026-03-29 18:16:41 -10:00
J. Nick Koston cee1168293 Use if-else instead of switch to avoid CSWTCH in rodata
On ESP8266, GCC generates a lookup table in .rodata for switch
statements, which lives in flash. Use if-else chain to keep the
logic entirely in IRAM.
2026-03-29 18:10:28 -10:00
J. Nick Koston 438553ccfe Fix clang-tidy NOLINT placement for s_sta_state
Move the NOLINT comment to NOLINTNEXTLINE so clang-tidy sees it
on the line with the variable declaration, not the continuation.
2026-03-29 18:09:49 -10:00
J. Nick Koston f43a598a83 [wifi] Avoid redundant SDK calls in WiFi loop on ESP8266
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.
2026-03-29 17:55:55 -10:00
J. Nick Koston 7389526a3a revert socket 2026-03-29 16:14:26 -10:00
J. Nick Koston 0112f8fb5d wip 2026-03-29 16:10:52 -10:00
J. Nick Koston 02660b1ad4 merge 2026-03-29 16:09:16 -10:00
J. Nick Koston e5e85b010c merge 2026-03-29 16:08:43 -10:00
J. Nick Koston b392f14684 merge 2026-03-29 16:08:01 -10:00
J. Nick Koston 20a60c119a merge 2026-03-29 16:07:34 -10:00
J. Nick Koston 5c7d4d3941 Merge branch 'peel_plus_short_float' into integration 2026-03-29 16:05:04 -10:00
J. Nick Koston ae66c7c7e7 Merge remote-tracking branch 'upstream/dev' into peel_plus_short_float 2026-03-29 16:01:02 -10:00
J. Nick Koston 4beeaff6f6 Merge branch 'float-to-raw-optimization' into peel_plus_short_float 2026-03-29 15:59:29 -10:00
J. Nick Koston 3205ab39d9 Merge branch 'api-sint32-short-varint' into peel_plus_short 2026-03-29 15:49:22 -10:00
J. Nick Koston 4abe29436a merge 2026-03-29 15:44:59 -10:00
J. Nick Koston e97cc8cc3e merge 2026-03-29 15:43:54 -10:00
J. Nick Koston cf7b92b275 merge 2026-03-29 15:42:27 -10:00
J. Nick Koston 067cdb2ca2 fix 2026-03-29 15:40:30 -10:00
J. Nick Koston 7bc8edcf3e fix 2026-03-29 15:39:04 -10:00
J. Nick Koston 5a4056f12b reverts 2026-03-29 15:38:36 -10:00
J. Nick Koston 71a6f876cf reverts 2026-03-29 15:38:05 -10:00
J. Nick Koston 46918addf7 reverts 2026-03-29 15:37:40 -10:00
J. Nick Koston fd06aa3f8b reverts 2026-03-29 15:37:21 -10:00
J. Nick Koston 3caf1436ff reverts 2026-03-29 15:37:01 -10:00
J. Nick Koston 9b3b251053 Merge remote-tracking branch 'upstream/dev' into integration 2026-03-29 15:33:29 -10:00
J. Nick Koston f28084d464 Merge remote-tracking branch 'upstream/api/peel-first-write-iteration' into integration 2026-03-29 15:33:19 -10:00
J. Nick Koston 18168ad7fd [sensor] Use std::array in CalibrateLinearFilter (#15263) 2026-03-29 15:07:15 -10:00
J. Nick Koston a308b8993e Merge branch 'dev' into api/peel-first-write-iteration 2026-03-29 15:06:57 -10:00
J. Nick Koston 3ad35a1b60 fix refactoring error 2026-03-29 15:06:23 -10:00
J. Nick Koston 17afbeb87b [binary_sensor] Use std::array in MultiClickTrigger (#15267) 2026-03-29 14:57:15 -10:00
J. Nick Koston d51b047f63 [sensor] Use std::array in CalibratePolynomialFilter (#15264) 2026-03-29 14:56:04 -10:00
J. Nick Koston 508ec295a4 [sensor] Use std::array in OrFilter (#15262) 2026-03-29 14:55:46 -10:00
J. Nick Koston 2e68b89fff [api] Use HEADER_PADDING directly instead of local alias 2026-03-29 14:34:29 -10:00
J. Nick Koston adf0ce7fbd [api] Remove redundant frame_header_padding arg from write_plaintext_header
It's always HEADER_PADDING (constexpr 6). Using it directly inside
the function eliminates an argument and lets the compiler constant-fold.
2026-03-29 14:33:51 -10:00
J. Nick Koston ccafd442a7 [api] Use static constexpr HEADER_PADDING instead of loading member field
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.
2026-03-29 14:32:47 -10:00