- 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.
Tests now verify packed values via comment strings and non-zero
checks rather than decoding individual bit positions. This removes
the coupling to internal bit layout constants.
All internal-flag tests now extract the packed value and verify
bit 24 is set/clear for the correct entities, instead of just
checking configure_entity_() call presence.
All internal-flag tests now extract the packed value and verify
bit 24 is set/clear for the correct entities, instead of just
checking configure_entity_() call presence.
Tests now go through _setup_entity_impl + setup_device_class/
setup_unit_of_measurement + finalize_entity_strings using real
CONF_* keys instead of internal _KEY_* constants.
- Remove hardcoded _ENTITY_CATEGORY_NAMES dict, derive from cv.ENTITY_CATEGORIES keys
- Remove redundant local import re (already at top level)
- Remove last setup_test_environment noqa line