12static const char *
const TAG =
"uart_tcp";
15static constexpr uint32_t MAX_PACE_SPAN_MS = 4000;
19#ifdef USE_SOCKET_TCP_LISTENER
22#ifdef USE_BINARY_SENSOR
38 " Reconnect Interval: %" PRIu32
"ms",
39 this->
server_ ? LOG_STR_LITERAL(
"Listen") : LOG_STR_LITERAL(
"Host"),
40 this->
server_ ? LOG_STR_LITERAL(
"*") : this->
link_.
host(), this->link_.port(),
41 this->link_.reconnect_interval());
42#ifdef USE_SOCKET_TCP_LISTENER
45#ifdef USE_BINARY_SENSOR
55#ifdef USE_SOCKET_TCP_LISTENER
67#ifdef USE_BINARY_SENSOR
85 if (room == SIZE_MAX) {
92 room = std::max<size_t>(1, paced);
99 size_t want = std::min(room,
sizeof(tmp));
118 size_t n = std::min(left,
sizeof(dump));
134#ifdef USE_SOCKET_TCP_LISTENER
uint32_t get_loop_interval() const
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.
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.
uint32_t get_baud_rate() const
virtual size_t available_for_write()
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_
sensor::Sensor * disconnects_sensor_
void on_shutdown() override
static constexpr size_t READ_CHUNK
socket::TcpListener listener_
binary_sensor::BinarySensor * connected_sensor_
void dump_config() override
Application App
Global storage of Application pointer - only one Application can exist.