The logger only writes to UART, never reads. Previously it used
tx_buffer_size (512 bytes) for both RX and TX buffers. Since ESP-IDF
requires rx_buffer_size > UART_HW_FIFO_LEN (128), use the minimum
of 129 bytes instead of 512, saving ~383 bytes of heap.
The logger only writes to UART, never reads. Previously it used
tx_buffer_size (512 bytes) for both RX and TX buffers. Since ESP-IDF
requires rx_buffer_size > UART_HW_FIFO_LEN (128), use the minimum
of 129 bytes instead of 512, saving ~383 bytes of heap.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Expose the scheduler's existing 64-bit millisecond tracking as a public
API and use it in the uptime sensors, replacing their manual rollover
handling.
Co-Authored-By: J. Nick Koston <nick@koston.org>
Tracks heap usage per component during both construction and setup() phases.
Logs deltas inline as components are registered and set up, then prints a
sorted summary after setup() completes. Storage is freed after the summary.
This is a diagnostic tool - not intended for production use. It was used to
discover the logger's unused UART event queue allocation (#14168).
The logger's uart_driver_install() was allocating a 10-item FreeRTOS
event queue but passing nullptr as the queue handle, meaning nothing
could ever read from it. Setting the queue size to 0 saves ~212 bytes
of heap.
Replace std::unique_ptr<Socket> with raw Socket* for listen sockets
that are created once in setup() and live for the program lifetime.
The unique_ptr move-assign generates dead code to destroy the previous
value (which is always nullptr in setup), including a virtual destructor
call through the vtable that the compiler cannot eliminate because
__uniq_ptr_impl::reset is not inlined.
Changes:
- Use .release() to extract raw pointer from socket factory return
- Add socket_failed_/server_failed_ helpers that combine error logging,
cleanup, and mark_failed into a single call
- Convert error messages to LOG_STR for flash storage on ESP8266
- Socket destructor already calls close(), so explicit close() before
delete is unnecessary
Saves 20 bytes on ESP32-IDF, 180 bytes on ESP8266.
Resolve conflict in defines.h - keep both new NRF52 defines
(USE_LOGGER_EARLY_MESSAGE, USE_LOGGER_WAIT_FOR_CDC from dev) and
existing defines (USE_LOGGER_UART_SELECTION_USB_CDC, USE_LOGGER_USB_CDC
from this branch).
Reduce CPU usage when USB components are idle by disabling the
component loop when there are no events or data to process. The
loop is re-enabled from USB task callbacks via
enable_loop_soon_any_context() when new events or data arrive.
- Extract process_usb_events_() from USBClient::loop() returning
bool so subclasses can combine with their own work checks for a
single disable_loop() decision
- Add enable_loop_soon_any_context() calls in client_event_cb and
USB data input callback
- Start with loop disabled in setup(), enabled by first event
- Reorder USBClient members by thread-safety context
- Reorder TransferStatus fields for optimal struct packing
- Fix missing early return after mark_failed() in setup()
Reduce CPU usage when USB components are idle by disabling the
component loop when there are no events or data to process. The
loop is re-enabled from USB task callbacks via
enable_loop_soon_any_context() when new events or data arrive.
- Extract process_usb_events_() from USBClient::loop() returning
bool so subclasses can combine with their own work checks for a
single disable_loop() decision
- Add enable_loop_soon_any_context() calls in client_event_cb and
USB data input callback
- Start with loop disabled in setup(), enabled by first event
- Reorder USBClient members by thread-safety context
- Reorder TransferStatus fields for optimal struct packing
- Fix missing early return after mark_failed() in setup()
The logger loop disable optimization was guarded by USE_LOGGER_USB_CDC,
which is a platform capability flag defined whenever the platform
supports USB CDC. This meant the optimization was disabled on all
ESP32-S2, S3, C3, C5, C6, C61, H2, and P4 variants regardless of
whether USB CDC was actually selected as the hardware UART.
Changed all guards to use USE_LOGGER_UART_SELECTION_USB_CDC which is
only defined when USB CDC is the selected hardware UART. Also changed
the guard logic from || to && so the loop only stays permanently active
when both Zephyr AND USB CDC is selected (the only case that needs
cdc_loop_() to poll port readiness).
Additionally set USE_LOGGER_UART_SELECTION_USB_CDC in the Zephyr
codepath when USB CDC is selected, and updated defines.h for static
analysis coverage.