[serial_proxy] Make port mode protocol-neutral

Rename SERIAL_PROXY_MODE_EZSP_ASH to SERIAL_PROXY_MODE_PROTOCOL so the
serial_proxy API surface carries no protocol-specific names. The mode now
means "the port's tap is active"; which protocol the tap speaks is a
property of the device configuration, discoverable from the tap
component's own API surface. Future protocol taps need no serial_proxy
or API changes.
This commit is contained in:
kbx81
2026-09-02 14:19:52 -05:00
parent 1cc48bfee2
commit 5e79c617e8
7 changed files with 20 additions and 16 deletions
+7 -4
View File
@@ -2845,12 +2845,15 @@ message SerialProxyRequestResponse {
string error_message = 4; // Additional detail on failure (optional)
}
// How a port treats the bytes passing through it. RAW is a plain byte pipe; EZSP_ASH lets
// a protocol-aware tap acknowledge NCP frames and read network metadata. A client that is
// about to flash firmware selects RAW first, which definitively disables that injection.
// How a port treats the bytes passing through it. RAW is a plain byte pipe; PROTOCOL
// activates the port's protocol-aware tap (if one is configured), letting it observe
// traffic and inject protocol bytes such as acknowledgements. Which protocol the tap
// speaks is a property of the device configuration, discoverable from the tap
// component's own API surface. A client that is about to flash firmware selects RAW
// first, which definitively disables that injection.
enum SerialProxyMode {
SERIAL_PROXY_MODE_RAW = 0;
SERIAL_PROXY_MODE_EZSP_ASH = 1;
SERIAL_PROXY_MODE_PROTOCOL = 1;
}
message SerialProxySetModeRequest {
+1 -1
View File
@@ -368,7 +368,7 @@ enum SerialProxyStatus : uint32_t {
};
enum SerialProxyMode : uint32_t {
SERIAL_PROXY_MODE_RAW = 0,
SERIAL_PROXY_MODE_EZSP_ASH = 1,
SERIAL_PROXY_MODE_PROTOCOL = 1,
};
#endif
#ifdef USE_ZIGBEE_PROXY
+2 -2
View File
@@ -882,8 +882,8 @@ template<> const char *proto_enum_to_string<enums::SerialProxyMode>(enums::Seria
switch (value) {
case enums::SERIAL_PROXY_MODE_RAW:
return ESPHOME_PSTR("SERIAL_PROXY_MODE_RAW");
case enums::SERIAL_PROXY_MODE_EZSP_ASH:
return ESPHOME_PSTR("SERIAL_PROXY_MODE_EZSP_ASH");
case enums::SERIAL_PROXY_MODE_PROTOCOL:
return ESPHOME_PSTR("SERIAL_PROXY_MODE_PROTOCOL");
default:
return ESPHOME_PSTR("UNKNOWN");
}
+5 -4
View File
@@ -41,12 +41,13 @@ SERIAL_PROXY_PORT_TYPES = {
}
SerialProxyMode = api_enums_ns.enum("SerialProxyMode")
# The mode a port starts in. `raw` is a plain byte pipe; `ezsp_ash` lets a tap
# acknowledge NCP frames and read network metadata off the wire. Clients may change
# it at runtime, so this only decides what the device boots into.
# The mode a port starts in. `raw` is a plain byte pipe; `protocol` activates the
# port's tap (if one is configured), letting it observe traffic and inject protocol
# bytes such as acknowledgements. Clients may change it at runtime, so this only
# decides what the device boots into.
SERIAL_PROXY_MODES = {
"RAW": SerialProxyMode.SERIAL_PROXY_MODE_RAW,
"EZSP_ASH": SerialProxyMode.SERIAL_PROXY_MODE_EZSP_ASH,
"PROTOCOL": SerialProxyMode.SERIAL_PROXY_MODE_PROTOCOL,
}
CONF_DTR_PIN = "dtr_pin"
@@ -130,7 +130,7 @@ bool SerialProxy::tap_observing_() const {
// Otherwise the mode decides. RAW must be inert: a client that flips to RAW before
// flashing firmware is entitled to a byte pipe with nothing injecting protocol bytes
// into it, and "the tap turned out not to recognise the stream" is not good enough.
return this->mode_ == api::enums::SERIAL_PROXY_MODE_EZSP_ASH;
return this->mode_ == api::enums::SERIAL_PROXY_MODE_PROTOCOL;
}
void SerialProxy::tap_pump() {
@@ -156,7 +156,7 @@ void SerialProxy::dump_config() {
this->port_type_ == api::enums::SERIAL_PROXY_PORT_TYPE_RS485 ? LOG_STR_LITERAL("RS485")
: this->port_type_ == api::enums::SERIAL_PROXY_PORT_TYPE_RS232 ? LOG_STR_LITERAL("RS232")
: LOG_STR_LITERAL("TTL"),
this->mode_ == api::enums::SERIAL_PROXY_MODE_EZSP_ASH ? LOG_STR_LITERAL("EZSP_ASH") : LOG_STR_LITERAL("RAW"),
this->mode_ == api::enums::SERIAL_PROXY_MODE_PROTOCOL ? LOG_STR_LITERAL("PROTOCOL") : LOG_STR_LITERAL("RAW"),
this->rts_pin_ != nullptr ? LOG_STR_LITERAL("configured") : LOG_STR_LITERAL("not configured"),
this->dtr_pin_ != nullptr ? LOG_STR_LITERAL("configured") : LOG_STR_LITERAL("not configured"));
}
@@ -239,7 +239,7 @@ void SerialProxy::set_mode(api::APIConnection *api_connection, api::enums::Seria
}
#endif
ESP_LOGD(TAG, "Serial proxy [%" PRIu32 "] mode set to %s", this->instance_index_,
mode == api::enums::SERIAL_PROXY_MODE_EZSP_ASH ? "EZSP_ASH" : "RAW");
mode == api::enums::SERIAL_PROXY_MODE_PROTOCOL ? "PROTOCOL" : "RAW");
const bool leaving_protocol_mode =
this->mode_ != api::enums::SERIAL_PROXY_MODE_RAW && mode == api::enums::SERIAL_PROXY_MODE_RAW;
this->mode_ = mode;
+1 -1
View File
@@ -20,4 +20,4 @@ serial_proxy:
uart_id: zigbee_uart
name: Zigbee
port_type: TTL
mode: ezsp_ash
mode: protocol
@@ -22,7 +22,7 @@ serial_proxy:
uart_id: zigbee_usb_channel
name: Zigbee
port_type: TTL
mode: ezsp_ash
mode: protocol
zigbee_proxy:
serial_proxy_id: zigbee_usb_serial