diff options
| author | ceekdee <[email protected]> | 2023-09-24 10:33:03 -0500 |
|---|---|---|
| committer | ceekdee <[email protected]> | 2023-09-24 10:33:03 -0500 |
| commit | 7d5e62d4a7764c80a9378e34e755239838081a00 (patch) | |
| tree | 31410a06d86f85eee6d44963fe194deeac961c0e /examples | |
| parent | 65d36f9f99c3b8055e7b9c02e1b1aae3cb242d6a (diff) | |
Update for rust-lorawan and lora-phy version 2.
Diffstat (limited to 'examples')
20 files changed, 54 insertions, 103 deletions
diff --git a/examples/nrf52840/Cargo.toml b/examples/nrf52840/Cargo.toml index a40a9dc14..d54847fff 100644 --- a/examples/nrf52840/Cargo.toml +++ b/examples/nrf52840/Cargo.toml | |||
| @@ -38,7 +38,7 @@ embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defm | |||
| 38 | embedded-io = { version = "0.5.0", features = ["defmt-03"] } | 38 | embedded-io = { version = "0.5.0", features = ["defmt-03"] } |
| 39 | embedded-io-async = { version = "0.5.0", optional = true, features = ["defmt-03"] } | 39 | embedded-io-async = { version = "0.5.0", optional = true, features = ["defmt-03"] } |
| 40 | embassy-lora = { version = "0.1.0", path = "../../embassy-lora", features = ["time", "defmt"], optional = true } | 40 | embassy-lora = { version = "0.1.0", path = "../../embassy-lora", features = ["time", "defmt"], optional = true } |
| 41 | lora-phy = { version = "1", optional = true } | 41 | lora-phy = { version = "2", optional = true } |
| 42 | lorawan-device = { version = "0.10.0", default-features = false, features = ["async", "external-lora-phy"], optional = true } | 42 | lorawan-device = { version = "0.10.0", default-features = false, features = ["async", "external-lora-phy"], optional = true } |
| 43 | lorawan = { version = "0.7.3", default-features = false, features = ["default-crypto"], optional = true } | 43 | lorawan = { version = "0.7.3", default-features = false, features = ["default-crypto"], optional = true } |
| 44 | embassy-net-esp-hosted = { version = "0.1.0", path = "../../embassy-net-esp-hosted", features = ["defmt"], optional = true } | 44 | embassy-net-esp-hosted = { version = "0.1.0", path = "../../embassy-net-esp-hosted", features = ["defmt"], optional = true } |
| @@ -67,4 +67,5 @@ microfft = "0.5.0" | |||
| 67 | debug = 2 | 67 | debug = 2 |
| 68 | 68 | ||
| 69 | [patch.crates-io] | 69 | [patch.crates-io] |
| 70 | lora-phy = { git = "https://github.com/embassy-rs/lora-phy", rev = "1323eccc1c470d4259f95f4f315d1be830d572a3"} | 70 | lorawan-device = { git = "https://github.com/ivajloip/rust-lorawan", rev = "b0502c1a802427638cc8bcd928fc632d13b778b6"} |
| 71 | lorawan = { git = "https://github.com/ivajloip/rust-lorawan", rev = "b0502c1a802427638cc8bcd928fc632d13b778b6"} | ||
diff --git a/examples/nrf52840/src/bin/lora_cad.rs b/examples/nrf52840/src/bin/lora_cad.rs index beca061ed..3a98133c9 100644 --- a/examples/nrf52840/src/bin/lora_cad.rs +++ b/examples/nrf52840/src/bin/lora_cad.rs | |||
| @@ -41,10 +41,8 @@ async fn main(_spawner: Spawner) { | |||
| 41 | let iv = | 41 | let iv = |
| 42 | GenericSx126xInterfaceVariant::new(nss, reset, dio1, busy, Some(rf_switch_rx), Some(rf_switch_tx)).unwrap(); | 42 | GenericSx126xInterfaceVariant::new(nss, reset, dio1, busy, Some(rf_switch_rx), Some(rf_switch_tx)).unwrap(); |
| 43 | 43 | ||
| 44 | let mut delay = Delay; | ||
| 45 | |||
| 46 | let mut lora = { | 44 | let mut lora = { |
| 47 | match LoRa::new(SX1261_2::new(BoardType::Rak4631Sx1262, spim, iv), false, &mut delay).await { | 45 | match LoRa::new(SX1261_2::new(BoardType::Rak4631Sx1262, spim, iv), false, Delay).await { |
| 48 | Ok(l) => l, | 46 | Ok(l) => l, |
| 49 | Err(err) => { | 47 | Err(err) => { |
| 50 | info!("Radio error = {}", err); | 48 | info!("Radio error = {}", err); |
diff --git a/examples/nrf52840/src/bin/lora_lorawan.rs b/examples/nrf52840/src/bin/lora_lorawan.rs index c953680c6..666330ba1 100644 --- a/examples/nrf52840/src/bin/lora_lorawan.rs +++ b/examples/nrf52840/src/bin/lora_lorawan.rs | |||
| @@ -20,6 +20,7 @@ use lora_phy::LoRa; | |||
| 20 | use lorawan::default_crypto::DefaultFactory as Crypto; | 20 | use lorawan::default_crypto::DefaultFactory as Crypto; |
| 21 | use lorawan_device::async_device::lora_radio::LoRaRadio; | 21 | use lorawan_device::async_device::lora_radio::LoRaRadio; |
| 22 | use lorawan_device::async_device::{region, Device, JoinMode}; | 22 | use lorawan_device::async_device::{region, Device, JoinMode}; |
| 23 | use lorawan_device::{AppEui, AppKey, DevEui}; | ||
| 23 | use {defmt_rtt as _, panic_probe as _}; | 24 | use {defmt_rtt as _, panic_probe as _}; |
| 24 | 25 | ||
| 25 | const LORAWAN_REGION: region::Region = region::Region::EU868; // warning: set this appropriately for the region | 26 | const LORAWAN_REGION: region::Region = region::Region::EU868; // warning: set this appropriately for the region |
| @@ -47,10 +48,8 @@ async fn main(_spawner: Spawner) { | |||
| 47 | let iv = | 48 | let iv = |
| 48 | GenericSx126xInterfaceVariant::new(nss, reset, dio1, busy, Some(rf_switch_rx), Some(rf_switch_tx)).unwrap(); | 49 | GenericSx126xInterfaceVariant::new(nss, reset, dio1, busy, Some(rf_switch_rx), Some(rf_switch_tx)).unwrap(); |
| 49 | 50 | ||
| 50 | let mut delay = Delay; | ||
| 51 | |||
| 52 | let lora = { | 51 | let lora = { |
| 53 | match LoRa::new(SX1261_2::new(BoardType::Rak4631Sx1262, spim, iv), true, &mut delay).await { | 52 | match LoRa::new(SX1261_2::new(BoardType::Rak4631Sx1262, spim, iv), true, Delay).await { |
| 54 | Ok(l) => l, | 53 | Ok(l) => l, |
| 55 | Err(err) => { | 54 | Err(err) => { |
| 56 | info!("Radio error = {}", err); | 55 | info!("Radio error = {}", err); |
| @@ -68,9 +67,9 @@ async fn main(_spawner: Spawner) { | |||
| 68 | // TODO: Adjust the EUI and Keys according to your network credentials | 67 | // TODO: Adjust the EUI and Keys according to your network credentials |
| 69 | match device | 68 | match device |
| 70 | .join(&JoinMode::OTAA { | 69 | .join(&JoinMode::OTAA { |
| 71 | deveui: [0, 0, 0, 0, 0, 0, 0, 0], | 70 | deveui: DevEui::from([0, 0, 0, 0, 0, 0, 0, 0]), |
| 72 | appeui: [0, 0, 0, 0, 0, 0, 0, 0], | 71 | appeui: AppEui::from([0, 0, 0, 0, 0, 0, 0, 0]), |
| 73 | appkey: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], | 72 | appkey: AppKey::from([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), |
| 74 | }) | 73 | }) |
| 75 | .await | 74 | .await |
| 76 | { | 75 | { |
diff --git a/examples/nrf52840/src/bin/lora_p2p_receive.rs b/examples/nrf52840/src/bin/lora_p2p_receive.rs index 563fe42ec..1d293c6bf 100644 --- a/examples/nrf52840/src/bin/lora_p2p_receive.rs +++ b/examples/nrf52840/src/bin/lora_p2p_receive.rs | |||
| @@ -41,10 +41,8 @@ async fn main(_spawner: Spawner) { | |||
| 41 | let iv = | 41 | let iv = |
| 42 | GenericSx126xInterfaceVariant::new(nss, reset, dio1, busy, Some(rf_switch_rx), Some(rf_switch_tx)).unwrap(); | 42 | GenericSx126xInterfaceVariant::new(nss, reset, dio1, busy, Some(rf_switch_rx), Some(rf_switch_tx)).unwrap(); |
| 43 | 43 | ||
| 44 | let mut delay = Delay; | ||
| 45 | |||
| 46 | let mut lora = { | 44 | let mut lora = { |
| 47 | match LoRa::new(SX1261_2::new(BoardType::Rak4631Sx1262, spim, iv), false, &mut delay).await { | 45 | match LoRa::new(SX1261_2::new(BoardType::Rak4631Sx1262, spim, iv), false, Delay).await { |
| 48 | Ok(l) => l, | 46 | Ok(l) => l, |
| 49 | Err(err) => { | 47 | Err(err) => { |
| 50 | info!("Radio error = {}", err); | 48 | info!("Radio error = {}", err); |
| @@ -88,7 +86,7 @@ async fn main(_spawner: Spawner) { | |||
| 88 | }; | 86 | }; |
| 89 | 87 | ||
| 90 | match lora | 88 | match lora |
| 91 | .prepare_for_rx(&mdltn_params, &rx_pkt_params, None, true, false, 0, 0x00ffffffu32) | 89 | .prepare_for_rx(&mdltn_params, &rx_pkt_params, None, None, false) |
| 92 | .await | 90 | .await |
| 93 | { | 91 | { |
| 94 | Ok(()) => {} | 92 | Ok(()) => {} |
diff --git a/examples/nrf52840/src/bin/lora_p2p_receive_duty_cycle.rs b/examples/nrf52840/src/bin/lora_p2p_receive_duty_cycle.rs index 1fd8f61a2..eee4d20e7 100644 --- a/examples/nrf52840/src/bin/lora_p2p_receive_duty_cycle.rs +++ b/examples/nrf52840/src/bin/lora_p2p_receive_duty_cycle.rs | |||
| @@ -41,10 +41,8 @@ async fn main(_spawner: Spawner) { | |||
| 41 | let iv = | 41 | let iv = |
| 42 | GenericSx126xInterfaceVariant::new(nss, reset, dio1, busy, Some(rf_switch_rx), Some(rf_switch_tx)).unwrap(); | 42 | GenericSx126xInterfaceVariant::new(nss, reset, dio1, busy, Some(rf_switch_rx), Some(rf_switch_tx)).unwrap(); |
| 43 | 43 | ||
| 44 | let mut delay = Delay; | ||
| 45 | |||
| 46 | let mut lora = { | 44 | let mut lora = { |
| 47 | match LoRa::new(SX1261_2::new(BoardType::Rak4631Sx1262, spim, iv), false, &mut delay).await { | 45 | match LoRa::new(SX1261_2::new(BoardType::Rak4631Sx1262, spim, iv), false, Delay).await { |
| 48 | Ok(l) => l, | 46 | Ok(l) => l, |
| 49 | Err(err) => { | 47 | Err(err) => { |
| 50 | info!("Radio error = {}", err); | 48 | info!("Radio error = {}", err); |
| @@ -92,14 +90,12 @@ async fn main(_spawner: Spawner) { | |||
| 92 | .prepare_for_rx( | 90 | .prepare_for_rx( |
| 93 | &mdltn_params, | 91 | &mdltn_params, |
| 94 | &rx_pkt_params, | 92 | &rx_pkt_params, |
| 93 | None, | ||
| 95 | Some(&DutyCycleParams { | 94 | Some(&DutyCycleParams { |
| 96 | rx_time: 300_000, // 300_000 units * 15.625 us/unit = 4.69 s | 95 | rx_time: 300_000, // 300_000 units * 15.625 us/unit = 4.69 s |
| 97 | sleep_time: 200_000, // 200_000 units * 15.625 us/unit = 3.13 s | 96 | sleep_time: 200_000, // 200_000 units * 15.625 us/unit = 3.13 s |
| 98 | }), | 97 | }), |
| 99 | false, | 98 | false, |
| 100 | false, | ||
| 101 | 0, | ||
| 102 | 0, | ||
| 103 | ) | 99 | ) |
| 104 | .await | 100 | .await |
| 105 | { | 101 | { |
diff --git a/examples/nrf52840/src/bin/lora_p2p_send.rs b/examples/nrf52840/src/bin/lora_p2p_send.rs index 1c8bbc27a..676221a27 100644 --- a/examples/nrf52840/src/bin/lora_p2p_send.rs +++ b/examples/nrf52840/src/bin/lora_p2p_send.rs | |||
| @@ -41,10 +41,8 @@ async fn main(_spawner: Spawner) { | |||
| 41 | let iv = | 41 | let iv = |
| 42 | GenericSx126xInterfaceVariant::new(nss, reset, dio1, busy, Some(rf_switch_rx), Some(rf_switch_tx)).unwrap(); | 42 | GenericSx126xInterfaceVariant::new(nss, reset, dio1, busy, Some(rf_switch_rx), Some(rf_switch_tx)).unwrap(); |
| 43 | 43 | ||
| 44 | let mut delay = Delay; | ||
| 45 | |||
| 46 | let mut lora = { | 44 | let mut lora = { |
| 47 | match LoRa::new(SX1261_2::new(BoardType::Rak4631Sx1262, spim, iv), false, &mut delay).await { | 45 | match LoRa::new(SX1261_2::new(BoardType::Rak4631Sx1262, spim, iv), false, Delay).await { |
| 48 | Ok(l) => l, | 46 | Ok(l) => l, |
| 49 | Err(err) => { | 47 | Err(err) => { |
| 50 | info!("Radio error = {}", err); | 48 | info!("Radio error = {}", err); |
| @@ -97,7 +95,7 @@ async fn main(_spawner: Spawner) { | |||
| 97 | } | 95 | } |
| 98 | }; | 96 | }; |
| 99 | 97 | ||
| 100 | match lora.sleep(&mut delay).await { | 98 | match lora.sleep(false).await { |
| 101 | Ok(()) => info!("Sleep successful"), | 99 | Ok(()) => info!("Sleep successful"), |
| 102 | Err(err) => info!("Sleep unsuccessful = {}", err), | 100 | Err(err) => info!("Sleep unsuccessful = {}", err), |
| 103 | } | 101 | } |
diff --git a/examples/rp/Cargo.toml b/examples/rp/Cargo.toml index 4b125ed8a..5fe08fb09 100644 --- a/examples/rp/Cargo.toml +++ b/examples/rp/Cargo.toml | |||
| @@ -17,7 +17,7 @@ embassy-net-wiznet = { version = "0.1.0", path = "../../embassy-net-wiznet", fea | |||
| 17 | embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } | 17 | embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } |
| 18 | embassy-usb-logger = { version = "0.1.0", path = "../../embassy-usb-logger" } | 18 | embassy-usb-logger = { version = "0.1.0", path = "../../embassy-usb-logger" } |
| 19 | embassy-lora = { version = "0.1.0", path = "../../embassy-lora", features = ["time", "defmt"] } | 19 | embassy-lora = { version = "0.1.0", path = "../../embassy-lora", features = ["time", "defmt"] } |
| 20 | lora-phy = { version = "1" } | 20 | lora-phy = { version = "2" } |
| 21 | lorawan-device = { version = "0.10.0", default-features = false, features = ["async", "external-lora-phy"] } | 21 | lorawan-device = { version = "0.10.0", default-features = false, features = ["async", "external-lora-phy"] } |
| 22 | lorawan = { version = "0.7.3", default-features = false, features = ["default-crypto"] } | 22 | lorawan = { version = "0.7.3", default-features = false, features = ["default-crypto"] } |
| 23 | cyw43 = { path = "../../cyw43", features = ["defmt", "firmware-logs"] } | 23 | cyw43 = { path = "../../cyw43", features = ["defmt", "firmware-logs"] } |
| @@ -57,4 +57,5 @@ rand = { version = "0.8.5", default-features = false } | |||
| 57 | debug = 2 | 57 | debug = 2 |
| 58 | 58 | ||
| 59 | [patch.crates-io] | 59 | [patch.crates-io] |
| 60 | lora-phy = { git = "https://github.com/embassy-rs/lora-phy", rev = "1323eccc1c470d4259f95f4f315d1be830d572a3"} | 60 | lorawan-device = { git = "https://github.com/ivajloip/rust-lorawan", rev = "b0502c1a802427638cc8bcd928fc632d13b778b6"} |
| 61 | lorawan = { git = "https://github.com/ivajloip/rust-lorawan", rev = "b0502c1a802427638cc8bcd928fc632d13b778b6"} | ||
diff --git a/examples/rp/src/bin/lora_lorawan.rs b/examples/rp/src/bin/lora_lorawan.rs index d631fafa1..e7e81863e 100644 --- a/examples/rp/src/bin/lora_lorawan.rs +++ b/examples/rp/src/bin/lora_lorawan.rs | |||
| @@ -19,6 +19,7 @@ use lora_phy::LoRa; | |||
| 19 | use lorawan::default_crypto::DefaultFactory as Crypto; | 19 | use lorawan::default_crypto::DefaultFactory as Crypto; |
| 20 | use lorawan_device::async_device::lora_radio::LoRaRadio; | 20 | use lorawan_device::async_device::lora_radio::LoRaRadio; |
| 21 | use lorawan_device::async_device::{region, Device, JoinMode}; | 21 | use lorawan_device::async_device::{region, Device, JoinMode}; |
| 22 | use lorawan_device::{AppEui, AppKey, DevEui}; | ||
| 22 | use {defmt_rtt as _, panic_probe as _}; | 23 | use {defmt_rtt as _, panic_probe as _}; |
| 23 | 24 | ||
| 24 | const LORAWAN_REGION: region::Region = region::Region::EU868; // warning: set this appropriately for the region | 25 | const LORAWAN_REGION: region::Region = region::Region::EU868; // warning: set this appropriately for the region |
| @@ -39,16 +40,8 @@ async fn main(_spawner: Spawner) { | |||
| 39 | 40 | ||
| 40 | let iv = GenericSx126xInterfaceVariant::new(nss, reset, dio1, busy, None, None).unwrap(); | 41 | let iv = GenericSx126xInterfaceVariant::new(nss, reset, dio1, busy, None, None).unwrap(); |
| 41 | 42 | ||
| 42 | let mut delay = Delay; | ||
| 43 | |||
| 44 | let lora = { | 43 | let lora = { |
| 45 | match LoRa::new( | 44 | match LoRa::new(SX1261_2::new(BoardType::RpPicoWaveshareSx1262, spi, iv), true, Delay).await { |
| 46 | SX1261_2::new(BoardType::RpPicoWaveshareSx1262, spi, iv), | ||
| 47 | true, | ||
| 48 | &mut delay, | ||
| 49 | ) | ||
| 50 | .await | ||
| 51 | { | ||
| 52 | Ok(l) => l, | 45 | Ok(l) => l, |
| 53 | Err(err) => { | 46 | Err(err) => { |
| 54 | info!("Radio error = {}", err); | 47 | info!("Radio error = {}", err); |
| @@ -66,9 +59,9 @@ async fn main(_spawner: Spawner) { | |||
| 66 | // TODO: Adjust the EUI and Keys according to your network credentials | 59 | // TODO: Adjust the EUI and Keys according to your network credentials |
| 67 | match device | 60 | match device |
| 68 | .join(&JoinMode::OTAA { | 61 | .join(&JoinMode::OTAA { |
| 69 | deveui: [0, 0, 0, 0, 0, 0, 0, 0], | 62 | deveui: DevEui::from([0, 0, 0, 0, 0, 0, 0, 0]), |
| 70 | appeui: [0, 0, 0, 0, 0, 0, 0, 0], | 63 | appeui: AppEui::from([0, 0, 0, 0, 0, 0, 0, 0]), |
| 71 | appkey: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], | 64 | appkey: AppKey::from([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), |
| 72 | }) | 65 | }) |
| 73 | .await | 66 | .await |
| 74 | { | 67 | { |
diff --git a/examples/rp/src/bin/lora_p2p_receive.rs b/examples/rp/src/bin/lora_p2p_receive.rs index 396d669de..5891826fd 100644 --- a/examples/rp/src/bin/lora_p2p_receive.rs +++ b/examples/rp/src/bin/lora_p2p_receive.rs | |||
| @@ -35,16 +35,8 @@ async fn main(_spawner: Spawner) { | |||
| 35 | 35 | ||
| 36 | let iv = GenericSx126xInterfaceVariant::new(nss, reset, dio1, busy, None, None).unwrap(); | 36 | let iv = GenericSx126xInterfaceVariant::new(nss, reset, dio1, busy, None, None).unwrap(); |
| 37 | 37 | ||
| 38 | let mut delay = Delay; | ||
| 39 | |||
| 40 | let mut lora = { | 38 | let mut lora = { |
| 41 | match LoRa::new( | 39 | match LoRa::new(SX1261_2::new(BoardType::RpPicoWaveshareSx1262, spi, iv), false, Delay).await { |
| 42 | SX1261_2::new(BoardType::RpPicoWaveshareSx1262, spi, iv), | ||
| 43 | false, | ||
| 44 | &mut delay, | ||
| 45 | ) | ||
| 46 | .await | ||
| 47 | { | ||
| 48 | Ok(l) => l, | 40 | Ok(l) => l, |
| 49 | Err(err) => { | 41 | Err(err) => { |
| 50 | info!("Radio error = {}", err); | 42 | info!("Radio error = {}", err); |
| @@ -83,7 +75,7 @@ async fn main(_spawner: Spawner) { | |||
| 83 | }; | 75 | }; |
| 84 | 76 | ||
| 85 | match lora | 77 | match lora |
| 86 | .prepare_for_rx(&mdltn_params, &rx_pkt_params, None, true, false, 0, 0x00ffffffu32) | 78 | .prepare_for_rx(&mdltn_params, &rx_pkt_params, None, None, false) |
| 87 | .await | 79 | .await |
| 88 | { | 80 | { |
| 89 | Ok(()) => {} | 81 | Ok(()) => {} |
diff --git a/examples/rp/src/bin/lora_p2p_send.rs b/examples/rp/src/bin/lora_p2p_send.rs index a0f70fa5c..94bdb4e92 100644 --- a/examples/rp/src/bin/lora_p2p_send.rs +++ b/examples/rp/src/bin/lora_p2p_send.rs | |||
| @@ -35,16 +35,8 @@ async fn main(_spawner: Spawner) { | |||
| 35 | 35 | ||
| 36 | let iv = GenericSx126xInterfaceVariant::new(nss, reset, dio1, busy, None, None).unwrap(); | 36 | let iv = GenericSx126xInterfaceVariant::new(nss, reset, dio1, busy, None, None).unwrap(); |
| 37 | 37 | ||
| 38 | let mut delay = Delay; | ||
| 39 | |||
| 40 | let mut lora = { | 38 | let mut lora = { |
| 41 | match LoRa::new( | 39 | match LoRa::new(SX1261_2::new(BoardType::RpPicoWaveshareSx1262, spi, iv), false, Delay).await { |
| 42 | SX1261_2::new(BoardType::RpPicoWaveshareSx1262, spi, iv), | ||
| 43 | false, | ||
| 44 | &mut delay, | ||
| 45 | ) | ||
| 46 | .await | ||
| 47 | { | ||
| 48 | Ok(l) => l, | 40 | Ok(l) => l, |
| 49 | Err(err) => { | 41 | Err(err) => { |
| 50 | info!("Radio error = {}", err); | 42 | info!("Radio error = {}", err); |
| @@ -97,7 +89,7 @@ async fn main(_spawner: Spawner) { | |||
| 97 | } | 89 | } |
| 98 | }; | 90 | }; |
| 99 | 91 | ||
| 100 | match lora.sleep(&mut delay).await { | 92 | match lora.sleep(false).await { |
| 101 | Ok(()) => info!("Sleep successful"), | 93 | Ok(()) => info!("Sleep successful"), |
| 102 | Err(err) => info!("Sleep unsuccessful = {}", err), | 94 | Err(err) => info!("Sleep unsuccessful = {}", err), |
| 103 | } | 95 | } |
diff --git a/examples/rp/src/bin/lora_p2p_send_multicore.rs b/examples/rp/src/bin/lora_p2p_send_multicore.rs index b54cc92f6..e31aa62a2 100644 --- a/examples/rp/src/bin/lora_p2p_send_multicore.rs +++ b/examples/rp/src/bin/lora_p2p_send_multicore.rs | |||
| @@ -69,16 +69,9 @@ async fn core1_task( | |||
| 69 | iv: GenericSx126xInterfaceVariant<Output<'static, AnyPin>, Input<'static, AnyPin>>, | 69 | iv: GenericSx126xInterfaceVariant<Output<'static, AnyPin>, Input<'static, AnyPin>>, |
| 70 | ) { | 70 | ) { |
| 71 | info!("Hello from core 1"); | 71 | info!("Hello from core 1"); |
| 72 | let mut delay = Delay; | ||
| 73 | 72 | ||
| 74 | let mut lora = { | 73 | let mut lora = { |
| 75 | match LoRa::new( | 74 | match LoRa::new(SX1261_2::new(BoardType::RpPicoWaveshareSx1262, spi, iv), false, Delay).await { |
| 76 | SX1261_2::new(BoardType::RpPicoWaveshareSx1262, spi, iv), | ||
| 77 | false, | ||
| 78 | &mut delay, | ||
| 79 | ) | ||
| 80 | .await | ||
| 81 | { | ||
| 82 | Ok(l) => l, | 75 | Ok(l) => l, |
| 83 | Err(err) => { | 76 | Err(err) => { |
| 84 | info!("Radio error = {}", err); | 77 | info!("Radio error = {}", err); |
| @@ -132,7 +125,7 @@ async fn core1_task( | |||
| 132 | } | 125 | } |
| 133 | }; | 126 | }; |
| 134 | 127 | ||
| 135 | match lora.sleep(&mut delay).await { | 128 | match lora.sleep(false).await { |
| 136 | Ok(()) => info!("Sleep successful"), | 129 | Ok(()) => info!("Sleep successful"), |
| 137 | Err(err) => info!("Sleep unsuccessful = {}", err), | 130 | Err(err) => info!("Sleep unsuccessful = {}", err), |
| 138 | } | 131 | } |
diff --git a/examples/stm32l0/Cargo.toml b/examples/stm32l0/Cargo.toml index befebccea..71ec4f5a7 100644 --- a/examples/stm32l0/Cargo.toml +++ b/examples/stm32l0/Cargo.toml | |||
| @@ -16,7 +16,7 @@ embassy-sync = { version = "0.3.0", path = "../../embassy-sync", features = ["de | |||
| 16 | embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } | 16 | embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } |
| 17 | embassy-time = { version = "0.1.3", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } | 17 | embassy-time = { version = "0.1.3", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } |
| 18 | embassy-lora = { version = "0.1.0", path = "../../embassy-lora", features = ["time", "defmt"], optional = true } | 18 | embassy-lora = { version = "0.1.0", path = "../../embassy-lora", features = ["time", "defmt"], optional = true } |
| 19 | lora-phy = { version = "1", optional = true } | 19 | lora-phy = { version = "2", optional = true } |
| 20 | lorawan-device = { version = "0.10.0", default-features = false, features = ["async", "external-lora-phy"], optional = true } | 20 | lorawan-device = { version = "0.10.0", default-features = false, features = ["async", "external-lora-phy"], optional = true } |
| 21 | lorawan = { version = "0.7.3", default-features = false, features = ["default-crypto"], optional = true } | 21 | lorawan = { version = "0.7.3", default-features = false, features = ["default-crypto"], optional = true } |
| 22 | 22 | ||
| @@ -39,4 +39,5 @@ static_cell = "1.1" | |||
| 39 | debug = 2 | 39 | debug = 2 |
| 40 | 40 | ||
| 41 | [patch.crates-io] | 41 | [patch.crates-io] |
| 42 | lora-phy = { git = "https://github.com/embassy-rs/lora-phy", rev = "1323eccc1c470d4259f95f4f315d1be830d572a3"} | 42 | lorawan-device = { git = "https://github.com/ivajloip/rust-lorawan", rev = "b0502c1a802427638cc8bcd928fc632d13b778b6"} |
| 43 | lorawan = { git = "https://github.com/ivajloip/rust-lorawan", rev = "b0502c1a802427638cc8bcd928fc632d13b778b6"} | ||
diff --git a/examples/stm32l0/src/bin/lora_cad.rs b/examples/stm32l0/src/bin/lora_cad.rs index 7729b4163..900848fd8 100644 --- a/examples/stm32l0/src/bin/lora_cad.rs +++ b/examples/stm32l0/src/bin/lora_cad.rs | |||
| @@ -41,10 +41,8 @@ async fn main(_spawner: Spawner) { | |||
| 41 | 41 | ||
| 42 | let iv = Stm32l0InterfaceVariant::new(nss, reset, irq, None, None).unwrap(); | 42 | let iv = Stm32l0InterfaceVariant::new(nss, reset, irq, None, None).unwrap(); |
| 43 | 43 | ||
| 44 | let mut delay = Delay; | ||
| 45 | |||
| 46 | let mut lora = { | 44 | let mut lora = { |
| 47 | match LoRa::new(SX1276_7_8_9::new(BoardType::Stm32l0Sx1276, spi, iv), false, &mut delay).await { | 45 | match LoRa::new(SX1276_7_8_9::new(BoardType::Stm32l0Sx1276, spi, iv), false, Delay).await { |
| 48 | Ok(l) => l, | 46 | Ok(l) => l, |
| 49 | Err(err) => { | 47 | Err(err) => { |
| 50 | info!("Radio error = {}", err); | 48 | info!("Radio error = {}", err); |
diff --git a/examples/stm32l0/src/bin/lora_lorawan.rs b/examples/stm32l0/src/bin/lora_lorawan.rs index 10608aebf..7a93737e1 100644 --- a/examples/stm32l0/src/bin/lora_lorawan.rs +++ b/examples/stm32l0/src/bin/lora_lorawan.rs | |||
| @@ -21,6 +21,7 @@ use lora_phy::LoRa; | |||
| 21 | use lorawan::default_crypto::DefaultFactory as Crypto; | 21 | use lorawan::default_crypto::DefaultFactory as Crypto; |
| 22 | use lorawan_device::async_device::lora_radio::LoRaRadio; | 22 | use lorawan_device::async_device::lora_radio::LoRaRadio; |
| 23 | use lorawan_device::async_device::{region, Device, JoinMode}; | 23 | use lorawan_device::async_device::{region, Device, JoinMode}; |
| 24 | use lorawan_device::{AppEui, AppKey, DevEui}; | ||
| 24 | use {defmt_rtt as _, panic_probe as _}; | 25 | use {defmt_rtt as _, panic_probe as _}; |
| 25 | 26 | ||
| 26 | bind_interrupts!(struct Irqs { | 27 | bind_interrupts!(struct Irqs { |
| @@ -50,10 +51,8 @@ async fn main(_spawner: Spawner) { | |||
| 50 | 51 | ||
| 51 | let iv = Stm32l0InterfaceVariant::new(nss, reset, irq, None, None).unwrap(); | 52 | let iv = Stm32l0InterfaceVariant::new(nss, reset, irq, None, None).unwrap(); |
| 52 | 53 | ||
| 53 | let mut delay = Delay; | ||
| 54 | |||
| 55 | let lora = { | 54 | let lora = { |
| 56 | match LoRa::new(SX1276_7_8_9::new(BoardType::Stm32l0Sx1276, spi, iv), true, &mut delay).await { | 55 | match LoRa::new(SX1276_7_8_9::new(BoardType::Stm32l0Sx1276, spi, iv), true, Delay).await { |
| 57 | Ok(l) => l, | 56 | Ok(l) => l, |
| 58 | Err(err) => { | 57 | Err(err) => { |
| 59 | info!("Radio error = {}", err); | 58 | info!("Radio error = {}", err); |
| @@ -71,9 +70,9 @@ async fn main(_spawner: Spawner) { | |||
| 71 | // TODO: Adjust the EUI and Keys according to your network credentials | 70 | // TODO: Adjust the EUI and Keys according to your network credentials |
| 72 | match device | 71 | match device |
| 73 | .join(&JoinMode::OTAA { | 72 | .join(&JoinMode::OTAA { |
| 74 | deveui: [0, 0, 0, 0, 0, 0, 0, 0], | 73 | deveui: DevEui::from([0, 0, 0, 0, 0, 0, 0, 0]), |
| 75 | appeui: [0, 0, 0, 0, 0, 0, 0, 0], | 74 | appeui: AppEui::from([0, 0, 0, 0, 0, 0, 0, 0]), |
| 76 | appkey: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], | 75 | appkey: AppKey::from([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), |
| 77 | }) | 76 | }) |
| 78 | .await | 77 | .await |
| 79 | { | 78 | { |
diff --git a/examples/stm32l0/src/bin/lora_p2p_receive.rs b/examples/stm32l0/src/bin/lora_p2p_receive.rs index 0f9f60952..edd14bb81 100644 --- a/examples/stm32l0/src/bin/lora_p2p_receive.rs +++ b/examples/stm32l0/src/bin/lora_p2p_receive.rs | |||
| @@ -41,10 +41,8 @@ async fn main(_spawner: Spawner) { | |||
| 41 | 41 | ||
| 42 | let iv = Stm32l0InterfaceVariant::new(nss, reset, irq, None, None).unwrap(); | 42 | let iv = Stm32l0InterfaceVariant::new(nss, reset, irq, None, None).unwrap(); |
| 43 | 43 | ||
| 44 | let mut delay = Delay; | ||
| 45 | |||
| 46 | let mut lora = { | 44 | let mut lora = { |
| 47 | match LoRa::new(SX1276_7_8_9::new(BoardType::Stm32l0Sx1276, spi, iv), false, &mut delay).await { | 45 | match LoRa::new(SX1276_7_8_9::new(BoardType::Stm32l0Sx1276, spi, iv), false, Delay).await { |
| 48 | Ok(l) => l, | 46 | Ok(l) => l, |
| 49 | Err(err) => { | 47 | Err(err) => { |
| 50 | info!("Radio error = {}", err); | 48 | info!("Radio error = {}", err); |
| @@ -88,7 +86,7 @@ async fn main(_spawner: Spawner) { | |||
| 88 | }; | 86 | }; |
| 89 | 87 | ||
| 90 | match lora | 88 | match lora |
| 91 | .prepare_for_rx(&mdltn_params, &rx_pkt_params, None, true, false, 0, 0x00ffffffu32) | 89 | .prepare_for_rx(&mdltn_params, &rx_pkt_params, None, None, false) |
| 92 | .await | 90 | .await |
| 93 | { | 91 | { |
| 94 | Ok(()) => {} | 92 | Ok(()) => {} |
diff --git a/examples/stm32l0/src/bin/lora_p2p_send.rs b/examples/stm32l0/src/bin/lora_p2p_send.rs index c85c3c2b6..23cc1c6f7 100644 --- a/examples/stm32l0/src/bin/lora_p2p_send.rs +++ b/examples/stm32l0/src/bin/lora_p2p_send.rs | |||
| @@ -41,10 +41,8 @@ async fn main(_spawner: Spawner) { | |||
| 41 | 41 | ||
| 42 | let iv = Stm32l0InterfaceVariant::new(nss, reset, irq, None, None).unwrap(); | 42 | let iv = Stm32l0InterfaceVariant::new(nss, reset, irq, None, None).unwrap(); |
| 43 | 43 | ||
| 44 | let mut delay = Delay; | ||
| 45 | |||
| 46 | let mut lora = { | 44 | let mut lora = { |
| 47 | match LoRa::new(SX1276_7_8_9::new(BoardType::Stm32l0Sx1276, spi, iv), false, &mut delay).await { | 45 | match LoRa::new(SX1276_7_8_9::new(BoardType::Stm32l0Sx1276, spi, iv), false, Delay).await { |
| 48 | Ok(l) => l, | 46 | Ok(l) => l, |
| 49 | Err(err) => { | 47 | Err(err) => { |
| 50 | info!("Radio error = {}", err); | 48 | info!("Radio error = {}", err); |
| @@ -97,7 +95,7 @@ async fn main(_spawner: Spawner) { | |||
| 97 | } | 95 | } |
| 98 | }; | 96 | }; |
| 99 | 97 | ||
| 100 | match lora.sleep(&mut delay).await { | 98 | match lora.sleep(false).await { |
| 101 | Ok(()) => info!("Sleep successful"), | 99 | Ok(()) => info!("Sleep successful"), |
| 102 | Err(err) => info!("Sleep unsuccessful = {}", err), | 100 | Err(err) => info!("Sleep unsuccessful = {}", err), |
| 103 | } | 101 | } |
diff --git a/examples/stm32wl/Cargo.toml b/examples/stm32wl/Cargo.toml index 155c6dbcd..69abf53f4 100644 --- a/examples/stm32wl/Cargo.toml +++ b/examples/stm32wl/Cargo.toml | |||
| @@ -12,7 +12,7 @@ embassy-executor = { version = "0.3.0", path = "../../embassy-executor", feature | |||
| 12 | embassy-time = { version = "0.1.3", path = "../../embassy-time", features = ["nightly", "unstable-traits", "defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } | 12 | embassy-time = { version = "0.1.3", path = "../../embassy-time", features = ["nightly", "unstable-traits", "defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } |
| 13 | embassy-embedded-hal = { version = "0.1.0", path = "../../embassy-embedded-hal" } | 13 | embassy-embedded-hal = { version = "0.1.0", path = "../../embassy-embedded-hal" } |
| 14 | embassy-lora = { version = "0.1.0", path = "../../embassy-lora", features = ["stm32wl", "time", "defmt"] } | 14 | embassy-lora = { version = "0.1.0", path = "../../embassy-lora", features = ["stm32wl", "time", "defmt"] } |
| 15 | lora-phy = { version = "1" } | 15 | lora-phy = { version = "2" } |
| 16 | lorawan-device = { version = "0.10.0", default-features = false, features = ["async", "external-lora-phy"] } | 16 | lorawan-device = { version = "0.10.0", default-features = false, features = ["async", "external-lora-phy"] } |
| 17 | lorawan = { version = "0.7.3", default-features = false, features = ["default-crypto"] } | 17 | lorawan = { version = "0.7.3", default-features = false, features = ["default-crypto"] } |
| 18 | 18 | ||
| @@ -32,4 +32,5 @@ chrono = { version = "^0.4", default-features = false } | |||
| 32 | debug = 2 | 32 | debug = 2 |
| 33 | 33 | ||
| 34 | [patch.crates-io] | 34 | [patch.crates-io] |
| 35 | lora-phy = { git = "https://github.com/embassy-rs/lora-phy", rev = "1323eccc1c470d4259f95f4f315d1be830d572a3"} | 35 | lorawan-device = { git = "https://github.com/ivajloip/rust-lorawan", rev = "b0502c1a802427638cc8bcd928fc632d13b778b6"} |
| 36 | lorawan = { git = "https://github.com/ivajloip/rust-lorawan", rev = "b0502c1a802427638cc8bcd928fc632d13b778b6"} | ||
diff --git a/examples/stm32wl/src/bin/lora_lorawan.rs b/examples/stm32wl/src/bin/lora_lorawan.rs index 230df4752..fb2495326 100644 --- a/examples/stm32wl/src/bin/lora_lorawan.rs +++ b/examples/stm32wl/src/bin/lora_lorawan.rs | |||
| @@ -20,6 +20,7 @@ use lora_phy::LoRa; | |||
| 20 | use lorawan::default_crypto::DefaultFactory as Crypto; | 20 | use lorawan::default_crypto::DefaultFactory as Crypto; |
| 21 | use lorawan_device::async_device::lora_radio::LoRaRadio; | 21 | use lorawan_device::async_device::lora_radio::LoRaRadio; |
| 22 | use lorawan_device::async_device::{region, Device, JoinMode}; | 22 | use lorawan_device::async_device::{region, Device, JoinMode}; |
| 23 | use lorawan_device::{AppEui, AppKey, DevEui}; | ||
| 23 | use {defmt_rtt as _, panic_probe as _}; | 24 | use {defmt_rtt as _, panic_probe as _}; |
| 24 | 25 | ||
| 25 | const LORAWAN_REGION: region::Region = region::Region::EU868; // warning: set this appropriately for the region | 26 | const LORAWAN_REGION: region::Region = region::Region::EU868; // warning: set this appropriately for the region |
| @@ -46,10 +47,8 @@ async fn main(_spawner: Spawner) { | |||
| 46 | let _ctrl3 = Output::new(p.PC3.degrade(), Level::High, Speed::High); | 47 | let _ctrl3 = Output::new(p.PC3.degrade(), Level::High, Speed::High); |
| 47 | let iv = Stm32wlInterfaceVariant::new(Irqs, None, Some(ctrl2)).unwrap(); | 48 | let iv = Stm32wlInterfaceVariant::new(Irqs, None, Some(ctrl2)).unwrap(); |
| 48 | 49 | ||
| 49 | let mut delay = Delay; | ||
| 50 | |||
| 51 | let lora = { | 50 | let lora = { |
| 52 | match LoRa::new(SX1261_2::new(BoardType::Stm32wlSx1262, spi, iv), true, &mut delay).await { | 51 | match LoRa::new(SX1261_2::new(BoardType::Stm32wlSx1262, spi, iv), true, Delay).await { |
| 53 | Ok(l) => l, | 52 | Ok(l) => l, |
| 54 | Err(err) => { | 53 | Err(err) => { |
| 55 | info!("Radio error = {}", err); | 54 | info!("Radio error = {}", err); |
| @@ -66,9 +65,9 @@ async fn main(_spawner: Spawner) { | |||
| 66 | // TODO: Adjust the EUI and Keys according to your network credentials | 65 | // TODO: Adjust the EUI and Keys according to your network credentials |
| 67 | match device | 66 | match device |
| 68 | .join(&JoinMode::OTAA { | 67 | .join(&JoinMode::OTAA { |
| 69 | deveui: [0, 0, 0, 0, 0, 0, 0, 0], | 68 | deveui: DevEui::from([0, 0, 0, 0, 0, 0, 0, 0]), |
| 70 | appeui: [0, 0, 0, 0, 0, 0, 0, 0], | 69 | appeui: AppEui::from([0, 0, 0, 0, 0, 0, 0, 0]), |
| 71 | appkey: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], | 70 | appkey: AppKey::from([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), |
| 72 | }) | 71 | }) |
| 73 | .await | 72 | .await |
| 74 | { | 73 | { |
diff --git a/examples/stm32wl/src/bin/lora_p2p_receive.rs b/examples/stm32wl/src/bin/lora_p2p_receive.rs index d3f051b1c..3d8c31ff3 100644 --- a/examples/stm32wl/src/bin/lora_p2p_receive.rs +++ b/examples/stm32wl/src/bin/lora_p2p_receive.rs | |||
| @@ -37,10 +37,8 @@ async fn main(_spawner: Spawner) { | |||
| 37 | let _ctrl3 = Output::new(p.PC3.degrade(), Level::High, Speed::High); | 37 | let _ctrl3 = Output::new(p.PC3.degrade(), Level::High, Speed::High); |
| 38 | let iv = Stm32wlInterfaceVariant::new(Irqs, None, Some(ctrl2)).unwrap(); | 38 | let iv = Stm32wlInterfaceVariant::new(Irqs, None, Some(ctrl2)).unwrap(); |
| 39 | 39 | ||
| 40 | let mut delay = Delay; | ||
| 41 | |||
| 42 | let mut lora = { | 40 | let mut lora = { |
| 43 | match LoRa::new(SX1261_2::new(BoardType::Stm32wlSx1262, spi, iv), false, &mut delay).await { | 41 | match LoRa::new(SX1261_2::new(BoardType::Stm32wlSx1262, spi, iv), false, Delay).await { |
| 44 | Ok(l) => l, | 42 | Ok(l) => l, |
| 45 | Err(err) => { | 43 | Err(err) => { |
| 46 | info!("Radio error = {}", err); | 44 | info!("Radio error = {}", err); |
| @@ -84,7 +82,7 @@ async fn main(_spawner: Spawner) { | |||
| 84 | }; | 82 | }; |
| 85 | 83 | ||
| 86 | match lora | 84 | match lora |
| 87 | .prepare_for_rx(&mdltn_params, &rx_pkt_params, None, true, false, 0, 0x00ffffffu32) | 85 | .prepare_for_rx(&mdltn_params, &rx_pkt_params, None, None, false) |
| 88 | .await | 86 | .await |
| 89 | { | 87 | { |
| 90 | Ok(()) => {} | 88 | Ok(()) => {} |
diff --git a/examples/stm32wl/src/bin/lora_p2p_send.rs b/examples/stm32wl/src/bin/lora_p2p_send.rs index fc5205c85..fbd0b0320 100644 --- a/examples/stm32wl/src/bin/lora_p2p_send.rs +++ b/examples/stm32wl/src/bin/lora_p2p_send.rs | |||
| @@ -37,10 +37,8 @@ async fn main(_spawner: Spawner) { | |||
| 37 | let _ctrl3 = Output::new(p.PC3.degrade(), Level::High, Speed::High); | 37 | let _ctrl3 = Output::new(p.PC3.degrade(), Level::High, Speed::High); |
| 38 | let iv = Stm32wlInterfaceVariant::new(Irqs, None, Some(ctrl2)).unwrap(); | 38 | let iv = Stm32wlInterfaceVariant::new(Irqs, None, Some(ctrl2)).unwrap(); |
| 39 | 39 | ||
| 40 | let mut delay = Delay; | ||
| 41 | |||
| 42 | let mut lora = { | 40 | let mut lora = { |
| 43 | match LoRa::new(SX1261_2::new(BoardType::Stm32wlSx1262, spi, iv), false, &mut delay).await { | 41 | match LoRa::new(SX1261_2::new(BoardType::Stm32wlSx1262, spi, iv), false, Delay).await { |
| 44 | Ok(l) => l, | 42 | Ok(l) => l, |
| 45 | Err(err) => { | 43 | Err(err) => { |
| 46 | info!("Radio error = {}", err); | 44 | info!("Radio error = {}", err); |
| @@ -93,7 +91,7 @@ async fn main(_spawner: Spawner) { | |||
| 93 | } | 91 | } |
| 94 | }; | 92 | }; |
| 95 | 93 | ||
| 96 | match lora.sleep(&mut delay).await { | 94 | match lora.sleep(false).await { |
| 97 | Ok(()) => info!("Sleep successful"), | 95 | Ok(()) => info!("Sleep successful"), |
| 98 | Err(err) => info!("Sleep unsuccessful = {}", err), | 96 | Err(err) => info!("Sleep unsuccessful = {}", err), |
| 99 | } | 97 | } |
