From: Thomas Karpiniec Date: Fri, 17 Jan 2025 10:24:39 +0000 (+1100) Subject: Fix packet encoding X-Git-Url: https://code.octet-stream.net/m17rt/commitdiff_plain/2798b7a8f62b73aa2a88d4b34e861debd6462015?ds=sidebyside Fix packet encoding --- diff --git a/m17core/src/decode.rs b/m17core/src/decode.rs index 115ff63..6c8e02b 100755 --- a/m17core/src/decode.rs +++ b/m17core/src/decode.rs @@ -144,8 +144,8 @@ pub(crate) fn parse_packet(frame: &[f32] /* length 192 */) -> Option 0; - let number = packet[25] >> 3; + let final_frame = (packet[25] & 0x80) > 0; + let number = (packet[25] >> 2) & 0x1f; let counter = if final_frame { PacketFrameCounter::FinalFrame { payload_len: number as usize, diff --git a/m17core/src/encode.rs b/m17core/src/encode.rs index 4fc7429..5e0951e 100644 --- a/m17core/src/encode.rs +++ b/m17core/src/encode.rs @@ -31,11 +31,11 @@ pub(crate) fn encode_packet(frame: &PacketFrame) -> [f32; 192] { match frame.counter { PacketFrameCounter::Frame { index } => { type1[0..25].copy_from_slice(&frame.payload); - type1[25] = (index as u8) << 3; + type1[25] = (index as u8) << 2; } PacketFrameCounter::FinalFrame { payload_len } => { type1[0..payload_len].copy_from_slice(&frame.payload[0..payload_len]); - type1[25] = ((payload_len as u8) << 3) | 0x04; + type1[25] = ((payload_len as u8) << 2) | 0x80; } } let type3 = fec::encode(&type1, 206, p_3);