4#ifdef USE_BINARY_SENSOR
11#ifdef USE_SOCKET_TCP_LISTENER
16#ifdef USE_TCP_UART_MAX_CONNECTIONS
26#ifdef USE_BINARY_SENSOR
27 SUB_BINARY_SENSOR(connected)
30 SUB_SENSOR(disconnects)
36 void set_host(
const char *host) { this->
link_.
set_host(host); }
40#ifdef USE_SOCKET_TCP_LISTENER
42#ifdef USE_SOCKET_IPV4_ALLOW
46#ifdef USE_TCP_UART_MAX_CONNECTIONS
48 void set_max_connections(uint8_t
count);
54 uint16_t turn()
const {
return this->
turn_; }
59#ifdef USE_TCP_UART_MAX_CONNECTIONS
66 void release_turn(uint16_t rest = 0) {
68#ifdef USE_TCP_UART_MAX_CONNECTIONS
74 void setup()
override;
76 void dump_config()
override;
77 void on_shutdown()
override;
80 void write_array(
const uint8_t *data,
size_t len)
override;
81 bool peek_byte(uint8_t *data)
override;
82 bool read_array(uint8_t *data,
size_t len)
override;
83 size_t available()
override {
return static_cast<size_t>(this->
rx_end_ - this->
rx_start_); }
85 size_t available_for_write()
override {
87 return link !=
nullptr ? link->
tx_free() : 0;
90 bool is_connected()
override;
91#if defined(USE_ESP8266) || defined(USE_ESP32) || defined(USE_ZEPHYR)
93 using UARTComponent::load_settings;
97#ifdef USE_TCP_UART_MAX_CONNECTIONS
110#ifdef USE_TCP_UART_MAX_CONNECTIONS
119#ifdef USE_TCP_UART_MAX_CONNECTIONS
120 if (!this->
extra_.empty()) {
126#ifdef USE_TCP_UART_MAX_CONNECTIONS
145#ifdef USE_SOCKET_TCP_LISTENER
152#ifdef USE_TCP_UART_MAX_CONNECTIONS
186#ifdef USE_TCP_UART_MAX_CONNECTIONS
Fixed-capacity vector - sized once through init() or try_init(); push_back never reallocates This avo...
void set_host(const char *host)
void set_port(uint16_t port)
static constexpr size_t TX_BUFFER_SIZE
void set_idle_timeout(uint32_t ms)
0 leaves the link up.
void set_reconnect_interval(uint32_t ms)
A link with its own outgoing buffer.
A link whose outgoing buffer belongs to its owner, so several links can share one.
size_t queue(uint8_t *tx, const uint8_t *data, size_t len)
bool flush_tx(uint8_t *tx)
The server side of a bridged TCP link: owns the listen socket and the allow list.
void set_allow(const Ipv4AllowEntry *entries, size_t count)
TCP client or server presented as a UART. Bytes are copied unchanged.
size_t queue_link_(Link &link, const uint8_t *data, size_t len)
socket::TcpClientLinkSharedTx Link
bool tx_drained_(uint32_t now)
True once the last holder's reply has left the shared TX buffer.
uint16_t turn_timeout_ms_
void loop_pool_(bool waiting)
void check_logger_conflict() override
void end_turn_(uint32_t now)
uint32_t last_traffic_ms_
size_t read_socket_(Link &link, size_t limit=RX_BUFFER_SIZE)
Reads at most limit bytes and returns how many arrived.
void accept_slot_(uint32_t now)
void publish_connected_(bool up)
Link * tx_link_()
The connection that writes go to, or nullptr.
static constexpr size_t RX_BUFFER_SIZE
uint32_t last_drop_log_ms_
bool flush_link_(Link &link)
static constexpr uint8_t NO_SLOT
uint8_t rx_[RX_BUFFER_SIZE]
void read_holder_(uint32_t now)
uint8_t slot_count_() const
void pick_holder_(uint32_t now)
void slot_edge_(uint8_t i)
FixedVector< Link > extra_
uint8_t tx_[Link::TX_BUFFER_SIZE]
socket::TcpListener listener_
void load_settings()
Load the UART settings.
constexpr float AFTER_WIFI
For components that should be initialized after WiFi is connected.
UARTFlushResult
Result of a flush() call.
One allowed IPv4 network, network byte order, host bits cleared.