mirror of
https://github.com/esphome/esphome.git
synced 2025-10-08 12:53:45 +01:00
preen
This commit is contained in:
@@ -175,9 +175,9 @@ APIError APINoiseFrameHelper::try_read_frame_() {
|
|||||||
return APIError::BAD_HANDSHAKE_PACKET_LEN;
|
return APIError::BAD_HANDSHAKE_PACKET_LEN;
|
||||||
}
|
}
|
||||||
|
|
||||||
// reserve space for body
|
// Reserve space for body
|
||||||
if (rx_buf_.size() != msg_size) {
|
if (this->rx_buf_.size() != msg_size) {
|
||||||
rx_buf_.resize(msg_size);
|
this->rx_buf_.resize(msg_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rx_buf_len_ < msg_size) {
|
if (rx_buf_len_ < msg_size) {
|
||||||
@@ -233,7 +233,6 @@ APIError APINoiseFrameHelper::state_action_() {
|
|||||||
this->prologue_[old_size] = (uint8_t) (this->rx_buf_.size() >> 8);
|
this->prologue_[old_size] = (uint8_t) (this->rx_buf_.size() >> 8);
|
||||||
this->prologue_[old_size + 1] = (uint8_t) this->rx_buf_.size();
|
this->prologue_[old_size + 1] = (uint8_t) this->rx_buf_.size();
|
||||||
std::memcpy(this->prologue_.data() + old_size + 2, this->rx_buf_.data(), this->rx_buf_.size());
|
std::memcpy(this->prologue_.data() + old_size + 2, this->rx_buf_.data(), this->rx_buf_.size());
|
||||||
this->rx_buf_.clear();
|
|
||||||
|
|
||||||
state_ = State::SERVER_HELLO;
|
state_ = State::SERVER_HELLO;
|
||||||
}
|
}
|
||||||
@@ -300,7 +299,6 @@ APIError APINoiseFrameHelper::state_action_() {
|
|||||||
return handle_noise_error_(err, LOG_STR("noise_handshakestate_read_message"),
|
return handle_noise_error_(err, LOG_STR("noise_handshakestate_read_message"),
|
||||||
APIError::HANDSHAKESTATE_READ_FAILED);
|
APIError::HANDSHAKESTATE_READ_FAILED);
|
||||||
}
|
}
|
||||||
this->rx_buf_.clear();
|
|
||||||
|
|
||||||
aerr = check_handshake_finished_();
|
aerr = check_handshake_finished_();
|
||||||
if (aerr != APIError::OK)
|
if (aerr != APIError::OK)
|
||||||
@@ -412,7 +410,6 @@ APIError APINoiseFrameHelper::read_packet(ReadPacketBuffer *buffer) {
|
|||||||
buffer->data_offset = 4;
|
buffer->data_offset = 4;
|
||||||
buffer->data_len = data_len;
|
buffer->data_len = data_len;
|
||||||
buffer->type = type;
|
buffer->type = type;
|
||||||
this->rx_buf_.clear();
|
|
||||||
return APIError::OK;
|
return APIError::OK;
|
||||||
}
|
}
|
||||||
APIError APINoiseFrameHelper::write_protobuf_packet(uint8_t type, ProtoWriteBuffer buffer) {
|
APIError APINoiseFrameHelper::write_protobuf_packet(uint8_t type, ProtoWriteBuffer buffer) {
|
||||||
|
@@ -142,9 +142,9 @@ APIError APIPlaintextFrameHelper::try_read_frame_() {
|
|||||||
}
|
}
|
||||||
// header reading done
|
// header reading done
|
||||||
|
|
||||||
// reserve space for body
|
// Reserve space for body
|
||||||
if (rx_buf_.size() != rx_header_parsed_len_) {
|
if (this->rx_buf_.size() != this->rx_header_parsed_len_) {
|
||||||
rx_buf_.resize(rx_header_parsed_len_);
|
this->rx_buf_.resize(this->rx_header_parsed_len_);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rx_buf_len_ < rx_header_parsed_len_) {
|
if (rx_buf_len_ < rx_header_parsed_len_) {
|
||||||
@@ -214,7 +214,6 @@ APIError APIPlaintextFrameHelper::read_packet(ReadPacketBuffer *buffer) {
|
|||||||
buffer->data_offset = 0;
|
buffer->data_offset = 0;
|
||||||
buffer->data_len = this->rx_header_parsed_len_;
|
buffer->data_len = this->rx_header_parsed_len_;
|
||||||
buffer->type = this->rx_header_parsed_type_;
|
buffer->type = this->rx_header_parsed_type_;
|
||||||
this->rx_buf_.clear();
|
|
||||||
return APIError::OK;
|
return APIError::OK;
|
||||||
}
|
}
|
||||||
APIError APIPlaintextFrameHelper::write_protobuf_packet(uint8_t type, ProtoWriteBuffer buffer) {
|
APIError APIPlaintextFrameHelper::write_protobuf_packet(uint8_t type, ProtoWriteBuffer buffer) {
|
||||||
|
Reference in New Issue
Block a user