mirror of
https://github.com/esphome/esphome.git
synced 2025-08-01 07:57:47 +00:00
[api] Remove unused add_fixed_field template function
This commit is contained in:
parent
fc286c8bf4
commit
14e2c85028
@ -225,11 +225,10 @@ void APIConnection::loop() {
|
|||||||
if (this->image_reader_ && this->image_reader_->available() && this->helper_->can_write_without_blocking()) {
|
if (this->image_reader_ && this->image_reader_->available() && this->helper_->can_write_without_blocking()) {
|
||||||
uint32_t to_send = std::min((size_t) MAX_BATCH_PACKET_SIZE, this->image_reader_->available());
|
uint32_t to_send = std::min((size_t) MAX_BATCH_PACKET_SIZE, this->image_reader_->available());
|
||||||
bool done = this->image_reader_->available() == to_send;
|
bool done = this->image_reader_->available() == to_send;
|
||||||
uint32_t msg_size = 0;
|
|
||||||
ProtoSize::add_fixed_field<4>(msg_size, 1, true);
|
|
||||||
// partial message size calculated manually since its a special case
|
// partial message size calculated manually since its a special case
|
||||||
// 1 for the data field, varint for the data size, and the data itself
|
// fixed32 key = 1 (1 byte for field header + 4 bytes for fixed32)
|
||||||
msg_size += 1 + ProtoSize::varint(to_send) + to_send;
|
// bytes data = 2 (1 byte for field header + varint for data size + data itself)
|
||||||
|
uint32_t msg_size = 1 + 4 + 1 + ProtoSize::varint(to_send) + to_send;
|
||||||
ProtoSize::add_bool_field(msg_size, 1, done);
|
ProtoSize::add_bool_field(msg_size, 1, done);
|
||||||
|
|
||||||
auto buffer = this->create_buffer(msg_size);
|
auto buffer = this->create_buffer(msg_size);
|
||||||
|
@ -527,25 +527,6 @@ class ProtoSize {
|
|||||||
total_size += field_id_size + 1;
|
total_size += field_id_size + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Calculates and adds the size of a fixed field to the total message size
|
|
||||||
*
|
|
||||||
* Fixed fields always take exactly N bytes (4 for fixed32/float, 8 for fixed64/double).
|
|
||||||
*
|
|
||||||
* @tparam NumBytes The number of bytes for this fixed field (4 or 8)
|
|
||||||
* @param is_nonzero Whether the value is non-zero
|
|
||||||
*/
|
|
||||||
template<uint32_t NumBytes>
|
|
||||||
static inline void add_fixed_field(uint32_t &total_size, uint32_t field_id_size, bool is_nonzero) {
|
|
||||||
// Skip calculation if value is zero
|
|
||||||
if (!is_nonzero) {
|
|
||||||
return; // No need to update total_size
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fixed fields always take exactly NumBytes
|
|
||||||
total_size += field_id_size + NumBytes;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Calculates and adds the size of a float field to the total message size
|
* @brief Calculates and adds the size of a float field to the total message size
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user