aboutsummaryrefslogtreecommitdiff
path: root/embassy-lora/src
diff options
context:
space:
mode:
authorceekdee <[email protected]>2022-10-10 12:35:42 -0500
committerceekdee <[email protected]>2022-10-10 12:35:42 -0500
commit327d3cf0df7a1b116ea7ec44d36a569e6ba6ca16 (patch)
tree67c69a2d511ba9dee2def2f7858e859d8150559b /embassy-lora/src
parent79ba20d315f456ac525daf4c3d5dd0d2ce92ad2b (diff)
Change rak4631 feature to sx126x, removing use in board-specific processing; simplify the P2P examples; correct RSSI computation.
Diffstat (limited to 'embassy-lora/src')
-rw-r--r--embassy-lora/src/lib.rs2
-rw-r--r--embassy-lora/src/sx126x/sx126x_lora/board_specific.rs28
-rw-r--r--embassy-lora/src/sx126x/sx126x_lora/subroutine.rs6
3 files changed, 12 insertions, 24 deletions
diff --git a/embassy-lora/src/lib.rs b/embassy-lora/src/lib.rs
index 342f66b2a..3e4748430 100644
--- a/embassy-lora/src/lib.rs
+++ b/embassy-lora/src/lib.rs
@@ -7,7 +7,7 @@ pub(crate) mod fmt;
7 7
8#[cfg(feature = "stm32wl")] 8#[cfg(feature = "stm32wl")]
9pub mod stm32wl; 9pub mod stm32wl;
10#[cfg(feature = "rak4631")] 10#[cfg(feature = "sx126x")]
11pub mod sx126x; 11pub mod sx126x;
12#[cfg(feature = "sx127x")] 12#[cfg(feature = "sx127x")]
13pub mod sx127x; 13pub mod sx127x;
diff --git a/embassy-lora/src/sx126x/sx126x_lora/board_specific.rs b/embassy-lora/src/sx126x/sx126x_lora/board_specific.rs
index 1fb085887..a7b9e1486 100644
--- a/embassy-lora/src/sx126x/sx126x_lora/board_specific.rs
+++ b/embassy-lora/src/sx126x/sx126x_lora/board_specific.rs
@@ -10,8 +10,7 @@ use super::LoRa;
10// Defines the time required for the TCXO to wakeup [ms]. 10// Defines the time required for the TCXO to wakeup [ms].
11const BRD_TCXO_WAKEUP_TIME: u32 = 10; 11const BRD_TCXO_WAKEUP_TIME: u32 = 10;
12 12
13// Provides board-specific functionality for Semtech SX126x-based boards. Use #[cfg(feature = "board_type")] to specify unique board functionality. 13// Provides board-specific functionality for Semtech SX126x-based boards.
14// The base implementation supports the RAK4631 board.
15 14
16impl<SPI, CTRL, WAIT, BUS> LoRa<SPI, CTRL, WAIT> 15impl<SPI, CTRL, WAIT, BUS> LoRa<SPI, CTRL, WAIT>
17where 16where
@@ -203,44 +202,33 @@ where
203 202
204 // Get the radio type 203 // Get the radio type
205 pub(super) fn brd_get_radio_type(&mut self) -> RadioType { 204 pub(super) fn brd_get_radio_type(&mut self) -> RadioType {
206 #[cfg(feature = "rak4631")]
207 RadioType::SX1262 205 RadioType::SX1262
208 } 206 }
209 207
210 // Quiesce the antenna(s). 208 // Quiesce the antenna(s).
211 pub(super) fn brd_ant_sleep(&mut self) -> Result<(), RadioError<BUS>> { 209 pub(super) fn brd_ant_sleep(&mut self) -> Result<(), RadioError<BUS>> {
212 #[cfg(feature = "rak4631")] 210 self.antenna_tx.set_low().map_err(|_| AntTx)?;
213 { 211 self.antenna_rx.set_low().map_err(|_| AntRx)?;
214 self.antenna_tx.set_low().map_err(|_| AntTx)?;
215 self.antenna_rx.set_low().map_err(|_| AntRx)?;
216 }
217 Ok(()) 212 Ok(())
218 } 213 }
219 214
220 // Prepare the antenna(s) for a receive operation 215 // Prepare the antenna(s) for a receive operation
221 pub(super) fn brd_ant_set_rx(&mut self) -> Result<(), RadioError<BUS>> { 216 pub(super) fn brd_ant_set_rx(&mut self) -> Result<(), RadioError<BUS>> {
222 #[cfg(feature = "rak4631")] 217 self.antenna_tx.set_low().map_err(|_| AntTx)?;
223 { 218 self.antenna_rx.set_high().map_err(|_| AntRx)?;
224 self.antenna_tx.set_low().map_err(|_| AntTx)?;
225 self.antenna_rx.set_high().map_err(|_| AntRx)?;
226 }
227 Ok(()) 219 Ok(())
228 } 220 }
229 221
230 // Prepare the antenna(s) for a send operation 222 // Prepare the antenna(s) for a send operation
231 pub(super) fn brd_ant_set_tx(&mut self) -> Result<(), RadioError<BUS>> { 223 pub(super) fn brd_ant_set_tx(&mut self) -> Result<(), RadioError<BUS>> {
232 #[cfg(feature = "rak4631")] 224 self.antenna_rx.set_low().map_err(|_| AntRx)?;
233 { 225 self.antenna_tx.set_high().map_err(|_| AntTx)?;
234 self.antenna_rx.set_low().map_err(|_| AntRx)?;
235 self.antenna_tx.set_high().map_err(|_| AntTx)?;
236 }
237 Ok(()) 226 Ok(())
238 } 227 }
239 228
240 // Check if the given RF frequency is supported by the hardware 229 // Check if the given RF frequency is supported by the hardware
241 pub(super) async fn brd_check_rf_frequency(&mut self, _frequency: u32) -> Result<bool, RadioError<BUS>> { 230 pub(super) async fn brd_check_rf_frequency(&mut self, _frequency: u32) -> Result<bool, RadioError<BUS>> {
242 #[cfg(feature = "rak4631")] 231 Ok(true)
243 Ok(true) // all frequencies currently supported for the SX1262 within a rak4631
244 } 232 }
245 233
246 // Get the duration required for the TCXO to wakeup [ms]. 234 // Get the duration required for the TCXO to wakeup [ms].
diff --git a/embassy-lora/src/sx126x/sx126x_lora/subroutine.rs b/embassy-lora/src/sx126x/sx126x_lora/subroutine.rs
index 283e60993..2e78b919b 100644
--- a/embassy-lora/src/sx126x/sx126x_lora/subroutine.rs
+++ b/embassy-lora/src/sx126x/sx126x_lora/subroutine.rs
@@ -564,7 +564,7 @@ where
564 pub(super) async fn sub_get_rssi_inst(&mut self) -> Result<i8, RadioError<BUS>> { 564 pub(super) async fn sub_get_rssi_inst(&mut self) -> Result<i8, RadioError<BUS>> {
565 let mut buffer = [0x00u8]; 565 let mut buffer = [0x00u8];
566 self.brd_read_command(OpCode::GetRSSIInst, &mut buffer).await?; 566 self.brd_read_command(OpCode::GetRSSIInst, &mut buffer).await?;
567 let rssi: i8 = (-(buffer[0] as i8)) >> 1; // check this ??? 567 let rssi: i8 = ((-(buffer[0] as i32)) >> 1) as i8; // check this ???
568 Ok(rssi) 568 Ok(rssi)
569 } 569 }
570 570
@@ -597,9 +597,9 @@ where
597 self.brd_read_command(OpCode::GetPacketStatus, &mut status).await?; 597 self.brd_read_command(OpCode::GetPacketStatus, &mut status).await?;
598 598
599 // check this ??? 599 // check this ???
600 let rssi = (-(status[0] as i8)) >> 1; 600 let rssi = ((-(status[0] as i32)) >> 1) as i8;
601 let snr = ((status[1] as i8) + 2) >> 2; 601 let snr = ((status[1] as i8) + 2) >> 2;
602 let signal_rssi = (-(status[2] as i8)) >> 1; 602 let signal_rssi = ((-(status[2] as i32)) >> 1) as i8;
603 let freq_error = self.frequency_error; 603 let freq_error = self.frequency_error;
604 604
605 Ok(PacketStatus { 605 Ok(PacketStatus {