pub fn parity_line(coded: u16, nb_frag: u16, line: &mut [u8]) -> usizeExpand description
Builds one row of the parity matrix: which uncoded fragments a coded one is made of.
§Arguments
coded- which coded fragment this is, counting from one. A session’s fragmentnpast itsnb_fraguncoded ones is coded fragmentn.nb_frag- how many uncoded fragments the block was cut into.line- a bit for every uncoded fragment, cleared and then filled in, little end first. It must hold at leastnb_fragbits.
§Returns
How many fragments the coded one is the exclusive-or of, which is half of nb_frag
rounded down.
§Examples
use pamoja_lorawan::packages::fragment::parity_line;
let mut line = [0u8; 1];
assert_eq!(parity_line(1, 6, &mut line), 3);
assert_eq!(line[0] & 0b0011_1111, 0b0001_0011, "fragments 1, 2 and 5");