ESPHome  2024.10.2
Data Structures | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes
esphome::api::APIPlaintextFrameHelper Class Reference

#include <api_frame_helper.h>

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

Data Structures

struct  ParsedFrame
 

Public Member Functions

 APIPlaintextFrameHelper (std::unique_ptr< socket::Socket > socket)
 
 ~APIPlaintextFrameHelper () override=default
 
APIError init () override
 Initialize the frame helper, returns OK if successful. More...
 
APIError loop () override
 Not used for plaintext. More...
 
APIError read_packet (ReadPacketBuffer *buffer) override
 
bool can_write_without_blocking () override
 
APIError write_packet (uint16_t type, const uint8_t *payload, size_t len) override
 
std::string getpeername () override
 
int getpeername (struct sockaddr *addr, socklen_t *addrlen) override
 
APIError close () override
 
APIError shutdown (int how) override
 
void set_log_info (std::string info) override
 
- Public Member Functions inherited from esphome::api::APIFrameHelper
virtual ~APIFrameHelper ()=default
 

Protected Types

enum  State { State::INITIALIZE = 1, State::DATA = 2, State::CLOSED = 3, State::FAILED = 4 }
 

Protected Member Functions

APIError try_read_frame_ (ParsedFrame *frame)
 Read a packet into the rx_buf_. More...
 
APIError try_send_tx_buf_ ()
 
APIError write_raw_ (const struct iovec *iov, int iovcnt)
 Write the data to the socket, or buffer it a write would block. More...
 

Protected Attributes

std::unique_ptr< socket::Socketsocket_
 
std::string info_
 
std::vector< uint8_t > rx_header_buf_
 
bool rx_header_parsed_ = false
 
uint32_t rx_header_parsed_type_ = 0
 
uint32_t rx_header_parsed_len_ = 0
 
std::vector< uint8_t > rx_buf_
 
size_t rx_buf_len_ = 0
 
std::vector< uint8_t > tx_buf_
 
enum esphome::api::APIPlaintextFrameHelper::State state_ = State::INITIALIZE
 

Detailed Description

Definition at line 142 of file api_frame_helper.h.

Member Enumeration Documentation

◆ State

Enumerator
INITIALIZE 
DATA 
CLOSED 
FAILED 

Definition at line 182 of file api_frame_helper.h.

Constructor & Destructor Documentation

◆ APIPlaintextFrameHelper()

esphome::api::APIPlaintextFrameHelper::APIPlaintextFrameHelper ( std::unique_ptr< socket::Socket socket)
inline

Definition at line 144 of file api_frame_helper.h.

◆ ~APIPlaintextFrameHelper()

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

Member Function Documentation

◆ can_write_without_blocking()

bool esphome::api::APIPlaintextFrameHelper::can_write_without_blocking ( )
overridevirtual

Implements esphome::api::APIFrameHelper.

Definition at line 905 of file api_frame_helper.cpp.

◆ close()

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

Implements esphome::api::APIFrameHelper.

Definition at line 1011 of file api_frame_helper.cpp.

◆ getpeername() [1/2]

std::string esphome::api::APIPlaintextFrameHelper::getpeername ( )
inlineoverridevirtual

Implements esphome::api::APIFrameHelper.

Definition at line 151 of file api_frame_helper.h.

◆ getpeername() [2/2]

int esphome::api::APIPlaintextFrameHelper::getpeername ( struct sockaddr addr,
socklen_t addrlen 
)
inlineoverridevirtual

Implements esphome::api::APIFrameHelper.

Definition at line 152 of file api_frame_helper.h.

◆ init()

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

Initialize the frame helper, returns OK if successful.

Implements esphome::api::APIFrameHelper.

Definition at line 748 of file api_frame_helper.cpp.

◆ loop()

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

Not used for plaintext.

Implements esphome::api::APIFrameHelper.

Definition at line 771 of file api_frame_helper.cpp.

◆ read_packet()

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

Implements esphome::api::APIFrameHelper.

Definition at line 887 of file api_frame_helper.cpp.

◆ set_log_info()

void esphome::api::APIPlaintextFrameHelper::set_log_info ( std::string  info)
inlineoverridevirtual

Implements esphome::api::APIFrameHelper.

Definition at line 158 of file api_frame_helper.h.

◆ shutdown()

APIError esphome::api::APIPlaintextFrameHelper::shutdown ( int  how)
overridevirtual

Implements esphome::api::APIFrameHelper.

Definition at line 1018 of file api_frame_helper.cpp.

◆ try_read_frame_()

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

Read a packet into the rx_buf_.

If successful, stores frame data in the frame parameter

Parameters
frameThe struct to hold the frame information in. msg: store the parsed frame in that struct
Returns
See APIError

error API_ERROR_BAD_INDICATOR: Bad indicator byte at start of frame.

Definition at line 794 of file api_frame_helper.cpp.

◆ try_send_tx_buf_()

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

Definition at line 927 of file api_frame_helper.cpp.

◆ write_packet()

APIError esphome::api::APIPlaintextFrameHelper::write_packet ( uint16_t  type,
const uint8_t *  payload,
size_t  len 
)
overridevirtual

Implements esphome::api::APIFrameHelper.

Definition at line 906 of file api_frame_helper.cpp.

◆ write_raw_()

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

Write the data to the socket, or buffer it a write would block.

Parameters
dataThe data to write
lenThe length of data

Definition at line 950 of file api_frame_helper.cpp.

Field Documentation

◆ info_

std::string esphome::api::APIPlaintextFrameHelper::info_
protected

Definition at line 171 of file api_frame_helper.h.

◆ rx_buf_

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

Definition at line 177 of file api_frame_helper.h.

◆ rx_buf_len_

size_t esphome::api::APIPlaintextFrameHelper::rx_buf_len_ = 0
protected

Definition at line 178 of file api_frame_helper.h.

◆ rx_header_buf_

std::vector<uint8_t> esphome::api::APIPlaintextFrameHelper::rx_header_buf_
protected

Definition at line 172 of file api_frame_helper.h.

◆ rx_header_parsed_

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

Definition at line 173 of file api_frame_helper.h.

◆ rx_header_parsed_len_

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

Definition at line 175 of file api_frame_helper.h.

◆ rx_header_parsed_type_

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

Definition at line 174 of file api_frame_helper.h.

◆ socket_

std::unique_ptr<socket::Socket> esphome::api::APIPlaintextFrameHelper::socket_
protected

Definition at line 169 of file api_frame_helper.h.

◆ state_

enum esphome::api::APIPlaintextFrameHelper::State esphome::api::APIPlaintextFrameHelper::state_ = State::INITIALIZE
protected

◆ tx_buf_

std::vector<uint8_t> esphome::api::APIPlaintextFrameHelper::tx_buf_
protected

Definition at line 180 of file api_frame_helper.h.


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