[sx126x][sx127x] Take the packet size at construction

The radio links have no buffer of their own, so code generation passes
the configured max_packet_size to the constructor.

Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
clydebarrow
2026-10-20 09:35:06 +11:00
co-authored by Claude Code
parent 2357b59103
commit e5f6e5f09f
4 changed files with 6 additions and 4 deletions
@@ -52,7 +52,7 @@ FINAL_VALIDATE_SCHEMA = _final_validate
async def to_code(config: ConfigType) -> None:
radio = await cg.get_variable(config[CONF_SX126X_ID])
var = await new_packet_interface(config, radio)
var = await new_packet_interface(config, radio, config[CONF_MAX_PACKET_SIZE])
radio_config = next(
conf for conf in CORE.config[DOMAIN] if conf[CONF_ID] == config[CONF_SX126X_ID]
)
@@ -11,7 +11,8 @@ namespace esphome::sx126x {
/// sends, so sending is refused while the radio is receiving a packet; the layers above send again shortly.
class SX126xPacketInterface : public packet_interface::PacketInterface, public SX126xListener {
public:
explicit SX126xPacketInterface(SX126x *radio) : radio_(radio) {}
SX126xPacketInterface(SX126x *radio, size_t max_packet_size)
: packet_interface::PacketInterface(max_packet_size), radio_(radio) {}
void setup() override { this->radio_->register_listener(this); }
void set_max_busy(uint32_t max_busy_ms) { this->listen_before_talk_.set_max_busy(max_busy_ms); }
@@ -66,7 +66,7 @@ FINAL_VALIDATE_SCHEMA = _final_validate
async def to_code(config: ConfigType) -> None:
radio = await cg.get_variable(config[CONF_SX127X_ID])
var = await new_packet_interface(config, radio)
var = await new_packet_interface(config, radio, config[CONF_MAX_PACKET_SIZE])
radio_config = next(
conf for conf in CORE.config[DOMAIN] if conf[CONF_ID] == config[CONF_SX127X_ID]
)
@@ -11,7 +11,8 @@ namespace esphome::sx127x {
/// sends, so sending is refused while the radio is receiving a packet; the layers above send again shortly.
class SX127xPacketInterface : public packet_interface::PacketInterface, public SX127xListener {
public:
explicit SX127xPacketInterface(SX127x *radio) : radio_(radio) {}
SX127xPacketInterface(SX127x *radio, size_t max_packet_size)
: packet_interface::PacketInterface(max_packet_size), radio_(radio) {}
void setup() override { this->radio_->register_listener(this); }
void set_max_busy(uint32_t max_busy_ms) { this->listen_before_talk_.set_max_busy(max_busy_ms); }