mirror of
https://github.com/esphome/esphome.git
synced 2025-09-06 13:22:19 +01:00
save 4 bytes since we must store as uint32_t anyways
This commit is contained in:
@@ -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 {
|
||||
|
@@ -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);
|
||||
|
@@ -1857,8 +1857,7 @@ class BluetoothGATTDescriptor : public ProtoMessage {
|
||||
public:
|
||||
std::array<uint64_t, 2> 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<BluetoothGATTDescriptor> 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<uint64_t, 2> uuid{};
|
||||
uint32_t handle{0};
|
||||
std::vector<BluetoothGATTCharacteristic> 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
|
||||
|
@@ -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");
|
||||
|
@@ -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;
|
||||
|
Reference in New Issue
Block a user