Fix CN470 ping-slot frequencies + add comments.

The frequency-hopping ping-slots are equal to the beacon frequencys.
With the US915 and AU915 channels using the Class-A downlink
channels as beacon-frequencies, this was wrongly implemented in the
same way, but in case of CN470 the beacon-frequencies are not equal
to the Class-A downlink frequencies.
This commit is contained in:
Orne Brocaar 2023-06-09 09:24:06 +01:00
parent a284a8179e
commit 318f097344
3 changed files with 11 additions and 2 deletions

View File

@ -987,6 +987,8 @@ impl Region for Configuration {
let down_channel = (u32::from_be_bytes(dev_addr.to_be_bytes()) as usize
+ (beacon_time.as_secs() / 128) as usize)
% 8;
// Beaconing is performed on the same channel that normal downstream traffic as defined in the Class A specification.
Ok(self.base.downlink_channels[down_channel].frequency)
}

View File

@ -454,7 +454,12 @@ impl Region for Configuration {
let down_channel = (u32::from_be_bytes(dev_addr.to_be_bytes()) as usize
+ (beacon_time.as_secs() / 128) as usize)
% 8;
Ok(self.base.downlink_channels[down_channel].frequency)
let beacon_freqs: Vec<u32> = vec![
508300000, 508500000, 508700000, 508900000, 509100000, 509300000, 509500000, 509700000,
];
Ok(beacon_freqs[down_channel])
}
fn get_downlink_tx_power(&self, _freq: u32) -> isize {
@ -594,7 +599,7 @@ mod tests {
let beacon_time = Duration::from_secs((334382 * 60 * 60) + (52 * 60) + 44);
let freq = c.get_ping_slot_frequency(dev_addr, beacon_time).unwrap();
assert_eq!(501100000, freq);
assert_eq!(509100000, freq);
}
#[test]

View File

@ -675,6 +675,8 @@ impl Region for Configuration {
let down_channel = (u32::from_be_bytes(dev_addr.to_be_bytes()) as usize
+ (beacon_time.as_secs() / 128) as usize)
% 8;
// Beaconing is performed on the same channel that normal downstream traffic as defined in the Class A specification.
Ok(self.base.downlink_channels[down_channel].frequency)
}