pub fn gain_for(table: &[Gain], wanted_dbm: i8) -> Option<Gain>Expand description
Picks the entry to transmit a wanted power at.
The strongest entry that does not exceed what was asked for, so a gateway told to transmit at more than its table reaches transmits at the most it has rather than refusing or exceeding it. A request below the whole table takes the weakest entry.
§Arguments
table- the board’s table, strongest last.wanted_dbm- the power asked for.
§Returns
The entry, or None for an empty table.
§Examples
use pamoja_radios::sx1302::tx::{gain_for, DEFAULT_GAINS};
// Exactly on an entry, and between two.
assert_eq!(gain_for(&DEFAULT_GAINS, 20).map(|g| g.radiated_dbm), Some(20));
assert_eq!(gain_for(&DEFAULT_GAINS, 16).map(|g| g.radiated_dbm), Some(16));
// Past the top of the table, and below the bottom of it.
assert_eq!(gain_for(&DEFAULT_GAINS, 30).map(|g| g.radiated_dbm), Some(27));
assert_eq!(gain_for(&DEFAULT_GAINS, 2).map(|g| g.radiated_dbm), Some(12));