diff --git a/esphome/components/api/api.proto b/esphome/components/api/api.proto index 4103b0976d..4aa5cc4be0 100644 --- a/esphome/components/api/api.proto +++ b/esphome/components/api/api.proto @@ -1485,12 +1485,11 @@ message BluetoothGATTDescriptor { repeated uint64 uuid = 1 [(fixed_array_size) = 2, (fixed_array_skip_zero) = true]; uint32 handle = 2; - // New fields for efficient UUID (v1.12+) - // Only one of uuid, uuid16, or uuid32 will be set. - // uuid16/uuid32 are only used for 16/32-bit UUIDs with v1.12+ clients. + // New field for efficient UUID (v1.12+) + // Only one of uuid or short_uuid will be set. + // short_uuid is used for both 16-bit and 32-bit UUIDs with v1.12+ clients. // 128-bit UUIDs always use the uuid field for backwards compatibility. - uint32 uuid16 = 3; // 16-bit UUID - uint32 uuid32 = 4; // 32-bit UUID + uint32 short_uuid = 3; // 16-bit or 32-bit UUID } message BluetoothGATTCharacteristic { @@ -1499,12 +1498,11 @@ message BluetoothGATTCharacteristic { uint32 properties = 3; repeated BluetoothGATTDescriptor descriptors = 4; - // New fields for efficient UUID (v1.12+) - // Only one of uuid, uuid16, or uuid32 will be set. - // uuid16/uuid32 are only used for 16/32-bit UUIDs with v1.12+ clients. + // New field for efficient UUID (v1.12+) + // Only one of uuid or short_uuid will be set. + // short_uuid is used for both 16-bit and 32-bit UUIDs with v1.12+ clients. // 128-bit UUIDs always use the uuid field for backwards compatibility. - uint32 uuid16 = 5; // 16-bit UUID - uint32 uuid32 = 6; // 32-bit UUID + uint32 short_uuid = 5; // 16-bit or 32-bit UUID } message BluetoothGATTService { @@ -1512,12 +1510,11 @@ message BluetoothGATTService { uint32 handle = 2; repeated BluetoothGATTCharacteristic characteristics = 3; - // New fields for efficient UUID (v1.12+) - // Only one of uuid, uuid16, or uuid32 will be set. - // uuid16/uuid32 are only used for 16/32-bit UUIDs with v1.12+ clients. + // New field for efficient UUID (v1.12+) + // Only one of uuid or short_uuid will be set. + // short_uuid is used for both 16-bit and 32-bit UUIDs with v1.12+ clients. // 128-bit UUIDs always use the uuid field for backwards compatibility. - uint32 uuid16 = 4; // 16-bit UUID - uint32 uuid32 = 5; // 32-bit UUID + uint32 short_uuid = 4; // 16-bit or 32-bit UUID } message BluetoothGATTGetServicesResponse { diff --git a/esphome/components/api/api_pb2.cpp b/esphome/components/api/api_pb2.cpp index b797aa3ca6..29d0f2842c 100644 --- a/esphome/components/api/api_pb2.cpp +++ b/esphome/components/api/api_pb2.cpp @@ -1893,8 +1893,7 @@ void BluetoothGATTDescriptor::encode(ProtoWriteBuffer buffer) const { buffer.encode_uint64(1, this->uuid[1], true); } buffer.encode_uint32(2, this->handle); - buffer.encode_uint32(3, this->uuid16); - buffer.encode_uint32(4, this->uuid32); + buffer.encode_uint32(3, this->short_uuid); } void BluetoothGATTDescriptor::calculate_size(ProtoSize &size) const { if (this->uuid[0] != 0 || this->uuid[1] != 0) { @@ -1902,8 +1901,7 @@ void BluetoothGATTDescriptor::calculate_size(ProtoSize &size) const { size.add_uint64_force(1, this->uuid[1]); } size.add_uint32(1, this->handle); - size.add_uint32(1, this->uuid16); - size.add_uint32(1, this->uuid32); + size.add_uint32(1, this->short_uuid); } void BluetoothGATTCharacteristic::encode(ProtoWriteBuffer buffer) const { if (this->uuid[0] != 0 || this->uuid[1] != 0) { @@ -1915,8 +1913,7 @@ void BluetoothGATTCharacteristic::encode(ProtoWriteBuffer buffer) const { for (auto &it : this->descriptors) { buffer.encode_message(4, it, true); } - buffer.encode_uint32(5, this->uuid16); - buffer.encode_uint32(6, this->uuid32); + buffer.encode_uint32(5, this->short_uuid); } void BluetoothGATTCharacteristic::calculate_size(ProtoSize &size) const { if (this->uuid[0] != 0 || this->uuid[1] != 0) { @@ -1926,8 +1923,7 @@ void BluetoothGATTCharacteristic::calculate_size(ProtoSize &size) const { size.add_uint32(1, this->handle); size.add_uint32(1, this->properties); size.add_repeated_message(1, this->descriptors); - size.add_uint32(1, this->uuid16); - size.add_uint32(1, this->uuid32); + size.add_uint32(1, this->short_uuid); } void BluetoothGATTService::encode(ProtoWriteBuffer buffer) const { if (this->uuid[0] != 0 || this->uuid[1] != 0) { @@ -1938,8 +1934,7 @@ void BluetoothGATTService::encode(ProtoWriteBuffer buffer) const { for (auto &it : this->characteristics) { buffer.encode_message(3, it, true); } - buffer.encode_uint32(4, this->uuid16); - buffer.encode_uint32(5, this->uuid32); + buffer.encode_uint32(4, this->short_uuid); } void BluetoothGATTService::calculate_size(ProtoSize &size) const { if (this->uuid[0] != 0 || this->uuid[1] != 0) { @@ -1948,8 +1943,7 @@ void BluetoothGATTService::calculate_size(ProtoSize &size) const { } size.add_uint32(1, this->handle); size.add_repeated_message(1, this->characteristics); - size.add_uint32(1, this->uuid16); - size.add_uint32(1, this->uuid32); + size.add_uint32(1, this->short_uuid); } void BluetoothGATTGetServicesResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_uint64(1, this->address); diff --git a/esphome/components/api/api_pb2.h b/esphome/components/api/api_pb2.h index 9dd2460166..524674e6ef 100644 --- a/esphome/components/api/api_pb2.h +++ b/esphome/components/api/api_pb2.h @@ -1857,8 +1857,7 @@ class BluetoothGATTDescriptor : public ProtoMessage { public: std::array uuid{}; uint32_t handle{0}; - uint32_t uuid16{0}; - uint32_t uuid32{0}; + uint32_t short_uuid{0}; void encode(ProtoWriteBuffer buffer) const override; void calculate_size(ProtoSize &size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP @@ -1873,8 +1872,7 @@ class BluetoothGATTCharacteristic : public ProtoMessage { uint32_t handle{0}; uint32_t properties{0}; std::vector descriptors{}; - uint32_t uuid16{0}; - uint32_t uuid32{0}; + uint32_t short_uuid{0}; void encode(ProtoWriteBuffer buffer) const override; void calculate_size(ProtoSize &size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP @@ -1888,8 +1886,7 @@ class BluetoothGATTService : public ProtoMessage { std::array uuid{}; uint32_t handle{0}; std::vector characteristics{}; - uint32_t uuid16{0}; - uint32_t uuid32{0}; + uint32_t short_uuid{0}; void encode(ProtoWriteBuffer buffer) const override; void calculate_size(ProtoSize &size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP diff --git a/esphome/components/api/api_pb2_dump.cpp b/esphome/components/api/api_pb2_dump.cpp index 64b88caabc..b212353ad8 100644 --- a/esphome/components/api/api_pb2_dump.cpp +++ b/esphome/components/api/api_pb2_dump.cpp @@ -1561,8 +1561,7 @@ void BluetoothGATTDescriptor::dump_to(std::string &out) const { dump_field(out, "uuid", it, 4); } dump_field(out, "handle", this->handle); - dump_field(out, "uuid16", this->uuid16); - dump_field(out, "uuid32", this->uuid32); + dump_field(out, "short_uuid", this->short_uuid); } void BluetoothGATTCharacteristic::dump_to(std::string &out) const { MessageDumpHelper helper(out, "BluetoothGATTCharacteristic"); @@ -1576,8 +1575,7 @@ void BluetoothGATTCharacteristic::dump_to(std::string &out) const { it.dump_to(out); out.append("\n"); } - dump_field(out, "uuid16", this->uuid16); - dump_field(out, "uuid32", this->uuid32); + dump_field(out, "short_uuid", this->short_uuid); } void BluetoothGATTService::dump_to(std::string &out) const { MessageDumpHelper helper(out, "BluetoothGATTService"); @@ -1590,8 +1588,7 @@ void BluetoothGATTService::dump_to(std::string &out) const { it.dump_to(out); out.append("\n"); } - dump_field(out, "uuid16", this->uuid16); - dump_field(out, "uuid32", this->uuid32); + dump_field(out, "short_uuid", this->short_uuid); } void BluetoothGATTGetServicesResponse::dump_to(std::string &out) const { MessageDumpHelper helper(out, "BluetoothGATTGetServicesResponse"); diff --git a/esphome/components/bluetooth_proxy/bluetooth_connection.cpp b/esphome/components/bluetooth_proxy/bluetooth_connection.cpp index b7326e3a4a..fdc6e9d12a 100644 --- a/esphome/components/bluetooth_proxy/bluetooth_connection.cpp +++ b/esphome/components/bluetooth_proxy/bluetooth_connection.cpp @@ -113,9 +113,9 @@ void BluetoothConnection::send_service_for_discovery_() { // Use 128-bit format for old clients or when UUID is already 128-bit fill_128bit_uuid_array(service_resp.uuid, service_result.uuid); } else if (service_result.uuid.len == ESP_UUID_LEN_16) { - service_resp.uuid16 = service_result.uuid.uuid.uuid16; + service_resp.short_uuid = service_result.uuid.uuid.uuid16; } else if (service_result.uuid.len == ESP_UUID_LEN_32) { - service_resp.uuid32 = service_result.uuid.uuid.uuid32; + service_resp.short_uuid = service_result.uuid.uuid.uuid32; } service_resp.handle = service_result.start_handle; @@ -167,9 +167,9 @@ void BluetoothConnection::send_service_for_discovery_() { // Use 128-bit format for old clients or when UUID is already 128-bit fill_128bit_uuid_array(characteristic_resp.uuid, char_result.uuid); } else if (char_result.uuid.len == ESP_UUID_LEN_16) { - characteristic_resp.uuid16 = char_result.uuid.uuid.uuid16; + characteristic_resp.short_uuid = char_result.uuid.uuid.uuid16; } else if (char_result.uuid.len == ESP_UUID_LEN_32) { - characteristic_resp.uuid32 = char_result.uuid.uuid.uuid32; + characteristic_resp.short_uuid = char_result.uuid.uuid.uuid32; } characteristic_resp.handle = char_result.char_handle; @@ -220,9 +220,9 @@ void BluetoothConnection::send_service_for_discovery_() { // Use 128-bit format for old clients or when UUID is already 128-bit fill_128bit_uuid_array(descriptor_resp.uuid, desc_result.uuid); } else if (desc_result.uuid.len == ESP_UUID_LEN_16) { - descriptor_resp.uuid16 = desc_result.uuid.uuid.uuid16; + descriptor_resp.short_uuid = desc_result.uuid.uuid.uuid16; } else if (desc_result.uuid.len == ESP_UUID_LEN_32) { - descriptor_resp.uuid32 = desc_result.uuid.uuid.uuid32; + descriptor_resp.short_uuid = desc_result.uuid.uuid.uuid32; } descriptor_resp.handle = desc_result.handle;