ESPHome 2026.10.1
Loading...
Searching...
No Matches
esphome::serial_proxy::SerialProxyTap Class Referenceabstract

Observes a port's traffic without owning it, and may inject bytes of its own. More...

#include <serial_proxy.h>

Public Member Functions

virtual void on_device_rx (const uint8_t *data, size_t len)=0
 Bytes read from the device, before they are forwarded to any subscriber.
 
virtual void on_client_tx (const uint8_t *data, size_t len)=0
 Bytes a subscriber sent towards the device, after they have been written.
 
virtual bool tap_needs_port () const =0
 True when the port must keep reading even with no subscriber attached, so a tap can do its own protocol work while nobody is listening.
 
virtual void on_protocol_disabled ()=0
 A client explicitly turned protocol handling off for this port.
 

Detailed Description

Observes a port's traffic without owning it, and may inject bytes of its own.

This exists so protocol-aware behaviour can be layered onto a plain byte pipe without the pipe knowing anything about the protocol: the tap is compiled in only when some component asks for one, so a proxy carrying an RS485 meter pays nothing for it.

A tap is an observer, never a gatekeeper – it cannot suppress or alter the bytes flowing in either direction, so a misbehaving tap cannot corrupt the stream.

Definition at line 79 of file serial_proxy.h.

Member Function Documentation

◆ on_client_tx()

virtual void esphome::serial_proxy::SerialProxyTap::on_client_tx ( const uint8_t * data,
size_t len )
pure virtual

Bytes a subscriber sent towards the device, after they have been written.

◆ on_device_rx()

virtual void esphome::serial_proxy::SerialProxyTap::on_device_rx ( const uint8_t * data,
size_t len )
pure virtual

Bytes read from the device, before they are forwarded to any subscriber.

◆ on_protocol_disabled()

virtual void esphome::serial_proxy::SerialProxyTap::on_protocol_disabled ( )
pure virtual

A client explicitly turned protocol handling off for this port.

Distinct from the automatic reset when a session ends: this one means a client intends to do something else with the device – reflash it, most likely – so anything the tap believes about it should be treated as suspect.

◆ tap_needs_port()

virtual bool esphome::serial_proxy::SerialProxyTap::tap_needs_port ( ) const
pure virtual

True when the port must keep reading even with no subscriber attached, so a tap can do its own protocol work while nobody is listening.

Honoured only while no subscriber holds the port; with one attached, the port mode alone decides.


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