pub struct Plan {
pub carrier_hz: u32,
pub channels: [Listener; 8],
pub spreading_factors: u8,
pub public: bool,
pub service: Option<Service>,
pub fsk: Option<Fsk>,
}Expand description
What a concentrator is to listen for.
Fields§
§carrier_hz: u32The carrier the first radio is tuned to, in hertz, which every offset is measured from.
channels: [Listener; 8]The eight receivers that take any spreading factor.
spreading_factors: u8Which spreading factors to look for, one bit each counting from
MIN_SPREADING_FACTOR.
public: boolWhether the network is a public one, which decides the sync word the receivers look for. LoRaWAN networks are public; the chip powers up expecting a private one.
service: Option<Service>The receiver fixed to one spreading factor, or None to leave it where reset left it.
fsk: Option<Fsk>The receiver that hears frequency shift keying, or None to leave it where reset
left it.
Implementations§
Source§impl Plan
impl Plan
Sourcepub fn new(carrier_hz: u32, offsets_hz: &[i32]) -> Plan
pub fn new(carrier_hz: u32, offsets_hz: &[i32]) -> Plan
A plan on one carrier, listening on these offsets.
§Arguments
carrier_hz- what the radio is tuned to.offsets_hz- how far from it each receiver listens. Anything past the eighth is ignored, and any receiver left over is switched off.
§Returns
The plan, looking for every spreading factor.
§Examples
use pamoja_radios::sx1302::channel::Plan;
// The eight channels a European gateway usually runs, 867.1 MHz through 868.5 MHz.
// The carrier sits in the middle of them, because a radio only hears so far either
// side of what it is tuned to.
let plan = Plan::new(
867_800_000,
&[-700_000, -500_000, -300_000, -100_000, 100_000, 300_000, 500_000, 700_000],
);
assert!(plan.channels[0].enabled);
assert_eq!(plan.channels[4].offset_hz, 100_000);Sourcepub const fn network(self, public: bool) -> Plan
pub const fn network(self, public: bool) -> Plan
The same plan, on a public network or a private one.
§Arguments
public- whether the network is public. Every LoRaWAN network is.
§Returns
The plan.
§Examples
use pamoja_radios::sx1302::channel::Plan;
// A plan listens to a public network unless it is told otherwise.
assert!(Plan::new(867_800_000, &[0]).public);
assert!(!Plan::new(867_800_000, &[0]).network(false).public);Sourcepub const fn serving(self, service: Service) -> Plan
pub const fn serving(self, service: Service) -> Plan
The same plan, with the fixed-rate receiver pointed at a channel.
That receiver is switched on whatever a plan says, so one never given a channel listens wherever reset left it. This is what gives it somewhere to listen.
§Arguments
service- the channel it runs on.
§Returns
The plan.
§Examples
use pamoja_radios::sx1302::channel::{Plan, Service};
let plan = Plan::new(867_800_000, &[-300_000])
.serving(Service::at(500_000, 7).bandwidth(250_000));
assert_eq!(plan.service.map(|service| service.spreading_factor), Some(7));Sourcepub const fn hearing(self, fsk: Fsk) -> Plan
pub const fn hearing(self, fsk: Fsk) -> Plan
The same plan, with the frequency shift keying receiver pointed at a channel.
That receiver is switched on whatever a plan says, so one never given a channel listens wherever reset left it, as the fixed-rate one does.
§Arguments
fsk- the channel it runs on.
§Returns
The plan.
§Examples
use pamoja_radios::sx1302::channel::{Fsk, Plan};
use pamoja_radios::sx1302::tx::Chain;
let plan = Plan::new(867_800_000, &[-300_000]).hearing(Fsk::at(600_000).on(Chain::B));
assert_eq!(plan.fsk.map(|fsk| fsk.bitrate), Some(50_000));Sourcepub fn looking_for(self, wanted: &[u8]) -> Plan
pub fn looking_for(self, wanted: &[u8]) -> Plan
The same plan, looking only for these spreading factors.
§Arguments
wanted- the spreading factors to look for. Anything outside 5 to 12 is ignored.
§Returns
The plan.
§Examples
use pamoja_radios::sx1302::channel::Plan;
// A network that only runs the faster half of the range.
let plan = Plan::new(867_500_000, &[-400_000]).looking_for(&[7, 8, 9]);
assert_eq!(plan.spreading_factors, 0b0001_1100);Sourcepub const fn radios(&self) -> u8
pub const fn radios(&self) -> u8
Which radio each receiver takes its samples from, one bit per receiver.
§Returns
The mask the chip takes, with a bit set for every receiver on the second radio.
§Examples
use pamoja_radios::sx1302::channel::Plan;
use pamoja_radios::sx1302::tx::Chain;
let mut plan = Plan::new(867_500_000, &[0, 0]);
plan.channels[1] = plan.channels[1].on(Chain::B);
assert_eq!(plan.radios(), 0b0000_0010);