Skip to main content

packet_len

Function packet_len 

Source
pub const fn packet_len(payload_len: usize, metrics: u8) -> usize
Expand description

How many bytes a packet takes in the buffer.

§Arguments

  • payload_len - the length the head metadata announced.
  • metrics - how many fine timestamp metrics the tail announced.

§Returns

The whole span, which is where the next packet starts. The metrics are counted because a reader that leaves them out finds the next packet in the wrong place.

§Examples

use pamoja_radios::sx1302::rx::packet_len;

// Four bytes of payload and no metrics: nine of head and fourteen of tail around it.
assert_eq!(packet_len(4, 0), 27);

// Each metric adds two bytes after the tail.
assert_eq!(packet_len(4, 3), 33);