Skip to main content

scan_counts

Function scan_counts 

Source
pub fn scan_counts(answer: &[u8], rssi_offset: i8) -> Option<[Level; 33]>
Expand description

Reads what a spectral scan counted.

§Arguments

  • answer - the bytes the read moved, starting with the address that went out.
  • rssi_offset - the board’s correction, in dB, from its own calibration.

§Returns

The levels, strongest first, four decibels apart, or None when the answer is too short.

The last level repeats the one before it rather than continuing down, because it counts everything heard below the lowest threshold rather than at a level of its own. Subtracting one count from the other is what a caller does with it.

§Examples

use pamoja_radios::sx1302::sx1261::{scan_counts, SCAN_TRANSFER};

let mut answer = [0u8; SCAN_TRANSFER];
answer[3] = 0x01;
answer[4] = 0x2c;

let levels = scan_counts(&answer, -3).expect("that is a whole answer");
assert_eq!(levels[0].dbm, -3, "the strongest level, corrected for the board");
assert_eq!(levels[0].count, 300);
assert_eq!(levels[1].dbm, -7, "four decibels down");
assert_eq!(levels[32].dbm, levels[31].dbm, "everything below the last one");