43 if (this->
count_ >= API_MAX_SEND_QUEUE)
46 uint16_t buffer_size = total_len - skip;
48 auto *entry =
new Entry{
new uint8_t[buffer_size], buffer_size, 0};
51 uint16_t to_skip = skip;
52 uint16_t write_pos = 0;
54 for (
int i = 0; i < iovcnt; i++) {
55 if (to_skip >= iov[i].iov_len) {
56 to_skip -=
static_cast<uint16_t
>(iov[i].
iov_len);
58 const uint8_t *src =
reinterpret_cast<uint8_t *
>(iov[i].
iov_base) + to_skip;
59 uint16_t
len =
static_cast<uint16_t
>(iov[i].
iov_len) - to_skip;
60 std::memcpy(entry->data + write_pos, src,
len);
66 this->
tail_ = (this->
tail_ + 1) % API_MAX_SEND_QUEUE;
A single heap-allocated send-backlog entry.
uint16_t remaining() const
const uint8_t * current_data() const
static ESPHOME_ALWAYS_INLINE void destroy(Entry *entry)
Free this entry and its data buffer.