Add MTU discovery with typed ProtocolError enum#200
Merged
okhsunrog merged 6 commits intojamesmunns:mainfrom Mar 28, 2026
Merged
Add MTU discovery with typed ProtocolError enum#200okhsunrog merged 6 commits intojamesmunns:mainfrom
okhsunrog merged 6 commits intojamesmunns:mainfrom
Conversation
Cherry-picked from feature/mtu-discovery and adapted for unified Router: - Add mtu() to InterfaceSink trait (cobs_stream, framed_stream, multi_interface) - Add ISE_PACKET_TOO_BIG protocol error (18) and PacketTooBig payload struct - Add MTU check in EdgePort::send_raw before forwarding - Send PROTOCOL_ERROR back to source when forwarded frame exceeds outgoing MTU - Add ErgotPathMtuEndpoint well-known endpoint with PathMtuQuery/PathMtuResult
Replace ProtocolError(u16) with a proper enum where each variant can
carry its own data. This allows IsePacketTooBig { mtu: u16 } to
natively encode the bottleneck MTU in the wire frame, eliminating the
need for a separate query round-trip.
Remove the now-unnecessary PacketTooBig struct and
encode_frame_err_with_payload helper. Add e2e tests for wire format
round-trip and router MTU enforcement.
Add PacketReceiver/PacketSender traits and a combined RX/TX worker that handles the frame processing loop, optional liveness timeout, and interface state management. New transports (BLE, CAN FD, ESP-NOW, SPI) only need to implement the two traits (~10 lines each) instead of duplicating the full worker loop.
The std feature was unconditionally enabling embassy-time via "embassy-time/std", which pulls in embassy-executor-timer-queue and its unresolved __embassy_time_queue_item_from_waker symbol. This caused MSVC linker failures on Windows for tokio-based demos that don't provide an embassy executor. Changed to "embassy-time?/std" so the std sub-feature only activates if embassy-time is already enabled by another feature.
run() already sets InterfaceState::Down on exit. The Drop impl now checks whether the interface is already Down before setting it again.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add MTU discovery so routers can detect and report oversized frames.
InterfaceSinkgains anmtu()method,EdgePort::send_rawchecks frame size before sending, and the router replies with aPacketTooBigerror carrying the bottleneck MTU value. To make this work cleanly on the wire,ProtocolErroris changed from astruct(u16)newtype to a proper enum — each variant can now carry its own typed payload (e.g.IsePacketTooBig { mtu: u16 }), serialized natively by postcard.mtu()toInterfaceSinktrait; implement incobs_stream::Sink,framed_stream::Sink, andmulti_interface!macroInterfaceSendError::PacketTooBig { mtu }variant with MTU check inEdgePort::send_rawprocess_framecatchesPacketTooBigand sends error back to source with the MTU valueProtocolError(u16)+ associated constants withenum ProtocolError— variants carry typed dataPacketTooBigstruct andencode_frame_err_with_payload(enum handles this natively)ErgotPathMtuEndpointwell-known endpoint (types only, no server yet)Breaking changes:
ProtocolErroris now an enum — all code matching onProtocolError::SSE_NO_SPACEetc. must useProtocolError::SseNoSpacestyle variantsInterfaceSinkimplementations must addfn mtu(&self) -> u16