13static constexpr uint32_t DROP_LOG_INTERVAL_MS = 5000;
17#ifdef USE_SOCKET_TCP_LISTENER
34 " Reconnect Interval: %" PRIu32
"ms",
35 this->
server_ ? LOG_STR_LITERAL(
"Listen") : LOG_STR_LITERAL(
"Host"),
36 this->
server_ ? LOG_STR_LITERAL(
"*") : this->
link_.
host(), this->link_.port(),
37 this->link_.reconnect_interval());
38#ifdef USE_SOCKET_TCP_LISTENER
49#ifdef USE_SOCKET_TCP_LISTENER
92 this->rx_end_ +=
static_cast<uint16_t
>(
count);
97#ifdef USE_SOCKET_TCP_LISTENER
125 ESP_LOGW(TAG,
"%s, dropped %u bytes",
126 this->
link_.
connected() ? LOG_STR_LITERAL(
"TX buffer full") : LOG_STR_LITERAL(
"Not connected"),
127 static_cast<unsigned>(
len - queued));
uint32_t IRAM_ATTR HOT get_loop_component_start_time() const
Get the cached time in milliseconds from when the current component started its loop execution.
void publish_state(bool new_state)
Publish a new state to the front-end.
void publish_state(float state)
Publish a new state to the front-end.
const char * host() const
bool flush_tx()
Send the front of the buffer; true once it is empty.
void close()
Close without scheduling a reconnect (shutdown).
ssize_t read(uint8_t *buf, size_t len)
Returns bytes moved, 0 when nothing can move now, -1 when the link dropped.
void begin(const char *tag)
Call from setup(). tag names this link's log lines.
size_t queue(const uint8_t *data, size_t len)
Copy into the outgoing buffer; returns how many bytes fit.
void poll()
Connect state machine; call every loop while acting as a client.
void poll(TcpClientLink &link, bool may_accept)
Server state machine; call every loop.
void begin(const char *tag)
Call from setup(); tag names the log lines.
void dump_config() const
One config line per allowed network.
bool read_array(uint8_t *data, size_t len) override
socket::TcpClientLink link_
void write_array(const uint8_t *data, size_t len) override
size_t available() override
binary_sensor::BinarySensor * connected_sensor_
void dump_config() override
void on_shutdown() override
static constexpr size_t RX_BUFFER_SIZE
uint32_t last_drop_log_ms_
uint8_t rx_[RX_BUFFER_SIZE]
uart::UARTFlushResult flush() override
bool peek_byte(uint8_t *data) override
sensor::Sensor * disconnects_sensor_
socket::TcpListener listener_
ESPHOME_LOG_TAG(TAG, "tcp_uart")
UARTFlushResult
Result of a flush() call.
@ UART_FLUSH_RESULT_SUCCESS
Confirmed: all bytes left the TX FIFO.
@ UART_FLUSH_RESULT_FAILED
Confirmed: driver or hardware error.
@ UART_FLUSH_RESULT_TIMEOUT
Confirmed: timed out before TX completed.
Application App
Global storage of Application pointer - only one Application can exist.