Commit Graph

22434 Commits

Author SHA1 Message Date
J. Nick Koston
97c080e465 Merge branch 'wifi-memcpy-sort' into integration 2026-02-12 12:42:55 -06:00
J. Nick Koston
88df48a52d Add TODO for std::trivially_relocatable when available 2026-02-12 12:42:09 -06:00
J. Nick Koston
8676b99219 Merge branch 'wifi-memcpy-sort' into integration 2026-02-12 12:33:55 -06:00
J. Nick Koston
282ba90f62 Address review feedback: add explicit includes and clarify comments
- Add #include <type_traits> to both .cpp and .h for static_asserts
- Clarify CompactString comment: explicitly note it is not trivially
  copyable, and that memcpy safety relies on validated layout property
- Use memcpy_fn indirection to suppress both GCC -Wclass-memaccess
  and clang-tidy bugprone-undefined-memory-manipulation without
  platform-specific pragma guards
2026-02-12 12:32:06 -06:00
J. Nick Koston
58f8029264 [wifi] Use memcpy-based insertion sort for scan results
Replace copy-assignment with raw memcpy in the WiFi scan result
insertion sort. Copy assignment on WiFiScanResult calls
CompactString's destructor then placement-new for every shift,
which means delete[]/new[] per shift for heap-allocated SSIDs.

With 70+ networks visible (e.g., during captive portal transition
showing full scan results), this caused event loop blocking from
hundreds of heap allocations in a tight loop on an 80MHz ESP8266.

This optimization is safe because we're permuting elements within
the same array - each slot is overwritten exactly once, so no
ownership duplication occurs. CompactString stores either inline
data or a heap pointer, never a self-referential pointer (unlike
libstdc++ std::string SSO). This was made possible by PR#13472
which replaced std::string with CompactString.

Static asserts guard the memcpy safety assumptions at compile time.

