mirror of
https://github.com/esphome/esphome.git
synced 2026-10-04 02:05:59 +00:00
Remove buffer_size config, the max ASH size is static
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include "esphome/core/defines.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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++) {
|
||||
|
||||
@@ -9,7 +9,3 @@ esp32:
|
||||
|
||||
zigbee_proxy:
|
||||
serial_proxy_id: zigbee_serial
|
||||
buffer_size: 1024
|
||||
initial_timeout: 1600
|
||||
min_timeout: 400
|
||||
max_timeout: 3200
|
||||
|
||||
@@ -9,4 +9,3 @@ esp8266:
|
||||
|
||||
zigbee_proxy:
|
||||
serial_proxy_id: zigbee_serial
|
||||
buffer_size: 512
|
||||
|
||||
Reference in New Issue
Block a user