Avoid calling reserve() when capacity is already sufficient.
After warmup, resize() becomes just a compare + store with no
function call overhead on the hot path.
The API protobuf write path uses a shared buffer that gets resize()'d on
every message send. std::vector::resize() zero-fills new bytes, but every
byte is overwritten by the encoder before being read. For a 16-advertisement
BLE proxy batch, this wastes ~1300 bytes of memset per flush (~10x/second).
ProtoByteBuffer is a minimal replacement that skips zero-initialization on
resize(). On ESP32/RP2040/LibreTiny it also skips zero-fill on allocation
via make_unique_for_overwrite. On ESP8266 it falls back to make_unique
(zero-fills on alloc, but resize still doesn't zero-fill — the main win
is preserved since reserve is typically a no-op after warmup).
Remove value-initialization ({}) from StaticVector's underlying
std::array. Only elements [0, count_) are ever accessed, so
initializing the full array is wasted work.
This eliminates a memset on every construction. Most impactful for
stack-allocated StaticVectors in hot paths like
APIPlaintextFrameHelper::write_protobuf_messages, which was
memsetting 276 bytes of iovec storage on every BLE proxy flush.
Move ble_addr_to_uint64 from ble.cpp to ble.h as inline. This
eliminates the indirect call and Xtensa register window rotation
at all 3 call sites, most importantly in the BLE proxy hot path
(BluetoothProxy::parse_devices) which calls it per advertisement.
Saves 24 bytes of flash overall.
- Pass line_callbacks through to run_external_process so the crystal
frequency warning works when ESPHOME_USE_SUBPROCESS is set
- Fix filter_lines type annotation from str to list[str] to match
actual usage
The line buffering and callback processing only ran when a filter
pattern was configured. Enter the line processing branch whenever
line_callbacks are registered too.
When flashing an ESP32 via serial, esptool prints the detected crystal
frequency. This change parses that output in real-time and warns the
user if it doesn't match the configured CONFIG_XTAL_FREQ in sdkconfig.
This is particularly important for ESP32-C2 (ESP8684) boards where
some modules use 26MHz crystals but the default sdkconfig assumes 40MHz,
causing UART logging and other clock-dependent features to silently fail.
Also adds a generic line_callbacks mechanism to RedirectText so future
output-based checks can be added without modifying the class directly.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add null check for api_connection_ before sending response
- Clamp uint32_t protobuf fields to uint16_t range for BLE spec
- Include connection index and address in warning log message
Change update_conn_params_ to return esp_err_t so the actual error
from esp_ble_gap_update_conn_params() is propagated back to the
API caller instead of always returning ESP_OK.
Add support for setting BLE connection parameters (min/max interval,
latency, supervision timeout) on connected devices via the native API.
This allows integrations like yalexs-ble to reduce battery drain on
"Always Connected" BLE devices by switching from fast connection intervals
to slower ones after connection is established.
Adds new BluetoothSetConnectionParamsRequest/Response protobuf messages
(IDs 145/146) and routes them through the bluetooth proxy to call
esp_ble_gap_update_conn_params() on the ESP32.
Related: home-assistant/core#153977