diff --git a/esphome/components/zigbee_proxy/__init__.py b/esphome/components/zigbee_proxy/__init__.py index ba421e3221..6f73f5544d 100644 --- a/esphome/components/zigbee_proxy/__init__.py +++ b/esphome/components/zigbee_proxy/__init__.py @@ -1,7 +1,7 @@ import esphome.codegen as cg from esphome.components import serial_proxy import esphome.config_validation as cv -from esphome.const import CONF_BUFFER_SIZE, CONF_ID, CONF_POWER_SAVE_MODE, CONF_WIFI +from esphome.const import CONF_ID, CONF_POWER_SAVE_MODE, CONF_WIFI import esphome.final_validate as fv from esphome.types import ConfigType @@ -31,11 +31,6 @@ CONFIG_SCHEMA = cv.Schema( { cv.GenerateID(): cv.declare_id(ZigbeeProxy), cv.Required(CONF_SERIAL_PROXY_ID): cv.use_id(serial_proxy.SerialProxy), - cv.Optional(CONF_BUFFER_SIZE): cv.SplitDefault( - cv.int_range(min=256, max=2048), - esp8266=512, - default=1024, - ), } ).extend(cv.COMPONENT_SCHEMA) @@ -50,7 +45,3 @@ async def to_code(config: ConfigType) -> None: cg.add_define("USE_ZIGBEE_PROXY") # Compiles the tap interface into serial_proxy; without it the port is a plain byte pipe cg.add_define("USE_SERIAL_PROXY_TAP") - - # Set buffer size via define for compile-time allocation - if (buffer_size := config.get(CONF_BUFFER_SIZE)) is not None: - cg.add_define("ZIGBEE_PROXY_BUFFER_SIZE", buffer_size) diff --git a/esphome/components/zigbee_proxy/ash_protocol.h b/esphome/components/zigbee_proxy/ash_protocol.h index c3d513c338..0891b439f8 100644 --- a/esphome/components/zigbee_proxy/ash_protocol.h +++ b/esphome/components/zigbee_proxy/ash_protocol.h @@ -1,7 +1,5 @@ #pragma once -#include "esphome/core/defines.h" - #include #include @@ -31,16 +29,12 @@ inline bool ash_is_reserved(uint8_t byte) { // 0x7E framing, so Spinel frames systematically fail this check. uint16_t ash_crc16(const uint8_t *data, size_t length, uint16_t init = 0xFFFF); -// Buffer size configuration -#ifdef ZIGBEE_PROXY_BUFFER_SIZE -static constexpr size_t MAX_ASH_FRAME_SIZE = ZIGBEE_PROXY_BUFFER_SIZE; -#else -#ifdef USE_ESP8266 -static constexpr size_t MAX_ASH_FRAME_SIZE = 512; // Limited RAM on ESP8266 -#else -static constexpr size_t MAX_ASH_FRAME_SIZE = 1024; // Full buffer on ESP32/RP2040 -#endif -#endif +// ASH bounds a frame's Data Field at 128 bytes, so the largest body a scanner has to +// hold is that field plus the control byte and the two CRC bytes ahead of the closing +// delimiter. Byte stuffing happens on the wire only and is undone as bytes arrive, so it +// does not enlarge this. +static constexpr size_t ASH_MAX_DATA_FIELD_SIZE = 128; +static constexpr size_t MAX_ASH_FRAME_SIZE = 1 + ASH_MAX_DATA_FIELD_SIZE + 2; // Protocol limits static constexpr uint8_t ASH_MAX_SEQUENCE = 7; // 3-bit sequence number (0-7) diff --git a/esphome/components/zigbee_proxy/zigbee_proxy.cpp b/esphome/components/zigbee_proxy/zigbee_proxy.cpp index 4f9260a684..c5cf71786e 100644 --- a/esphome/components/zigbee_proxy/zigbee_proxy.cpp +++ b/esphome/components/zigbee_proxy/zigbee_proxy.cpp @@ -10,13 +10,7 @@ static const char *const TAG = "zigbee_proxy"; void ZigbeeProxy::setup() { this->parent_->set_tap(this); } -void ZigbeeProxy::dump_config() { - ESP_LOGCONFIG(TAG, - "Zigbee Proxy:\n" - " Port: %s\n" - " Buffer Size: %u bytes", - this->parent_->get_name(), MAX_ASH_FRAME_SIZE); -} +void ZigbeeProxy::dump_config() { ESP_LOGCONFIG(TAG, "Zigbee Proxy:\n Port: %s", this->parent_->get_name()); } void ZigbeeProxy::on_device_rx(const uint8_t *data, size_t len) { for (size_t i = 0; i < len; i++) { diff --git a/tests/components/zigbee_proxy/test.esp32-idf.yaml b/tests/components/zigbee_proxy/test.esp32-idf.yaml index 6c4c86a9a4..4c27e96efd 100644 --- a/tests/components/zigbee_proxy/test.esp32-idf.yaml +++ b/tests/components/zigbee_proxy/test.esp32-idf.yaml @@ -9,7 +9,3 @@ esp32: zigbee_proxy: serial_proxy_id: zigbee_serial - buffer_size: 1024 - initial_timeout: 1600 - min_timeout: 400 - max_timeout: 3200 diff --git a/tests/components/zigbee_proxy/test.esp8266-ard.yaml b/tests/components/zigbee_proxy/test.esp8266-ard.yaml index 9c970b37d8..f08b9eee94 100644 --- a/tests/components/zigbee_proxy/test.esp8266-ard.yaml +++ b/tests/components/zigbee_proxy/test.esp8266-ard.yaml @@ -9,4 +9,3 @@ esp8266: zigbee_proxy: serial_proxy_id: zigbee_serial - buffer_size: 512