aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2022-07-04 08:59:06 +0000
committerGitHub <[email protected]>2022-07-04 08:59:06 +0000
commit87e3ae321b2e9d0ccddb323d6ca10b1b1591927c (patch)
treee6244281cabdcecb8bf05a31770270e3e66b7f05
parent0ed4e57ea45087e007bfa2b2d2b0a7807923d35b (diff)
parentdaf3ea24d7ecec4727ed036e8d431417999064cf (diff)
Merge #843
843: Document configuration options and handle optional downlink r=lulf a=lulf Co-authored-by: Ulf Lilleengen <[email protected]>
-rw-r--r--examples/stm32wl/src/bin/lorawan.rs24
1 files changed, 21 insertions, 3 deletions
diff --git a/examples/stm32wl/src/bin/lorawan.rs b/examples/stm32wl/src/bin/lorawan.rs
index 4f0dc7dfc..158c17e18 100644
--- a/examples/stm32wl/src/bin/lorawan.rs
+++ b/examples/stm32wl/src/bin/lorawan.rs
@@ -38,9 +38,22 @@ async fn main(_spawner: embassy::executor::Spawner, p: Peripherals) {
38 static mut RADIO_STATE: SubGhzState<'static> = SubGhzState::new(); 38 static mut RADIO_STATE: SubGhzState<'static> = SubGhzState::new();
39 let radio = unsafe { SubGhzRadio::new(&mut RADIO_STATE, radio, rfs, irq) }; 39 let radio = unsafe { SubGhzRadio::new(&mut RADIO_STATE, radio, rfs, irq) };
40 40
41 let region = region::EU868::default().into(); 41 let mut region: region::Configuration = region::EU868::default().into();
42
43 // NOTE: This is specific for TTN, as they have a special RX1 delay
44 region.set_receive_delay1(5000);
45
42 let mut device: Device<_, Crypto, _, _> = Device::new(region, radio, LoraTimer, Rng::new(p.RNG)); 46 let mut device: Device<_, Crypto, _, _> = Device::new(region, radio, LoraTimer, Rng::new(p.RNG));
43 47
48 // Depending on network, this might be part of JOIN
49 device.set_datarate(region::DR::_0); // SF12
50
51 // device.set_datarate(region::DR::_1); // SF11
52 // device.set_datarate(region::DR::_2); // SF10
53 // device.set_datarate(region::DR::_3); // SF9
54 // device.set_datarate(region::DR::_4); // SF8
55 // device.set_datarate(region::DR::_5); // SF7
56
44 defmt::info!("Joining LoRaWAN network"); 57 defmt::info!("Joining LoRaWAN network");
45 58
46 // TODO: Adjust the EUI and Keys according to your network credentials 59 // TODO: Adjust the EUI and Keys according to your network credentials
@@ -55,7 +68,12 @@ async fn main(_spawner: embassy::executor::Spawner, p: Peripherals) {
55 .unwrap(); 68 .unwrap();
56 defmt::info!("LoRaWAN network joined"); 69 defmt::info!("LoRaWAN network joined");
57 70
71 let mut rx: [u8; 255] = [0; 255];
58 defmt::info!("Sending 'PING'"); 72 defmt::info!("Sending 'PING'");
59 device.send(b"PING", 1, false).await.ok().unwrap(); 73 let len = device.send_recv(b"PING", &mut rx[..], 1, true).await.ok().unwrap();
60 defmt::info!("Message sent!"); 74 if len > 0 {
75 defmt::info!("Message sent, received downlink: {:?}", &rx[..len]);
76 } else {
77 defmt::info!("Message sent!");
78 }
61} 79}