14void UartTcp::setup() {
16#ifdef USE_SOCKET_TCP_LISTENER
19#ifdef USE_BINARY_SENSOR
20 PUBLISH_STATE(this->connected_binary_sensor_,
false);
23 PUBLISH_STATE(this->disconnects_sensor_, 0);
27void UartTcp::dump_config() {
31 " Reconnect Interval: %" PRIu32
"ms",
32 this->
server_ ? LOG_STR_LITERAL(
"Listen") : LOG_STR_LITERAL(
"Host"),
33 this->
server_ ? LOG_STR_LITERAL(
"*") : this->
link_.
host(), this->link_.port(),
34 this->link_.reconnect_interval());
35#ifdef USE_SOCKET_TCP_LISTENER
38#ifdef USE_BINARY_SENSOR
39 LOG_BINARY_SENSOR(
" ",
"Connected", this->connected_binary_sensor_);
42 LOG_SENSOR(
" ",
"Disconnects", this->disconnects_sensor_);
46void UartTcp::on_shutdown() {
48#ifdef USE_SOCKET_TCP_LISTENER
60#ifdef USE_BINARY_SENSOR
61 PUBLISH_STATE(this->connected_binary_sensor_, up);
65 if (!up && this->disconnects_sensor_ !=
nullptr) {
67 this->disconnects_sensor_->publish_state(this->
disconnects_);
81 size_t want = std::min(room,
sizeof(tmp));
100 size_t n = std::min(left,
sizeof(dump));
115void UartTcp::loop() {
116#ifdef USE_SOCKET_TCP_LISTENER
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 tx_commit(size_t len)
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.
uint8_t * tx_tail()
Direct access to the buffer's free tail.
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.
size_t paced_write_room(uint32_t last_write_ms)
optional< std::array< uint8_t, N > > read_array()
void write_array(const uint8_t *data, size_t len)
static constexpr size_t DISCARD_CHUNK
socket::TcpClientLink link_
static constexpr size_t READ_CHUNK
socket::TcpListener listener_
ESPHOME_LOG_TAG(TAG, "uart_tcp")
Application App
Global storage of Application pointer - only one Application can exist.