diff options
| author | goueslati <[email protected]> | 2023-07-13 15:20:50 +0100 |
|---|---|---|
| committer | goueslati <[email protected]> | 2023-07-13 15:20:50 +0100 |
| commit | 3f0c8bafb060fdf81a677f0ec37d4db11e732266 (patch) | |
| tree | d8d17b9b141cbb2dc17fc8e14920d28fb42bc0ad /examples/stm32wb/src/bin/mac_ffd.rs | |
| parent | eccd2ecebf01753e70705a6ca1e21bc83b2c204c (diff) | |
make it work, disgustingly
Diffstat (limited to 'examples/stm32wb/src/bin/mac_ffd.rs')
| -rw-r--r-- | examples/stm32wb/src/bin/mac_ffd.rs | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/examples/stm32wb/src/bin/mac_ffd.rs b/examples/stm32wb/src/bin/mac_ffd.rs index 4e2578a21..37d36fcdd 100644 --- a/examples/stm32wb/src/bin/mac_ffd.rs +++ b/examples/stm32wb/src/bin/mac_ffd.rs | |||
| @@ -6,8 +6,9 @@ use defmt::*; | |||
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::bind_interrupts; | 7 | use embassy_stm32::bind_interrupts; |
| 8 | use embassy_stm32::ipcc::{Config, ReceiveInterruptHandler, TransmitInterruptHandler}; | 8 | use embassy_stm32::ipcc::{Config, ReceiveInterruptHandler, TransmitInterruptHandler}; |
| 9 | use embassy_stm32_wpan::sub::mac::commands::{ResetRequest, SetRequest, StartRequest}; | 9 | use embassy_stm32_wpan::sub::mac::commands::{AssociateResponse, ResetRequest, SetRequest, StartRequest}; |
| 10 | use embassy_stm32_wpan::sub::mac::typedefs::{MacChannel, PibId}; | 10 | use embassy_stm32_wpan::sub::mac::event::MacEvent; |
| 11 | use embassy_stm32_wpan::sub::mac::typedefs::{MacChannel, MacStatus, PanId, PibId, SecurityLevel}; | ||
| 11 | use embassy_stm32_wpan::sub::mm; | 12 | use embassy_stm32_wpan::sub::mm; |
| 12 | use embassy_stm32_wpan::TlMbox; | 13 | use embassy_stm32_wpan::TlMbox; |
| 13 | use {defmt_rtt as _, panic_probe as _}; | 14 | use {defmt_rtt as _, panic_probe as _}; |
| @@ -123,7 +124,7 @@ async fn main(spawner: Spawner) { | |||
| 123 | info!("starting FFD device"); | 124 | info!("starting FFD device"); |
| 124 | mbox.mac_subsystem | 125 | mbox.mac_subsystem |
| 125 | .send_command(&StartRequest { | 126 | .send_command(&StartRequest { |
| 126 | pan_id: [0xAA, 0x1A], | 127 | pan_id: PanId([0x1A, 0xAA]), |
| 127 | channel_number: MacChannel::Channel16, | 128 | channel_number: MacChannel::Channel16, |
| 128 | beacon_order: 0x0F, | 129 | beacon_order: 0x0F, |
| 129 | superframe_order: 0x0F, | 130 | superframe_order: 0x0F, |
| @@ -151,5 +152,28 @@ async fn main(spawner: Spawner) { | |||
| 151 | loop { | 152 | loop { |
| 152 | let evt = mbox.mac_subsystem.read().await; | 153 | let evt = mbox.mac_subsystem.read().await; |
| 153 | defmt::info!("{:#x}", evt); | 154 | defmt::info!("{:#x}", evt); |
| 155 | |||
| 156 | if let Ok(evt) = evt { | ||
| 157 | match evt { | ||
| 158 | MacEvent::MlmeAssociateInd(association) => mbox | ||
| 159 | .mac_subsystem | ||
| 160 | .send_command(&AssociateResponse { | ||
| 161 | device_address: association.device_address, | ||
| 162 | assoc_short_address: [0x33, 0x44], | ||
| 163 | status: MacStatus::Success, | ||
| 164 | security_level: SecurityLevel::Unsecure, | ||
| 165 | ..Default::default() | ||
| 166 | }) | ||
| 167 | .await | ||
| 168 | .unwrap(), | ||
| 169 | MacEvent::McpsDataInd(data_ind) => { | ||
| 170 | let data_addr = data_ind.msdu_ptr; | ||
| 171 | let mut a = [0u8; 256]; | ||
| 172 | unsafe { data_addr.copy_to(&mut a as *mut _, data_ind.msdu_length as usize) } | ||
| 173 | info!("{}", a[..data_ind.msdu_length as usize]) | ||
| 174 | } | ||
| 175 | _ => {} | ||
| 176 | } | ||
| 177 | } | ||
| 154 | } | 178 | } |
| 155 | } | 179 | } |
