diff --git a/esphome/components/bluetooth_proxy/bluetooth_connection.cpp b/esphome/components/bluetooth_proxy/bluetooth_connection.cpp index 1f4bfd9806..2f350d74fc 100644 --- a/esphome/components/bluetooth_proxy/bluetooth_connection.cpp +++ b/esphome/components/bluetooth_proxy/bluetooth_connection.cpp @@ -297,14 +297,13 @@ void BluetoothConnection::send_service_for_discovery_() { int size_diff = (int) service_size - (int) estimated_size; ESP_LOGV(TAG, "[%d] [%s] Service %d actual: %d, estimated: %d, diff: %+d", this->connection_index_, this->address_str().c_str(), this->send_service_, service_size, estimated_size, size_diff); - ESP_LOGV(TAG, "[%d] [%s] Total size now: %d", this->connection_index_, this->address_str().c_str(), current_size); // Successfully added this service, increment counter this->send_service_++; } // Send the message with dynamically batched services - ESP_LOGD(TAG, "[%d] [%s] Sending batch with %d services, total size %d", this->connection_index_, + ESP_LOGV(TAG, "[%d] [%s] Sending batch with %d services, total size %d", this->connection_index_, this->address_str().c_str(), resp.services.size(), current_size); api_conn->send_message(resp, api::BluetoothGATTGetServicesResponse::MESSAGE_TYPE); } diff --git a/script/api_protobuf/api_protobuf.py b/script/api_protobuf/api_protobuf.py index 9424f4bbab..f21d344527 100755 --- a/script/api_protobuf/api_protobuf.py +++ b/script/api_protobuf/api_protobuf.py @@ -1122,6 +1122,18 @@ class FixedArrayRepeatedType(TypeInfo): ] return f"if ({non_zero_checks}) {{\n" + "\n".join(encode_lines) + "\n}" + # If skip_zero is enabled, wrap encoding in a zero check + if self.skip_zero: + # Build the condition to check if at least one element is non-zero + non_zero_checks = " || ".join( + [f"this->{self.field_name}[{i}] != 0" for i in range(self.array_size)] + ) + encode_lines = [ + f" {encode_element(f'this->{self.field_name}[{i}]')}" + for i in range(self.array_size) + ] + return f"if ({non_zero_checks}) {{\n" + "\n".join(encode_lines) + "\n}" + # Unroll small arrays for efficiency if self.array_size == 1: return encode_element(f"this->{self.field_name}[0]")