diff --git a/src/config.rs b/src/config.rs index ee071a14ef11972f6c13590c1830dad03ffe580f..1ef9b9ac69c4d1446136ebed3db00ca556ee05dc 100644 --- a/src/config.rs +++ b/src/config.rs @@ -250,7 +250,8 @@ pub const RADIO_CONFIG_500_4: [u8; 643] = [ 0xC, 0x11, 0x40, 0x8, 0x0, 0x3A, 0xC, 0xB1, 0x7E, 0x44, 0x44, 0x20, 0xFE, ]; -// 430.5 MHz +// 430.000 MHz @ channel 0 +// 430.500 MHZ @ channel 20 (default CATS frequency) // 9600 baud 2-FSK // Variable packet length up to 8191 bytes pub const RADIO_CONFIG_CATS: [u8; 644] = [ diff --git a/src/lib.rs b/src/lib.rs index 9943a6fb8ac39f1b15bb9aeb9c92e2d0aca05b6a..b957b3195d3f4ad9f4d73351ef8a640dabdd404e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -26,6 +26,7 @@ pub struct Rf4463<const MAX_PACKET_LEN: usize, Spi, SdnPin, CsPin, Delay> { radio: InternalRadio<Spi, SdnPin, CsPin, Delay>, state: InternalState<MAX_PACKET_LEN>, rx_forever: bool, + channel: u8, } impl< @@ -56,6 +57,7 @@ where radio: InternalRadio::new(spi, sdn, cs, delay, config)?, state: InternalState::Idle, rx_forever: false, + channel: 0, }) } @@ -71,6 +73,10 @@ where self.radio.get_rssi() } + pub fn set_channel(&mut self, channel: u8) { + self.channel = channel; + } + pub fn is_idle(&mut self) -> bool { matches!(self.state, InternalState::Idle) } @@ -88,7 +94,7 @@ where self.radio.send_command::<0>(&mut [ START_RX, - 0, + self.channel, 0, (MAX_PACKET_LEN >> 8).try_into().unwrap(), (MAX_PACKET_LEN & 0xff).try_into().unwrap(), @@ -167,10 +173,10 @@ where self.radio .send_command::<0>(&mut [ START_TX, - 0, + self.channel, u8::from(State::Sleep) << 4, - (MAX_PACKET_LEN >> 8).try_into().unwrap(), - (MAX_PACKET_LEN & 0xff).try_into().unwrap(), + (len >> 8).try_into().unwrap(), + (len & 0xff).try_into().unwrap(), 0, 0, ])