bluetooth_proxy's loop() ran every main loop iteration (~7400 times/60s)
but only flushed advertisements every 100ms (~600 times/60s). The remaining
~6800 iterations just checked a timestamp and returned, wasting loop
framework overhead.
Replace with set_interval(100ms) so the component only runs when there's
work to do. Move flush_pending_advertisements to an inline method in the
header to avoid out-of-line call overhead in the hot parse_devices path.
Remove redundant is_connected/api_connection checks from flush since all
callers already guard.
The runtime_stats component used a std::map<Component*, ComponentRuntimeStats>
to record per-component timing data. Every loop iteration for every component
required a red-black tree lookup to record its time, adding ~2-3µs of
measurement overhead per component — often exceeding the actual work done
by lightweight components like OTA idle checks.
Move RuntimeStats struct directly onto Component (behind #ifdef USE_RUNTIME_STATS)
so recording is a direct member access with zero lookup cost. The
RuntimeStatsCollector now iterates App.components_ to collect stats instead of
maintaining its own map, eliminating ~2KB of red-black tree code.
The FreeRTOS timer command queue moves from heap to BSS on all
LibreTiny targets, not just BK72xx. RTL87xx and LN882x benefit
from the same heap savings.
Add build flag and required callbacks (following ESP-IDF's pvPortMalloc
approach) so FreeRTOSQueue can use xQueueCreateStatic — queue storage
lives in BSS with zero runtime heap allocation.
- Protect dropped_count_ increment and get+reset with
portENTER_CRITICAL/portEXIT_CRITICAL since std::atomic is unavailable
on NO_ATOMICS platforms
- Delete copy/move constructors and assignment operators
- Remove volatile qualifier (critical sections provide proper
synchronization)
BK72xx's FreeRTOS does not enable configSUPPORT_STATIC_ALLOCATION,
so xQueueCreateStatic is unavailable. Fall back to xQueueCreate
which is a one-time heap allocation during setup.
Replace static FreeRTOS queue globals in the LibreTiny WiFi component
with the same queue abstraction used by ESP32:
- ESPHOME_THREAD_MULTI_ATOMICS (RTL87xx, LN882x): LockFreeQueue
- ESPHOME_THREAD_MULTI_NO_ATOMICS (BK72xx): new FreeRTOSQueue wrapper
Add FreeRTOSQueue in freertos_queue.h — an xQueue wrapper providing
the same API as LockFreeQueue (push, pop, get_and_reset_dropped_count)
for platforms without hardware atomic instructions.
The event queue is now a class member instead of a static global,
matching the ESP32 pattern.