- The ESP-NOW link reports the free slots in the shared send queue, and
addressing ports pass on their link's capacity, so fragmentation does
not start a packet that the queue cannot take whole.
- An ESP-NOW peer_address must be a device's own address or broadcast,
not a group or all-zero address.
- The broadcast address is added as a peer at boot, not at the first send.
- A UDP destination of 0.0.0.0 or 255.255.255.255 is not taken as one peer.
- A test for the once a minute warning of a dropped UDP sender.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
interface_has_layer() looked up the provided layers by the type of the
configuration holding the layers, which for an addressing peer is the
peer, so a peer never had what its link provides.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A link that refuses a fragment after others were sent leaves the peer
with part of a packet, which it drops. The fragmentation layer now logs
a warning then. The TCP link's capacity comment no longer claims that
this cannot happen: a socket that stalls part way through still cuts a
packet short.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A session layer's peer does not answer each packet, so turn taking on a link without a
reliability layer only refused sends that nothing would send again. A failed interrupt
read in SX126xRadio::is_receiving() read as a free channel, so the link could send over
a reception it could not see; it now holds the send, and warns if the radio stays unreadable.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An ESP-NOW peer with a larger max_packet_size has its larger packets dropped, which was
logged only at verbose level, and the size check now runs after the peer filter, so other
senders' packets are not counted. A UDP read that fails other than for want of data is
logged: the raw lwIP socket consumes a packet whose source address it cannot convert.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On TCP, encryption sits right below fragmentation, and reported an unlimited capacity
whatever the link had room for, so a fragmented packet could be started that the link
could not take in full.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dev now packs the SX126x interrupt setup through set_dio_irq_params_(). It takes the
flagged interrupts and the DIO1 ones separately, so receive can flag a valid header
or sync word without signalling it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
07 is now based on clydebarrow/sx127x-async-transmit (esphome PR 22733), which is on dev
after the SX126x radio lifecycle refactor (PR 22197). 07's driver changes are ported:
- is_receiving() moves into SX126xRadio, and into the new SX127x radio state; both report
a held packet and stay false while sending or asleep.
- SX126x flags a valid header or sync word for is_receiving() without signalling it on DIO1.
- SX127x FSK packets are at most 63 bytes, as the FIFO also holds the length byte.
- The radio link takes an Error value of 0 as success, as both radios' NONE values are renamed.
- 07's own FSK SNR change is dropped; both drivers now report NAN.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
configure() is refused while a send is on air, but the setters still changed the
modulation, payload length, packet mode, RX start and frequency that the end of
the send and later sends and packets used, before the chip had them.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The warning's log message can run user code that calls configure(). Armed
afterwards, the retry stayed set on a radio that had already recovered, and reset
it a second later.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An SX1276 stays in TX when asked for RX while a packet is still going out, so a
cancelled or timed out send set a warning until the radio was configured again.
The test chip now behaves the same way.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Out of line, it shares the RP2040 .time_critical section with inline functions such
as get_loop_component_start_time(), which the compiler rejects as a section type conflict.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Matches the SX126x changes: start_transmit_async(), cancel_transmit_async() and
is_transmitting(), with SX127xTransmitListener. A received packet still waiting
when a send starts is kept, the send returns BUSY, and the next loop delivers
the packet. Mode changes are ignored while a send is on air.
A mode change that does not take now sets a warning and the radio is configured
again every second, instead of marking the component failed. The error values
are renamed to SX127X_ERROR_*, and FSK packets report NAN for SNR.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
After a send, the next frame of a burst went out at once, on top of the peer's
acknowledgement or reply, as the radio only notices a packet once its header
has arrived. Both packets were lost, and the reliability layer threw away the
rest of the burst. Now, on a link with a layer that needs replies, a send in a
later loop pass waits until the peer has had time to start a reply and its
header to be received, unless a packet arrives first. Sends in the same loop
pass, such as the fragments of one packet, are not held apart, and one-way
links are unchanged.
On a SX1262 and SX1276 pair at SF10, 45 minutes of counter updates both ways
went from 86 to 90 percent delivered, with a link reset every 9 minutes, to
all 540 delivered each way with no resends.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Resending every unacknowledged frame on each timeout let two radio peers whose
acknowledgements were lost keep sending long bursts that collided again, until
one side reset the link. Now only the oldest frame is resent; the peer's answer
acknowledges whatever it already has, and the remaining frames follow.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Listen before talk reads the current time, not the loop's start: earlier sends in the same loop pass may have
waited seconds for the radio, and a reception first seen then could be sent over at once.
- A send made over a busy flag that seemed stuck ends the busy period, so a reception that starts before loop()
runs is waited for again.
- An accepted packet ends a run of dropped oversized ones.
- The reliability timeout and the listen before talk limit allow for the largest packet any device on the channel
can send, not only this link's own; a refused resend still counts as a retry.
- The suggested max_packet_size is never below 16, the smallest allowed.
- A warning is logged when one send can become several radio packets that together hold up other components for
more than 4 s, as the drivers wait for each packet to be sent.
- SX126x FSK packets report the SNR as NAN, as the radio does not measure it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- A peer sending without a pause no longer holds the main loop in the receive loop; a frame being read carries over.
- While frames wait for the socket, the link reports how many more full frames fit, so a fragmentation layer above
does not start a packet that would be cut short.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Without a timeout, ack_delay was checked against the 200 ms default even on a radio link, which works out a longer
timeout that allows for the delay.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- A reliability layer on a radio link without a timeout gets one long enough for the peer's largest packet and an
acknowledgement, from the radio's settings; a timeout set shorter is rejected.
- A max_packet_size whose packets take longer to send than the drivers wait for (4 s) is rejected, naming the largest
that fits.
- Listen before talk holds sends back for as long as the largest packet the radio can receive takes, not the link's
own limit.
- A received packet larger than the link's max_packet_size is dropped.
- SX127x: in LoRa mode DIO0 also signals TX_DONE when the radio sleeps after sending, which was taken for a received
packet, both by is_receiving() and loop(); FSK and OOK packets report RSSI and SNR as NAN, as the radio does not
measure them; variable length FSK and OOK packets hold at most 63 bytes, as the FIFO also holds the length byte.
- The radio's configuration is found with fv.get_declaring_config().
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Declared first, it fills the byte the base class leaves at its end, which takes each radio link from 56 to 52 bytes
on ESP32.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A log line can run an automation that sends again, which would overwrite the buffer of a layer above before the
radio had read it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The preamble flag stays set when no sync word follows, so a packet from
another network held every send back until max_busy ran out. A link
without LoRa now needs a sync_value.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Without one the radio cannot tell that a packet is arriving, so listen
before talk does nothing.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Without LoRa, require the SX127x radio to have a sync word or preamble
detection, as listen before talk cannot see a packet arriving otherwise
- Warn once when a send finds the radio failed
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Warn when a send goes ahead over a busy period at its limit, as that
means a stuck busy indication or a jammed channel
- Log an empty packet at verbose level, and say why it counts as sent
- Name the radio id if code generation cannot find its configuration
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Reject a radio with rx_start false when the link or a peer has a layer
that needs packets back from the peer, as the radio sleeps after sending
- Log a send over a long busy period at debug level, so a lost reception
can be traced
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Make both links one RadioLink template in packet_interface, with shared
code generation in radio_link.py, so a fix applies to both radios
- While sending is held back, watch the radio from loop() and end the
busy period once it is free, so a later reception starts a new period
instead of being sent over
- Reject an SX127x link without LoRa unless the radio is in packet mode
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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>
- Hold a send back for at most the airtime of the largest packet, worked
out from the radio settings and at least 2 s, instead of a fixed 2 s
that a LoRa packet at a high spreading factor outlasts
- End a busy period when a send finds the radio free, so a busy flag that
never clears is released however rarely sends are tried
- Detect an FSK reception on the SX127x from its preamble and sync word
flags
- Test the radio links' final validation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each packet is one radio packet, with the RSSI and SNR of received
packets in the metadata. A radio cannot hear while it sends, so a link
refuses to send while its radio is receiving a packet, for up to two
seconds, and the layers above send again shortly.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A deferred call could outlive the layer in the unit tests, which run many components in one program.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- A send refused because another is in progress is now logged once per layer, from the next loop, as the logger
drops lines logged from an automation that a log line runs.
- Each addressing port warns about its own refused destinations, naming the port, so a refusal on one port does not
hide a later one on another.
- The session layer reports its one byte header and its keep-alive size to config validation, so the sizes there
match the C++ layers.
- A layer that the layers below leave no room for is rejected during validation, not when the device starts.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- The UART link writes a frame in pieces, so a send made from a UART debug automation, possibly through another
addressing peer, is now refused instead of landing inside the frame.
- Addressing peers whose encryption keeps state for one peer, such as the rolling code, must use different keys; a
packet relabelled with another peer's source address would otherwise pass that peer's checks.
- An addressing port named with port_id is now found when an application refers to it.
- The reliability layer refuses a packet with a chosen destination, which it could not keep for a resend.
- The fragmentation layer and entity_transport take buffers from cg.static_buffer, in PSRAM when it is enabled;
entity_transport's size comes from the configured layers, and setup() fails if the C++ layers need more.
- destination is validated with cv validators that schema tooling can describe, and the address header uses
put_le16().
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The six byte peer address now sits with the two flags, and the UDP link's flag fills the spare byte at the end of
the packet interface base, which takes the ESP-NOW link from 76 to 72 bytes and the UDP link from 56 to 52 on
ESP32.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
It sat alone after the listener, padded to a word, which took the link from 76 to 80 bytes on ESP32.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Declared first, it fills the byte the base class leaves at its end, which takes each radio link from 56 to 52 bytes
on ESP32.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The length of the packet being joined fits in 16 bits, as configuration limits it to 16384 bytes, and the two flags
share a byte, which takes the layer from 56 to 52 bytes on ESP32.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Without a reliability layer above, a peer that is off, out of range or has another address went unreported, as the
delivery result was logged only at verbose level by the espnow component.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The failed write closes the link and discards the queued frame, so returning true lost the packet without the
sender knowing.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A port to one peer may have layers that keep state for that peer, such as reliability, a session or a rolling code,
which a packet sent elsewhere would break. A packet to this device's own address is dropped by every receiver, as
metadata copied from a received packet would give. Both are now refused with a warning.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
One limit covered every kind of drop, so a steady stream of one kind, such as a neighbour on other firmware, could
take nearly every warning and leave a rarer kind seldom reported. The name of the device that sent each new
dictionary is now logged at debug level, so a provider that matches no device heard is easy to spot.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A log line can run an automation that sends again, which would overwrite the buffer of a layer above before the
radio had read it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A log line further down, such as the radio's warning that it is sending although busy, can run an automation that
sends again before the layer below has read the layer's buffer. The nested send overwrote that buffer, so the outer
packet went out with the nested one's bytes. PacketInterface gets a helper that refuses such a send, which callers
already handle as a send that was not accepted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Applications send through top(), so the id of a layer still uses every layer of its link. Final validation now
finds the link from a layer's id and checks its layers, where the previous commit rejected the id with a wrong
reason.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An application given the id of a layer would leave out the layers above it, and final validation found no
interface for it, so its checks were skipped without an error. A packet with our own dictionary id that is not a
request is now logged at verbose level, as another device with the same name and entities sends such packets.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A failure that repeats on every send, such as a peer that could not be
added, was logged only at verbose level. The error name helper is now
shared so the link can name the error.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Add point_to_point to the UDP link, to override the guess that an
address ending in .255 is a broadcast address, for subnets other than
/24
- Warn, at most once a minute, when a point to point UDP link drops a
packet from another sender
- Say that on ESP8266 an ESP-NOW peer link also receives the peer's
broadcasts
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The ESP-NOW link derives max_packet_size from the span it is given, as
the UDP point-to-point link already does.
Co-Authored-By: Claude Code <noreply@anthropic.com>
- Reject reliability, session and the rolling code on a broadcast UDP or
ESP-NOW link without addressing, as every device hears the link
- Test the UDP and ESP-NOW final validation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Code generation declares the ESP-NOW link's buffer for packets split
across buffers as a static array of max_packet_size bytes, so it is not
allocated at run time.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The ESP-NOW link sends to one peer, which also provides addressing, or
broadcasts to every device on the channel. The UDP link accepts packets
only from the peer when the udp component sends to one unicast IPv4
address, and then provides addressing; the udp component now reports the
sender of each packet to its listeners.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
TCP provides the session itself, so its config has no session key and
the timeout check let it through. update_interval then defaults to
never, and unchanged states timed out on a working link. Record the
layers each link class provides and check those too.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The preamble flag stays set when no sync word follows, so a packet from
another network held every send back until max_busy ran out. A link
without LoRa now needs a sync_value.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Without one the radio cannot tell that a packet is arriving, so listen
before talk does nothing.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Without LoRa, require the SX127x radio to have a sync word or preamble
detection, as listen before talk cannot see a packet arriving otherwise
- Warn once when a send finds the radio failed
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Publish the connected sensor as off at setup, so a link that never
comes up does not show as unknown
- Add a timeout option, defaulting to three keep-alive intervals and
longer than one, as the peer's keep_alive sets how often packets
arrive; limit keep_alive to 1 h and timeout to 3 h
- Load binary_sensor for an empty config from tooling
- Name the layer in the error when a provided layer is configured
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Warn when a send goes ahead over a busy period at its limit, as that
means a stuck busy indication or a jammed channel
- Log an empty packet at verbose level, and say why it counts as sent
- Name the radio id if code generation cannot find its configuration
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The link takes the buffer as a std::span and derives max_packet_size
from its size, so a length beyond the buffer is refused and the
connection is closed.
Co-Authored-By: Claude Code <noreply@anthropic.com>
- Reject a radio with rx_start false when the link or a peer has a layer
that needs packets back from the peer, as the radio sleeps after sending
- Log a send over a long busy period at debug level, so a lost reception
can be traced
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Make both links one RadioLink template in packet_interface, with shared
code generation in radio_link.py, so a fix applies to both radios
- While sending is held back, watch the radio from loop() and end the
busy period once it is free, so a later reception starts a new period
instead of being sent over
- Reject an SX127x link without LoRa unless the radio is in packet mode
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Reserve the link's sockets, so the socket pool is sized for them
- Test the server role: accepting a client, receiving from it, and
accepting the next after it disconnects
- Test a frame assembled across several reads, after a keep-alive
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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>
Code generation declares the TCP link's receive buffer as a static array
of max_packet_size bytes, so it is not allocated at run time.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Hold a send back for at most the airtime of the largest packet, worked
out from the radio settings and at least 2 s, instead of a fixed 2 s
that a LoRa packet at a high spreading factor outlasts
- End a busy period when a send finds the radio free, so a busy flag that
never clears is released however rarely sends are tried
- Detect an FSK reception on the SX127x from its preamble and sync word
flags
- Test the radio links' final validation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each packet is one radio packet, with the RSSI and SNR of received
packets in the metadata. A radio cannot hear while it sends, so a link
refuses to send while its radio is receiving a packet, for up to two
seconds, and the layers above send again shortly.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Packets go over one TCP connection, as a client that connects to a host
or a server that accepts one client at a time. TCP resends what is lost
and joins exactly two devices, so the link provides the reliability,
addressing and session layers itself, and those cannot be configured on
it. A link platform names such layers with the new provides argument.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Work out each layer's packet size during validation, as the C++ does,
and reject a fragmentation max_packet_size whose fragments do not all
fit in the reliability queue at once, or need more than 128 fragments
- Fit the test peer's largest packet in its queue
- Reuse interface_layers() in final_validate_interface()
- Keep the earlier tests in place in test_packet_interface.py
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A broadcast from a device with its own port went to that port, whose
layers drop it, so a broadcast port could not reach reliable peers. It now
goes to the broadcast port when there is one.
Fragmentation allocates its buffers with RAMAllocator and fails setup when
they cannot be allocated. A fragment from another source no longer drops
the packet being joined.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
AddressingPort derives max_packet_size from the link in its constructor,
and the fragmentation layer passes its configured size to the base
constructor.
Co-Authored-By: Claude Code <noreply@anthropic.com>
- Reject an addressing destination or peer that is this device's own
address, whose packets would be dropped as echoes
- Show 0 fragments, not SIZE_MAX, for a link with no room
- Test the check that applications use a peer's id
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
As in the other layers, addressing ports and fragmentation get no room
when max_packet_size is smaller than their header, and fragmentation
fails its setup instead of dividing by zero.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The addressing layer lets several devices share a channel such as an
RS485 bus or a radio, with 16-bit addresses. A link can carry several
peers, each with its own stack of layers and its own id. Layers that work
between two devices only are rejected with broadcast addressing. The
fragmentation layer splits packets larger than the layers below allow,
and joins them again.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Set a warning once the interface has accepted no packets for a minute,
and log refused dictionary packets as data packets are
- Clear remote entities that a provider's dictionary does not name also
when the provider goes back to a dictionary already seen
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Check a data packet before asking for its dictionary, so a damaged
packet does not make the provider resend everything
- When a provider's complete dictionary does not name a remote entity,
warn and clear that entity's state, as a typo in provider or remote_id,
or an entity the provider no longer sends, was otherwise silent
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A dictionary packet now carries its part index and a last-part flag. A dictionary counts as received, and is not
asked for again, only once its last part follows every other part in order. Until then, data under it sends a
request even when some remote entities are already known.
A refused request no longer starts the request interval. A short or malformed packet, or one with another format
version, is logged as a warning at most once a minute.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With a session and a reliability layer, the update interval defaults to
never, and unchanged states are not sent again, so a receiver's timeout
cleared them on a working link. The session layer already clears the
states when the other device cannot be reached.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each data record now starts with a 16-bit tag holding the entity's number
and type, and the form of its payload, so that more entity types can be
added and a receiver can skip records of types it does not know. A binary
sensor's state is in the tag; a sensor has a 4 byte state, or none.
Data and dictionary packets are checked in full before anything in them
is used, so a damaged or forged packet changes no state and teaches nothing.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A dictionary that names none of the remote entities was asked for again
every 5 seconds while any remote entity was unresolved, and each request
made its provider resend everything. A provider's new dictionary was not
asked for once every remote entity was resolved.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The mock link takes max_packet_size in its constructor, so a test that
needs a different size builds a local link.
Co-Authored-By: Claude Code <noreply@anthropic.com>
- Compare received ids by length and bytes, so an id with an embedded NUL
cannot read past the configured string
- Fail setup when max_packet_size cannot hold the device name and the
longest entity id, instead of skipping the id at every resend
- Reject two entities of one type sent with the same id
- Avoid an unused variable without remote entities
- Use matching ids in the test configuration
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sends sensor and binary sensor states to other devices over a packet
interface. A dictionary sent on connect, on request and at an interval
names the entities, so data packets refer to them by number. The update
interval and the handling of a lost peer follow the layers the interface
has, and remote states can time out.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A single SHA-256 of the key text let a captured packet check about 2^30
guesses for every one that passes, so a weak key text fell quickly to
an offline search. Derive the key with PBKDF2-HMAC-SHA256 at 600,000
iterations instead; this runs at build time, so the device pays nothing.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The rolling code accepts a packet only once the peer has sent back this
device's boot number, so a device that only receives never gets a packet.
The session's keep-alives make sure packets go both ways.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Both layers derive max_packet_size from the layer below in their
constructors instead of assigning it in the body.
Co-Authored-By: Claude Code <noreply@anthropic.com>
- Fail setup, instead of underflowing, when max_packet_size leaves the
encryption or session layer no room
- Warn when the boot number cannot be saved
- Warn once when the peer's packets carry an older boot number, which
happens when its flash is erased
- Test the counter wrapping to a new boot number
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The session layer sends keep-alives and reports whether the peer can be
reached, including after it restarts or a reliability layer below loses
data. The encryption layer encrypts and checks each packet with XXTEA,
with an optional rolling code against replays. Components that a layer
needs, such as binary_sensor, are loaded only when it is configured.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Such a type would be missing from the link schema, and selecting it would
fail with an unrelated error.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
While the peer is away the layers above keep sending, so the message
repeated about once a second until the link came up again.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A frame larger than max_packet_size, usually from a peer with a larger
setting, is warned about once. A link reset that the peer does not answer
is warned about after max_retries tries, and a full queue is logged at
debug level while the link is down.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every module in layers/ is imported automatically, so two modules
registering the same name silently replaced one with the other, in an
order decided by pkgutil. Registration now raises, so the mistake is
found when the configuration is loaded.
Co-Authored-By: Claude Code <noreply@anthropic.com>
A peer that has not heard the UA repeats its SABM, and cannot have sent a
numbered frame meanwhile. Treating that as a restart threw away queued
frames and reported the session lost for a single dropped UA. A SABM is
now a restart only if the peer has sent a numbered frame since the link
came up.
Co-Authored-By: Claude Code <noreply@anthropic.com>
max_packet_size is derived from the layer below in the constructor
instead of being assigned in the body.
Co-Authored-By: Claude Code <noreply@anthropic.com>
- Keep App alive across the HDLC tests, as the test main requires
- Run a layer's loop in the tests only while it has asked for it, so
the loop's disable and request bookkeeping is tested, and wait for the
retry timer in the tests of refused sends
- Report no send capacity while the layer has no send queue
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Reset the link after max_retries even when it is 255, where the retry
counter used to wrap
- Require a reliability timeout of at least 50 ms
- Drop received frames larger than the layer's max_packet_size
- Fail setup, instead of aborting, when the send queue cannot be
allocated or max_packet_size leaves no room
- Test the ack delay timer and a refused REJ
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Layers stack on a link and are configured on its packet_interface entry.
Each layer type registers itself with its kind, so a new type needs only
a new module. The first is a reliability layer in the style of HDLC
asynchronous balanced mode, with go-back-N retransmission.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The link derives max_packet_size from the span it is given, so a packet
larger than the copy buffer cannot be copied into it.
Co-Authored-By: Claude Code <noreply@anthropic.com>
The copy buffer is sized by code generation to max_packet_size, but
set_max_packet_size() can raise the limit afterwards, and copying a split
packet would then overflow it. The link now takes the buffer as a span
and refuses a split packet larger than it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A read cuts a datagram longer than the buffer to fit, so a 600 byte
datagram arrived as a valid looking 508 byte packet. The buffer is now one
byte longer, and a read that fills it is dropped. The split packet test
also checks the bytes joined in the copy buffer.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Code generation declares the UDP link's buffer for packets split across
buffers as a static array of max_packet_size bytes, so it is not
allocated at run time.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Enforce max_packet_size on send and receive
- Copy split packets into a buffer allocated in setup, not on the stack
- Add unit tests for the link's send and receive paths
- Explain why the broadcast socket is always enabled
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each packet is one UDP datagram, using the settings of the udp component.
The udp component now reports whether a packet was sent, and an ENOMEM
refusal from lwIP is logged at verbose level as the packet can be sent
again.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-23 13:28:08 +11:00
24 changed files with 792 additions and 20 deletions
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.