aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorgoueslati <[email protected]>2023-07-12 15:06:56 +0100
committergoueslati <[email protected]>2023-07-12 15:06:56 +0100
commitd5a4457b5e3a95a12f249315fb1d9b6a577307f2 (patch)
tree6f0b4c98653ce287b483a14dc2a031b2ee6de638 /examples
parentfbddfcbfb7f732db593eecd5383742d9ce7308e7 (diff)
parsing MAC structs
Diffstat (limited to 'examples')
-rw-r--r--examples/stm32wb/src/bin/mac_ffd.rs101
-rw-r--r--examples/stm32wb/src/bin/mac_rfd.rs14
2 files changed, 50 insertions, 65 deletions
diff --git a/examples/stm32wb/src/bin/mac_ffd.rs b/examples/stm32wb/src/bin/mac_ffd.rs
index 4100d1ac5..18b29362b 100644
--- a/examples/stm32wb/src/bin/mac_ffd.rs
+++ b/examples/stm32wb/src/bin/mac_ffd.rs
@@ -7,7 +7,7 @@ use 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::{ResetRequest, SetRequest, StartRequest}; 9use embassy_stm32_wpan::sub::mac::commands::{ResetRequest, SetRequest, StartRequest};
10use embassy_stm32_wpan::sub::mac::typedefs::PibId; 10use embassy_stm32_wpan::sub::mac::typedefs::{MacChannel, PibId};
11use embassy_stm32_wpan::sub::mm; 11use embassy_stm32_wpan::sub::mm;
12use embassy_stm32_wpan::TlMbox; 12use embassy_stm32_wpan::TlMbox;
13use {defmt_rtt as _, panic_probe as _}; 13use {defmt_rtt as _, panic_probe as _};
@@ -65,109 +65,92 @@ async fn main(spawner: Spawner) {
65 info!("initialized mac: {}", result); 65 info!("initialized mac: {}", result);
66 66
67 info!("resetting"); 67 info!("resetting");
68 let response = mbox 68 mbox.mac_subsystem
69 .mac_subsystem
70 .send_command(ResetRequest { set_default_pib: true }) 69 .send_command(ResetRequest { set_default_pib: true })
71 .await; 70 .await
72 info!("{}", response); 71 .unwrap();
72 let evt = mbox.mac_subsystem.read().await;
73 defmt::info!("{:#x}", evt);
73 74
74 info!("setting extended address"); 75 info!("setting extended address");
75 let extended_address: u64 = 0xACDE480000000001; 76 let extended_address: u64 = 0xACDE480000000001;
76 let response = mbox 77 mbox.mac_subsystem
77 .mac_subsystem
78 .send_command(SetRequest { 78 .send_command(SetRequest {
79 pib_attribute_ptr: &extended_address as *const _ as *const u8, 79 pib_attribute_ptr: &extended_address as *const _ as *const u8,
80 pib_attribute: PibId::ExtendedAddress, 80 pib_attribute: PibId::ExtendedAddress,
81 }) 81 })
82 .await; 82 .await
83 info!("{}", response); 83 .unwrap();
84 let evt = mbox.mac_subsystem.read().await;
85 defmt::info!("{:#x}", evt);
84 86
85 info!("setting short address"); 87 info!("setting short address");
86 let short_address: u16 = 0x1122; 88 let short_address: u16 = 0x1122;
87 let response = mbox 89 mbox.mac_subsystem
88 .mac_subsystem
89 .send_command(SetRequest { 90 .send_command(SetRequest {
90 pib_attribute_ptr: &short_address as *const _ as *const u8, 91 pib_attribute_ptr: &short_address as *const _ as *const u8,
91 pib_attribute: PibId::ShortAddress, 92 pib_attribute: PibId::ShortAddress,
92 }) 93 })
93 .await; 94 .await
94 info!("{}", response); 95 .unwrap();
96 let evt = mbox.mac_subsystem.read().await;
97 defmt::info!("{:#x}", evt);
95 98
96 info!("setting association permit"); 99 info!("setting association permit");
97 let association_permit: bool = true; 100 let association_permit: bool = true;
98 let response = mbox 101 mbox.mac_subsystem
99 .mac_subsystem
100 .send_command(SetRequest { 102 .send_command(SetRequest {
101 pib_attribute_ptr: &association_permit as *const _ as *const u8, 103 pib_attribute_ptr: &association_permit as *const _ as *const u8,
102 pib_attribute: PibId::AssociationPermit, 104 pib_attribute: PibId::AssociationPermit,
103 }) 105 })
104 .await; 106 .await
105 info!("{}", response); 107 .unwrap();
108 let evt = mbox.mac_subsystem.read().await;
109 defmt::info!("{:#x}", evt);
106 110
107 info!("setting TX power"); 111 info!("setting TX power");
108 let transmit_power: i8 = 2; 112 let transmit_power: i8 = 2;
109 let response = mbox 113 mbox.mac_subsystem
110 .mac_subsystem
111 .send_command(SetRequest { 114 .send_command(SetRequest {
112 pib_attribute_ptr: &transmit_power as *const _ as *const u8, 115 pib_attribute_ptr: &transmit_power as *const _ as *const u8,
113 pib_attribute: PibId::TransmitPower, 116 pib_attribute: PibId::TransmitPower,
114 }) 117 })
115 .await; 118 .await
116 info!("{}", response); 119 .unwrap();
120 let evt = mbox.mac_subsystem.read().await;
121 defmt::info!("{:#x}", evt);
117 122
118 info!("starting FFD device"); 123 info!("starting FFD device");
119 let response = mbox 124 mbox.mac_subsystem
120 .mac_subsystem
121 .send_command(StartRequest { 125 .send_command(StartRequest {
122 channel_number: 16, 126 channel_number: MacChannel::Channel16,
123 beacon_order: 0x0F, 127 beacon_order: 0x0F,
124 superframe_order: 0x0F, 128 superframe_order: 0x0F,
125 pan_coordinator: true, 129 pan_coordinator: true,
126 battery_life_extension: false, 130 battery_life_extension: false,
127 ..Default::default() 131 ..Default::default()
128 }) 132 })
129 .await; 133 .await
130 info!("{}", response); 134 .unwrap();
135 let evt = mbox.mac_subsystem.read().await;
136 defmt::info!("{:#x}", evt);
131 137
132 info!("setting RX on when idle"); 138 info!("setting RX on when idle");
133 let rx_on_while_idle: bool = true; 139 let rx_on_while_idle: bool = true;
134 let response = mbox 140 mbox.mac_subsystem
135 .mac_subsystem
136 .send_command(SetRequest { 141 .send_command(SetRequest {
137 pib_attribute_ptr: &rx_on_while_idle as *const _ as *const u8, 142 pib_attribute_ptr: &rx_on_while_idle as *const _ as *const u8,
138 pib_attribute: PibId::RxOnWhenIdle, 143 pib_attribute: PibId::RxOnWhenIdle,
139 }) 144 })
140 .await; 145 .await
141 info!("{}", response); 146 .unwrap();
142 147 let evt = mbox.mac_subsystem.read().await;
143 // info!("association request"); 148 defmt::info!("{:#x}", evt);
144 // mbox.mac_subsystem 149
145 // .send_command(AssociateRequest { 150 loop {
146 // channel_number: 16, 151 let evt = mbox.mac_subsystem.read().await;
147 // channel_page: 0, 152 defmt::info!("{:#x}", evt);
148 // coord_addr_mode: 2, 153 }
149 // coord_address: MacAddress { short: [0x22, 0x11] },
150 // capability_information: 0x80,
151 // coord_pan_id: [0xAA, 0x1A],
152 // security_level: 0,
153
154 // key_id_mode: 0,
155 // key_index: 0,
156 // key_source: [0; 8],
157 // })
158 // .await;
159 // info!("reading");
160 // let result = mbox.mac_subsystem.read().await;
161 // info!("{}", result.payload());
162
163 //
164 // info!("starting ble...");
165 // mbox.ble_subsystem.t_write(0x0c, &[]).await;
166 //
167 // info!("waiting for ble...");
168 // let ble_event = mbox.ble_subsystem.tl_read().await;
169 //
170 // info!("ble event: {}", ble_event.payload());
171 154
172 info!("Test OK"); 155 info!("Test OK");
173 cortex_m::asm::bkpt(); 156 cortex_m::asm::bkpt();
diff --git a/examples/stm32wb/src/bin/mac_rfd.rs b/examples/stm32wb/src/bin/mac_rfd.rs
index 938fe754f..8042a3704 100644
--- a/examples/stm32wb/src/bin/mac_rfd.rs
+++ b/examples/stm32wb/src/bin/mac_rfd.rs
@@ -7,7 +7,9 @@ use 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, ResetRequest, SetRequest, StartRequest};
10use embassy_stm32_wpan::sub::mac::typedefs::{AddressMode, MacAddress, PibId}; 10use embassy_stm32_wpan::sub::mac::typedefs::{
11 AddressMode, Capabilities, KeyIdMode, MacAddress, MacChannel, PibId, SecurityLevel,
12};
11use embassy_stm32_wpan::sub::mm; 13use embassy_stm32_wpan::sub::mm;
12use embassy_stm32_wpan::TlMbox; 14use embassy_stm32_wpan::TlMbox;
13use {defmt_rtt as _, panic_probe as _}; 15use {defmt_rtt as _, panic_probe as _};
@@ -86,14 +88,14 @@ async fn main(spawner: Spawner) {
86 let response = mbox 88 let response = mbox
87 .mac_subsystem 89 .mac_subsystem
88 .send_command(AssociateRequest { 90 .send_command(AssociateRequest {
89 channel_number: 16, 91 channel_number: MacChannel::Channel16,
90 channel_page: 0, 92 channel_page: 0,
91 coord_addr_mode: AddressMode::Short, 93 coord_addr_mode: AddressMode::Short,
92 coord_address: MacAddress { short: [0x22, 0x11] }, 94 coord_address: MacAddress::Short([0x22, 0x11]),
93 capability_information: 0x80, 95 capability_information: Capabilities::ALLOCATE_ADDRESS,
94 coord_pan_id: [0xAA, 0x1A], 96 coord_pan_id: [0xAA, 0x1A],
95 security_level: 0x00, 97 security_level: SecurityLevel::Unsecure,
96 key_id_mode: 0, 98 key_id_mode: KeyIdMode::Implicite,
97 key_source: [0; 8], 99 key_source: [0; 8],
98 key_index: 0, 100 key_index: 0,
99 }) 101 })