feat(kerykeion): serial/TCP transport, frame codec, AES-CTR encryption, config handshake#56
Merged
forkwright merged 3 commits intomainfrom Mar 19, 2026
Merged
Conversation
…n, config handshake Implements the Meshtastic serial protocol layer in the kerykeion crate: - codec.rs: tokio_util Decoder/Encoder with 4-byte frame header (0x94 0xC3 MSB LSB), magic seeking, max-512-byte enforcement, zero-length and back-to-back frame handling (10 tests) - transport/serial.rs: SerialTransport at 115 200 baud, no flow control, DTR/RTS false to avoid firmware reboot on connect, exponential backoff reconnect (1 s → 30 s cap) - transport/tcp.rs: TcpTransport on default port 4403, 3 s connect timeout, same Meshtastic framing (2 tests) - transport/mod.rs: ConnectionHandle enum dispatch (Serial | Tcp) for non-dyn-compatible async-fn traits; connect() factory - handshake.rs: config handshake state machine — sends want_config_id, receives MyNodeInfo / NodeInfo / Channel / config_complete_id, 10 s timeout, discards in-flight MeshPackets, fails on Rebooted (3 tests) - crypto.rs: AES-128/256-CTR via ctr crate; nonce layout matches Meshtastic firmware; PSK expansion for 1-byte shorthands; multi-channel decrypt with protobuf probe (15 tests) - heartbeat.rs: 30 s keepalive loop driven by CancellationToken, empty ToRadio as keepalive signal (2 tests) Also updates connection.rs to use proto types (ToRadio/FromRadio), adds From<io::Error> to Error for tokio_util codec trait bounds, and exposes new modules in lib.rs. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
|
Consider splitting into smaller PRs for easier review. Not a blocker, just a signal. |
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.
Summary
tokio_utilDecoder/Encoder with 4-byte Meshtastic frame header (0x94 0xC3 MSB LSB), magic seeking on corrupt input, max-512-byte enforcement, zero-length and back-to-back frame handlingSerialTransport(115 200 baud, DTR/RTS false, exponential backoff reconnect) andTcpTransport(port 4403, 3 s connect timeout);ConnectionHandleenum dispatch bridges the non-dyn-compatible async-fn traitwant_config_id, collectsMyNodeInfo/NodeInfo/Channelmessages, completes on matchingconfig_complete_id, 10 s timeoutctrcrate; nonce layout matches Meshtastic firmware (packet_id as u64 LE || from_node u32 LE || 0x00000000); PSK expansion for 1-byte shorthands; multi-channel decrypt with protobuf probeCancellationToken; uses emptyToRadio(no payload variant) as the keepalive signal — the vendored proto has no dedicatedHeartbeatmessage type61 tests in kerykeion, all passing.
cargo clippy --workspace --all-targets -- -D warningsclean.Notes
Box<dyn MeshConnection>is not viable becauseasync fnin traits (Rust 2024) is not object-safe.ConnectionHandleenum dispatch is the idiomatic alternative.mesh.protodoes not defineConfigorModuleConfigmessages, soHandshakeResultcarries onlychannels: Vec<Channel>from the dump.ToRadio { payload_variant: None }is used as the heartbeat keepalive since no dedicated message type exists in the proto.Test plan
cargo test -p kerykeion— 61 tests passcargo test --workspace— 418 tests pass, 0 failurescargo clippy --workspace --all-targets -- -D warnings— 0 warningscargo fmt --all— no diffs🤖 Generated with Claude Code