SOC_MOD_CLK_APB does not exist in the soc_module_clk_t enum on
ESP32-C6, C5, H2, and P4 variants. Revert to esp_clk_apb_freq()
which works on all variants and is the same function the ESP-IDF
PCNT driver uses internally for glitch filter calculation.
Browsers open multiple concurrent connections for page resources, SSE
event streams, and POST requests for entity control. POST connections
may linger before closing, causing httpd_accept_conn errors (ENFILE)
when the socket pool is too small.
The reduction from 768 to 512 was overly aggressive - the stack
overflow was caused by the 1400+ byte multipart parser, not the
serialization buffer. 640 bytes covers climate DETAIL_ALL payloads
(~520 bytes) on the stack without heap fallback.
Payloads exceeding 1024 bytes are not known to exist in real
configurations. One doubling iteration covers all known entity types.
Cap at 4096 as a safety limit.
Avoids instantiating DummyWriter templates (~736 bytes flash) by
doubling the heap buffer until the payload fits. The temporary
over-allocation (at most 2x) is acceptable since payloads exceeding
the 512-byte stack buffer are rare.
Avoids instantiating DummyWriter templates (~736 bytes flash) by
doubling the heap buffer until the payload fits. The temporary
over-allocation (at most 2x) is acceptable since payloads exceeding
the 512-byte stack buffer are rare.
ArduinoJson's serializeJson() with a bounded buffer returns the actual
bytes written (truncated count), NOT the would-be size like snprintf().
When the payload exceeded the 512-byte stack buffer, the return value
was used as the exact size for heap reallocation, but this was only the
truncated count. The heap buffer was allocated too small, the second
serialization was also truncated, and no NUL terminator was written.
This caused corrupted JSON in SSE streams for entities with payloads
exceeding 512 bytes (e.g., climate DETAIL_ALL with many features).
Fix: use measureJson() in the heap fallback path to get the exact
untruncated size before allocating. Also add the missing set_size_()
call after the second serialization to ensure proper NUL termination.
Move min/max temperature and step traits into DETAIL_ALL block
so they are only sent once on initial connection instead of on
every state update. Rename keys from min_temperature/max_temperature
to min_temp/max_temp to match what the frontend expects.
Discovered while reviewing #14061.
feed_wdt() calls status_led::global_status_led->call() which is a
vtable dispatch into flash. arch_feed_wdt() calls esp_task_wdt_reset()
which is in .flash.text. Neither function can execute with the flash
cache disabled, so IRAM_ATTR provides no benefit.
Neither yield() nor delay() can be called from ISR context or during
flash operations. yield() calls vPortYield/::yield which are not
ISR-safe, and delay() calls vTaskDelay/::delay which block the calling
task. IRAM_ATTR was applied as a blanket attribute when the HAL
abstraction was created in 2021 (#2303) but was never actually needed
for these two functions.
Retains HOT attribute for compiler optimization hints.
std::list uses per-node heap allocation (one allocation per element)
and has poor cache locality. std::vector is contiguous and uses a
single allocation.
Changes:
- Replace std::list<Header> with std::vector<Header> in perform()
virtual method signature across all platforms (IDF, Arduino, Host)
- Update all start(), get(), post() overloads accordingly
- Add ESPDEPRECATED overloads for std::list<Header> callers
- Update online_image to use std::vector<Header>
- Clean up request_headers construction in play() using structured
bindings and reserve()
The sizes are known at Python codegen time, so use FixedVector with
init() for a single allocation and no reallocation machinery. This
eliminates _M_realloc_append template instantiations for these types.
request_headers_ and json_ are populated at config time via
add_request_header()/add_json() and only iterated linearly at
runtime. std::map's red-black tree is unnecessary overhead for
these small collections. Drop the <map> include.
Move header lowercasing from the per-request start() path to config time:
- Python codegen now lowercases collect_headers values before passing to C++
- add_collect_header() stores values as-is (already lowered by Python)
- start() with std::vector is now a direct passthrough to perform()
- Deprecated std::set overload still lowercases for external callers
Rename collect_headers_ to lower_case_collect_headers_ and update all
parameter names throughout the chain to make the lowercase invariant
explicit in the API contract.
This eliminates per-request allocation of a temporary vector and
str_lower_case() calls on every HTTP request, reducing stack usage
in the perform() call chain where stack space is critical for HTTPS
TLS handshakes.
Only default fan_mode to AUTO when no custom fan mode is set.
When a custom fan mode is active, send empty fan_mode to avoid
the frontend showing AUTO instead of the custom mode.
component.h is included before defines.h in application.h,
so the #ifdef guards on declarations were evaluated before the
define was visible. Keep declarations always visible (harmless
unused declarations cost nothing) and only guard the definitions.
The setup_priority override mechanism (struct, vector, linear scan,
allocation, and cleanup) is only needed when a user explicitly sets
setup_priority: in their YAML config. In practice this is almost
never used - components define their priorities via C++ virtual
methods instead.
Gate the entire mechanism behind USE_SETUP_PRIORITY_OVERRIDE, which
is only defined when the codegen encounters a setup_priority: config
entry. This eliminates dead code (struct, std::vector with reserve,
new/delete, linear scan in get_actual_setup_priority) from nearly
all builds.
Also removes the unnecessary reserve(10) call since the override
count is always very small.