aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorxoviat <[email protected]>2025-11-23 13:11:18 -0600
committerxoviat <[email protected]>2025-11-23 13:11:18 -0600
commit08125aa919a4dc4de79f91de9a7f3586e51a7739 (patch)
treebe2320ff9ee6b1bb3a2f9b35d714ba8c8d202b18 /examples
parent54a153a9a24a58a7cfa1210f78f61beb913baf2d (diff)
wpan: restructure ipcc and hil test wpan_mac
Diffstat (limited to 'examples')
-rw-r--r--examples/stm32wb/src/bin/eddystone_beacon.rs116
-rw-r--r--examples/stm32wb/src/bin/gatt_server.rs118
-rw-r--r--examples/stm32wb/src/bin/mac_ffd.rs47
-rw-r--r--examples/stm32wb/src/bin/mac_ffd_net.rs9
-rw-r--r--examples/stm32wb/src/bin/mac_rfd.rs40
-rw-r--r--examples/stm32wb/src/bin/tl_mbox.rs2
-rw-r--r--examples/stm32wb/src/bin/tl_mbox_ble.rs21
-rw-r--r--examples/stm32wb/src/bin/tl_mbox_mac.rs12
8 files changed, 168 insertions, 197 deletions
diff --git a/examples/stm32wb/src/bin/eddystone_beacon.rs b/examples/stm32wb/src/bin/eddystone_beacon.rs
index f309ca3a2..413b1ac8f 100644
--- a/examples/stm32wb/src/bin/eddystone_beacon.rs
+++ b/examples/stm32wb/src/bin/eddystone_beacon.rs
@@ -57,126 +57,112 @@ async fn main(_spawner: Spawner) {
57 info!("Hello World!"); 57 info!("Hello World!");
58 58
59 let config = Config::default(); 59 let config = Config::default();
60 let mut mbox = TlMbox::init(p.IPCC, Irqs, config); 60 let mbox = TlMbox::init(p.IPCC, Irqs, config).await;
61 let mut sys = mbox.sys_subsystem;
62 let mut ble = mbox.ble_subsystem;
61 63
62 let sys_event = mbox.sys_subsystem.read().await; 64 let _ = sys.shci_c2_ble_init(Default::default()).await;
63 info!("sys event: {}", sys_event.payload());
64
65 let _ = mbox.sys_subsystem.shci_c2_ble_init(Default::default()).await;
66 65
67 info!("resetting BLE..."); 66 info!("resetting BLE...");
68 mbox.ble_subsystem.reset().await; 67 ble.reset().await;
69 let response = mbox.ble_subsystem.read().await.unwrap(); 68 let response = ble.read().await.unwrap();
70 defmt::info!("{}", response); 69 defmt::info!("{}", response);
71 70
72 info!("config public address..."); 71 info!("config public address...");
73 mbox.ble_subsystem 72 ble.write_config_data(&ConfigData::public_address(get_bd_addr()).build())
74 .write_config_data(&ConfigData::public_address(get_bd_addr()).build())
75 .await; 73 .await;
76 let response = mbox.ble_subsystem.read().await.unwrap(); 74 let response = ble.read().await.unwrap();
77 defmt::info!("{}", response); 75 defmt::info!("{}", response);
78 76
79 info!("config random address..."); 77 info!("config random address...");
80 mbox.ble_subsystem 78 ble.write_config_data(&ConfigData::random_address(get_random_addr()).build())
81 .write_config_data(&ConfigData::random_address(get_random_addr()).build())
82 .await; 79 .await;
83 let response = mbox.ble_subsystem.read().await.unwrap(); 80 let response = ble.read().await.unwrap();
84 defmt::info!("{}", response); 81 defmt::info!("{}", response);
85 82
86 info!("config identity root..."); 83 info!("config identity root...");
87 mbox.ble_subsystem 84 ble.write_config_data(&ConfigData::identity_root(&get_irk()).build())
88 .write_config_data(&ConfigData::identity_root(&get_irk()).build())
89 .await; 85 .await;
90 let response = mbox.ble_subsystem.read().await.unwrap(); 86 let response = ble.read().await.unwrap();
91 defmt::info!("{}", response); 87 defmt::info!("{}", response);
92 88
93 info!("config encryption root..."); 89 info!("config encryption root...");
94 mbox.ble_subsystem 90 ble.write_config_data(&ConfigData::encryption_root(&get_erk()).build())
95 .write_config_data(&ConfigData::encryption_root(&get_erk()).build())
96 .await; 91 .await;
97 let response = mbox.ble_subsystem.read().await.unwrap(); 92 let response = ble.read().await.unwrap();
98 defmt::info!("{}", response); 93 defmt::info!("{}", response);
99 94
100 info!("config tx power level..."); 95 info!("config tx power level...");
101 mbox.ble_subsystem.set_tx_power_level(PowerLevel::ZerodBm).await; 96 ble.set_tx_power_level(PowerLevel::ZerodBm).await;
102 let response = mbox.ble_subsystem.read().await.unwrap(); 97 let response = ble.read().await.unwrap();
103 defmt::info!("{}", response); 98 defmt::info!("{}", response);
104 99
105 info!("GATT init..."); 100 info!("GATT init...");
106 mbox.ble_subsystem.init_gatt().await; 101 ble.init_gatt().await;
107 let response = mbox.ble_subsystem.read().await.unwrap(); 102 let response = ble.read().await.unwrap();
108 defmt::info!("{}", response); 103 defmt::info!("{}", response);
109 104
110 info!("GAP init..."); 105 info!("GAP init...");
111 mbox.ble_subsystem 106 ble.init_gap(Role::PERIPHERAL, false, BLE_GAP_DEVICE_NAME_LENGTH).await;
112 .init_gap(Role::PERIPHERAL, false, BLE_GAP_DEVICE_NAME_LENGTH) 107 let response = ble.read().await.unwrap();
113 .await;
114 let response = mbox.ble_subsystem.read().await.unwrap();
115 defmt::info!("{}", response); 108 defmt::info!("{}", response);
116 109
117 // info!("set scan response..."); 110 // info!("set scan response...");
118 // mbox.ble_subsystem.le_set_scan_response_data(&[]).await.unwrap(); 111 // ble.le_set_scan_response_data(&[]).await.unwrap();
119 // let response = mbox.ble_subsystem.read().await.unwrap(); 112 // let response = ble.read().await.unwrap();
120 // defmt::info!("{}", response); 113 // defmt::info!("{}", response);
121 114
122 info!("set discoverable..."); 115 info!("set discoverable...");
123 mbox.ble_subsystem 116 ble.set_discoverable(&DiscoverableParameters {
124 .set_discoverable(&DiscoverableParameters { 117 advertising_type: AdvertisingType::NonConnectableUndirected,
125 advertising_type: AdvertisingType::NonConnectableUndirected, 118 advertising_interval: Some((Duration::from_millis(250), Duration::from_millis(250))),
126 advertising_interval: Some((Duration::from_millis(250), Duration::from_millis(250))), 119 address_type: OwnAddressType::Public,
127 address_type: OwnAddressType::Public, 120 filter_policy: AdvertisingFilterPolicy::AllowConnectionAndScan,
128 filter_policy: AdvertisingFilterPolicy::AllowConnectionAndScan, 121 local_name: None,
129 local_name: None, 122 advertising_data: &[],
130 advertising_data: &[], 123 conn_interval: (None, None),
131 conn_interval: (None, None), 124 })
132 }) 125 .await
133 .await 126 .unwrap();
134 .unwrap(); 127
135 128 let response = ble.read().await;
136 let response = mbox.ble_subsystem.read().await;
137 defmt::info!("{}", response); 129 defmt::info!("{}", response);
138 130
139 // remove some advertisement to decrease the packet size 131 // remove some advertisement to decrease the packet size
140 info!("delete tx power ad type..."); 132 info!("delete tx power ad type...");
141 mbox.ble_subsystem 133 ble.delete_ad_type(AdvertisingDataType::TxPowerLevel).await;
142 .delete_ad_type(AdvertisingDataType::TxPowerLevel) 134 let response = ble.read().await.unwrap();
143 .await;
144 let response = mbox.ble_subsystem.read().await.unwrap();
145 defmt::info!("{}", response); 135 defmt::info!("{}", response);
146 136
147 info!("delete conn interval ad type..."); 137 info!("delete conn interval ad type...");
148 mbox.ble_subsystem 138 ble.delete_ad_type(AdvertisingDataType::PeripheralConnectionInterval)
149 .delete_ad_type(AdvertisingDataType::PeripheralConnectionInterval)
150 .await; 139 .await;
151 let response = mbox.ble_subsystem.read().await.unwrap(); 140 let response = ble.read().await.unwrap();
152 defmt::info!("{}", response); 141 defmt::info!("{}", response);
153 142
154 info!("update advertising data..."); 143 info!("update advertising data...");
155 mbox.ble_subsystem 144 ble.update_advertising_data(&eddystone_advertising_data())
156 .update_advertising_data(&eddystone_advertising_data())
157 .await 145 .await
158 .unwrap(); 146 .unwrap();
159 let response = mbox.ble_subsystem.read().await.unwrap(); 147 let response = ble.read().await.unwrap();
160 defmt::info!("{}", response); 148 defmt::info!("{}", response);
161 149
162 info!("update advertising data type..."); 150 info!("update advertising data type...");
163 mbox.ble_subsystem 151 ble.update_advertising_data(&[3, AdvertisingDataType::UuidCompleteList16 as u8, 0xaa, 0xfe])
164 .update_advertising_data(&[3, AdvertisingDataType::UuidCompleteList16 as u8, 0xaa, 0xfe])
165 .await 152 .await
166 .unwrap(); 153 .unwrap();
167 let response = mbox.ble_subsystem.read().await.unwrap(); 154 let response = ble.read().await.unwrap();
168 defmt::info!("{}", response); 155 defmt::info!("{}", response);
169 156
170 info!("update advertising data flags..."); 157 info!("update advertising data flags...");
171 mbox.ble_subsystem 158 ble.update_advertising_data(&[
172 .update_advertising_data(&[ 159 2,
173 2, 160 AdvertisingDataType::Flags as u8,
174 AdvertisingDataType::Flags as u8, 161 (0x02 | 0x04) as u8, // BLE general discoverable, without BR/EDR support
175 (0x02 | 0x04) as u8, // BLE general discoverable, without BR/EDR support 162 ])
176 ]) 163 .await
177 .await 164 .unwrap();
178 .unwrap(); 165 let response = ble.read().await.unwrap();
179 let response = mbox.ble_subsystem.read().await.unwrap();
180 defmt::info!("{}", response); 166 defmt::info!("{}", response);
181 167
182 cortex_m::asm::wfi(); 168 cortex_m::asm::wfi();
diff --git a/examples/stm32wb/src/bin/gatt_server.rs b/examples/stm32wb/src/bin/gatt_server.rs
index 2ed257566..3484f1844 100644
--- a/examples/stm32wb/src/bin/gatt_server.rs
+++ b/examples/stm32wb/src/bin/gatt_server.rs
@@ -69,92 +69,85 @@ async fn main(spawner: Spawner) {
69 info!("Hello World!"); 69 info!("Hello World!");
70 70
71 let config = Config::default(); 71 let config = Config::default();
72 let mut mbox = TlMbox::init(p.IPCC, Irqs, config); 72 let mbox = TlMbox::init(p.IPCC, Irqs, config).await;
73 let mut sys = mbox.sys_subsystem;
74 let mut ble = mbox.ble_subsystem;
73 75
74 spawner.spawn(run_mm_queue(mbox.mm_subsystem).unwrap()); 76 spawner.spawn(run_mm_queue(mbox.mm_subsystem).unwrap());
75 let sys_event = mbox.sys_subsystem.read().await;
76 info!("sys event: {}", sys_event.payload());
77 77
78 let _ = mbox.sys_subsystem.shci_c2_ble_init(Default::default()).await; 78 let _ = sys.shci_c2_ble_init(Default::default()).await;
79 79
80 info!("resetting BLE..."); 80 info!("resetting BLE...");
81 mbox.ble_subsystem.reset().await; 81 ble.reset().await;
82 let response = mbox.ble_subsystem.read().await; 82 let response = ble.read().await;
83 defmt::debug!("{}", response); 83 defmt::debug!("{}", response);
84 84
85 info!("config public address..."); 85 info!("config public address...");
86 mbox.ble_subsystem 86 ble.write_config_data(&ConfigData::public_address(get_bd_addr()).build())
87 .write_config_data(&ConfigData::public_address(get_bd_addr()).build())
88 .await; 87 .await;
89 let response = mbox.ble_subsystem.read().await; 88 let response = ble.read().await;
90 defmt::debug!("{}", response); 89 defmt::debug!("{}", response);
91 90
92 info!("config random address..."); 91 info!("config random address...");
93 mbox.ble_subsystem 92 ble.write_config_data(&ConfigData::random_address(get_random_addr()).build())
94 .write_config_data(&ConfigData::random_address(get_random_addr()).build())
95 .await; 93 .await;
96 let response = mbox.ble_subsystem.read().await; 94 let response = ble.read().await;
97 defmt::debug!("{}", response); 95 defmt::debug!("{}", response);
98 96
99 info!("config identity root..."); 97 info!("config identity root...");
100 mbox.ble_subsystem 98 ble.write_config_data(&ConfigData::identity_root(&get_irk()).build())
101 .write_config_data(&ConfigData::identity_root(&get_irk()).build())
102 .await; 99 .await;
103 let response = mbox.ble_subsystem.read().await; 100 let response = ble.read().await;
104 defmt::debug!("{}", response); 101 defmt::debug!("{}", response);
105 102
106 info!("config encryption root..."); 103 info!("config encryption root...");
107 mbox.ble_subsystem 104 ble.write_config_data(&ConfigData::encryption_root(&get_erk()).build())
108 .write_config_data(&ConfigData::encryption_root(&get_erk()).build())
109 .await; 105 .await;
110 let response = mbox.ble_subsystem.read().await; 106 let response = ble.read().await;
111 defmt::debug!("{}", response); 107 defmt::debug!("{}", response);
112 108
113 info!("config tx power level..."); 109 info!("config tx power level...");
114 mbox.ble_subsystem.set_tx_power_level(PowerLevel::ZerodBm).await; 110 ble.set_tx_power_level(PowerLevel::ZerodBm).await;
115 let response = mbox.ble_subsystem.read().await; 111 let response = ble.read().await;
116 defmt::debug!("{}", response); 112 defmt::debug!("{}", response);
117 113
118 info!("GATT init..."); 114 info!("GATT init...");
119 mbox.ble_subsystem.init_gatt().await; 115 ble.init_gatt().await;
120 let response = mbox.ble_subsystem.read().await; 116 let response = ble.read().await;
121 defmt::debug!("{}", response); 117 defmt::debug!("{}", response);
122 118
123 info!("GAP init..."); 119 info!("GAP init...");
124 mbox.ble_subsystem 120 ble.init_gap(Role::PERIPHERAL, false, BLE_GAP_DEVICE_NAME_LENGTH).await;
125 .init_gap(Role::PERIPHERAL, false, BLE_GAP_DEVICE_NAME_LENGTH) 121 let response = ble.read().await;
126 .await;
127 let response = mbox.ble_subsystem.read().await;
128 defmt::debug!("{}", response); 122 defmt::debug!("{}", response);
129 123
130 info!("set IO capabilities..."); 124 info!("set IO capabilities...");
131 mbox.ble_subsystem.set_io_capability(IoCapability::DisplayConfirm).await; 125 ble.set_io_capability(IoCapability::DisplayConfirm).await;
132 let response = mbox.ble_subsystem.read().await; 126 let response = ble.read().await;
133 defmt::debug!("{}", response); 127 defmt::debug!("{}", response);
134 128
135 info!("set authentication requirements..."); 129 info!("set authentication requirements...");
136 mbox.ble_subsystem 130 ble.set_authentication_requirement(&AuthenticationRequirements {
137 .set_authentication_requirement(&AuthenticationRequirements { 131 bonding_required: false,
138 bonding_required: false, 132 keypress_notification_support: false,
139 keypress_notification_support: false, 133 mitm_protection_required: false,
140 mitm_protection_required: false, 134 encryption_key_size_range: (8, 16),
141 encryption_key_size_range: (8, 16), 135 fixed_pin: Pin::Requested,
142 fixed_pin: Pin::Requested, 136 identity_address_type: AddressType::Public,
143 identity_address_type: AddressType::Public, 137 secure_connection_support: SecureConnectionSupport::Optional,
144 secure_connection_support: SecureConnectionSupport::Optional, 138 })
145 }) 139 .await
146 .await 140 .unwrap();
147 .unwrap(); 141 let response = ble.read().await;
148 let response = mbox.ble_subsystem.read().await;
149 defmt::debug!("{}", response); 142 defmt::debug!("{}", response);
150 143
151 info!("set scan response data..."); 144 info!("set scan response data...");
152 mbox.ble_subsystem.le_set_scan_response_data(b"TXTX").await.unwrap(); 145 ble.le_set_scan_response_data(b"TXTX").await.unwrap();
153 let response = mbox.ble_subsystem.read().await; 146 let response = ble.read().await;
154 defmt::debug!("{}", response); 147 defmt::debug!("{}", response);
155 148
156 defmt::info!("initializing services and characteristics..."); 149 defmt::info!("initializing services and characteristics...");
157 let mut ble_context = init_gatt_services(&mut mbox.ble_subsystem).await.unwrap(); 150 let mut ble_context = init_gatt_services(&mut ble).await.unwrap();
158 defmt::info!("{}", ble_context); 151 defmt::info!("{}", ble_context);
159 152
160 let discovery_params = DiscoverableParameters { 153 let discovery_params = DiscoverableParameters {
@@ -168,12 +161,12 @@ async fn main(spawner: Spawner) {
168 }; 161 };
169 162
170 info!("set discoverable..."); 163 info!("set discoverable...");
171 mbox.ble_subsystem.set_discoverable(&discovery_params).await.unwrap(); 164 ble.set_discoverable(&discovery_params).await.unwrap();
172 let response = mbox.ble_subsystem.read().await; 165 let response = ble.read().await;
173 defmt::debug!("{}", response); 166 defmt::debug!("{}", response);
174 167
175 loop { 168 loop {
176 let response = mbox.ble_subsystem.read().await; 169 let response = ble.read().await;
177 defmt::debug!("{}", response); 170 defmt::debug!("{}", response);
178 171
179 if let Ok(Packet::Event(event)) = response { 172 if let Ok(Packet::Event(event)) = response {
@@ -184,24 +177,23 @@ async fn main(spawner: Spawner) {
184 Event::DisconnectionComplete(_) => { 177 Event::DisconnectionComplete(_) => {
185 defmt::info!("disconnected"); 178 defmt::info!("disconnected");
186 ble_context.is_subscribed = false; 179 ble_context.is_subscribed = false;
187 mbox.ble_subsystem.set_discoverable(&discovery_params).await.unwrap(); 180 ble.set_discoverable(&discovery_params).await.unwrap();
188 } 181 }
189 Event::Vendor(vendor_event) => match vendor_event { 182 Event::Vendor(vendor_event) => match vendor_event {
190 VendorEvent::AttReadPermitRequest(read_req) => { 183 VendorEvent::AttReadPermitRequest(read_req) => {
191 defmt::info!("read request received {}, allowing", read_req); 184 defmt::info!("read request received {}, allowing", read_req);
192 mbox.ble_subsystem.allow_read(read_req.conn_handle).await 185 ble.allow_read(read_req.conn_handle).await
193 } 186 }
194 VendorEvent::AttWritePermitRequest(write_req) => { 187 VendorEvent::AttWritePermitRequest(write_req) => {
195 defmt::info!("write request received {}, allowing", write_req); 188 defmt::info!("write request received {}, allowing", write_req);
196 mbox.ble_subsystem 189 ble.write_response(&WriteResponseParameters {
197 .write_response(&WriteResponseParameters { 190 conn_handle: write_req.conn_handle,
198 conn_handle: write_req.conn_handle, 191 attribute_handle: write_req.attribute_handle,
199 attribute_handle: write_req.attribute_handle, 192 status: Ok(()),
200 status: Ok(()), 193 value: write_req.value(),
201 value: write_req.value(), 194 })
202 }) 195 .await
203 .await 196 .unwrap()
204 .unwrap()
205 } 197 }
206 VendorEvent::GattAttributeModified(attribute) => { 198 VendorEvent::GattAttributeModified(attribute) => {
207 defmt::info!("{}", ble_context); 199 defmt::info!("{}", ble_context);
@@ -224,7 +216,7 @@ async fn main(spawner: Spawner) {
224} 216}
225 217
226#[embassy_executor::task] 218#[embassy_executor::task]
227async fn run_mm_queue(memory_manager: mm::MemoryManager) { 219async fn run_mm_queue(mut memory_manager: mm::MemoryManager<'static>) {
228 memory_manager.run_queue().await; 220 memory_manager.run_queue().await;
229} 221}
230 222
@@ -285,7 +277,7 @@ pub struct CharHandles {
285 pub notify: AttributeHandle, 277 pub notify: AttributeHandle,
286} 278}
287 279
288pub async fn init_gatt_services(ble_subsystem: &mut Ble) -> Result<BleContext, ()> { 280pub async fn init_gatt_services<'a>(ble_subsystem: &mut Ble<'a>) -> Result<BleContext, ()> {
289 let service_handle = gatt_add_service(ble_subsystem, Uuid::Uuid16(0x500)).await?; 281 let service_handle = gatt_add_service(ble_subsystem, Uuid::Uuid16(0x500)).await?;
290 282
291 let read = gatt_add_char( 283 let read = gatt_add_char(
@@ -322,7 +314,7 @@ pub async fn init_gatt_services(ble_subsystem: &mut Ble) -> Result<BleContext, (
322 }) 314 })
323} 315}
324 316
325async fn gatt_add_service(ble_subsystem: &mut Ble, uuid: Uuid) -> Result<AttributeHandle, ()> { 317async fn gatt_add_service<'a>(ble_subsystem: &mut Ble<'a>, uuid: Uuid) -> Result<AttributeHandle, ()> {
326 ble_subsystem 318 ble_subsystem
327 .add_service(&AddServiceParameters { 319 .add_service(&AddServiceParameters {
328 uuid, 320 uuid,
@@ -348,8 +340,8 @@ async fn gatt_add_service(ble_subsystem: &mut Ble, uuid: Uuid) -> Result<Attribu
348 } 340 }
349} 341}
350 342
351async fn gatt_add_char( 343async fn gatt_add_char<'a>(
352 ble_subsystem: &mut Ble, 344 ble_subsystem: &mut Ble<'a>,
353 service_handle: AttributeHandle, 345 service_handle: AttributeHandle,
354 characteristic_uuid: Uuid, 346 characteristic_uuid: Uuid,
355 characteristic_properties: CharacteristicProperty, 347 characteristic_properties: CharacteristicProperty,
diff --git a/examples/stm32wb/src/bin/mac_ffd.rs b/examples/stm32wb/src/bin/mac_ffd.rs
index 18a52e162..4bab6ea9f 100644
--- a/examples/stm32wb/src/bin/mac_ffd.rs
+++ b/examples/stm32wb/src/bin/mac_ffd.rs
@@ -19,7 +19,7 @@ bind_interrupts!(struct Irqs{
19}); 19});
20 20
21#[embassy_executor::task] 21#[embassy_executor::task]
22async fn run_mm_queue(memory_manager: mm::MemoryManager) { 22async fn run_mm_queue(mut memory_manager: mm::MemoryManager<'static>) {
23 memory_manager.run_queue().await; 23 memory_manager.run_queue().await;
24} 24}
25 25
@@ -54,74 +54,72 @@ async fn main(spawner: Spawner) {
54 info!("Hello World!"); 54 info!("Hello World!");
55 55
56 let config = Config::default(); 56 let config = Config::default();
57 let mbox = TlMbox::init(p.IPCC, Irqs, config); 57 let mbox = TlMbox::init(p.IPCC, Irqs, config).await;
58 let mut sys = mbox.sys_subsystem;
58 59
59 spawner.spawn(run_mm_queue(mbox.mm_subsystem).unwrap()); 60 spawner.spawn(run_mm_queue(mbox.mm_subsystem).unwrap());
60 61
61 let sys_event = mbox.sys_subsystem.read().await; 62 let result = sys.shci_c2_mac_802_15_4_init().await;
62 info!("sys event: {}", sys_event.payload());
63
64 core::mem::drop(sys_event);
65
66 let result = mbox.sys_subsystem.shci_c2_mac_802_15_4_init().await;
67 info!("initialized mac: {}", result); 63 info!("initialized mac: {}", result);
68 64
65 let (mut mac_rx, mut mac_tx) = mbox.mac_subsystem.split();
66
69 info!("resetting"); 67 info!("resetting");
70 mbox.mac_subsystem 68 mac_tx
71 .send_command(&ResetRequest { 69 .send_command(&ResetRequest {
72 set_default_pib: true, 70 set_default_pib: true,
73 ..Default::default() 71 ..Default::default()
74 }) 72 })
75 .await 73 .await
76 .unwrap(); 74 .unwrap();
77 defmt::info!("{:#x}", mbox.mac_subsystem.read().await.unwrap()); 75 defmt::info!("{:#x}", mac_rx.read().await.unwrap());
78 76
79 info!("setting extended address"); 77 info!("setting extended address");
80 let extended_address: u64 = 0xACDE480000000001; 78 let extended_address: u64 = 0xACDE480000000001;
81 mbox.mac_subsystem 79 mac_tx
82 .send_command(&SetRequest { 80 .send_command(&SetRequest {
83 pib_attribute_ptr: &extended_address as *const _ as *const u8, 81 pib_attribute_ptr: &extended_address as *const _ as *const u8,
84 pib_attribute: PibId::ExtendedAddress, 82 pib_attribute: PibId::ExtendedAddress,
85 }) 83 })
86 .await 84 .await
87 .unwrap(); 85 .unwrap();
88 defmt::info!("{:#x}", mbox.mac_subsystem.read().await.unwrap()); 86 defmt::info!("{:#x}", mac_rx.read().await.unwrap());
89 87
90 info!("setting short address"); 88 info!("setting short address");
91 let short_address: u16 = 0x1122; 89 let short_address: u16 = 0x1122;
92 mbox.mac_subsystem 90 mac_tx
93 .send_command(&SetRequest { 91 .send_command(&SetRequest {
94 pib_attribute_ptr: &short_address as *const _ as *const u8, 92 pib_attribute_ptr: &short_address as *const _ as *const u8,
95 pib_attribute: PibId::ShortAddress, 93 pib_attribute: PibId::ShortAddress,
96 }) 94 })
97 .await 95 .await
98 .unwrap(); 96 .unwrap();
99 defmt::info!("{:#x}", mbox.mac_subsystem.read().await.unwrap()); 97 defmt::info!("{:#x}", mac_rx.read().await.unwrap());
100 98
101 info!("setting association permit"); 99 info!("setting association permit");
102 let association_permit: bool = true; 100 let association_permit: bool = true;
103 mbox.mac_subsystem 101 mac_tx
104 .send_command(&SetRequest { 102 .send_command(&SetRequest {
105 pib_attribute_ptr: &association_permit as *const _ as *const u8, 103 pib_attribute_ptr: &association_permit as *const _ as *const u8,
106 pib_attribute: PibId::AssociationPermit, 104 pib_attribute: PibId::AssociationPermit,
107 }) 105 })
108 .await 106 .await
109 .unwrap(); 107 .unwrap();
110 defmt::info!("{:#x}", mbox.mac_subsystem.read().await.unwrap()); 108 defmt::info!("{:#x}", mac_rx.read().await.unwrap());
111 109
112 info!("setting TX power"); 110 info!("setting TX power");
113 let transmit_power: i8 = 2; 111 let transmit_power: i8 = 2;
114 mbox.mac_subsystem 112 mac_tx
115 .send_command(&SetRequest { 113 .send_command(&SetRequest {
116 pib_attribute_ptr: &transmit_power as *const _ as *const u8, 114 pib_attribute_ptr: &transmit_power as *const _ as *const u8,
117 pib_attribute: PibId::TransmitPower, 115 pib_attribute: PibId::TransmitPower,
118 }) 116 })
119 .await 117 .await
120 .unwrap(); 118 .unwrap();
121 defmt::info!("{:#x}", mbox.mac_subsystem.read().await.unwrap()); 119 defmt::info!("{:#x}", mac_rx.read().await.unwrap());
122 120
123 info!("starting FFD device"); 121 info!("starting FFD device");
124 mbox.mac_subsystem 122 mac_tx
125 .send_command(&StartRequest { 123 .send_command(&StartRequest {
126 pan_id: PanId([0x1A, 0xAA]), 124 pan_id: PanId([0x1A, 0xAA]),
127 channel_number: MacChannel::Channel16, 125 channel_number: MacChannel::Channel16,
@@ -133,28 +131,27 @@ async fn main(spawner: Spawner) {
133 }) 131 })
134 .await 132 .await
135 .unwrap(); 133 .unwrap();
136 defmt::info!("{:#x}", mbox.mac_subsystem.read().await.unwrap()); 134 defmt::info!("{:#x}", mac_rx.read().await.unwrap());
137 135
138 info!("setting RX on when idle"); 136 info!("setting RX on when idle");
139 let rx_on_while_idle: bool = true; 137 let rx_on_while_idle: bool = true;
140 mbox.mac_subsystem 138 mac_tx
141 .send_command(&SetRequest { 139 .send_command(&SetRequest {
142 pib_attribute_ptr: &rx_on_while_idle as *const _ as *const u8, 140 pib_attribute_ptr: &rx_on_while_idle as *const _ as *const u8,
143 pib_attribute: PibId::RxOnWhenIdle, 141 pib_attribute: PibId::RxOnWhenIdle,
144 }) 142 })
145 .await 143 .await
146 .unwrap(); 144 .unwrap();
147 defmt::info!("{:#x}", mbox.mac_subsystem.read().await.unwrap()); 145 defmt::info!("{:#x}", mac_rx.read().await.unwrap());
148 146
149 loop { 147 loop {
150 let evt = mbox.mac_subsystem.read().await; 148 let evt = mac_rx.read().await;
151 if let Ok(evt) = evt { 149 if let Ok(evt) = evt {
152 defmt::info!("parsed mac event"); 150 defmt::info!("parsed mac event");
153 defmt::info!("{:#x}", evt); 151 defmt::info!("{:#x}", evt);
154 152
155 match evt { 153 match evt {
156 MacEvent::MlmeAssociateInd(association) => mbox 154 MacEvent::MlmeAssociateInd(association) => mac_tx
157 .mac_subsystem
158 .send_command(&AssociateResponse { 155 .send_command(&AssociateResponse {
159 device_address: association.device_address, 156 device_address: association.device_address,
160 assoc_short_address: [0x33, 0x44], 157 assoc_short_address: [0x33, 0x44],
diff --git a/examples/stm32wb/src/bin/mac_ffd_net.rs b/examples/stm32wb/src/bin/mac_ffd_net.rs
index 5d946b35b..b4789e3ee 100644
--- a/examples/stm32wb/src/bin/mac_ffd_net.rs
+++ b/examples/stm32wb/src/bin/mac_ffd_net.rs
@@ -27,7 +27,7 @@ bind_interrupts!(struct Irqs{
27}); 27});
28 28
29#[embassy_executor::task] 29#[embassy_executor::task]
30async fn run_mm_queue(memory_manager: mm::MemoryManager) -> ! { 30async fn run_mm_queue(mut memory_manager: mm::MemoryManager<'static>) -> ! {
31 memory_manager.run_queue().await 31 memory_manager.run_queue().await
32} 32}
33 33
@@ -72,15 +72,10 @@ async fn main(spawner: Spawner) {
72 info!("Hello World!"); 72 info!("Hello World!");
73 73
74 let config = Config::default(); 74 let config = Config::default();
75 let mbox = TlMbox::init(p.IPCC, Irqs, config); 75 let mut mbox = TlMbox::init(p.IPCC, Irqs, config).await;
76 76
77 spawner.spawn(run_mm_queue(mbox.mm_subsystem).unwrap()); 77 spawner.spawn(run_mm_queue(mbox.mm_subsystem).unwrap());
78 78
79 let sys_event = mbox.sys_subsystem.read().await;
80 info!("sys event: {}", sys_event.payload());
81
82 core::mem::drop(sys_event);
83
84 let result = mbox.sys_subsystem.shci_c2_mac_802_15_4_init().await; 79 let result = mbox.sys_subsystem.shci_c2_mac_802_15_4_init().await;
85 info!("initialized mac: {}", result); 80 info!("initialized mac: {}", result);
86 81
diff --git a/examples/stm32wb/src/bin/mac_rfd.rs b/examples/stm32wb/src/bin/mac_rfd.rs
index 883179023..dae3c5200 100644
--- a/examples/stm32wb/src/bin/mac_rfd.rs
+++ b/examples/stm32wb/src/bin/mac_rfd.rs
@@ -21,7 +21,7 @@ bind_interrupts!(struct Irqs{
21}); 21});
22 22
23#[embassy_executor::task] 23#[embassy_executor::task]
24async fn run_mm_queue(memory_manager: mm::MemoryManager) { 24async fn run_mm_queue(mut memory_manager: mm::MemoryManager<'static>) {
25 memory_manager.run_queue().await; 25 memory_manager.run_queue().await;
26} 26}
27 27
@@ -56,41 +56,39 @@ async fn main(spawner: Spawner) {
56 info!("Hello World!"); 56 info!("Hello World!");
57 57
58 let config = Config::default(); 58 let config = Config::default();
59 let mbox = TlMbox::init(p.IPCC, Irqs, config); 59 let mbox = TlMbox::init(p.IPCC, Irqs, config).await;
60 let mut sys = mbox.sys_subsystem;
60 61
61 spawner.spawn(run_mm_queue(mbox.mm_subsystem).unwrap()); 62 spawner.spawn(run_mm_queue(mbox.mm_subsystem).unwrap());
62 63
63 let sys_event = mbox.sys_subsystem.read().await; 64 let result = sys.shci_c2_mac_802_15_4_init().await;
64 info!("sys event: {}", sys_event.payload());
65
66 core::mem::drop(sys_event);
67
68 let result = mbox.sys_subsystem.shci_c2_mac_802_15_4_init().await;
69 info!("initialized mac: {}", result); 65 info!("initialized mac: {}", result);
70 66
67 let (mut mac_rx, mut mac_tx) = mbox.mac_subsystem.split();
68
71 info!("resetting"); 69 info!("resetting");
72 mbox.mac_subsystem 70 mac_tx
73 .send_command(&ResetRequest { 71 .send_command(&ResetRequest {
74 set_default_pib: true, 72 set_default_pib: true,
75 ..Default::default() 73 ..Default::default()
76 }) 74 })
77 .await 75 .await
78 .unwrap(); 76 .unwrap();
79 defmt::info!("{:#x}", mbox.mac_subsystem.read().await.unwrap()); 77 defmt::info!("{:#x}", mac_rx.read().await.unwrap());
80 78
81 info!("setting extended address"); 79 info!("setting extended address");
82 let extended_address: u64 = 0xACDE480000000002; 80 let extended_address: u64 = 0xACDE480000000002;
83 mbox.mac_subsystem 81 mac_tx
84 .send_command(&SetRequest { 82 .send_command(&SetRequest {
85 pib_attribute_ptr: &extended_address as *const _ as *const u8, 83 pib_attribute_ptr: &extended_address as *const _ as *const u8,
86 pib_attribute: PibId::ExtendedAddress, 84 pib_attribute: PibId::ExtendedAddress,
87 }) 85 })
88 .await 86 .await
89 .unwrap(); 87 .unwrap();
90 defmt::info!("{:#x}", mbox.mac_subsystem.read().await.unwrap()); 88 defmt::info!("{:#x}", mac_rx.read().await.unwrap());
91 89
92 info!("getting extended address"); 90 info!("getting extended address");
93 mbox.mac_subsystem 91 mac_tx
94 .send_command(&GetRequest { 92 .send_command(&GetRequest {
95 pib_attribute: PibId::ExtendedAddress, 93 pib_attribute: PibId::ExtendedAddress,
96 ..Default::default() 94 ..Default::default()
@@ -99,7 +97,7 @@ async fn main(spawner: Spawner) {
99 .unwrap(); 97 .unwrap();
100 98
101 { 99 {
102 let evt = mbox.mac_subsystem.read().await.unwrap(); 100 let evt = mac_rx.read().await.unwrap();
103 info!("{:#x}", evt); 101 info!("{:#x}", evt);
104 102
105 if let MacEvent::MlmeGetCnf(evt) = evt { 103 if let MacEvent::MlmeGetCnf(evt) = evt {
@@ -125,9 +123,9 @@ async fn main(spawner: Spawner) {
125 key_index: 152, 123 key_index: 152,
126 }; 124 };
127 info!("{}", a); 125 info!("{}", a);
128 mbox.mac_subsystem.send_command(&a).await.unwrap(); 126 mac_tx.send_command(&a).await.unwrap();
129 let short_addr = { 127 let short_addr = {
130 let evt = mbox.mac_subsystem.read().await.unwrap(); 128 let evt = mac_rx.read().await.unwrap();
131 info!("{:#x}", evt); 129 info!("{:#x}", evt);
132 130
133 if let MacEvent::MlmeAssociateCnf(conf) = evt { 131 if let MacEvent::MlmeAssociateCnf(conf) = evt {
@@ -138,7 +136,7 @@ async fn main(spawner: Spawner) {
138 }; 136 };
139 137
140 info!("setting short address"); 138 info!("setting short address");
141 mbox.mac_subsystem 139 mac_tx
142 .send_command(&SetRequest { 140 .send_command(&SetRequest {
143 pib_attribute_ptr: &short_addr as *const _ as *const u8, 141 pib_attribute_ptr: &short_addr as *const _ as *const u8,
144 pib_attribute: PibId::ShortAddress, 142 pib_attribute: PibId::ShortAddress,
@@ -146,13 +144,13 @@ async fn main(spawner: Spawner) {
146 .await 144 .await
147 .unwrap(); 145 .unwrap();
148 { 146 {
149 let evt = mbox.mac_subsystem.read().await.unwrap(); 147 let evt = mac_rx.read().await.unwrap();
150 info!("{:#x}", evt); 148 info!("{:#x}", evt);
151 } 149 }
152 150
153 info!("sending data"); 151 info!("sending data");
154 let data = b"Hello from embassy!"; 152 let data = b"Hello from embassy!";
155 mbox.mac_subsystem 153 mac_tx
156 .send_command( 154 .send_command(
157 DataRequest { 155 DataRequest {
158 src_addr_mode: AddressMode::Short, 156 src_addr_mode: AddressMode::Short,
@@ -170,12 +168,12 @@ async fn main(spawner: Spawner) {
170 .await 168 .await
171 .unwrap(); 169 .unwrap();
172 { 170 {
173 let evt = mbox.mac_subsystem.read().await.unwrap(); 171 let evt = mac_rx.read().await.unwrap();
174 info!("{:#x}", evt); 172 info!("{:#x}", evt);
175 } 173 }
176 174
177 loop { 175 loop {
178 match mbox.mac_subsystem.read().await { 176 match mac_rx.read().await {
179 Ok(evt) => info!("{:#x}", evt), 177 Ok(evt) => info!("{:#x}", evt),
180 _ => continue, 178 _ => continue,
181 }; 179 };
diff --git a/examples/stm32wb/src/bin/tl_mbox.rs b/examples/stm32wb/src/bin/tl_mbox.rs
index 4e7f2304d..0902e28e8 100644
--- a/examples/stm32wb/src/bin/tl_mbox.rs
+++ b/examples/stm32wb/src/bin/tl_mbox.rs
@@ -46,7 +46,7 @@ async fn main(_spawner: Spawner) {
46 info!("Hello World!"); 46 info!("Hello World!");
47 47
48 let config = Config::default(); 48 let config = Config::default();
49 let mbox = TlMbox::init(p.IPCC, Irqs, config); 49 let mbox = TlMbox::init(p.IPCC, Irqs, config).await;
50 50
51 loop { 51 loop {
52 let wireless_fw_info = mbox.sys_subsystem.wireless_fw_info(); 52 let wireless_fw_info = mbox.sys_subsystem.wireless_fw_info();
diff --git a/examples/stm32wb/src/bin/tl_mbox_ble.rs b/examples/stm32wb/src/bin/tl_mbox_ble.rs
index 72a4c18e6..763dc32cd 100644
--- a/examples/stm32wb/src/bin/tl_mbox_ble.rs
+++ b/examples/stm32wb/src/bin/tl_mbox_ble.rs
@@ -7,6 +7,7 @@ use embassy_stm32::bind_interrupts;
7use embassy_stm32::ipcc::{Config, ReceiveInterruptHandler, TransmitInterruptHandler}; 7use embassy_stm32::ipcc::{Config, ReceiveInterruptHandler, TransmitInterruptHandler};
8use embassy_stm32::rcc::WPAN_DEFAULT; 8use embassy_stm32::rcc::WPAN_DEFAULT;
9use embassy_stm32_wpan::TlMbox; 9use embassy_stm32_wpan::TlMbox;
10use embassy_stm32_wpan::sub::mm;
10use {defmt_rtt as _, panic_probe as _}; 11use {defmt_rtt as _, panic_probe as _};
11 12
12bind_interrupts!(struct Irqs{ 13bind_interrupts!(struct Irqs{
@@ -14,8 +15,13 @@ bind_interrupts!(struct Irqs{
14 IPCC_C1_TX => TransmitInterruptHandler; 15 IPCC_C1_TX => TransmitInterruptHandler;
15}); 16});
16 17
18#[embassy_executor::task]
19async fn run_mm_queue(mut memory_manager: mm::MemoryManager<'static>) {
20 memory_manager.run_queue().await;
21}
22
17#[embassy_executor::main] 23#[embassy_executor::main]
18async fn main(_spawner: Spawner) { 24async fn main(spawner: Spawner) {
19 /* 25 /*
20 How to make this work: 26 How to make this work:
21 27
@@ -45,18 +51,19 @@ async fn main(_spawner: Spawner) {
45 info!("Hello World!"); 51 info!("Hello World!");
46 52
47 let config = Config::default(); 53 let config = Config::default();
48 let mbox = TlMbox::init(p.IPCC, Irqs, config); 54 let mbox = TlMbox::init(p.IPCC, Irqs, config).await;
55 let mut sys = mbox.sys_subsystem;
56 let mut ble = mbox.ble_subsystem;
49 57
50 let sys_event = mbox.sys_subsystem.read().await; 58 spawner.spawn(run_mm_queue(mbox.mm_subsystem).unwrap());
51 info!("sys event: {}", sys_event.payload());
52 59
53 let _ = mbox.sys_subsystem.shci_c2_ble_init(Default::default()).await; 60 let _ = sys.shci_c2_ble_init(Default::default()).await;
54 61
55 info!("starting ble..."); 62 info!("starting ble...");
56 mbox.ble_subsystem.tl_write(0x0c, &[]).await; 63 ble.tl_write(0x0c, &[]).await;
57 64
58 info!("waiting for ble..."); 65 info!("waiting for ble...");
59 let ble_event = mbox.ble_subsystem.tl_read().await; 66 let ble_event = ble.tl_read().await;
60 67
61 info!("ble event: {}", ble_event.payload()); 68 info!("ble event: {}", ble_event.payload());
62 69
diff --git a/examples/stm32wb/src/bin/tl_mbox_mac.rs b/examples/stm32wb/src/bin/tl_mbox_mac.rs
index 16d0a1527..235a48241 100644
--- a/examples/stm32wb/src/bin/tl_mbox_mac.rs
+++ b/examples/stm32wb/src/bin/tl_mbox_mac.rs
@@ -16,7 +16,7 @@ bind_interrupts!(struct Irqs{
16}); 16});
17 17
18#[embassy_executor::task] 18#[embassy_executor::task]
19async fn run_mm_queue(memory_manager: mm::MemoryManager) { 19async fn run_mm_queue(mut memory_manager: mm::MemoryManager<'static>) {
20 memory_manager.run_queue().await; 20 memory_manager.run_queue().await;
21} 21}
22 22
@@ -51,16 +51,12 @@ async fn main(spawner: Spawner) {
51 info!("Hello World!"); 51 info!("Hello World!");
52 52
53 let config = Config::default(); 53 let config = Config::default();
54 let mbox = TlMbox::init(p.IPCC, Irqs, config); 54 let mbox = TlMbox::init(p.IPCC, Irqs, config).await;
55 let mut sys = mbox.sys_subsystem;
55 56
56 spawner.spawn(run_mm_queue(mbox.mm_subsystem).unwrap()); 57 spawner.spawn(run_mm_queue(mbox.mm_subsystem).unwrap());
57 58
58 let sys_event = mbox.sys_subsystem.read().await; 59 let result = sys.shci_c2_mac_802_15_4_init().await;
59 info!("sys event: {}", sys_event.payload());
60
61 core::mem::drop(sys_event);
62
63 let result = mbox.sys_subsystem.shci_c2_mac_802_15_4_init().await;
64 info!("initialized mac: {}", result); 60 info!("initialized mac: {}", result);
65 61
66 // 62 //