Commit Graph

22409 Commits

Author SHA1 Message Date
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
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
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
J. Nick Koston
1a926da7b4 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:35 -06:00
J. Nick Koston
961b830df5 Merge branch 'web_server_use_arg_api' into integration 2026-02-11 19:07:31 -06:00
J. Nick Koston
52461f10e7 Use httpd_req_get_url_query_len instead of strlen for query length
The parsed URL already has the query length available via the httpd API.
Avoids redundant strlen over the query string.
2026-02-11 19:06:28 -06:00
J. Nick Koston
2348ad2a03 Access URL query string directly from req->uri instead of stack copy
The query string already lives in req->uri. Access it via strchr('?')
instead of copying into a 513-byte stack buffer via httpd_req_get_url_query_str.
This is the same pattern url_to() uses — http_parser identifies URI
components by offset/length without modifying the source string.

Eliminates 513 bytes of stack usage on the httpd task, leaving only
the 128-byte value extraction buffer in query_key_value.
2026-02-11 19:06:02 -06:00
J. Nick Koston
94cab38206 Access URL query string directly from req->uri instead of stack copy
The query string already lives in req->uri. Access it via strchr('?')
instead of copying into a 513-byte stack buffer via httpd_req_get_url_query_str.
This is the same pattern url_to() uses — http_parser identifies URI
components by offset/length without modifying the source string.

Eliminates 513 bytes of stack usage on the httpd task, leaving only
the 128-byte value extraction buffer in query_key_value.
2026-02-11 19:05:52 -06:00
J. Nick Koston
1ea653e6ab Merge branch 'json_web_server_stack' into integration 2026-02-11 19:02:10 -06:00
J. Nick Koston
aa870483f1 Reduce SerializationBuffer stack size from 768 to 512 bytes
768 bytes on the httpd task stack contributes to stack overflow when
combined with other stack-allocated buffers (query string parsing, etc.).
512 bytes still covers all typical JSON payloads (sensors ~200B, lights
~170B, climate ~500-700B). Only extreme edge cases with 40+ options
trigger heap fallback.
2026-02-11 18:58:28 -06:00
J. Nick Koston
181fb4f8ac Reduce SerializationBuffer stack size from 768 to 512 bytes
768 bytes on the httpd task stack contributes to stack overflow when
combined with other stack-allocated buffers (query string parsing, etc.).
512 bytes still covers all typical JSON payloads (sensors ~200B, lights
~170B, climate ~500-700B). Only extreme edge cases with 40+ options
trigger heap fallback.
2026-02-11 18:57:53 -06:00
J. Nick Koston
9ef0ad3f9d Merge branch 'web_server_use_arg_api' into integration 2026-02-11 18:55:06 -06:00
J. Nick Koston
2b5bd961ef Fix stack overflow: use small stack buffer with heap fallback in query_key_value
Revert direct req->uri access (unsafe — ESP-IDF uses parsed offsets,
not strchr). Instead fix the root cause: query_key_value used a full
CONFIG_HTTPD_MAX_URI_LEN+1 (513 byte) stack buffer while
search_query_sources had another 513 byte buffer on the stack
simultaneously, totaling ~1KB on the httpd thread's limited stack.

Use SmallBufferWithHeapFallback<128> for the value extraction buffer.
128 bytes covers typical parameter values on stack; longer values
(e.g. base64 IR data) fall back to heap.
2026-02-11 18:53:58 -06:00
J. Nick Koston
5a88bb6d8a Fix stack overflow: access URL query directly from req->uri
search_query_sources was copying the URL query string into a 513-byte
stack buffer, then query_key_value added another 513-byte buffer for
the extracted value — 1026 bytes simultaneously on the httpd thread's
limited stack, causing a crash in lwip_select.

The query string already lives in req->uri after the '?'. Access it
directly via pointer instead of copying, eliminating one buffer entirely.
2026-02-11 18:51:45 -06:00
J. Nick Koston
1bb6b24a1a Merge branch 'web_server_use_arg_api' into integration 2026-02-11 18:39:53 -06:00
J. Nick Koston
53345724f2 Use fixed stack buffer for query strings bounded by CONFIG_HTTPD_MAX_URI_LEN
Query strings cannot exceed the max URI length, so SmallBufferWithHeapFallback
is unnecessary. Use a plain stack array instead for zero heap allocation.
2026-02-11 18:38:25 -06:00
J. Nick Koston
92d800412a Skip empty post_query in search_query_sources; reuse find_query_value_ in getParam
- Add early return for empty post_query (common GET request path)
- Refactor getParam to use find_query_value_ instead of duplicating search logic
- Remove now-unused request_get_url_query (and its heap allocation)
- Remove unused std::string overload of query_key_value
2026-02-11 18:35:10 -06:00
J. Nick Koston
e57612d522 Avoid heap allocation for URL query in hasArg/arg
Replace request_get_url_query (returns std::string) with inline
httpd_req_get_url_query_str into a SmallBufferWithHeapFallback
stack buffer. Typical query strings (<256 bytes) now use zero
heap allocations for parameter lookups.
2026-02-11 18:27:55 -06:00
J. Nick Koston
f0828928b4 Extract search_query_sources to deduplicate hasArg/find_query_value_
Both methods iterated post_query_ then url_query with the same
pattern. Extracted a file-local template that takes a callback,
avoiding duplicated request_get_url_query heap allocation logic.
2026-02-11 18:26:13 -06:00
J. Nick Koston
e42cc2e394 Add query_has_key for efficient hasArg without string allocation
hasArg only needs to know if a key exists, not its value.
query_has_key uses a 1-byte buffer and checks the return code
from httpd_query_key_value — no url_decode, no std::string.
2026-02-11 18:23:38 -06:00
J. Nick Koston
1d70341da9 Merge branch 'web_server_use_arg_api' into integration 2026-02-11 18:18:12 -06:00
J. Nick Koston
592d5ec24c Restore hasArg guard in parse_string_param_
Empty string is a valid value for string params (e.g. select
options). Must use hasArg to distinguish missing from empty.
2026-02-11 18:17:24 -06:00
J. Nick Koston
91a0b0989e Simplify captive_portal lambda capture
Capture auto type directly and use c_str() overload of
save_wifi_sta. Works on both std::string and Arduino String.
2026-02-11 18:14:46 -06:00
J. Nick Koston
f35dfefdf3 Remove readability-redundant-string-cstr NOLINTs from captive_portal
Use const auto& to bind arg() result directly. Construct
std::string only in deferred lambda capture where ownership
is needed.
2026-02-11 18:13:32 -06:00
J. Nick Koston
892804e02e Remove remaining readability-redundant-string-cstr NOLINTs
Use const auto& to bind arg() result directly, avoiding
unnecessary std::string intermediate copies. Construct
std::string only where needed (lambda capture, setter call).
2026-02-11 18:12:47 -06:00
J. Nick Koston
5585b5967e Avoid std::string copy in date/time/datetime handlers
Use const auto& to bind directly to arg() result (std::string on
IDF, Arduino String on Arduino) and pass c_str()/length() to the
setter. No intermediate std::string copy needed.
2026-02-11 18:11:49 -06:00
J. Nick Koston
73867c62be Pass c_str() and size() directly to date/time/datetime setters
These setters have (const char*, size_t) overloads that do the
actual work. Skip the std::string& overload indirection.
2026-02-11 18:10:43 -06:00
J. Nick Koston
a6579dc2f1 Pass c_str() and size() directly to date/time/datetime setters
These setters have (const char*, size_t) overloads that do the
actual work. Skip the std::string& overload indirection.
2026-02-11 18:10:36 -06:00