|
ESPHome 2026.11.0-dev
|
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_enabled ()=0 |
| A client turned protocol handling on for this port. | |
| virtual void | on_protocol_disabled ()=0 |
| A client explicitly turned protocol handling off for this port. | |
| virtual void | on_device_disconnected ()=0 |
| The device behind the port went away – unplugged, or its power was cut. | |
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 85 of file serial_proxy.h.
|
pure virtual |
Bytes a subscriber sent towards the device, after they have been written.
Implemented in esphome::ezsp_proxy_tap::EzspProxyTap.
|
pure virtual |
The device behind the port went away – unplugged, or its power was cut.
Whatever session the tap had observed ended with it; the device that appears next starts from scratch and may not even be the same one. Only a USB UART can report this.
Implemented in esphome::ezsp_proxy_tap::EzspProxyTap.
|
pure virtual |
Bytes read from the device, before they are forwarded to any subscriber.
Implemented in esphome::ezsp_proxy_tap::EzspProxyTap.
|
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.
Implemented in esphome::ezsp_proxy_tap::EzspProxyTap.
|
pure virtual |
A client turned protocol handling on for this port.
The tap has seen none of the traffic since it was last on, so anything it remembers from then is stale.
Implemented in esphome::ezsp_proxy_tap::EzspProxyTap.
|
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.
Implemented in esphome::ezsp_proxy_tap::EzspProxyTap.