From 5aa121569d359dbb21f267676a09db66d6b41cd1 Mon Sep 17 00:00:00 2001 From: Priit Laes Date: Mon, 19 May 2025 10:27:46 +0300 Subject: [PATCH] Port to latest lora-rs changes (default-crypto removal) --- Cargo.lock | 25 ++++++++----------------- Cargo.toml | 12 ++++++++---- src/async_virtual_device/mod.rs | 4 ++-- src/util.rs | 2 +- src/virtual_device/mod.rs | 5 ++--- 5 files changed, 21 insertions(+), 27 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b81bbd9..0354317 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -747,16 +747,12 @@ checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" [[package]] name = "lora-modulation" version = "0.1.5" - -[[package]] -name = "lora-modulation" -version = "0.1.5" -source = "git+https://github.com/lora-rs/lora-rs.git#ee75a0c7110869051141aa1e53125c1ab775f44e" +source = "git+https://github.com/lora-rs/lora-rs.git?rev=a5e690a3f1f68c4e4c43efcd564467938c574ea3#a5e690a3f1f68c4e4c43efcd564467938c574ea3" [[package]] name = "lorawan" version = "0.9.1" -source = "git+https://github.com/lora-rs/lora-rs.git#ee75a0c7110869051141aa1e53125c1ab775f44e" +source = "git+https://github.com/lora-rs/lora-rs.git?rev=a5e690a3f1f68c4e4c43efcd564467938c574ea3#a5e690a3f1f68c4e4c43efcd564467938c574ea3" dependencies = [ "aes", "cmac", @@ -768,23 +764,22 @@ dependencies = [ [[package]] name = "lorawan-device" version = "0.12.2" -source = "git+https://github.com/lora-rs/lora-rs.git#ee75a0c7110869051141aa1e53125c1ab775f44e" +source = "git+https://github.com/lora-rs/lora-rs.git?rev=a5e690a3f1f68c4e4c43efcd564467938c574ea3#a5e690a3f1f68c4e4c43efcd564467938c574ea3" dependencies = [ "document-features", "fastrand", "futures", "heapless", - "lora-modulation 0.1.5 (git+https://github.com/lora-rs/lora-rs.git)", + "lora-modulation", "lorawan", "rand_core", - "seq-macro", "serde", ] [[package]] name = "lorawan-macros" version = "0.1.0" -source = "git+https://github.com/lora-rs/lora-rs.git#ee75a0c7110869051141aa1e53125c1ab775f44e" +source = "git+https://github.com/lora-rs/lora-rs.git?rev=a5e690a3f1f68c4e4c43efcd564467938c574ea3#a5e690a3f1f68c4e4c43efcd564467938c574ea3" dependencies = [ "proc-macro2", "quote", @@ -1096,10 +1091,12 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "semtech-udp" version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e188b7049d90ac633978c9cab2d56b165e34e0922908f8cadbc7cbcff6e3370" dependencies = [ "arrayref", "base64", - "lora-modulation 0.1.5", + "lora-modulation", "macaddr", "num_enum", "rand", @@ -1111,12 +1108,6 @@ dependencies = [ "triggered", ] -[[package]] -name = "seq-macro" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3f0bf26fd526d2a95683cd0f87bf103b8539e2ca1ef48ce002d67aad59aa0b4" - [[package]] name = "serde" version = "1.0.209" diff --git a/Cargo.toml b/Cargo.toml index 65c3e8c..45de9f3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,20 +18,24 @@ http-body-util = "0" hyper = { version = "1", features = ["full"] } hyper-util = { version = "0", features = ["tokio"] } log = "0" -lorawan-device = { git = "https://github.com/lora-rs/lora-rs.git", features = ["default-crypto", "serde"] } -#lorawan-device = { path = "../lora-rs/lorawan-device", features = ["default-crypto", "serde", "multicast"] } +lorawan-device = { version = ">=0.12.2", features = ["serde"] } prometheus = "0" rand_core = { version = "0.6", default-features = false, optional = true } -semtech-udp = { path = "../semtech-udp", features = ["client"] }#{ version = "0.11" } +semtech-udp = { version="0.12", features = ["client"] } serde = "1" structopt = "0" thiserror = "1" rand = "0" triggered = "0" +[patch.crates-io] +lorawan-device = { git = "https://github.com/lora-rs/lora-rs.git", rev="a5e690a3f1f68c4e4c43efcd564467938c574ea3" } +lora-modulation = { git = "https://github.com/lora-rs/lora-rs.git", rev="a5e690a3f1f68c4e4c43efcd564467938c574ea3" } + [dependencies.tokio] version = "1" features = ["macros", "sync", "time", "rt-multi-thread", "signal"] [features] -async-radio = ["rand_core"] +multicast = [ "lorawan-device/multicast" ] +async-radio = [ "rand_core/getrandom" ] diff --git a/src/async_virtual_device/mod.rs b/src/async_virtual_device/mod.rs index bfc5d90..51ade18 100644 --- a/src/async_virtual_device/mod.rs +++ b/src/async_virtual_device/mod.rs @@ -9,7 +9,6 @@ use lorawan_device::async_device::{ radio::{PhyRxTx, RxConfig, Timer}, Device, Downlink, JoinResponse, NetworkCredentials, SendResponse, Timings, }; -use lorawan_device::default_crypto::DefaultFactory; use lorawan_device::region::Configuration; use lorawan_device::{AppEui, AppKey, DevEui, JoinMode}; pub use semtech_udp::client_runtime::{ClientTx, DownlinkRequest}; @@ -27,7 +26,7 @@ pub struct VirtualDevice { secs_between_transmits: u64, secs_between_join_transmits: u64, credentials: NetworkCredentials, - device: Device, + device: Device, state: State, } @@ -62,6 +61,7 @@ impl VirtualDevice { rand_core::OsRng, ); device.enable_class_c(); + #[cfg(feature = "multicast")] device.set_multicast_ke_key(lorawan_device::async_device::McRootKey::from_str( "3371C1F28C755A5D328DFDD6E01A32ED", )?); diff --git a/src/util.rs b/src/util.rs index c64b33d..8f29cf2 100644 --- a/src/util.rs +++ b/src/util.rs @@ -71,7 +71,7 @@ impl From for Settings { impl Settings { pub fn get_datr(&self) -> DataRate { - DataRate::new(self.rf_config.bb.sf.into(), self.rf_config.bb.bw.into()) + DataRate::new(self.rf_config.bb.sf, self.rf_config.bb.bw) } pub fn get_codr(&self) -> CodingRate { diff --git a/src/virtual_device/mod.rs b/src/virtual_device/mod.rs index 9c9e9a9..3c072cf 100644 --- a/src/virtual_device/mod.rs +++ b/src/virtual_device/mod.rs @@ -1,5 +1,4 @@ use log::{debug, info, warn}; -use lorawan_device::default_crypto::DefaultFactory as LorawanCrypto; use lorawan_device::mac::NetworkCredentials; use lorawan_device::region::Configuration; use lorawan_device::{ @@ -19,7 +18,7 @@ mod udp_radio; pub struct VirtualDevice { label: String, - device: Device, + device: Device, receiver: mpsc::Receiver, sender: mpsc::Sender, metrics_sender: metrics::Sender, @@ -57,7 +56,7 @@ impl VirtualDevice { region: settings::Region, ) -> Result<(PacketSender, VirtualDevice)> { let (radio, receiver, sender) = UdpRadio::new(time, client_tx).await; - let device: Device = + let device: Device = Device::new(Configuration::new(region.into()), radio, rand::rngs::OsRng); Ok((