aboutsummaryrefslogtreecommitdiff
path: root/examples/stm32wb/src/bin/mac_rfd.rs
diff options
context:
space:
mode:
authorgoueslati <[email protected]>2023-07-12 16:49:37 +0100
committergoueslati <[email protected]>2023-07-12 16:49:37 +0100
commiteccd2ecebf01753e70705a6ca1e21bc83b2c204c (patch)
treeef355c98cce0872969eadeacc568c56acbe6ccea /examples/stm32wb/src/bin/mac_rfd.rs
parentd5a4457b5e3a95a12f249315fb1d9b6a577307f2 (diff)
change MacAddress to a union instead of an enum
Diffstat (limited to 'examples/stm32wb/src/bin/mac_rfd.rs')
-rw-r--r--examples/stm32wb/src/bin/mac_rfd.rs94
1 files changed, 59 insertions, 35 deletions
diff --git a/examples/stm32wb/src/bin/mac_rfd.rs b/examples/stm32wb/src/bin/mac_rfd.rs
index 8042a3704..e5f8d54c9 100644
--- a/examples/stm32wb/src/bin/mac_rfd.rs
+++ b/examples/stm32wb/src/bin/mac_rfd.rs
@@ -6,7 +6,8 @@ use defmt::*;
6use embassy_executor::Spawner; 6use embassy_executor::Spawner;
7use embassy_stm32::bind_interrupts; 7use embassy_stm32::bind_interrupts;
8use embassy_stm32::ipcc::{Config, ReceiveInterruptHandler, TransmitInterruptHandler}; 8use embassy_stm32::ipcc::{Config, ReceiveInterruptHandler, TransmitInterruptHandler};
9use embassy_stm32_wpan::sub::mac::commands::{AssociateRequest, ResetRequest, SetRequest, StartRequest}; 9use embassy_stm32_wpan::sub::mac::commands::{AssociateRequest, GetRequest, ResetRequest, SetRequest};
10use embassy_stm32_wpan::sub::mac::event::MacEvent;
10use embassy_stm32_wpan::sub::mac::typedefs::{ 11use embassy_stm32_wpan::sub::mac::typedefs::{
11 AddressMode, Capabilities, KeyIdMode, MacAddress, MacChannel, PibId, SecurityLevel, 12 AddressMode, Capabilities, KeyIdMode, MacAddress, MacChannel, PibId, SecurityLevel,
12}; 13};
@@ -67,52 +68,75 @@ async fn main(spawner: Spawner) {
67 info!("initialized mac: {}", result); 68 info!("initialized mac: {}", result);
68 69
69 info!("resetting"); 70 info!("resetting");
70 let response = mbox 71 mbox.mac_subsystem
71 .mac_subsystem 72 .send_command(&ResetRequest { set_default_pib: true })
72 .send_command(ResetRequest { set_default_pib: true }) 73 .await
73 .await; 74 .unwrap();
74 info!("{}", response); 75 let evt = mbox.mac_subsystem.read().await;
76 info!("{:#x}", evt);
75 77
76 info!("setting extended address"); 78 info!("setting extended address");
77 let extended_address: u64 = 0xACDE480000000002; 79 let extended_address: u64 = 0xACDE480000000002;
78 let response = mbox 80 mbox.mac_subsystem
79 .mac_subsystem 81 .send_command(&SetRequest {
80 .send_command(SetRequest {
81 pib_attribute_ptr: &extended_address as *const _ as *const u8, 82 pib_attribute_ptr: &extended_address as *const _ as *const u8,
82 pib_attribute: PibId::ExtendedAddress, 83 pib_attribute: PibId::ExtendedAddress,
83 }) 84 })
84 .await; 85 .await
85 info!("{}", response); 86 .unwrap();
87 let evt = mbox.mac_subsystem.read().await;
88 info!("{:#x}", evt);
89
90 info!("getting extended address");
91 mbox.mac_subsystem
92 .send_command(&GetRequest {
93 pib_attribute: PibId::ExtendedAddress,
94 })
95 .await
96 .unwrap();
97 let evt = mbox.mac_subsystem.read().await;
98 info!("{:#x}", evt);
99
100 if let Ok(MacEvent::MlmeGetCnf(evt)) = evt {
101 if evt.pib_attribute_value_len == 8 {
102 let value = unsafe { core::ptr::read_unaligned(evt.pib_attribute_value_ptr as *const u64) };
103
104 info!("value {:#x}", value)
105 }
106 }
86 107
87 info!("assocation request"); 108 info!("assocation request");
88 let response = mbox 109 let a = AssociateRequest {
89 .mac_subsystem 110 channel_number: MacChannel::Channel16,
90 .send_command(AssociateRequest { 111 channel_page: 0,
91 channel_number: MacChannel::Channel16, 112 coord_addr_mode: AddressMode::Short,
92 channel_page: 0, 113 coord_address: MacAddress { short: [34, 17] },
93 coord_addr_mode: AddressMode::Short, 114 capability_information: Capabilities::ALLOCATE_ADDRESS,
94 coord_address: MacAddress::Short([0x22, 0x11]), 115 coord_pan_id: [0xAA, 0x1A],
95 capability_information: Capabilities::ALLOCATE_ADDRESS, 116 security_level: SecurityLevel::Unsecure,
96 coord_pan_id: [0xAA, 0x1A], 117 key_id_mode: KeyIdMode::Implicite,
97 security_level: SecurityLevel::Unsecure, 118 key_source: [0; 8],
98 key_id_mode: KeyIdMode::Implicite, 119 key_index: 152,
99 key_source: [0; 8], 120 };
100 key_index: 0, 121 info!("{}", a);
101 }) 122 mbox.mac_subsystem.send_command(&a).await.unwrap();
102 .await; 123 let evt = mbox.mac_subsystem.read().await;
103 info!("{}", response); 124 info!("{:#x}", evt);
104 125
105 info!("setting short address"); 126 info!("setting short address");
106 let short: u64 = 0xACDE480000000002; 127 let short: u64 = 0xACDE480000000002;
107 let response = mbox 128 mbox.mac_subsystem
108 .mac_subsystem 129 .send_command(&SetRequest {
109 .send_command(SetRequest {
110 pib_attribute_ptr: &short as *const _ as *const u8, 130 pib_attribute_ptr: &short as *const _ as *const u8,
111 pib_attribute: PibId::ShortAddress, 131 pib_attribute: PibId::ShortAddress,
112 }) 132 })
113 .await; 133 .await
114 info!("{}", response); 134 .unwrap();
115 135 let evt = mbox.mac_subsystem.read().await;
116 info!("Test OK"); 136 info!("{:#x}", evt);
117 cortex_m::asm::bkpt(); 137
138 loop {
139 let evt = mbox.mac_subsystem.read().await;
140 info!("{:#x}", evt);
141 }
118} 142}