feat!: protocol v2 wire format and module restructure

The wire protocol is re-specified as DongLoRa Protocol v2 (see PROTOCOL.md). Every type_id, tag-correlation rule, and field layout is incompatible with 0.1.0.

* Add PROTOCOL.md as the normative spec for the v2 wire format.

* Replace framing.rs with a streaming FrameDecoder that emits (type_id, tag, payload) triples on each COBS-delimited, CRC-checked frame.

* Split the single-file lib.rs into dedicated modules: frame, commands, events, errors, modulation, info, crc, chip_id. Re-exports preserve convenience imports at the crate root.

* Replace RadioConfig / Bandwidth with a Modulation enum covering LoRa, FSK/GFSK, LR-FHSS, and FLRC, each with its own typed parameter struct.

* Add TxFlags, RxOrigin, SetConfigResult, OkPayload to model v2 response shapes, and RadioChipId for GET_INFO.

* Rewrite fuzz corpus: replace the 4 cobs_* / command_roundtrip targets with decoder_feed, frame_roundtrip, lora_config_roundtrip, and parse_device_message; drop parse_radio_config.

* Expand proptest and mutation-killer coverage for the new wire shape.

* Rewrite canonical-byte test vectors against the v2 spec.
This commit is contained in:
swaits committed 2026-04-22 09:21:11 -06:00
1 parent 35866edac4
commit 4cccb65124
29 files changed
+7115 -2285

No files matched your search

+9 -17
View File
@@ -40,13 +40,11 @@ test-deny:
# fuzz every target for 60s (requires nightly + cargo-fuzz)
test-fuzz:
cd fuzz && cargo +nightly fuzz run decoder_feed -- -max_total_time=60
cd fuzz && cargo +nightly fuzz run parse_command -- -max_total_time=60
cd fuzz && cargo +nightly fuzz run parse_radio_config -- -max_total_time=60
cd fuzz && cargo +nightly fuzz run cobs_decoder_feed -- -max_total_time=60
cd fuzz && cargo +nightly fuzz run cobs_roundtrip -- -max_total_time=60
cd fuzz && cargo +nightly fuzz run command_roundtrip -- -max_total_time=60
cd fuzz && cargo +nightly fuzz run cobs_decoder_multi_frame -- -max_total_time=60
cd fuzz && cargo +nightly fuzz run cobs_chunk_invariant -- -max_total_time=60
cd fuzz && cargo +nightly fuzz run parse_device_message -- -max_total_time=60
cd fuzz && cargo +nightly fuzz run frame_roundtrip -- -max_total_time=60
cd fuzz && cargo +nightly fuzz run lora_config_roundtrip -- -max_total_time=60
# run tests under miri (catches UB, requires nightly + miri component)
# The proptest suite is skipped — its file-persistence layer calls getcwd
@@ -59,22 +57,16 @@ test-miri:
#
# Runs under both feature configurations so that feature-gated paths
# (currently only the defmt::Format derives) are covered in both shapes.
# Three mutants are excluded as provably equivalent — swapping the
# operator does not change behaviour because a downstream check catches
# the resulting case. See the regex strings for the specific sites.
# No exclusions yet for the v1.0 codec — rerun mutation testing on a
# fresh target and add `-E` lines here for any provably-equivalent
# mutants that survive, with a comment explaining why.
test-mutants: test-mutants-default test-mutants-no-default
test-mutants-default:
cargo mutants --no-shuffle --test-tool=nextest \
-E 'replace > with >= in Command::from_bytes' \
-E 'replace > with >= in CobsDecoder::feed' \
-E 'replace < with <= in cobs_encode_response'
cargo mutants --no-shuffle --test-tool=nextest
test-mutants-no-default:
cargo mutants --no-shuffle --test-tool=nextest --no-default-features \
-E 'replace > with >= in Command::from_bytes' \
-E 'replace > with >= in CobsDecoder::feed' \
-E 'replace < with <= in cobs_encode_response'
cargo mutants --no-shuffle --test-tool=nextest --no-default-features
# format code
fmt: