ESPHome 2025.6.3
Loading...
Searching...
No Matches
esphome::api::APIFrameHelper Class Referenceabstract

#include <api_frame_helper.h>

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

Data Structures

struct  ParsedFrame
 
struct  SendBuffer
 

Public Member Functions

 APIFrameHelper ()=default
 
 APIFrameHelper (std::unique_ptr< socket::Socket > socket)
 
virtual ~APIFrameHelper ()=default
 
virtual APIError init ()=0
 
virtual APIError loop ()=0
 
virtual APIError read_packet (ReadPacketBuffer *buffer)=0
 
bool can_write_without_blocking ()
 
std::string getpeername ()
 
int getpeername (struct sockaddr *addr, socklen_t *addrlen)
 
APIError close ()
 
APIError shutdown (int how)
 
void set_log_info (std::string info)
 
virtual APIError write_protobuf_packet (uint16_t type, ProtoWriteBuffer buffer)=0
 
virtual APIError write_protobuf_packets (ProtoWriteBuffer buffer, const std::vector< PacketInfo > &packets)=0
 
virtual uint8_t frame_header_padding ()=0
 
virtual uint8_t frame_footer_size ()=0
 
bool is_socket_ready () const
 

Protected Types

enum class  State {
  INITIALIZE = 1 , CLIENT_HELLO = 2 , SERVER_HELLO = 3 , HANDSHAKE = 4 ,
  DATA = 5 , CLOSED = 6 , FAILED = 7 , EXPLICIT_REJECT = 8
}
 

Protected Member Functions

APIError write_raw_ (const struct iovec *iov, int iovcnt)
 
APIError try_send_tx_buf_ ()
 
void buffer_data_from_iov_ (const struct iovec *iov, int iovcnt, uint16_t total_write_len)
 
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)
 
APIError init_common_ ()
 

Protected Attributes

std::deque< SendBuffertx_buf_
 
State state_ {State::INITIALIZE}
 
std::string info_
 
socket::Socketsocket_ {nullptr}
 
std::unique_ptr< socket::Socketsocket_owned_
 
uint8_t frame_header_padding_ {0}
 
uint8_t frame_footer_size_ {0}
 
std::vector< struct iovecreusable_iovs_
 
std::vector< uint8_t > rx_buf_
 
uint16_t rx_buf_len_ = 0
 

Detailed Description

Definition at line 69 of file api_frame_helper.h.

Member Enumeration Documentation

◆ State

enum class esphome::api::APIFrameHelper::State
strongprotected
Enumerator
INITIALIZE 
CLIENT_HELLO 
SERVER_HELLO 
HANDSHAKE 
DATA 
CLOSED 
FAILED 
EXPLICIT_REJECT 

Definition at line 139 of file api_frame_helper.h.

Constructor & Destructor Documentation

◆ APIFrameHelper() [1/2]

esphome::api::APIFrameHelper::APIFrameHelper ( )
default

◆ APIFrameHelper() [2/2]

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

Definition at line 72 of file api_frame_helper.h.

◆ ~APIFrameHelper()

virtual esphome::api::APIFrameHelper::~APIFrameHelper ( )
virtualdefault

Member Function Documentation

◆ buffer_data_from_iov_()

void esphome::api::APIFrameHelper::buffer_data_from_iov_ ( const struct iovec * iov,
int iovcnt,
uint16_t total_write_len )
protected

Definition at line 70 of file api_frame_helper.cpp.

◆ can_write_without_blocking()

bool esphome::api::APIFrameHelper::can_write_without_blocking ( )
inline

Definition at line 79 of file api_frame_helper.h.

◆ close()

APIError esphome::api::APIFrameHelper::close ( )
inline

Definition at line 82 of file api_frame_helper.h.

◆ frame_footer_size()

virtual uint8_t esphome::api::APIFrameHelper::frame_footer_size ( )
pure virtual

◆ frame_header_padding()

virtual uint8_t esphome::api::APIFrameHelper::frame_header_padding ( )
pure virtual

