fixed arrays

This commit is contained in:
J. Nick Koston
2025-07-21 12:49:48 -10:00
parent 5343a6d16a
commit 91e1a4ff76
5 changed files with 163 additions and 40 deletions

View File

@@ -1891,21 +1891,19 @@ bool BluetoothGATTGetServicesRequest::decode_varint(uint32_t field_id, ProtoVarI
return true;
}
void BluetoothGATTDescriptor::encode(ProtoWriteBuffer buffer) const {
for (auto &it : this->uuid) {
for (const auto &it : this->uuid) {
buffer.encode_uint64(1, it, true);
}
buffer.encode_uint32(2, this->handle);
}
void BluetoothGATTDescriptor::calculate_size(uint32_t &total_size) const {
if (!this->uuid.empty()) {
for (const auto &it : this->uuid) {
ProtoSize::add_uint64_field_repeated(total_size, 1, it);
}
for (const auto &it : this->uuid) {
ProtoSize::add_uint64_field_repeated(total_size, 1, it);
}
ProtoSize::add_uint32_field(total_size, 1, this->handle);
}
void BluetoothGATTCharacteristic::encode(ProtoWriteBuffer buffer) const {
for (auto &it : this->uuid) {
for (const auto &it : this->uuid) {
buffer.encode_uint64(1, it, true);
}
buffer.encode_uint32(2, this->handle);
@@ -1915,17 +1913,15 @@ void BluetoothGATTCharacteristic::encode(ProtoWriteBuffer buffer) const {
}
}
void BluetoothGATTCharacteristic::calculate_size(uint32_t &total_size) const {
if (!this->uuid.empty()) {
for (const auto &it : this->uuid) {
ProtoSize::add_uint64_field_repeated(total_size, 1, it);
}
for (const auto &it : this->uuid) {
ProtoSize::add_uint64_field_repeated(total_size, 1, it);
}
ProtoSize::add_uint32_field(total_size, 1, this->handle);
ProtoSize::add_uint32_field(total_size, 1, this->properties);
ProtoSize::add_repeated_message(total_size, 1, this->descriptors);
}
void BluetoothGATTService::encode(ProtoWriteBuffer buffer) const {
for (auto &it : this->uuid) {
for (const auto &it : this->uuid) {
buffer.encode_uint64(1, it, true);
}
buffer.encode_uint32(2, this->handle);
@@ -1934,23 +1930,23 @@ void BluetoothGATTService::encode(ProtoWriteBuffer buffer) const {
}
}
void BluetoothGATTService::calculate_size(uint32_t &total_size) const {
if (!this->uuid.empty()) {
for (const auto &it : this->uuid) {
ProtoSize::add_uint64_field_repeated(total_size, 1, it);
}
for (const auto &it : this->uuid) {
ProtoSize::add_uint64_field_repeated(total_size, 1, it);
}
ProtoSize::add_uint32_field(total_size, 1, this->handle);
ProtoSize::add_repeated_message(total_size, 1, this->characteristics);
}
void BluetoothGATTGetServicesResponse::encode(ProtoWriteBuffer buffer) const {
buffer.encode_uint64(1, this->address);
for (auto &it : this->services) {
for (const auto &it : this->services) {
buffer.encode_message(2, it, true);
}
}
void BluetoothGATTGetServicesResponse::calculate_size(uint32_t &total_size) const {
ProtoSize::add_uint64_field(total_size, 1, this->address);
ProtoSize::add_repeated_message(total_size, 1, this->services);
for (const auto &it : this->services) {
ProtoSize::add_message_object_repeated(total_size, 1, it);
}
}
void BluetoothGATTGetServicesDoneResponse::encode(ProtoWriteBuffer buffer) const {
buffer.encode_uint64(1, this->address);