diff options
| -rw-r--r-- | embassy-stm32-wpan/src/mac/driver.rs | 6 | ||||
| -rw-r--r-- | embassy-stm32-wpan/src/mac/event.rs | 81 | ||||
| -rw-r--r-- | embassy-stm32-wpan/src/mac/runner.rs | 6 | ||||
| -rw-r--r-- | embassy-stm32-wpan/src/sub/mac.rs | 10 | ||||
| -rw-r--r-- | examples/stm32wb/src/bin/mac_ffd.rs | 39 | ||||
| -rw-r--r-- | examples/stm32wb/src/bin/mac_ffd_net.rs | 35 | ||||
| -rw-r--r-- | examples/stm32wb/src/bin/mac_rfd.rs | 24 | ||||
| -rw-r--r-- | tests/stm32/src/bin/wpan_mac.rs | 23 |
8 files changed, 85 insertions, 139 deletions
diff --git a/embassy-stm32-wpan/src/mac/driver.rs b/embassy-stm32-wpan/src/mac/driver.rs index 3017808f0..fffbb9edc 100644 --- a/embassy-stm32-wpan/src/mac/driver.rs +++ b/embassy-stm32-wpan/src/mac/driver.rs | |||
| @@ -7,7 +7,7 @@ use embassy_net_driver::{Capabilities, LinkState, Medium}; | |||
| 7 | use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex; | 7 | use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex; |
| 8 | use embassy_sync::channel::Channel; | 8 | use embassy_sync::channel::Channel; |
| 9 | 9 | ||
| 10 | use crate::mac::event::{Event, MacEvent}; | 10 | use crate::mac::event::MacEvent; |
| 11 | use crate::mac::runner::Runner; | 11 | use crate::mac::runner::Runner; |
| 12 | use crate::mac::MTU; | 12 | use crate::mac::MTU; |
| 13 | 13 | ||
| @@ -81,7 +81,7 @@ impl<'d> embassy_net_driver::Driver for Driver<'d> { | |||
| 81 | } | 81 | } |
| 82 | 82 | ||
| 83 | pub struct RxToken<'d> { | 83 | pub struct RxToken<'d> { |
| 84 | rx: &'d Channel<CriticalSectionRawMutex, Event<'d>, 1>, | 84 | rx: &'d Channel<CriticalSectionRawMutex, MacEvent<'d>, 1>, |
| 85 | } | 85 | } |
| 86 | 86 | ||
| 87 | impl<'d> embassy_net_driver::RxToken for RxToken<'d> { | 87 | impl<'d> embassy_net_driver::RxToken for RxToken<'d> { |
| @@ -91,7 +91,7 @@ impl<'d> embassy_net_driver::RxToken for RxToken<'d> { | |||
| 91 | { | 91 | { |
| 92 | // Only valid data events should be put into the queue | 92 | // Only valid data events should be put into the queue |
| 93 | 93 | ||
| 94 | let data_event = match *self.rx.try_recv().unwrap() { | 94 | let data_event = match self.rx.try_recv().unwrap() { |
| 95 | MacEvent::McpsDataInd(data_event) => data_event, | 95 | MacEvent::McpsDataInd(data_event) => data_event, |
| 96 | _ => unreachable!(), | 96 | _ => unreachable!(), |
| 97 | }; | 97 | }; |
diff --git a/embassy-stm32-wpan/src/mac/event.rs b/embassy-stm32-wpan/src/mac/event.rs index d975c5bda..b6f57fdae 100644 --- a/embassy-stm32-wpan/src/mac/event.rs +++ b/embassy-stm32-wpan/src/mac/event.rs | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | use core::{mem, ops}; | 1 | use core::{mem, ptr}; |
| 2 | 2 | ||
| 3 | use super::indications::{ | 3 | use super::indications::{ |
| 4 | AssociateIndication, BeaconNotifyIndication, CommStatusIndication, DataIndication, DisassociateIndication, | 4 | AssociateIndication, BeaconNotifyIndication, CommStatusIndication, DataIndication, DisassociateIndication, |
| @@ -8,9 +8,9 @@ use super::responses::{ | |||
| 8 | AssociateConfirm, CalibrateConfirm, DataConfirm, DisassociateConfirm, DpsConfirm, GetConfirm, GtsConfirm, | 8 | AssociateConfirm, CalibrateConfirm, DataConfirm, DisassociateConfirm, DpsConfirm, GetConfirm, GtsConfirm, |
| 9 | PollConfirm, PurgeConfirm, ResetConfirm, RxEnableConfirm, ScanConfirm, SetConfirm, SoundingConfirm, StartConfirm, | 9 | PollConfirm, PurgeConfirm, ResetConfirm, RxEnableConfirm, ScanConfirm, SetConfirm, SoundingConfirm, StartConfirm, |
| 10 | }; | 10 | }; |
| 11 | use crate::evt::EvtBox; | 11 | use crate::evt::{EvtBox, MemoryManager}; |
| 12 | use crate::mac::opcodes::OpcodeM0ToM4; | 12 | use crate::mac::opcodes::OpcodeM0ToM4; |
| 13 | use crate::sub::mac::Mac; | 13 | use crate::sub::mac::{self, Mac}; |
| 14 | 14 | ||
| 15 | pub(crate) trait ParseableMacEvent: Sized { | 15 | pub(crate) trait ParseableMacEvent: Sized { |
| 16 | fn from_buffer<'a>(buf: &'a [u8]) -> Result<&'a Self, ()> { | 16 | fn from_buffer<'a>(buf: &'a [u8]) -> Result<&'a Self, ()> { |
| @@ -22,13 +22,36 @@ pub(crate) trait ParseableMacEvent: Sized { | |||
| 22 | } | 22 | } |
| 23 | } | 23 | } |
| 24 | 24 | ||
| 25 | pub struct Event<'a> { | 25 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] |
| 26 | #[allow(dead_code)] | 26 | pub enum MacEvent<'a> { |
| 27 | event_box: EvtBox<Mac>, | 27 | MlmeAssociateCnf(&'a AssociateConfirm), |
| 28 | mac_event: MacEvent<'a>, | 28 | MlmeDisassociateCnf(&'a DisassociateConfirm), |
| 29 | MlmeGetCnf(&'a GetConfirm), | ||
| 30 | MlmeGtsCnf(&'a GtsConfirm), | ||
| 31 | MlmeResetCnf(&'a ResetConfirm), | ||
| 32 | MlmeRxEnableCnf(&'a RxEnableConfirm), | ||
| 33 | MlmeScanCnf(&'a ScanConfirm), | ||
| 34 | MlmeSetCnf(&'a SetConfirm), | ||
| 35 | MlmeStartCnf(&'a StartConfirm), | ||
| 36 | MlmePollCnf(&'a PollConfirm), | ||
| 37 | MlmeDpsCnf(&'a DpsConfirm), | ||
| 38 | MlmeSoundingCnf(&'a SoundingConfirm), | ||
| 39 | MlmeCalibrateCnf(&'a CalibrateConfirm), | ||
| 40 | McpsDataCnf(&'a DataConfirm), | ||
| 41 | McpsPurgeCnf(&'a PurgeConfirm), | ||
| 42 | MlmeAssociateInd(&'a AssociateIndication), | ||
| 43 | MlmeDisassociateInd(&'a DisassociateIndication), | ||
| 44 | MlmeBeaconNotifyInd(&'a BeaconNotifyIndication), | ||
| 45 | MlmeCommStatusInd(&'a CommStatusIndication), | ||
| 46 | MlmeGtsInd(&'a GtsIndication), | ||
| 47 | MlmeOrphanInd(&'a OrphanIndication), | ||
| 48 | MlmeSyncLossInd(&'a SyncLossIndication), | ||
| 49 | MlmeDpsInd(&'a DpsIndication), | ||
| 50 | McpsDataInd(&'a DataIndication), | ||
| 51 | MlmePollInd(&'a PollIndication), | ||
| 29 | } | 52 | } |
| 30 | 53 | ||
| 31 | impl<'a> Event<'a> { | 54 | impl<'a> MacEvent<'a> { |
| 32 | pub(crate) fn new(event_box: EvtBox<Mac>) -> Result<Self, ()> { | 55 | pub(crate) fn new(event_box: EvtBox<Mac>) -> Result<Self, ()> { |
| 33 | let payload = event_box.payload(); | 56 | let payload = event_box.payload(); |
| 34 | let opcode = u16::from_le_bytes(payload[0..2].try_into().unwrap()); | 57 | let opcode = u16::from_le_bytes(payload[0..2].try_into().unwrap()); |
| @@ -111,43 +134,17 @@ impl<'a> Event<'a> { | |||
| 111 | } | 134 | } |
| 112 | }; | 135 | }; |
| 113 | 136 | ||
| 114 | Ok(Self { event_box, mac_event }) | 137 | // Forget the event box so that drop isn't called |
| 115 | } | 138 | // We want to handle the lifetime ourselves |
| 116 | } | ||
| 117 | 139 | ||
| 118 | impl<'a> ops::Deref for Event<'a> { | 140 | mem::forget(event_box); |
| 119 | type Target = MacEvent<'a>; | ||
| 120 | 141 | ||
| 121 | fn deref(&self) -> &Self::Target { | 142 | Ok(mac_event) |
| 122 | &self.mac_event | ||
| 123 | } | 143 | } |
| 124 | } | 144 | } |
| 125 | 145 | ||
| 126 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] | 146 | impl<'a> Drop for MacEvent<'a> { |
| 127 | pub enum MacEvent<'a> { | 147 | fn drop(&mut self) { |
| 128 | MlmeAssociateCnf(&'a AssociateConfirm), | 148 | unsafe { mac::Mac::drop_event_packet(ptr::null_mut()) }; |
| 129 | MlmeDisassociateCnf(&'a DisassociateConfirm), | 149 | } |
| 130 | MlmeGetCnf(&'a GetConfirm), | ||
| 131 | MlmeGtsCnf(&'a GtsConfirm), | ||
| 132 | MlmeResetCnf(&'a ResetConfirm), | ||
| 133 | MlmeRxEnableCnf(&'a RxEnableConfirm), | ||
| 134 | MlmeScanCnf(&'a ScanConfirm), | ||
| 135 | MlmeSetCnf(&'a SetConfirm), | ||
| 136 | MlmeStartCnf(&'a StartConfirm), | ||
| 137 | MlmePollCnf(&'a PollConfirm), | ||
| 138 | MlmeDpsCnf(&'a DpsConfirm), | ||
| 139 | MlmeSoundingCnf(&'a SoundingConfirm), | ||
| 140 | MlmeCalibrateCnf(&'a CalibrateConfirm), | ||
| 141 | McpsDataCnf(&'a DataConfirm), | ||
| 142 | McpsPurgeCnf(&'a PurgeConfirm), | ||
| 143 | MlmeAssociateInd(&'a AssociateIndication), | ||
| 144 | MlmeDisassociateInd(&'a DisassociateIndication), | ||
| 145 | MlmeBeaconNotifyInd(&'a BeaconNotifyIndication), | ||
| 146 | MlmeCommStatusInd(&'a CommStatusIndication), | ||
| 147 | MlmeGtsInd(&'a GtsIndication), | ||
| 148 | MlmeOrphanInd(&'a OrphanIndication), | ||
| 149 | MlmeSyncLossInd(&'a SyncLossIndication), | ||
| 150 | MlmeDpsInd(&'a DpsIndication), | ||
| 151 | McpsDataInd(&'a DataIndication), | ||
| 152 | MlmePollInd(&'a PollIndication), | ||
| 153 | } | 150 | } |
diff --git a/embassy-stm32-wpan/src/mac/runner.rs b/embassy-stm32-wpan/src/mac/runner.rs index 779712cdc..a0090012e 100644 --- a/embassy-stm32-wpan/src/mac/runner.rs +++ b/embassy-stm32-wpan/src/mac/runner.rs | |||
| @@ -3,14 +3,14 @@ use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex; | |||
| 3 | use embassy_sync::channel::Channel; | 3 | use embassy_sync::channel::Channel; |
| 4 | 4 | ||
| 5 | use crate::mac::commands::DataRequest; | 5 | use crate::mac::commands::DataRequest; |
| 6 | use crate::mac::event::{Event, MacEvent}; | 6 | use crate::mac::event::MacEvent; |
| 7 | use crate::mac::typedefs::{AddressMode, MacAddress, PanId, SecurityLevel}; | 7 | use crate::mac::typedefs::{AddressMode, MacAddress, PanId, SecurityLevel}; |
| 8 | use crate::mac::MTU; | 8 | use crate::mac::MTU; |
| 9 | use crate::sub::mac::Mac; | 9 | use crate::sub::mac::Mac; |
| 10 | 10 | ||
| 11 | pub struct Runner<'a> { | 11 | pub struct Runner<'a> { |
| 12 | mac_subsystem: Mac, | 12 | mac_subsystem: Mac, |
| 13 | pub(crate) rx_channel: Channel<CriticalSectionRawMutex, Event<'a>, 1>, | 13 | pub(crate) rx_channel: Channel<CriticalSectionRawMutex, MacEvent<'a>, 1>, |
| 14 | pub(crate) tx_channel: Channel<CriticalSectionRawMutex, (&'a mut [u8; MTU], usize), 5>, | 14 | pub(crate) tx_channel: Channel<CriticalSectionRawMutex, (&'a mut [u8; MTU], usize), 5>, |
| 15 | pub(crate) tx_buf_channel: Channel<CriticalSectionRawMutex, &'a mut [u8; MTU], 5>, | 15 | pub(crate) tx_buf_channel: Channel<CriticalSectionRawMutex, &'a mut [u8; MTU], 5>, |
| 16 | } | 16 | } |
| @@ -36,7 +36,7 @@ impl<'a> Runner<'a> { | |||
| 36 | async { | 36 | async { |
| 37 | loop { | 37 | loop { |
| 38 | if let Ok(mac_event) = self.mac_subsystem.read().await { | 38 | if let Ok(mac_event) = self.mac_subsystem.read().await { |
| 39 | match *mac_event { | 39 | match mac_event { |
| 40 | MacEvent::McpsDataInd(_) => { | 40 | MacEvent::McpsDataInd(_) => { |
| 41 | self.rx_channel.send(mac_event).await; | 41 | self.rx_channel.send(mac_event).await; |
| 42 | } | 42 | } |
diff --git a/embassy-stm32-wpan/src/sub/mac.rs b/embassy-stm32-wpan/src/sub/mac.rs index 5ecbfe8c5..b0cf0248a 100644 --- a/embassy-stm32-wpan/src/sub/mac.rs +++ b/embassy-stm32-wpan/src/sub/mac.rs | |||
| @@ -12,7 +12,7 @@ use crate::cmd::CmdPacket; | |||
| 12 | use crate::consts::TlPacketType; | 12 | use crate::consts::TlPacketType; |
| 13 | use crate::evt::{EvtBox, EvtPacket}; | 13 | use crate::evt::{EvtBox, EvtPacket}; |
| 14 | use crate::mac::commands::MacCommand; | 14 | use crate::mac::commands::MacCommand; |
| 15 | use crate::mac::event::Event; | 15 | use crate::mac::event::MacEvent; |
| 16 | use crate::mac::typedefs::MacError; | 16 | use crate::mac::typedefs::MacError; |
| 17 | use crate::tables::{MAC_802_15_4_CMD_BUFFER, MAC_802_15_4_NOTIF_RSP_EVT_BUFFER}; | 17 | use crate::tables::{MAC_802_15_4_CMD_BUFFER, MAC_802_15_4_NOTIF_RSP_EVT_BUFFER}; |
| 18 | use crate::{channels, evt}; | 18 | use crate::{channels, evt}; |
| @@ -94,14 +94,16 @@ impl Mac { | |||
| 94 | } | 94 | } |
| 95 | } | 95 | } |
| 96 | 96 | ||
| 97 | pub async fn read(&self) -> Result<Event<'_>, ()> { | 97 | pub async fn read(&self) -> Result<MacEvent<'_>, ()> { |
| 98 | Event::new(self.tl_read().await) | 98 | MacEvent::new(self.tl_read().await) |
| 99 | } | 99 | } |
| 100 | } | 100 | } |
| 101 | 101 | ||
| 102 | impl evt::MemoryManager for Mac { | 102 | impl evt::MemoryManager for Mac { |
| 103 | /// SAFETY: passing a pointer to something other than a managed event packet is UB | 103 | /// SAFETY: passing a pointer to something other than a managed event packet is UB |
| 104 | unsafe fn drop_event_packet(_: *mut EvtPacket) { | 104 | unsafe fn drop_event_packet(_: *mut EvtPacket) { |
| 105 | trace!("mac drop event"); | ||
| 106 | |||
| 105 | // Write the ack | 107 | // Write the ack |
| 106 | CmdPacket::write_into( | 108 | CmdPacket::write_into( |
| 107 | MAC_802_15_4_NOTIF_RSP_EVT_BUFFER.as_mut_ptr() as *mut _, | 109 | MAC_802_15_4_NOTIF_RSP_EVT_BUFFER.as_mut_ptr() as *mut _, |
| @@ -111,7 +113,7 @@ impl evt::MemoryManager for Mac { | |||
| 111 | ); | 113 | ); |
| 112 | 114 | ||
| 113 | // Clear the rx flag | 115 | // Clear the rx flag |
| 114 | let _ = poll_once(Ipcc::receive::<bool>( | 116 | let _ = poll_once(Ipcc::receive::<()>( |
| 115 | channels::cpu2::IPCC_MAC_802_15_4_NOTIFICATION_ACK_CHANNEL, | 117 | channels::cpu2::IPCC_MAC_802_15_4_NOTIFICATION_ACK_CHANNEL, |
| 116 | || None, | 118 | || None, |
| 117 | )); | 119 | )); |
diff --git a/examples/stm32wb/src/bin/mac_ffd.rs b/examples/stm32wb/src/bin/mac_ffd.rs index 7de30778f..1379ac6ba 100644 --- a/examples/stm32wb/src/bin/mac_ffd.rs +++ b/examples/stm32wb/src/bin/mac_ffd.rs | |||
| @@ -73,10 +73,7 @@ async fn main(spawner: Spawner) { | |||
| 73 | }) | 73 | }) |
| 74 | .await | 74 | .await |
| 75 | .unwrap(); | 75 | .unwrap(); |
| 76 | { | 76 | defmt::info!("{:#x}", mbox.mac_subsystem.read().await.unwrap()); |
| 77 | let evt = mbox.mac_subsystem.read().await.unwrap(); | ||
| 78 | defmt::info!("{:#x}", *evt); | ||
| 79 | } | ||
| 80 | 77 | ||
| 81 | info!("setting extended address"); | 78 | info!("setting extended address"); |
| 82 | let extended_address: u64 = 0xACDE480000000001; | 79 | let extended_address: u64 = 0xACDE480000000001; |
| @@ -87,10 +84,7 @@ async fn main(spawner: Spawner) { | |||
| 87 | }) | 84 | }) |
| 88 | .await | 85 | .await |
| 89 | .unwrap(); | 86 | .unwrap(); |
| 90 | { | 87 | defmt::info!("{:#x}", mbox.mac_subsystem.read().await.unwrap()); |
| 91 | let evt = mbox.mac_subsystem.read().await.unwrap(); | ||
| 92 | defmt::info!("{:#x}", *evt); | ||
| 93 | } | ||
| 94 | 88 | ||
| 95 | info!("setting short address"); | 89 | info!("setting short address"); |
| 96 | let short_address: u16 = 0x1122; | 90 | let short_address: u16 = 0x1122; |
| @@ -101,10 +95,7 @@ async fn main(spawner: Spawner) { | |||
| 101 | }) | 95 | }) |
| 102 | .await | 96 | .await |
| 103 | .unwrap(); | 97 | .unwrap(); |
| 104 | { | 98 | defmt::info!("{:#x}", mbox.mac_subsystem.read().await.unwrap()); |
| 105 | let evt = mbox.mac_subsystem.read().await.unwrap(); | ||
| 106 | defmt::info!("{:#x}", *evt); | ||
| 107 | } | ||
| 108 | 99 | ||
| 109 | info!("setting association permit"); | 100 | info!("setting association permit"); |
| 110 | let association_permit: bool = true; | 101 | let association_permit: bool = true; |
| @@ -115,10 +106,7 @@ async fn main(spawner: Spawner) { | |||
| 115 | }) | 106 | }) |
| 116 | .await | 107 | .await |
| 117 | .unwrap(); | 108 | .unwrap(); |
| 118 | { | 109 | defmt::info!("{:#x}", mbox.mac_subsystem.read().await.unwrap()); |
| 119 | let evt = mbox.mac_subsystem.read().await.unwrap(); | ||
| 120 | defmt::info!("{:#x}", *evt); | ||
| 121 | } | ||
| 122 | 110 | ||
| 123 | info!("setting TX power"); | 111 | info!("setting TX power"); |
| 124 | let transmit_power: i8 = 2; | 112 | let transmit_power: i8 = 2; |
| @@ -129,10 +117,7 @@ async fn main(spawner: Spawner) { | |||
| 129 | }) | 117 | }) |
| 130 | .await | 118 | .await |
| 131 | .unwrap(); | 119 | .unwrap(); |
| 132 | { | 120 | defmt::info!("{:#x}", mbox.mac_subsystem.read().await.unwrap()); |
| 133 | let evt = mbox.mac_subsystem.read().await.unwrap(); | ||
| 134 | defmt::info!("{:#x}", *evt); | ||
| 135 | } | ||
| 136 | 121 | ||
| 137 | info!("starting FFD device"); | 122 | info!("starting FFD device"); |
| 138 | mbox.mac_subsystem | 123 | mbox.mac_subsystem |
| @@ -147,10 +132,7 @@ async fn main(spawner: Spawner) { | |||
| 147 | }) | 132 | }) |
| 148 | .await | 133 | .await |
| 149 | .unwrap(); | 134 | .unwrap(); |
| 150 | { | 135 | defmt::info!("{:#x}", mbox.mac_subsystem.read().await.unwrap()); |
| 151 | let evt = mbox.mac_subsystem.read().await.unwrap(); | ||
| 152 | defmt::info!("{:#x}", *evt); | ||
| 153 | } | ||
| 154 | 136 | ||
| 155 | info!("setting RX on when idle"); | 137 | info!("setting RX on when idle"); |
| 156 | let rx_on_while_idle: bool = true; | 138 | let rx_on_while_idle: bool = true; |
| @@ -161,18 +143,15 @@ async fn main(spawner: Spawner) { | |||
| 161 | }) | 143 | }) |
| 162 | .await | 144 | .await |
| 163 | .unwrap(); | 145 | .unwrap(); |
| 164 | { | 146 | defmt::info!("{:#x}", mbox.mac_subsystem.read().await.unwrap()); |
| 165 | let evt = mbox.mac_subsystem.read().await.unwrap(); | ||
| 166 | defmt::info!("{:#x}", *evt); | ||
| 167 | } | ||
| 168 | 147 | ||
| 169 | loop { | 148 | loop { |
| 170 | let evt = mbox.mac_subsystem.read().await; | 149 | let evt = mbox.mac_subsystem.read().await; |
| 171 | if let Ok(evt) = evt { | 150 | if let Ok(evt) = evt { |
| 172 | defmt::info!("parsed mac event"); | 151 | defmt::info!("parsed mac event"); |
| 173 | defmt::info!("{:#x}", *evt); | 152 | defmt::info!("{:#x}", evt); |
| 174 | 153 | ||
| 175 | match *evt { | 154 | match evt { |
| 176 | MacEvent::MlmeAssociateInd(association) => mbox | 155 | MacEvent::MlmeAssociateInd(association) => mbox |
| 177 | .mac_subsystem | 156 | .mac_subsystem |
| 178 | .send_command(&AssociateResponse { | 157 | .send_command(&AssociateResponse { |
diff --git a/examples/stm32wb/src/bin/mac_ffd_net.rs b/examples/stm32wb/src/bin/mac_ffd_net.rs index a55b1fc77..bbcd0a70f 100644 --- a/examples/stm32wb/src/bin/mac_ffd_net.rs +++ b/examples/stm32wb/src/bin/mac_ffd_net.rs | |||
| @@ -79,10 +79,7 @@ async fn main(spawner: Spawner) { | |||
| 79 | }) | 79 | }) |
| 80 | .await | 80 | .await |
| 81 | .unwrap(); | 81 | .unwrap(); |
| 82 | { | 82 | defmt::info!("{:#x}", mbox.mac_subsystem.read().await.unwrap()); |
| 83 | let evt = mbox.mac_subsystem.read().await.unwrap(); | ||
| 84 | defmt::info!("{:#x}", *evt); | ||
| 85 | } | ||
| 86 | 83 | ||
| 87 | info!("setting extended address"); | 84 | info!("setting extended address"); |
| 88 | let extended_address: u64 = 0xACDE480000000001; | 85 | let extended_address: u64 = 0xACDE480000000001; |
| @@ -93,10 +90,7 @@ async fn main(spawner: Spawner) { | |||
| 93 | }) | 90 | }) |
| 94 | .await | 91 | .await |
| 95 | .unwrap(); | 92 | .unwrap(); |
| 96 | { | 93 | defmt::info!("{:#x}", mbox.mac_subsystem.read().await.unwrap()); |
| 97 | let evt = mbox.mac_subsystem.read().await.unwrap(); | ||
| 98 | defmt::info!("{:#x}", *evt); | ||
| 99 | } | ||
| 100 | 94 | ||
| 101 | info!("setting short address"); | 95 | info!("setting short address"); |
| 102 | let short_address: u16 = 0x1122; | 96 | let short_address: u16 = 0x1122; |
| @@ -107,10 +101,7 @@ async fn main(spawner: Spawner) { | |||
| 107 | }) | 101 | }) |
| 108 | .await | 102 | .await |
| 109 | .unwrap(); | 103 | .unwrap(); |
| 110 | { | 104 | defmt::info!("{:#x}", mbox.mac_subsystem.read().await.unwrap()); |
| 111 | let evt = mbox.mac_subsystem.read().await.unwrap(); | ||
| 112 | defmt::info!("{:#x}", *evt); | ||
| 113 | } | ||
| 114 | 105 | ||
| 115 | info!("setting association permit"); | 106 | info!("setting association permit"); |
| 116 | let association_permit: bool = true; | 107 | let association_permit: bool = true; |
| @@ -121,10 +112,7 @@ async fn main(spawner: Spawner) { | |||
| 121 | }) | 112 | }) |
| 122 | .await | 113 | .await |
| 123 | .unwrap(); | 114 | .unwrap(); |
| 124 | { | 115 | defmt::info!("{:#x}", mbox.mac_subsystem.read().await.unwrap()); |
| 125 | let evt = mbox.mac_subsystem.read().await.unwrap(); | ||
| 126 | defmt::info!("{:#x}", *evt); | ||
| 127 | } | ||
| 128 | 116 | ||
| 129 | info!("setting TX power"); | 117 | info!("setting TX power"); |
| 130 | let transmit_power: i8 = 2; | 118 | let transmit_power: i8 = 2; |
| @@ -135,10 +123,7 @@ async fn main(spawner: Spawner) { | |||
| 135 | }) | 123 | }) |
| 136 | .await | 124 | .await |
| 137 | .unwrap(); | 125 | .unwrap(); |
| 138 | { | 126 | defmt::info!("{:#x}", mbox.mac_subsystem.read().await.unwrap()); |
| 139 | let evt = mbox.mac_subsystem.read().await.unwrap(); | ||
| 140 | defmt::info!("{:#x}", *evt); | ||
| 141 | } | ||
| 142 | 127 | ||
| 143 | info!("starting FFD device"); | 128 | info!("starting FFD device"); |
| 144 | mbox.mac_subsystem | 129 | mbox.mac_subsystem |
| @@ -153,10 +138,7 @@ async fn main(spawner: Spawner) { | |||
| 153 | }) | 138 | }) |
| 154 | .await | 139 | .await |
| 155 | .unwrap(); | 140 | .unwrap(); |
| 156 | { | 141 | defmt::info!("{:#x}", mbox.mac_subsystem.read().await.unwrap()); |
| 157 | let evt = mbox.mac_subsystem.read().await.unwrap(); | ||
| 158 | defmt::info!("{:#x}", *evt); | ||
| 159 | } | ||
| 160 | 142 | ||
| 161 | info!("setting RX on when idle"); | 143 | info!("setting RX on when idle"); |
| 162 | let rx_on_while_idle: bool = true; | 144 | let rx_on_while_idle: bool = true; |
| @@ -167,10 +149,7 @@ async fn main(spawner: Spawner) { | |||
| 167 | }) | 149 | }) |
| 168 | .await | 150 | .await |
| 169 | .unwrap(); | 151 | .unwrap(); |
| 170 | { | 152 | defmt::info!("{:#x}", mbox.mac_subsystem.read().await.unwrap()); |
| 171 | let evt = mbox.mac_subsystem.read().await.unwrap(); | ||
| 172 | defmt::info!("{:#x}", *evt); | ||
| 173 | } | ||
| 174 | 153 | ||
| 175 | let tx_queue = [ | 154 | let tx_queue = [ |
| 176 | make_static!([0u8; 127]), | 155 | make_static!([0u8; 127]), |
diff --git a/examples/stm32wb/src/bin/mac_rfd.rs b/examples/stm32wb/src/bin/mac_rfd.rs index d1307a844..4d8b6601a 100644 --- a/examples/stm32wb/src/bin/mac_rfd.rs +++ b/examples/stm32wb/src/bin/mac_rfd.rs | |||
| @@ -75,10 +75,7 @@ async fn main(spawner: Spawner) { | |||
| 75 | }) | 75 | }) |
| 76 | .await | 76 | .await |
| 77 | .unwrap(); | 77 | .unwrap(); |
| 78 | { | 78 | defmt::info!("{:#x}", mbox.mac_subsystem.read().await.unwrap()); |
| 79 | let evt = mbox.mac_subsystem.read().await.unwrap(); | ||
| 80 | defmt::info!("{:#x}", *evt); | ||
| 81 | } | ||
| 82 | 79 | ||
| 83 | info!("setting extended address"); | 80 | info!("setting extended address"); |
| 84 | let extended_address: u64 = 0xACDE480000000002; | 81 | let extended_address: u64 = 0xACDE480000000002; |
| @@ -89,10 +86,7 @@ async fn main(spawner: Spawner) { | |||
| 89 | }) | 86 | }) |
| 90 | .await | 87 | .await |
| 91 | .unwrap(); | 88 | .unwrap(); |
| 92 | { | 89 | defmt::info!("{:#x}", mbox.mac_subsystem.read().await.unwrap()); |
| 93 | let evt = mbox.mac_subsystem.read().await.unwrap(); | ||
| 94 | defmt::info!("{:#x}", *evt); | ||
| 95 | } | ||
| 96 | 90 | ||
| 97 | info!("getting extended address"); | 91 | info!("getting extended address"); |
| 98 | mbox.mac_subsystem | 92 | mbox.mac_subsystem |
| @@ -105,9 +99,9 @@ async fn main(spawner: Spawner) { | |||
| 105 | 99 | ||
| 106 | { | 100 | { |
| 107 | let evt = mbox.mac_subsystem.read().await.unwrap(); | 101 | let evt = mbox.mac_subsystem.read().await.unwrap(); |
| 108 | info!("{:#x}", *evt); | 102 | info!("{:#x}", evt); |
| 109 | 103 | ||
| 110 | if let MacEvent::MlmeGetCnf(evt) = *evt { | 104 | if let MacEvent::MlmeGetCnf(evt) = evt { |
| 111 | if evt.pib_attribute_value_len == 8 { | 105 | if evt.pib_attribute_value_len == 8 { |
| 112 | let value = unsafe { core::ptr::read_unaligned(evt.pib_attribute_value_ptr as *const u64) }; | 106 | let value = unsafe { core::ptr::read_unaligned(evt.pib_attribute_value_ptr as *const u64) }; |
| 113 | 107 | ||
| @@ -133,9 +127,9 @@ async fn main(spawner: Spawner) { | |||
| 133 | mbox.mac_subsystem.send_command(&a).await.unwrap(); | 127 | mbox.mac_subsystem.send_command(&a).await.unwrap(); |
| 134 | let short_addr = { | 128 | let short_addr = { |
| 135 | let evt = mbox.mac_subsystem.read().await.unwrap(); | 129 | let evt = mbox.mac_subsystem.read().await.unwrap(); |
| 136 | info!("{:#x}", *evt); | 130 | info!("{:#x}", evt); |
| 137 | 131 | ||
| 138 | if let MacEvent::MlmeAssociateCnf(conf) = *evt { | 132 | if let MacEvent::MlmeAssociateCnf(conf) = evt { |
| 139 | conf.assoc_short_address | 133 | conf.assoc_short_address |
| 140 | } else { | 134 | } else { |
| 141 | defmt::panic!() | 135 | defmt::panic!() |
| @@ -152,7 +146,7 @@ async fn main(spawner: Spawner) { | |||
| 152 | .unwrap(); | 146 | .unwrap(); |
| 153 | { | 147 | { |
| 154 | let evt = mbox.mac_subsystem.read().await.unwrap(); | 148 | let evt = mbox.mac_subsystem.read().await.unwrap(); |
| 155 | info!("{:#x}", *evt); | 149 | info!("{:#x}", evt); |
| 156 | } | 150 | } |
| 157 | 151 | ||
| 158 | info!("sending data"); | 152 | info!("sending data"); |
| @@ -176,12 +170,12 @@ async fn main(spawner: Spawner) { | |||
| 176 | .unwrap(); | 170 | .unwrap(); |
| 177 | { | 171 | { |
| 178 | let evt = mbox.mac_subsystem.read().await.unwrap(); | 172 | let evt = mbox.mac_subsystem.read().await.unwrap(); |
| 179 | info!("{:#x}", *evt); | 173 | info!("{:#x}", evt); |
| 180 | } | 174 | } |
| 181 | 175 | ||
| 182 | loop { | 176 | loop { |
| 183 | match mbox.mac_subsystem.read().await { | 177 | match mbox.mac_subsystem.read().await { |
| 184 | Ok(evt) => info!("{:#x}", *evt), | 178 | Ok(evt) => info!("{:#x}", evt), |
| 185 | _ => continue, | 179 | _ => continue, |
| 186 | }; | 180 | }; |
| 187 | } | 181 | } |
diff --git a/tests/stm32/src/bin/wpan_mac.rs b/tests/stm32/src/bin/wpan_mac.rs index 2b0d67bb5..b04a19ee9 100644 --- a/tests/stm32/src/bin/wpan_mac.rs +++ b/tests/stm32/src/bin/wpan_mac.rs | |||
| @@ -57,7 +57,7 @@ async fn main(spawner: Spawner) { | |||
| 57 | .unwrap(); | 57 | .unwrap(); |
| 58 | { | 58 | { |
| 59 | let evt = mbox.mac_subsystem.read().await.unwrap(); | 59 | let evt = mbox.mac_subsystem.read().await.unwrap(); |
| 60 | info!("{:#x}", *evt); | 60 | info!("{:#x}", evt); |
| 61 | } | 61 | } |
| 62 | 62 | ||
| 63 | info!("setting extended address"); | 63 | info!("setting extended address"); |
| @@ -71,7 +71,7 @@ async fn main(spawner: Spawner) { | |||
| 71 | .unwrap(); | 71 | .unwrap(); |
| 72 | { | 72 | { |
| 73 | let evt = mbox.mac_subsystem.read().await.unwrap(); | 73 | let evt = mbox.mac_subsystem.read().await.unwrap(); |
| 74 | info!("{:#x}", *evt); | 74 | info!("{:#x}", evt); |
| 75 | } | 75 | } |
| 76 | 76 | ||
| 77 | info!("getting extended address"); | 77 | info!("getting extended address"); |
| @@ -85,9 +85,9 @@ async fn main(spawner: Spawner) { | |||
| 85 | 85 | ||
| 86 | { | 86 | { |
| 87 | let evt = mbox.mac_subsystem.read().await.unwrap(); | 87 | let evt = mbox.mac_subsystem.read().await.unwrap(); |
| 88 | info!("{:#x}", *evt); | 88 | info!("{:#x}", evt); |
| 89 | 89 | ||
| 90 | if let MacEvent::MlmeGetCnf(evt) = *evt { | 90 | if let MacEvent::MlmeGetCnf(evt) = evt { |
| 91 | if evt.pib_attribute_value_len == 8 { | 91 | if evt.pib_attribute_value_len == 8 { |
| 92 | let value = unsafe { core::ptr::read_unaligned(evt.pib_attribute_value_ptr as *const u64) }; | 92 | let value = unsafe { core::ptr::read_unaligned(evt.pib_attribute_value_ptr as *const u64) }; |
| 93 | 93 | ||
| @@ -111,18 +111,13 @@ async fn main(spawner: Spawner) { | |||
| 111 | }; | 111 | }; |
| 112 | info!("{}", a); | 112 | info!("{}", a); |
| 113 | mbox.mac_subsystem.send_command(&a).await.unwrap(); | 113 | mbox.mac_subsystem.send_command(&a).await.unwrap(); |
| 114 | let short_addr = { | 114 | let short_addr = if let MacEvent::MlmeAssociateCnf(conf) = mbox.mac_subsystem.read().await.unwrap() { |
| 115 | let evt = mbox.mac_subsystem.read().await.unwrap(); | 115 | conf.assoc_short_address |
| 116 | info!("{:#x}", *evt); | 116 | } else { |
| 117 | 117 | defmt::panic!() | |
| 118 | if let MacEvent::MlmeAssociateCnf(conf) = *evt { | ||
| 119 | conf.assoc_short_address | ||
| 120 | } else { | ||
| 121 | defmt::panic!() | ||
| 122 | } | ||
| 123 | }; | 118 | }; |
| 124 | 119 | ||
| 125 | _ = short_addr; | 120 | info!("{}", short_addr); |
| 126 | 121 | ||
| 127 | info!("Test OK"); | 122 | info!("Test OK"); |
| 128 | cortex_m::asm::bkpt(); | 123 | cortex_m::asm::bkpt(); |