◆ getpeername() [1/2]

std::string esphome::api::APIFrameHelper::getpeername ( )
inline

Definition at line 80 of file api_frame_helper.h.

◆ getpeername() [2/2]

int esphome::api::APIFrameHelper::getpeername ( struct sockaddr * addr,
socklen_t * addrlen )
inline

Definition at line 81 of file api_frame_helper.h.

◆ init()

virtual APIError esphome::api::APIFrameHelper::init ( )
pure virtual

◆ init_common_()

APIError esphome::api::APIFrameHelper::init_common_ ( )
protected

Definition at line 194 of file api_frame_helper.cpp.

◆ is_socket_ready()

bool esphome::api::APIFrameHelper::is_socket_ready ( ) const
inline

Definition at line 110 of file api_frame_helper.h.

◆ loop()

virtual APIError esphome::api::APIFrameHelper::loop ( )
pure virtual

◆ read_packet()

virtual APIError esphome::api::APIFrameHelper::read_packet ( ReadPacketBuffer * buffer)
pure virtual

◆ set_log_info()

void esphome::api::APIFrameHelper::set_log_info ( std::string info)
inline

Definition at line 99 of file api_frame_helper.h.

◆ shutdown()

APIError esphome::api::APIFrameHelper::shutdown ( int how)
inline

Definition at line 89 of file api_frame_helper.h.

◆ try_send_tx_buf_()

APIError esphome::api::APIFrameHelper::try_send_tx_buf_ ( )
protected

Definition at line 155 of file api_frame_helper.cpp.

◆ write_protobuf_packet()

virtual APIError esphome::api::APIFrameHelper::write_protobuf_packet ( uint16_t type,
ProtoWriteBuffer buffer )
pure virtual

◆ write_protobuf_packets()

virtual APIError esphome::api::APIFrameHelper::write_protobuf_packets ( ProtoWriteBuffer buffer,
const std::vector< PacketInfo > & packets )
pure virtual

◆ write_raw_() [1/2]

APIError esphome::api::APIFrameHelper::write_raw_ ( const struct iovec * iov,
int iovcnt )
protected

Definition at line 81 of file api_frame_helper.cpp.

◆ write_raw_() [2/2]

template<typename StateEnum >
APIError esphome::api::APIFrameHelper::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 )
protected

Field Documentation

◆ frame_footer_size_

uint8_t esphome::api::APIFrameHelper::frame_footer_size_ {0}
protected

Definition at line 173 of file api_frame_helper.h.

◆ frame_header_padding_

uint8_t esphome::api::APIFrameHelper::frame_header_padding_ {0}
protected

Definition at line 172 of file api_frame_helper.h.

◆ info_

std::string esphome::api::APIFrameHelper::info_
protected

Definition at line 154 of file api_frame_helper.h.

◆ reusable_iovs_

std::vector<struct iovec> esphome::api::APIFrameHelper::reusable_iovs_
protected

Definition at line 176 of file api_frame_helper.h.

◆ rx_buf_

std::vector<uint8_t> esphome::api::APIFrameHelper::rx_buf_
protected

Definition at line 179 of file api_frame_helper.h.

◆ rx_buf_len_

uint16_t esphome::api::APIFrameHelper::rx_buf_len_ = 0
protected

Definition at line 180 of file api_frame_helper.h.

◆ socket_

socket::Socket* esphome::api::APIFrameHelper::socket_ {nullptr}
protected

Definition at line 157 of file api_frame_helper.h.

◆ socket_owned_

std::unique_ptr<socket::Socket> esphome::api::APIFrameHelper::socket_owned_
protected

Definition at line 158 of file api_frame_helper.h.

◆ state_

State esphome::api::APIFrameHelper::state_ {State::INITIALIZE}
protected

Definition at line 151 of file api_frame_helper.h.

◆ tx_buf_

std::deque<SendBuffer> esphome::api::APIFrameHelper::tx_buf_
protected

Definition at line 129 of file api_frame_helper.h.


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