Commit Graph
26249 Commits
Author SHA1 Message Date
J. Nick Koston e35efcbf91 Merge branch 'devirtualize-ble-handlers' into integration 2026-03-29 22:58:18 -10:00
J. Nick Koston 33230e1c94 Add type annotations to _add_callback 2026-03-29 22:51:23 -10:00
J. Nick Koston 888405790f Fix static storage duration capture warnings in lambdas
Use braced scope with local variable to avoid capturing static
storage duration variables directly in lambda captures.
2026-03-29 22:51:09 -10:00
J. Nick Koston d05ac6eae4 Revert unnecessary comment/docstring changes 2026-03-29 22:47:28 -10:00
J. Nick Koston 5850931d27 [esp32_ble] Devirtualize BLE event handler dispatch
Replace virtual handler interfaces (GAPEventHandler, GAPScanEventHandler,
GATTcEventHandler, GATTsEventHandler, BLEStatusEventHandler) with
StaticCallbackManager-based dispatch using lambda callbacks.

This eliminates vtable lookups and MI this-pointer adjustment thunks
on every BLE event dispatch in the hot path. Each lambda captures a
single pointer (fits in Callback inline storage, no heap allocation)
and the StaticCallbackManager avoids std::vector template bloat.

Breaking change: external components inheriting from the virtual handler
classes need to switch to add_*_callback() registration instead.
2026-03-29 22:45:25 -10:00
J. Nick Koston b1fca86df1 Merge remote-tracking branch 'upstream/fix-ble-scan-restart-after-ota-failure' into integration 2026-03-29 22:11:21 -10:00
J. Nick Koston dc9718b167 [esp32_ble_tracker] Restart BLE scan after OTA failure
When OTA starts, stop_scan() is called which clears the scan_continuous_
flag. If OTA fails or aborts, the scan was never restarted because
scan_continuous_ was already false. This left the device without BLE
scanning until reboot.

Save the scan_continuous_ state before stopping and restore it on
OTA_ERROR or OTA_ABORT to resume scanning.
2026-03-29 21:32:38 -10:00
Edward Firmoandpre-commit-ci-lite[bot] 95b0e60617 [nextion] Add accessor const qualifiers, return by ref, and deprecate get_wave_chan_id() (#15204)
Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
2026-03-30 02:20:04 -05:00
Edward Firmo ffbbe5eab3 [nextion] Fix log level for command processing limit message (#15302) 2026-03-30 01:55:40 -05:00
J. Nick Koston fec11d38d1 Merge remote-tracking branch 'upstream/wifi-idf-fast-path-queue' into integration 2026-03-29 19:41:29 -10:00
J. Nick Koston 346e6b40da [wifi] Replace FreeRTOS queue with LockFreeQueue on ESP-IDF
Replace the FreeRTOS xQueue (xQueueCreate/xQueueSend/xQueueReceive)
used for WiFi event passing with a lock-free SPSC queue. This avoids
the FreeRTOS kernel spinlock overhead on every loop iteration when
checking for events — the common case is an empty queue.

The LockFreeQueue::pop() fast path is just two atomic loads and a
comparison, vs xQueueReceive which takes a spinlock, checks the
queue, and releases the spinlock even when empty.

WiFi events are rare (connect/disconnect/scan) so heap allocation
for event data is retained — no EventPool needed unlike the BLE
path which processes hundreds of events per second.

This matches the lock-free pattern already used by esp32_ble.
2026-03-29 19:40:39 -10:00
J. Nick Koston 48466956c6 Merge branch 'wifi-idf-fast-path-queue' into integration
# Conflicts:
#	esphome/components/wifi/wifi_component.h
#	esphome/components/wifi/wifi_component_esp_idf.cpp
2026-03-29 19:39:33 -10:00
J. Nick Koston 51b4b8e743 [wifi] Replace FreeRTOS queue with LockFreeQueue on ESP-IDF
Replace the FreeRTOS xQueue (xQueueCreate/xQueueSend/xQueueReceive)
used for WiFi event passing with a lock-free SPSC queue. This avoids
the FreeRTOS kernel spinlock overhead on every loop iteration when
checking for events — the common case is an empty queue.

The LockFreeQueue::pop() fast path is just two atomic loads and a
comparison, vs xQueueReceive which takes a spinlock, checks the
queue, and releases the spinlock even when empty.

WiFi events are rare (connect/disconnect/scan) so heap allocation
for event data is retained — no EventPool needed unlike the BLE
path which processes hundreds of events per second.

This matches the lock-free pattern already used by esp32_ble.
2026-03-29 19:34:56 -10:00
J. Nick Koston 99232ba4f5 Merge branch 'wifi-idf-fast-path-queue' into integration
# Conflicts:
#	esphome/components/wifi/wifi_component_esp_idf.cpp
2026-03-29 19:23:35 -10:00
J. Nick Koston 09fc3bb9f5 [wifi] Replace FreeRTOS queue with LockFreeQueue on ESP-IDF
Replace the FreeRTOS xQueue (xQueueCreate/xQueueSend/xQueueReceive)
used for WiFi event passing with a lock-free SPSC queue. This avoids
the FreeRTOS kernel spinlock overhead on every loop iteration when
checking for events — the common case is an empty queue.

The LockFreeQueue::pop() fast path is just two atomic loads and a
comparison, vs xQueueReceive which takes a spinlock, checks the
queue, and releases the spinlock even when empty.

WiFi events are rare (connect/disconnect/scan) so heap allocation
for event data is retained — no EventPool needed unlike the BLE
path which processes hundreds of events per second.

This matches the lock-free pattern already used by esp32_ble.
2026-03-29 19:22:09 -10:00
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