diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/stm32/src/bin/wpan_ble.rs | 120 | ||||
| -rw-r--r-- | tests/stm32/src/bin/wpan_mac.rs | 29 |
2 files changed, 66 insertions, 83 deletions
diff --git a/tests/stm32/src/bin/wpan_ble.rs b/tests/stm32/src/bin/wpan_ble.rs index 0f396b848..b4c0cbf56 100644 --- a/tests/stm32/src/bin/wpan_ble.rs +++ b/tests/stm32/src/bin/wpan_ble.rs | |||
| @@ -32,7 +32,7 @@ bind_interrupts!(struct Irqs{ | |||
| 32 | const BLE_GAP_DEVICE_NAME_LENGTH: u8 = 7; | 32 | const BLE_GAP_DEVICE_NAME_LENGTH: u8 = 7; |
| 33 | 33 | ||
| 34 | #[embassy_executor::task] | 34 | #[embassy_executor::task] |
| 35 | async fn run_mm_queue(memory_manager: mm::MemoryManager) { | 35 | async fn run_mm_queue(mut memory_manager: mm::MemoryManager<'static>) { |
| 36 | memory_manager.run_queue().await; | 36 | memory_manager.run_queue().await; |
| 37 | } | 37 | } |
| 38 | 38 | ||
| @@ -45,14 +45,13 @@ async fn main(spawner: Spawner) { | |||
| 45 | info!("Hello World!"); | 45 | info!("Hello World!"); |
| 46 | 46 | ||
| 47 | let config = Config::default(); | 47 | let config = Config::default(); |
| 48 | let mut mbox = TlMbox::init(p.IPCC, Irqs, config); | 48 | let mbox = TlMbox::init(p.IPCC, Irqs, config).await; |
| 49 | let mut sys = mbox.sys_subsystem; | ||
| 50 | let mut ble = mbox.ble_subsystem; | ||
| 49 | 51 | ||
| 50 | spawner.spawn(run_mm_queue(mbox.mm_subsystem).unwrap()); | 52 | spawner.spawn(run_mm_queue(mbox.mm_subsystem).unwrap()); |
| 51 | 53 | ||
| 52 | let sys_event = mbox.sys_subsystem.read().await; | 54 | let fw_info = sys.wireless_fw_info().unwrap(); |
| 53 | info!("sys event: {}", sys_event.payload()); | ||
| 54 | |||
| 55 | let fw_info = mbox.sys_subsystem.wireless_fw_info().unwrap(); | ||
| 56 | let version_major = fw_info.version_major(); | 55 | let version_major = fw_info.version_major(); |
| 57 | let version_minor = fw_info.version_minor(); | 56 | let version_minor = fw_info.version_minor(); |
| 58 | let subversion = fw_info.subversion(); | 57 | let subversion = fw_info.subversion(); |
| @@ -65,121 +64,108 @@ async fn main(spawner: Spawner) { | |||
| 65 | version_major, version_minor, subversion, sram2a_size, sram2b_size | 64 | version_major, version_minor, subversion, sram2a_size, sram2b_size |
| 66 | ); | 65 | ); |
| 67 | 66 | ||
| 68 | let _ = mbox.sys_subsystem.shci_c2_ble_init(Default::default()).await; | 67 | let _ = sys.shci_c2_ble_init(Default::default()).await; |
| 69 | 68 | ||
| 70 | info!("resetting BLE..."); | 69 | info!("resetting BLE..."); |
| 71 | mbox.ble_subsystem.reset().await; | 70 | ble.reset().await; |
| 72 | let response = mbox.ble_subsystem.read().await.unwrap(); | 71 | let response = ble.read().await.unwrap(); |
| 73 | info!("{}", response); | 72 | info!("{}", response); |
| 74 | 73 | ||
| 75 | info!("config public address..."); | 74 | info!("config public address..."); |
| 76 | mbox.ble_subsystem | 75 | ble.write_config_data(&ConfigData::public_address(get_bd_addr()).build()) |
| 77 | .write_config_data(&ConfigData::public_address(get_bd_addr()).build()) | ||
| 78 | .await; | 76 | .await; |
| 79 | let response = mbox.ble_subsystem.read().await.unwrap(); | 77 | let response = ble.read().await.unwrap(); |
| 80 | info!("{}", response); | 78 | info!("{}", response); |
| 81 | 79 | ||
| 82 | info!("config random address..."); | 80 | info!("config random address..."); |
| 83 | mbox.ble_subsystem | 81 | ble.write_config_data(&ConfigData::random_address(get_random_addr()).build()) |
| 84 | .write_config_data(&ConfigData::random_address(get_random_addr()).build()) | ||
| 85 | .await; | 82 | .await; |
| 86 | let response = mbox.ble_subsystem.read().await.unwrap(); | 83 | let response = ble.read().await.unwrap(); |
| 87 | info!("{}", response); | 84 | info!("{}", response); |
| 88 | 85 | ||
| 89 | info!("config identity root..."); | 86 | info!("config identity root..."); |
| 90 | mbox.ble_subsystem | 87 | ble.write_config_data(&ConfigData::identity_root(&get_irk()).build()) |
| 91 | .write_config_data(&ConfigData::identity_root(&get_irk()).build()) | ||
| 92 | .await; | 88 | .await; |
| 93 | let response = mbox.ble_subsystem.read().await.unwrap(); | 89 | let response = ble.read().await.unwrap(); |
| 94 | info!("{}", response); | 90 | info!("{}", response); |
| 95 | 91 | ||
| 96 | info!("config encryption root..."); | 92 | info!("config encryption root..."); |
| 97 | mbox.ble_subsystem | 93 | ble.write_config_data(&ConfigData::encryption_root(&get_erk()).build()) |
| 98 | .write_config_data(&ConfigData::encryption_root(&get_erk()).build()) | ||
| 99 | .await; | 94 | .await; |
| 100 | let response = mbox.ble_subsystem.read().await.unwrap(); | 95 | let response = ble.read().await.unwrap(); |
| 101 | info!("{}", response); | 96 | info!("{}", response); |
| 102 | 97 | ||
| 103 | info!("config tx power level..."); | 98 | info!("config tx power level..."); |
| 104 | mbox.ble_subsystem.set_tx_power_level(PowerLevel::ZerodBm).await; | 99 | ble.set_tx_power_level(PowerLevel::ZerodBm).await; |
| 105 | let response = mbox.ble_subsystem.read().await.unwrap(); | 100 | let response = ble.read().await.unwrap(); |
| 106 | info!("{}", response); | 101 | info!("{}", response); |
| 107 | 102 | ||
| 108 | info!("GATT init..."); | 103 | info!("GATT init..."); |
| 109 | mbox.ble_subsystem.init_gatt().await; | 104 | ble.init_gatt().await; |
| 110 | let response = mbox.ble_subsystem.read().await.unwrap(); | 105 | let response = ble.read().await.unwrap(); |
| 111 | info!("{}", response); | 106 | info!("{}", response); |
| 112 | 107 | ||
| 113 | info!("GAP init..."); | 108 | info!("GAP init..."); |
| 114 | mbox.ble_subsystem | 109 | ble.init_gap(Role::PERIPHERAL, false, BLE_GAP_DEVICE_NAME_LENGTH).await; |
| 115 | .init_gap(Role::PERIPHERAL, false, BLE_GAP_DEVICE_NAME_LENGTH) | 110 | let response = ble.read().await.unwrap(); |
| 116 | .await; | ||
| 117 | let response = mbox.ble_subsystem.read().await.unwrap(); | ||
| 118 | info!("{}", response); | 111 | info!("{}", response); |
| 119 | 112 | ||
| 120 | // info!("set scan response..."); | 113 | // info!("set scan response..."); |
| 121 | // mbox.ble_subsystem.le_set_scan_response_data(&[]).await.unwrap(); | 114 | // ble.le_set_scan_response_data(&[]).await.unwrap(); |
| 122 | // let response = mbox.ble_subsystem.read().await.unwrap(); | 115 | // let response = ble.read().await.unwrap(); |
| 123 | // info!("{}", response); | 116 | // info!("{}", response); |
| 124 | 117 | ||
| 125 | info!("set discoverable..."); | 118 | info!("set discoverable..."); |
| 126 | mbox.ble_subsystem | 119 | ble.set_discoverable(&DiscoverableParameters { |
| 127 | .set_discoverable(&DiscoverableParameters { | 120 | advertising_type: AdvertisingType::NonConnectableUndirected, |
| 128 | advertising_type: AdvertisingType::NonConnectableUndirected, | 121 | advertising_interval: Some((Duration::from_millis(250), Duration::from_millis(250))), |
| 129 | advertising_interval: Some((Duration::from_millis(250), Duration::from_millis(250))), | 122 | address_type: OwnAddressType::Public, |
| 130 | address_type: OwnAddressType::Public, | 123 | filter_policy: AdvertisingFilterPolicy::AllowConnectionAndScan, |
| 131 | filter_policy: AdvertisingFilterPolicy::AllowConnectionAndScan, | 124 | local_name: None, |
| 132 | local_name: None, | 125 | advertising_data: &[], |
| 133 | advertising_data: &[], | 126 | conn_interval: (None, None), |
| 134 | conn_interval: (None, None), | 127 | }) |
| 135 | }) | 128 | .await |
| 136 | .await | 129 | .unwrap(); |
| 137 | .unwrap(); | 130 | |
| 138 | 131 | let response = ble.read().await; | |
| 139 | let response = mbox.ble_subsystem.read().await; | ||
| 140 | info!("{}", response); | 132 | info!("{}", response); |
| 141 | 133 | ||
| 142 | // remove some advertisement to decrease the packet size | 134 | // remove some advertisement to decrease the packet size |
| 143 | info!("delete tx power ad type..."); | 135 | info!("delete tx power ad type..."); |
| 144 | mbox.ble_subsystem | 136 | ble.delete_ad_type(AdvertisingDataType::TxPowerLevel).await; |
| 145 | .delete_ad_type(AdvertisingDataType::TxPowerLevel) | 137 | let response = ble.read().await.unwrap(); |
| 146 | .await; | ||
| 147 | let response = mbox.ble_subsystem.read().await.unwrap(); | ||
| 148 | info!("{}", response); | 138 | info!("{}", response); |
| 149 | 139 | ||
| 150 | info!("delete conn interval ad type..."); | 140 | info!("delete conn interval ad type..."); |
| 151 | mbox.ble_subsystem | 141 | ble.delete_ad_type(AdvertisingDataType::PeripheralConnectionInterval) |
| 152 | .delete_ad_type(AdvertisingDataType::PeripheralConnectionInterval) | ||
| 153 | .await; | 142 | .await; |
| 154 | let response = mbox.ble_subsystem.read().await.unwrap(); | 143 | let response = ble.read().await.unwrap(); |
| 155 | info!("{}", response); | 144 | info!("{}", response); |
| 156 | 145 | ||
| 157 | info!("update advertising data..."); | 146 | info!("update advertising data..."); |
| 158 | mbox.ble_subsystem | 147 | ble.update_advertising_data(&eddystone_advertising_data()) |
| 159 | .update_advertising_data(&eddystone_advertising_data()) | ||
| 160 | .await | 148 | .await |
| 161 | .unwrap(); | 149 | .unwrap(); |
| 162 | let response = mbox.ble_subsystem.read().await.unwrap(); | 150 | let response = ble.read().await.unwrap(); |
| 163 | info!("{}", response); | 151 | info!("{}", response); |
| 164 | 152 | ||
| 165 | info!("update advertising data type..."); | 153 | info!("update advertising data type..."); |
| 166 | mbox.ble_subsystem | 154 | ble.update_advertising_data(&[3, AdvertisingDataType::UuidCompleteList16 as u8, 0xaa, 0xfe]) |
| 167 | .update_advertising_data(&[3, AdvertisingDataType::UuidCompleteList16 as u8, 0xaa, 0xfe]) | ||
| 168 | .await | 155 | .await |
| 169 | .unwrap(); | 156 | .unwrap(); |
| 170 | let response = mbox.ble_subsystem.read().await.unwrap(); | 157 | let response = ble.read().await.unwrap(); |
| 171 | info!("{}", response); | 158 | info!("{}", response); |
| 172 | 159 | ||
| 173 | info!("update advertising data flags..."); | 160 | info!("update advertising data flags..."); |
| 174 | mbox.ble_subsystem | 161 | ble.update_advertising_data(&[ |
| 175 | .update_advertising_data(&[ | 162 | 2, |
| 176 | 2, | 163 | AdvertisingDataType::Flags as u8, |
| 177 | AdvertisingDataType::Flags as u8, | 164 | (0x02 | 0x04) as u8, // BLE general discoverable, without BR/EDR support |
| 178 | (0x02 | 0x04) as u8, // BLE general discoverable, without BR/EDR support | 165 | ]) |
| 179 | ]) | 166 | .await |
| 180 | .await | 167 | .unwrap(); |
| 181 | .unwrap(); | 168 | let response = ble.read().await.unwrap(); |
| 182 | let response = mbox.ble_subsystem.read().await.unwrap(); | ||
| 183 | info!("{}", response); | 169 | info!("{}", response); |
| 184 | 170 | ||
| 185 | info!("Test OK"); | 171 | info!("Test OK"); |
diff --git a/tests/stm32/src/bin/wpan_mac.rs b/tests/stm32/src/bin/wpan_mac.rs index f27146c44..42db39e7e 100644 --- a/tests/stm32/src/bin/wpan_mac.rs +++ b/tests/stm32/src/bin/wpan_mac.rs | |||
| @@ -25,7 +25,7 @@ bind_interrupts!(struct Irqs{ | |||
| 25 | }); | 25 | }); |
| 26 | 26 | ||
| 27 | #[embassy_executor::task] | 27 | #[embassy_executor::task] |
| 28 | async fn run_mm_queue(memory_manager: mm::MemoryManager) { | 28 | async fn run_mm_queue(mut memory_manager: mm::MemoryManager<'static>) { |
| 29 | memory_manager.run_queue().await; | 29 | memory_manager.run_queue().await; |
| 30 | } | 30 | } |
| 31 | 31 | ||
| @@ -38,20 +38,17 @@ async fn main(spawner: Spawner) { | |||
| 38 | info!("Hello World!"); | 38 | info!("Hello World!"); |
| 39 | 39 | ||
| 40 | let config = Config::default(); | 40 | let config = Config::default(); |
| 41 | let mbox = TlMbox::init(p.IPCC, Irqs, config); | 41 | let mbox = TlMbox::init(p.IPCC, Irqs, config).await; |
| 42 | let mut sys = mbox.sys_subsystem; | ||
| 43 | let (mut mac_rx, mut mac_tx) = mbox.mac_subsystem.split(); | ||
| 42 | 44 | ||
| 43 | spawner.spawn(run_mm_queue(mbox.mm_subsystem).unwrap()); | 45 | spawner.spawn(run_mm_queue(mbox.mm_subsystem).unwrap()); |
| 44 | 46 | ||
| 45 | let sys_event = mbox.sys_subsystem.read().await; | 47 | let result = sys.shci_c2_mac_802_15_4_init().await; |
| 46 | info!("sys event: {}", sys_event.payload()); | ||
| 47 | |||
| 48 | core::mem::drop(sys_event); | ||
| 49 | |||
| 50 | let result = mbox.sys_subsystem.shci_c2_mac_802_15_4_init().await; | ||
| 51 | info!("initialized mac: {}", result); | 48 | info!("initialized mac: {}", result); |
| 52 | 49 | ||
| 53 | info!("resetting"); | 50 | info!("resetting"); |
| 54 | mbox.mac_subsystem | 51 | mac_tx |
| 55 | .send_command(&ResetRequest { | 52 | .send_command(&ResetRequest { |
| 56 | set_default_pib: true, | 53 | set_default_pib: true, |
| 57 | ..Default::default() | 54 | ..Default::default() |
| @@ -59,13 +56,13 @@ async fn main(spawner: Spawner) { | |||
| 59 | .await | 56 | .await |
| 60 | .unwrap(); | 57 | .unwrap(); |
| 61 | { | 58 | { |
| 62 | let evt = mbox.mac_subsystem.read().await.unwrap(); | 59 | let evt = mac_rx.read().await.unwrap(); |
| 63 | info!("{:#x}", evt); | 60 | info!("{:#x}", evt); |
| 64 | } | 61 | } |
| 65 | 62 | ||
| 66 | info!("setting extended address"); | 63 | info!("setting extended address"); |
| 67 | let extended_address: u64 = 0xACDE480000000002; | 64 | let extended_address: u64 = 0xACDE480000000002; |
| 68 | mbox.mac_subsystem | 65 | mac_tx |
| 69 | .send_command(&SetRequest { | 66 | .send_command(&SetRequest { |
| 70 | pib_attribute_ptr: &extended_address as *const _ as *const u8, | 67 | pib_attribute_ptr: &extended_address as *const _ as *const u8, |
| 71 | pib_attribute: PibId::ExtendedAddress, | 68 | pib_attribute: PibId::ExtendedAddress, |
| @@ -73,12 +70,12 @@ async fn main(spawner: Spawner) { | |||
| 73 | .await | 70 | .await |
| 74 | .unwrap(); | 71 | .unwrap(); |
| 75 | { | 72 | { |
| 76 | let evt = mbox.mac_subsystem.read().await.unwrap(); | 73 | let evt = mac_rx.read().await.unwrap(); |
| 77 | info!("{:#x}", evt); | 74 | info!("{:#x}", evt); |
| 78 | } | 75 | } |
| 79 | 76 | ||
| 80 | info!("getting extended address"); | 77 | info!("getting extended address"); |
| 81 | mbox.mac_subsystem | 78 | mac_tx |
| 82 | .send_command(&GetRequest { | 79 | .send_command(&GetRequest { |
| 83 | pib_attribute: PibId::ExtendedAddress, | 80 | pib_attribute: PibId::ExtendedAddress, |
| 84 | ..Default::default() | 81 | ..Default::default() |
| @@ -87,7 +84,7 @@ async fn main(spawner: Spawner) { | |||
| 87 | .unwrap(); | 84 | .unwrap(); |
| 88 | 85 | ||
| 89 | { | 86 | { |
| 90 | let evt = mbox.mac_subsystem.read().await.unwrap(); | 87 | let evt = mac_rx.read().await.unwrap(); |
| 91 | info!("{:#x}", evt); | 88 | info!("{:#x}", evt); |
| 92 | 89 | ||
| 93 | if let MacEvent::MlmeGetCnf(evt) = evt { | 90 | if let MacEvent::MlmeGetCnf(evt) = evt { |
| @@ -113,8 +110,8 @@ async fn main(spawner: Spawner) { | |||
| 113 | key_index: 152, | 110 | key_index: 152, |
| 114 | }; | 111 | }; |
| 115 | info!("{}", a); | 112 | info!("{}", a); |
| 116 | mbox.mac_subsystem.send_command(&a).await.unwrap(); | 113 | mac_tx.send_command(&a).await.unwrap(); |
| 117 | let short_addr = if let MacEvent::MlmeAssociateCnf(conf) = mbox.mac_subsystem.read().await.unwrap() { | 114 | let short_addr = if let MacEvent::MlmeAssociateCnf(conf) = mac_rx.read().await.unwrap() { |
| 118 | conf.assoc_short_address | 115 | conf.assoc_short_address |
| 119 | } else { | 116 | } else { |
| 120 | defmt::panic!() | 117 | defmt::panic!() |
