1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-31 07:03:55 +00:00
This commit is contained in:
J. Nick Koston
2025-10-28 14:59:42 -05:00
parent 10b24a225c
commit afe628d62c

View File

@@ -230,10 +230,11 @@ class ProtoWriteBuffer {
return;
}
uint8_t *p = this->buffer_->data() + start;
uint8_t *p;
if (value < 16384) {
// 2 bytes
this->buffer_->resize(start + 2);
p = this->buffer_->data() + start;
p[0] = (value & 0x7F) | 0x80;
p[1] = (value >> 7) & 0x7F;
return;
@@ -241,6 +242,7 @@ class ProtoWriteBuffer {
if (value < 2097152) {
// 3 bytes
this->buffer_->resize(start + 3);
p = this->buffer_->data() + start;
p[0] = (value & 0x7F) | 0x80;
p[1] = ((value >> 7) & 0x7F) | 0x80;
p[2] = (value >> 14) & 0x7F;
@@ -249,6 +251,7 @@ class ProtoWriteBuffer {
if (value < 268435456) {
// 4 bytes
this->buffer_->resize(start + 4);
p = this->buffer_->data() + start;
p[0] = (value & 0x7F) | 0x80;
p[1] = ((value >> 7) & 0x7F) | 0x80;
p[2] = ((value >> 14) & 0x7F) | 0x80;
@@ -274,6 +277,7 @@ class ProtoWriteBuffer {
}
this->buffer_->resize(start + size);
p = this->buffer_->data() + start;
size_t bytes = 0;
while (value) {
uint8_t temp = value & 0x7F;