Confirmed on real device: event loop blocking during captive portal
transition is eliminated and WiFi connection is slightly faster.
2026-02-12 12:29:19 -06:00
Jesse Hills
1604b5d6e4 Merge branch 'beta' into dev 2026-02-13 07:11:49 +13:00
Jesse Hills
e000858d77 Merge pull request #13951 from esphome/bump-2026.2.0b1
2026.2.0b1
2026.2.0b1
2026-02-13 07:11:07 +13:00
J. Nick Koston
7fd535179e [helpers] Add heap warnings to format_hex_pretty, deprecate ethernet/web_server std::string APIs (#13959) 2026-02-12 17:47:44 +00:00
Lukáš Maňas
e3a457e402 [pulse_meter] Fix early edge detection (#12360)
Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
Co-authored-by: Jonathan Swoboda <154711427+swoboda1337@users.noreply.github.com>
2026-02-12 17:20:54 +00:00
J. Nick Koston
0dcff82bb4 [wifi] Deprecate wifi_ssid() in favor of wifi_ssid_to() (#13958) 2026-02-12 17:14:36 +00:00
J. Nick Koston
cde8b66719 [web_server] Switch from getParam to arg API to eliminate heap allocations (#13942) 2026-02-12 11:04:41 -06:00
J. Nick Koston
0e1433329d [api] Extract cold code from APIServer::loop() hot path (#13902) 2026-02-12 11:04:23 -06:00
J. Nick Koston
3d2227ff8d Merge remote-tracking branch 'origin/deprecate-std-string-apis' into integration 2026-02-12 11:00:56 -06:00
J. Nick Koston
94ea150082 [helpers] Add heap allocation warnings and deprecate unused std::string APIs
Add @warning comments to all format_hex_pretty() overloads in helpers.h
pointing to the buffer-based format_hex_pretty_to() alternatives.

Deprecate with ESPDEPRECATED (removal 2026.9.0):
- EthernetComponent::get_eth_mac_address_pretty()
  -> use get_eth_mac_address_pretty_into_buffer()
- AsyncWebServerRequest::url()
  -> use url_to()

Neither deprecated method has internal callers.
2026-02-12 10:59:10 -06:00
J. Nick Koston
e8f2d21d66 Merge remote-tracking branch 'origin/deprecate-wifi-ssid' into integration 2026-02-12 10:49:15 -06:00
J. Nick Koston
932067c332 [wifi] Deprecate wifi_ssid() in favor of wifi_ssid_to()
wifi_ssid() returns std::string which allocates on the heap.
All internal callers have already been migrated to the
buffer-based wifi_ssid_to() alternative. Mark as deprecated
with a 6-month removal window (2026.9.0).
2026-02-12 10:47:23 -06:00
J. Nick Koston
6dd555487b Fix off-by-one in get_descriptor_string loop bound
bLength includes the 2-byte descriptor header, so the character count
is (bLength - 2) / 2, not bLength / 2. The old loop read one wData
entry past the actual string data. Also guard bLength < 2.
2026-02-12 10:35:24 -06:00
J. Nick Koston
0556d27ced Merge branch 'usb-host-extract-cold-path' into integration 2026-02-12 10:28:37 -06:00
J. Nick Koston
60fef5e656 [analyze_memory] Fix mDNS packet buffer miscategorized as wifi_config (#13949)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-12 10:26:54 -06:00
J. Nick Koston
725e774fe7 [web_server] Guard icon JSON field with USE_ENTITY_ICON (#13948) 2026-02-12 10:26:36 -06:00
J. Nick Koston
9aa98ed6c6 [uart] Remove redundant mutex, fix flush race, conditional event queue (#13955) 2026-02-12 10:26:10 -06:00
J. Nick Koston
9c72c022b2 [usb_host] Extract cold path from loop(), replace std::string with buffer API
Extract the USB_CLIENT_OPEN state handling into handle_open_state_() to
keep loop() hot path small (~112 B vs 440 B before). Replace
get_descriptor_string() std::string return with caller-provided
fixed-size buffer via std::span to eliminate heap allocation during
device connection.
2026-02-12 10:25:53 -06:00
Guillermo Ruffino
7b251dcc31 [schema-gen] fix Windows: ensure UTF-8 encoding when reading component files (#13952) 2026-02-12 11:23:59 -05:00
J. Nick Koston
9e9af88f9f Merge branch 'uart-remove-redundant-lock' into integration 2026-02-12 08:37:26 -06:00
J. Nick Koston
b0058fe934 Add function-level comment to rx_event_task_func explaining its role 2026-02-12 08:35:09 -06:00
J. Nick Koston
750b0a7d00 Drop incomplete method list from thread safety comment 2026-02-12 08:32:45 -06:00
J. Nick Koston
046fca2be6 Improve uart_flush_input comment to explain architectural mismatch 2026-02-12 08:32:01 -06:00
J. Nick Koston
6d1fa9fa72 [uart] Remove redundant mutex, fix rx_event_task race, optimize event queue
Remove the FreeRTOS mutex (lock_) that wrapped all ESP-IDF UART driver
calls. A codebase audit confirmed all UART wrapper methods (read_array,
write_array, peek_byte, available, flush) are called exclusively from
the cooperative main loop. The lock was protecting single-threaded code
from itself and added 4 unnecessary semaphore operations per read_array
call on the hot path.

Fix a race condition in rx_event_task_func where uart_flush_input() was
called from a separate FreeRTOS task without taking the lock, racing
with read_array() on the main loop. This could destroy ring buffer data
mid-read, causing data loss. The flush was also unnecessary since the
ESP-IDF driver self-heals the buffer-full condition: uart_read_bytes()
internally calls uart_check_buf_full() which moves stashed FIFO bytes
back into the ring buffer and re-enables RX interrupts.

Move the event queue allocation behind USE_UART_WAKE_LOOP_ON_RX. When
the feature is disabled, uart_driver_install is called with queue_size=0
and uart_queue=NULL (the documented API for skipping the event queue).
This saves ~320 bytes of RAM per UART instance and reduces ISR overhead
since the driver skips xQueueSendFromISR when no queue exists.

Add thread safety documentation to the class and rx_event_task.
2026-02-12 08:19:42 -06:00
J. Nick Koston
bdcea4199a Merge branch 'posix_tz' into integration 2026-02-12 07:00:36 -06:00
schrob
8a08c688f6 [mipi_spi] Add Waveshare 1.83 v2 panel (#13680) 2026-02-12 23:25:51 +11:00
J. Nick Koston
9c185b42c3 Reword comment to avoid ci-custom scanf lint false positive
The regex matches `scanf (` in comments too since `\s*\(` matches the
space before the parenthesized size note.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-12 06:23:30 -06:00
J. Nick Koston
1fe95d8f82 Merge branch 'dev' into posix_tz 2026-02-12 05:40:07 -06:00
Jesse Hills
d6461251f9 Bump version to 2026.3.0-dev 2026-02-12 23:04:19 +13:00
Jesse Hills
97d6f394de Bump version to 2026.2.0b1 2026-02-12 23:04:18 +13:00
J. Nick Koston
da1ea2cfa3 [ethernet] Add per-PHY compile guards to eliminate unused PHY drivers (#13947) 2026-02-12 05:07:05 +00:00
J. Nick Koston
eb9dd60039 Merge remote-tracking branch 'origin/fix-analyze-memory-packet-category' into integration 2026-02-11 22:44:10 -06:00
J. Nick Koston
133a41790a [analyze_memory] Fix mDNS packet buffer miscategorized as wifi_config
Move `packet$` pattern from `wifi_config` to `mdns_lib` category.
The `packet$` static buffer is the mDNS packet assembly buffer used
by ESP-IDF's mDNS component, not a WiFi config symbol. This was
causing 1,460 B of mDNS RAM to appear under wifi_config in
ethernet-only builds.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-11 22:42:22 -06:00
J. Nick Koston
9b27caf84d Merge branch 'web-server-icon-guard' into integration 2026-02-11 22:20:23 -06:00
J. Nick Koston
d4fda33b19 [web_server] Guard icon JSON field with USE_ENTITY_ICON
Skip emitting the "icon" key in set_json_id() when USE_ENTITY_ICON
is not defined. This avoids the ArduinoJson .set() call overhead and
sending empty "icon":"" in every JSON response for builds without icons.
2026-02-11 22:18:51 -06:00
J. Nick Koston
b2fc10fa52 Merge branch 'ethernet-per-phy-compile-guards' into integration 2026-02-11 21:56:44 -06:00
J. Nick Koston
87a2923465 cleanup 2026-02-11 21:56:29 -06:00
J. Nick Koston
138b5b62f2 Merge remote-tracking branch 'origin/ethernet-per-phy-compile-guards' into integration 2026-02-11 21:53:23 -06:00
J. Nick Koston
bb86737cbb [ethernet] Add per-PHY compile guards to eliminate unused PHY drivers
Extend the per-PHY compile guard pattern (already used by KSZ8081 and
LAN8670) to all RMII PHY types: LAN8720, RTL8201, DP83848, IP101, and
JL1101. This allows the linker to strip unused PHY driver code, saving
~7.5 KB flash per build since only one PHY is ever used per device.
2026-02-11 21:51:01 -06:00
J. Nick Koston
9f0a640827 Merge remote-tracking branch 'origin/ethernet-per-phy-compile-guards' into integration 2026-02-11 21:38:52 -06:00
Awesome Walrus
c9d2adb717 [wifi] Allow fast_connect without preconfigured networks (#13946) 2026-02-11 21:34:59 -06:00
J. Nick Koston
283d19db8d [ethernet] Add per-PHY compile guards to eliminate unused PHY drivers
Extend the per-PHY compile guard pattern (already used by KSZ8081 and
LAN8670) to all RMII PHY types: LAN8720, RTL8201, DP83848, IP101, and
JL1101. This allows the linker to strip unused PHY driver code, saving
~7.5 KB flash per build since only one PHY is ever used per device.
2026-02-11 21:14:34 -06:00
Jonathan Swoboda
db6aea8969 Allow Python 3.14 (#13945)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-11 22:11:48 -05:00
Jonathan Swoboda
96eb129cf8 [esp32] Bump Arduino to 3.3.7, platform to 55.03.37 (#13943)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-11 20:29:17 -05:00
J. Nick Koston
d30b321f7c Merge branch 'web_server_use_arg_api' into integration 2026-02-11 19:16:27 -06:00
J. Nick Koston
220c2acf0e Check for ESP_OK or ESP_ERR_HTTPD_RESULT_TRUNC explicitly in query_has_key
Instead of treating any non-ESP_ERR_NOT_FOUND result as key-present,
explicitly check for the two success codes. This avoids false positives
from unexpected error codes like ESP_ERR_INVALID_ARG.
2026-02-11 19:15:43 -06:00