ESPHome 2026.2.2
Loading...
Searching...
No Matches
esphome::api::APIPlaintextFrameHelper Class Referencefinal

#include <api_frame_helper_plaintext.h>

Inheritance diagram for esphome::api::APIPlaintextFrameHelper:
esphome::api::APIFrameHelper

Public Member Functions

 APIPlaintextFrameHelper (std::unique_ptr< socket::Socket > socket)
 
 ~APIPlaintextFrameHelper () override=default
 
APIError init () override
 Initialize the frame helper, returns OK if successful.
 
APIError loop () override
 
APIError read_packet (ReadPacketBuffer *buffer) override
 
APIError write_protobuf_packet (uint8_t type, ProtoWriteBuffer buffer) override
 
APIError write_protobuf_messages (ProtoWriteBuffer buffer, std::span< const MessageInfo > messages) override
 
- Public Member Functions inherited from esphome::api::APIFrameHelper
 APIFrameHelper ()=default
 
 APIFrameHelper (std::unique_ptr< socket::Socket > socket)
 
const char * get_client_name () const
 
const char * get_peername_to (std::span< char, socket::SOCKADDR_STR_LEN > buf) const
 
void set_client_name (const char *name, size_t len)
 
virtual ~APIFrameHelper ()=default
 
bool can_write_without_blocking ()
 
int getpeername (struct sockaddr *addr, socklen_t *addrlen)
 
APIError close ()
 
APIError shutdown (int how)
 
void set_nodelay_for_message (bool is_log_message)
 
uint8_t frame_header_padding () const
 
uint8_t frame_footer_size () const
 
bool is_socket_ready () const
 
void release_buffers ()
 

Protected Member Functions

APIError try_read_frame_ ()
 Read a packet into the rx_buf_.
 
- Protected Member Functions inherited from esphome::api::APIFrameHelper
APIError write_raw_ (const struct iovec *iov, int iovcnt, uint16_t total_write_len)
 
APIError try_send_tx_buf_ ()
 
void buffer_data_from_iov_ (const struct iovec *iov, int iovcnt, uint16_t total_write_len, uint16_t offset)
 
APIError handle_socket_write_error_ ()
 
template<typename StateEnum >
APIError write_raw_ (const struct iovec *iov, int iovcnt, socket::Socket *socket, std::vector< uint8_t > &tx_buf, const std::string &info, StateEnum &state, StateEnum failed_state)
 
void set_nodelay_raw_ (bool enable)
 
APIError init_common_ ()
 
APIError handle_socket_read_result_ (ssize_t received)
 

Protected Attributes

uint16_t rx_header_parsed_type_ = 0
 
uint16_t rx_header_parsed_len_ = 0
 
uint8_t rx_header_buf_ [6]
 
uint8_t rx_header_buf_pos_ = 0
 
bool rx_header_parsed_ = false
 
- Protected Attributes inherited from esphome::api::APIFrameHelper
std::unique_ptr< socket::Socketsocket_
 
std::array< std::unique_ptr< SendBuffer >, API_MAX_SEND_QUEUE > tx_buf_
 
std::vector< uint8_t > rx_buf_
 
char client_name_ [CLIENT_INFO_NAME_MAX_LEN] {}
 
uint16_t rx_buf_len_ = 0
 
State state_ {State::INITIALIZE}
 
uint8_t frame_header_padding_ {0}
 
uint8_t frame_footer_size_ {0}
 
uint8_t tx_buf_head_ {0}
 
uint8_t tx_buf_tail_ {0}
 
uint8_t tx_buf_count_ {0}
 
int8_t nodelay_state_ {NODELAY_ON}
 

Additional Inherited Members

- Protected Types inherited from esphome::api::APIFrameHelper
enum class  State : uint8_t {
  INITIALIZE = 1 , CLIENT_HELLO = 2 , SERVER_HELLO = 3 , HANDSHAKE = 4 ,
  DATA = 5 , CLOSED = 6 , FAILED = 7 , EXPLICIT_REJECT = 8
}
 
- Static Protected Attributes inherited from esphome::api::APIFrameHelper
static constexpr int8_t NODELAY_ON = -1
 
static constexpr int8_t LOG_NAGLE_COUNT = 2
 

Detailed Description

Definition at line 8 of file api_frame_helper_plaintext.h.

Constructor & Destructor Documentation

◆ APIPlaintextFrameHelper()

esphome::api::APIPlaintextFrameHelper::APIPlaintextFrameHelper ( std::unique_ptr< socket::Socket > socket)
inlineexplicit

Definition at line 10 of file api_frame_helper_plaintext.h.

◆ ~APIPlaintextFrameHelper()

esphome::api::APIPlaintextFrameHelper::~APIPlaintextFrameHelper ( )
overridedefault

Member Function Documentation

◆ init()

APIError esphome::api::APIPlaintextFrameHelper::init ( )
overridevirtual

Initialize the frame helper, returns OK if successful.

Implements esphome::api::APIFrameHelper.

Definition at line 54 of file api_frame_helper_plaintext.cpp.

◆ loop()

APIError esphome::api::APIPlaintextFrameHelper::loop ( )
overridevirtual

Reimplemented from esphome::api::APIFrameHelper.

Definition at line 63 of file api_frame_helper_plaintext.cpp.

◆ read_packet()

APIError esphome::api::APIPlaintextFrameHelper::read_packet ( ReadPacketBuffer * buffer)
overridevirtual

Implements esphome::api::APIFrameHelper.

Definition at line 196 of file api_frame_helper_plaintext.cpp.

◆ try_read_frame_()

APIError esphome::api::APIPlaintextFrameHelper::try_read_frame_ ( )
protected

Read a packet into the rx_buf_.

Returns
See APIError

error API_ERROR_BAD_INDICATOR: Bad indicator byte at start of frame.

Definition at line 77 of file api_frame_helper_plaintext.cpp.

◆ write_protobuf_messages()

APIError esphome::api::APIPlaintextFrameHelper::write_protobuf_messages ( ProtoWriteBuffer buffer,
std::span< const MessageInfo > messages )
overridevirtual

Implements esphome::api::APIFrameHelper.

Definition at line 244 of file api_frame_helper_plaintext.cpp.

◆ write_protobuf_packet()

APIError esphome::api::APIPlaintextFrameHelper::write_protobuf_packet ( uint8_t type,
ProtoWriteBuffer buffer )
overridevirtual

Implements esphome::api::APIFrameHelper.

Definition at line 239 of file api_frame_helper_plaintext.cpp.

Field Documentation

◆ rx_header_buf_

uint8_t esphome::api::APIPlaintextFrameHelper::rx_header_buf_[6]
protected

Definition at line 41 of file api_frame_helper_plaintext.h.

◆ rx_header_buf_pos_

uint8_t esphome::api::APIPlaintextFrameHelper::rx_header_buf_pos_ = 0
protected

Definition at line 42 of file api_frame_helper_plaintext.h.

◆ rx_header_parsed_

bool esphome::api::APIPlaintextFrameHelper::rx_header_parsed_ = false
protected

Definition at line 43 of file api_frame_helper_plaintext.h.

◆ rx_header_parsed_len_

uint16_t esphome::api::APIPlaintextFrameHelper::rx_header_parsed_len_ = 0
protected

Definition at line 30 of file api_frame_helper_plaintext.h.

◆ rx_header_parsed_type_

uint16_t esphome::api::APIPlaintextFrameHelper::rx_header_parsed_type_ = 0
protected

Definition at line 29 of file api_frame_helper_plaintext.h.


The documentation for this class was generated from the following files: