- 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
Replace encode_message with encode_sub_message for protobuf submessage encoding.
For repeated submessage fields, encode_sub_message uses a backpatch approach:
writes field tag, reserves 1 byte for length varint, encodes the body, then
backpatches the actual length. For bodies >= 128 bytes, shifts the body forward
to make room for a multi-byte varint. This eliminates 2 of 3 calculate_size()
calls per repeated submessage element.
For singular submessage fields, encode_sub_message uses calculate_size() upfront
to skip empty submessages without writing to the buffer, preserving the debug
size check.
For the BLE advertisement proxy hot path (16 advertisements per batch), this
reduces calculate_size() calls from 48 to 16 per flush.
Replace encode_message with encode_sub_message for protobuf submessage encoding.
For repeated submessage fields, encode_sub_message uses a backpatch approach:
writes field tag, reserves 1 byte for length varint, encodes the body, then
backpatches the actual length. For bodies >= 128 bytes, shifts the body forward
to make room for a multi-byte varint. This eliminates 2 of 3 calculate_size()
calls per repeated submessage element.
For singular submessage fields, encode_sub_message uses calculate_size() upfront
to skip empty submessages without writing to the buffer, preserving the debug
size check.
For the BLE advertisement proxy hot path (16 advertisements per batch), this
reduces calculate_size() calls from 48 to 16 per flush.
Replace encode_message with encode_sub_message for protobuf submessage encoding.
For repeated submessage fields, encode_sub_message uses a backpatch approach:
writes field tag, reserves 1 byte for length varint, encodes the body, then
backpatches the actual length. For bodies >= 128 bytes, shifts the body forward
to make room for a multi-byte varint. This eliminates 2 of 3 calculate_size()
calls per repeated submessage element.
For singular submessage fields, encode_sub_message uses calculate_size() upfront
to skip empty submessages without writing to the buffer, preserving the debug
size check.
For the BLE advertisement proxy hot path (16 advertisements per batch), this
reduces calculate_size() calls from 48 to 16 per flush.
The is_connected() method is called on every BLE advertisement
in the bluetooth_proxy hot path, but was forced out-of-line by
the state_subscription_only parameter added in #11906.
The default path (no argument) is just `!clients_.empty()` — a
simple pointer comparison. Split into:
- is_connected(): inline in header (common fast path)
- is_connected_with_state_subscription(): out-of-line (rare path)
No callers pass true directly; only APIConnectedCondition uses
the state_subscription_only template value, updated accordingly.
- Fix extract_packed_value regex to handle commas in entity names
by matching C++ string literals instead of [^,]+
- Only describe dc/uom/icon in comments when their index is actually
non-zero, so comment matches what was packed
Move the flag-check early return for status_clear_warning() and
status_clear_error() into inline methods in the header. The slow
path (flag clear + log message) remains out-of-line.
This eliminates a call8 on every poll cycle for components that
call status_clear_warning() unconditionally on success, which is
the common pattern.