Update for rust-lorawan and lora-phy version 2.
This commit is contained in:
@ -41,10 +41,8 @@ async fn main(_spawner: Spawner) {
|
||||
let iv =
|
||||
GenericSx126xInterfaceVariant::new(nss, reset, dio1, busy, Some(rf_switch_rx), Some(rf_switch_tx)).unwrap();
|
||||
|
||||
let mut delay = Delay;
|
||||
|
||||
let mut lora = {
|
||||
match LoRa::new(SX1261_2::new(BoardType::Rak4631Sx1262, spim, iv), false, &mut delay).await {
|
||||
match LoRa::new(SX1261_2::new(BoardType::Rak4631Sx1262, spim, iv), false, Delay).await {
|
||||
Ok(l) => l,
|
||||
Err(err) => {
|
||||
info!("Radio error = {}", err);
|
||||
|
@ -20,6 +20,7 @@ use lora_phy::LoRa;
|
||||
use lorawan::default_crypto::DefaultFactory as Crypto;
|
||||
use lorawan_device::async_device::lora_radio::LoRaRadio;
|
||||
use lorawan_device::async_device::{region, Device, JoinMode};
|
||||
use lorawan_device::{AppEui, AppKey, DevEui};
|
||||
use {defmt_rtt as _, panic_probe as _};
|
||||
|
||||
const LORAWAN_REGION: region::Region = region::Region::EU868; // warning: set this appropriately for the region
|
||||
@ -47,10 +48,8 @@ async fn main(_spawner: Spawner) {
|
||||
let iv =
|
||||
GenericSx126xInterfaceVariant::new(nss, reset, dio1, busy, Some(rf_switch_rx), Some(rf_switch_tx)).unwrap();
|
||||
|
||||
let mut delay = Delay;
|
||||
|
||||
let lora = {
|
||||
match LoRa::new(SX1261_2::new(BoardType::Rak4631Sx1262, spim, iv), true, &mut delay).await {
|
||||
match LoRa::new(SX1261_2::new(BoardType::Rak4631Sx1262, spim, iv), true, Delay).await {
|
||||
Ok(l) => l,
|
||||
Err(err) => {
|
||||
info!("Radio error = {}", err);
|
||||
@ -68,9 +67,9 @@ async fn main(_spawner: Spawner) {
|
||||
// TODO: Adjust the EUI and Keys according to your network credentials
|
||||
match device
|
||||
.join(&JoinMode::OTAA {
|
||||
deveui: [0, 0, 0, 0, 0, 0, 0, 0],
|
||||
appeui: [0, 0, 0, 0, 0, 0, 0, 0],
|
||||
appkey: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||
deveui: DevEui::from([0, 0, 0, 0, 0, 0, 0, 0]),
|
||||
appeui: AppEui::from([0, 0, 0, 0, 0, 0, 0, 0]),
|
||||
appkey: AppKey::from([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]),
|
||||
})
|
||||
.await
|
||||
{
|
||||
|
@ -41,10 +41,8 @@ async fn main(_spawner: Spawner) {
|
||||
let iv =
|
||||
GenericSx126xInterfaceVariant::new(nss, reset, dio1, busy, Some(rf_switch_rx), Some(rf_switch_tx)).unwrap();
|
||||
|
||||
let mut delay = Delay;
|
||||
|
||||
let mut lora = {
|
||||
match LoRa::new(SX1261_2::new(BoardType::Rak4631Sx1262, spim, iv), false, &mut delay).await {
|
||||
match LoRa::new(SX1261_2::new(BoardType::Rak4631Sx1262, spim, iv), false, Delay).await {
|
||||
Ok(l) => l,
|
||||
Err(err) => {
|
||||
info!("Radio error = {}", err);
|
||||
@ -88,7 +86,7 @@ async fn main(_spawner: Spawner) {
|
||||
};
|
||||
|
||||
match lora
|
||||
.prepare_for_rx(&mdltn_params, &rx_pkt_params, None, true, false, 0, 0x00ffffffu32)
|
||||
.prepare_for_rx(&mdltn_params, &rx_pkt_params, None, None, false)
|
||||
.await
|
||||
{
|
||||
Ok(()) => {}
|
||||
|
@ -41,10 +41,8 @@ async fn main(_spawner: Spawner) {
|
||||
let iv =
|
||||
GenericSx126xInterfaceVariant::new(nss, reset, dio1, busy, Some(rf_switch_rx), Some(rf_switch_tx)).unwrap();
|
||||
|
||||
let mut delay = Delay;
|
||||
|
||||
let mut lora = {
|
||||
match LoRa::new(SX1261_2::new(BoardType::Rak4631Sx1262, spim, iv), false, &mut delay).await {
|
||||
match LoRa::new(SX1261_2::new(BoardType::Rak4631Sx1262, spim, iv), false, Delay).await {
|
||||
Ok(l) => l,
|
||||
Err(err) => {
|
||||
info!("Radio error = {}", err);
|
||||
@ -92,14 +90,12 @@ async fn main(_spawner: Spawner) {
|
||||
.prepare_for_rx(
|
||||
&mdltn_params,
|
||||
&rx_pkt_params,
|
||||
None,
|
||||
Some(&DutyCycleParams {
|
||||
rx_time: 300_000, // 300_000 units * 15.625 us/unit = 4.69 s
|
||||
sleep_time: 200_000, // 200_000 units * 15.625 us/unit = 3.13 s
|
||||
}),
|
||||
false,
|
||||
false,
|
||||
0,
|
||||
0,
|
||||
)
|
||||
.await
|
||||
{
|
||||
|
@ -41,10 +41,8 @@ async fn main(_spawner: Spawner) {
|
||||
let iv =
|
||||
GenericSx126xInterfaceVariant::new(nss, reset, dio1, busy, Some(rf_switch_rx), Some(rf_switch_tx)).unwrap();
|
||||
|
||||
let mut delay = Delay;
|
||||
|
||||
let mut lora = {
|
||||
match LoRa::new(SX1261_2::new(BoardType::Rak4631Sx1262, spim, iv), false, &mut delay).await {
|
||||
match LoRa::new(SX1261_2::new(BoardType::Rak4631Sx1262, spim, iv), false, Delay).await {
|
||||
Ok(l) => l,
|
||||
Err(err) => {
|
||||
info!("Radio error = {}", err);
|
||||
@ -97,7 +95,7 @@ async fn main(_spawner: Spawner) {
|
||||
}
|
||||
};
|
||||
|
||||
match lora.sleep(&mut delay).await {
|
||||
match lora.sleep(false).await {
|
||||
Ok(()) => info!("Sleep successful"),
|
||||
Err(err) => info!("Sleep unsuccessful = {}", err),
|
||||
}
|
||||
|
Reference in New Issue
Block a user