Enhance TRACE payload handling and path extraction in message processing

- Updated `update_mesh_graph_from_trace_data` to clarify the format of `path_hashes` as per-hop hash strings from the trace payload.
- Modified `MessageHandler` to differentiate between TRACE packets and regular transmissions, preventing incorrect extraction of repeater prefixes from RF path bytes.
- Introduced `parse_trace_payload_route_hashes` utility to extract TRACE route hash segments from payloads, ensuring accurate handling of path data.
- Enhanced `PacketCaptureService` to correctly populate packet information for TRACE packets, including SNR path and route hashes.
- Expanded test coverage for TRACE payload decoding and path extraction to validate functionality and correctness.

These changes improve the accuracy and reliability of TRACE data processing in the application.
This commit is contained in:
agessaman committed 2026-03-30 17:36:52 -07:00
1 parent 6a7a79af3c
commit f3e667e64f
7 files changed
+247 -76

No files matched your search

+26
View File
@@ -1136,6 +1136,32 @@ class TestDecodeMeshcorePacket:
assert result is not None
assert result["path_info"]["type"] == "trace"
def test_trace_decode_skye_sample_payload_hashes_not_snr_path(self, handler):
# Field report: RF path 31,28,23 was misread as node IDs; payload holds 37,d6,37.
raw = "26033128235F0AED1A000000000037D637"
result = handler.decode_meshcore_packet(raw)
assert result is not None
assert result["payload_type_name"] == "TRACE"
ph = result["path_info"].get("path_hashes") or result["path_info"].get("path")
assert ph == ["37", "D6", "37"]
assert len(result["path_info"]["snr_data"]) == 3
# Top-level path is still SNR chunks (legacy shape); real route is path_info
assert result["path"] # non-empty SNR-as-hex nodes
def test_trace_decode_flags_two_byte_path_hashes(self, handler):
# flags=1 → 2 bytes per hash; tail 4 bytes → AABB, CCDD
trace_payload = (
b"\x01\x00\x00\x00" # tag
+ b"\x00\x00\x00\x00" # auth
+ b"\x01" # flags: path_sz=1 → 2 bytes per hop
+ b"\xaa\xbb\xcc\xdd"
)
hex_str = _make_packet_hex(9, 2, path_bytes=b"", hop_count=0, payload_bytes=trace_payload)
result = handler.decode_meshcore_packet(hex_str)
assert result is not None
ph = result["path_info"].get("path_hashes") or result["path_info"].get("path")
assert ph == ["AABB", "CCDD"]
# ---------------------------------------------------------------------------
# parse_advert