aboutsummaryrefslogtreecommitdiff
path: root/embassy-stm32-wpan
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 /embassy-stm32-wpan
parentd5a4457b5e3a95a12f249315fb1d9b6a577307f2 (diff)
change MacAddress to a union instead of an enum
Diffstat (limited to 'embassy-stm32-wpan')
-rw-r--r--embassy-stm32-wpan/src/sub/mac/commands.rs20
-rw-r--r--embassy-stm32-wpan/src/sub/mac/indications.rs70
-rw-r--r--embassy-stm32-wpan/src/sub/mac/mod.rs4
-rw-r--r--embassy-stm32-wpan/src/sub/mac/responses.rs17
-rw-r--r--embassy-stm32-wpan/src/sub/mac/typedefs.rs43
5 files changed, 102 insertions, 52 deletions
diff --git a/embassy-stm32-wpan/src/sub/mac/commands.rs b/embassy-stm32-wpan/src/sub/mac/commands.rs
index d8a4e3ee1..7ccf10026 100644
--- a/embassy-stm32-wpan/src/sub/mac/commands.rs
+++ b/embassy-stm32-wpan/src/sub/mac/commands.rs
@@ -9,12 +9,13 @@ pub trait MacCommand {
9 const SIZE: usize; 9 const SIZE: usize;
10 10
11 fn copy_into_slice(&self, buf: &mut [u8]) { 11 fn copy_into_slice(&self, buf: &mut [u8]) {
12 unsafe { core::ptr::copy(self as *const _ as *const u8, buf as *mut _ as *mut u8, 8) }; 12 unsafe { core::ptr::copy(self as *const _ as *const u8, buf as *mut _ as *mut u8, Self::SIZE) };
13 } 13 }
14} 14}
15 15
16/// MLME ASSOCIATE Request used to request an association 16/// MLME ASSOCIATE Request used to request an association
17#[repr(C)] 17#[repr(C)]
18#[cfg_attr(feature = "defmt", derive(defmt::Format))]
18pub struct AssociateRequest { 19pub struct AssociateRequest {
19 /// the logical channel on which to attempt association 20 /// the logical channel on which to attempt association
20 pub channel_number: MacChannel, 21 pub channel_number: MacChannel,
@@ -45,6 +46,7 @@ impl MacCommand for AssociateRequest {
45 46
46/// MLME DISASSOCIATE Request sed to request a disassociation 47/// MLME DISASSOCIATE Request sed to request a disassociation
47#[repr(C)] 48#[repr(C)]
49#[cfg_attr(feature = "defmt", derive(defmt::Format))]
48pub struct DisassociateRequest { 50pub struct DisassociateRequest {
49 /// device addressing mode used 51 /// device addressing mode used
50 pub device_addr_mode: AddressMode, 52 pub device_addr_mode: AddressMode,
@@ -73,6 +75,7 @@ impl MacCommand for DisassociateRequest {
73 75
74/// MLME GET Request used to request a PIB value 76/// MLME GET Request used to request a PIB value
75#[repr(C)] 77#[repr(C)]
78#[cfg_attr(feature = "defmt", derive(defmt::Format))]
76pub struct GetRequest { 79pub struct GetRequest {
77 /// the name of the PIB attribute to read 80 /// the name of the PIB attribute to read
78 pub pib_attribute: PibId, 81 pub pib_attribute: PibId,
@@ -85,6 +88,7 @@ impl MacCommand for GetRequest {
85 88
86/// MLME GTS Request used to request and maintain GTSs 89/// MLME GTS Request used to request and maintain GTSs
87#[repr(C)] 90#[repr(C)]
91#[cfg_attr(feature = "defmt", derive(defmt::Format))]
88pub struct GtsRequest { 92pub struct GtsRequest {
89 /// the characteristics of the GTS 93 /// the characteristics of the GTS
90 pub characteristics: GtsCharacteristics, 94 pub characteristics: GtsCharacteristics,
@@ -104,6 +108,7 @@ impl MacCommand for GtsRequest {
104} 108}
105 109
106#[repr(C)] 110#[repr(C)]
111#[cfg_attr(feature = "defmt", derive(defmt::Format))]
107pub struct ResetRequest { 112pub struct ResetRequest {
108 /// MAC PIB attributes are set to their default values or not during reset 113 /// MAC PIB attributes are set to their default values or not during reset
109 pub set_default_pib: bool, 114 pub set_default_pib: bool,
@@ -117,6 +122,7 @@ impl MacCommand for ResetRequest {
117/// MLME RX ENABLE Request used to request that the receiver is either enabled 122/// MLME RX ENABLE Request used to request that the receiver is either enabled
118/// for a finite period of time or disabled 123/// for a finite period of time or disabled
119#[repr(C)] 124#[repr(C)]
125#[cfg_attr(feature = "defmt", derive(defmt::Format))]
120pub struct RxEnableRequest { 126pub struct RxEnableRequest {
121 /// the request operation can be deferred or not 127 /// the request operation can be deferred or not
122 pub defer_permit: bool, 128 pub defer_permit: bool,
@@ -148,6 +154,7 @@ impl MacCommand for RxEnableRequest {
148 154
149/// MLME SCAN Request used to initiate a channel scan over a given list of channels 155/// MLME SCAN Request used to initiate a channel scan over a given list of channels
150#[repr(C)] 156#[repr(C)]
157#[cfg_attr(feature = "defmt", derive(defmt::Format))]
151pub struct ScanRequest { 158pub struct ScanRequest {
152 /// the type of scan to be performed 159 /// the type of scan to be performed
153 pub scan_type: ScanType, 160 pub scan_type: ScanType,
@@ -174,6 +181,7 @@ impl MacCommand for ScanRequest {
174 181
175/// MLME SET Request used to attempt to write the given value to the indicated PIB attribute 182/// MLME SET Request used to attempt to write the given value to the indicated PIB attribute
176#[repr(C)] 183#[repr(C)]
184#[cfg_attr(feature = "defmt", derive(defmt::Format))]
177pub struct SetRequest { 185pub struct SetRequest {
178 /// the pointer to the value of the PIB attribute to set 186 /// the pointer to the value of the PIB attribute to set
179 pub pib_attribute_ptr: *const u8, 187 pub pib_attribute_ptr: *const u8,
@@ -190,6 +198,7 @@ impl MacCommand for SetRequest {
190/// configuration 198/// configuration
191#[derive(Default)] 199#[derive(Default)]
192#[repr(C)] 200#[repr(C)]
201#[cfg_attr(feature = "defmt", derive(defmt::Format))]
193pub struct StartRequest { 202pub struct StartRequest {
194 /// PAN indentifier to used by the device 203 /// PAN indentifier to used by the device
195 pub pan_id: [u8; 2], 204 pub pan_id: [u8; 2],
@@ -233,6 +242,7 @@ impl MacCommand for StartRequest {
233/// MLME SYNC Request used to synchronize with the coordinator by acquiring and, if 242/// MLME SYNC Request used to synchronize with the coordinator by acquiring and, if
234/// specified, tracking its beacons 243/// specified, tracking its beacons
235#[repr(C)] 244#[repr(C)]
245#[cfg_attr(feature = "defmt", derive(defmt::Format))]
236pub struct SyncRequest { 246pub struct SyncRequest {
237 /// the channel number on which to attempt coordinator synchronization 247 /// the channel number on which to attempt coordinator synchronization
238 pub channel_number: MacChannel, 248 pub channel_number: MacChannel,
@@ -252,6 +262,7 @@ impl MacCommand for SyncRequest {
252 262
253/// MLME POLL Request propmts the device to request data from the coordinator 263/// MLME POLL Request propmts the device to request data from the coordinator
254#[repr(C)] 264#[repr(C)]
265#[cfg_attr(feature = "defmt", derive(defmt::Format))]
255pub struct PollRequest { 266pub struct PollRequest {
256 /// addressing mode of the coordinator 267 /// addressing mode of the coordinator
257 pub coord_addr_mode: AddressMode, 268 pub coord_addr_mode: AddressMode,
@@ -277,6 +288,7 @@ impl MacCommand for PollRequest {
277/// MLME DPS Request allows the next higher layer to request that the PHY utilize a 288/// MLME DPS Request allows the next higher layer to request that the PHY utilize a
278/// given pair of preamble codes for a single use pending expiration of the DPSIndexDuration 289/// given pair of preamble codes for a single use pending expiration of the DPSIndexDuration
279#[repr(C)] 290#[repr(C)]
291#[cfg_attr(feature = "defmt", derive(defmt::Format))]
280pub struct DpsRequest { 292pub struct DpsRequest {
281 /// the index value for the transmitter 293 /// the index value for the transmitter
282 tx_dps_index: u8, 294 tx_dps_index: u8,
@@ -295,6 +307,7 @@ impl MacCommand for DpsRequest {
295/// MLME SOUNDING request primitive which is used by the next higher layer to request that 307/// MLME SOUNDING request primitive which is used by the next higher layer to request that
296/// the PHY respond with channel sounding information 308/// the PHY respond with channel sounding information
297#[repr(C)] 309#[repr(C)]
310#[cfg_attr(feature = "defmt", derive(defmt::Format))]
298pub struct SoundingRequest; 311pub struct SoundingRequest;
299 312
300impl MacCommand for SoundingRequest { 313impl MacCommand for SoundingRequest {
@@ -305,6 +318,7 @@ impl MacCommand for SoundingRequest {
305/// MLME CALIBRATE request primitive which used to obtain the results of a ranging 318/// MLME CALIBRATE request primitive which used to obtain the results of a ranging
306/// calibration request from an RDEV 319/// calibration request from an RDEV
307#[repr(C)] 320#[repr(C)]
321#[cfg_attr(feature = "defmt", derive(defmt::Format))]
308pub struct CalibrateRequest; 322pub struct CalibrateRequest;
309 323
310impl MacCommand for CalibrateRequest { 324impl MacCommand for CalibrateRequest {
@@ -314,6 +328,7 @@ impl MacCommand for CalibrateRequest {
314 328
315/// MCPS DATA Request used for MAC data related requests from the application 329/// MCPS DATA Request used for MAC data related requests from the application
316#[repr(C)] 330#[repr(C)]
331#[cfg_attr(feature = "defmt", derive(defmt::Format))]
317pub struct DataRequest { 332pub struct DataRequest {
318 /// the handle assocated with the MSDU to be transmitted 333 /// the handle assocated with the MSDU to be transmitted
319 pub msdu_ptr: *const u8, 334 pub msdu_ptr: *const u8,
@@ -362,6 +377,7 @@ impl MacCommand for DataRequest {
362 377
363/// for MCPS PURGE Request used to purge an MSDU from the transaction queue 378/// for MCPS PURGE Request used to purge an MSDU from the transaction queue
364#[repr(C)] 379#[repr(C)]
380#[cfg_attr(feature = "defmt", derive(defmt::Format))]
365pub struct PurgeRequest { 381pub struct PurgeRequest {
366 /// the handle associated with the MSDU to be purged from the transaction 382 /// the handle associated with the MSDU to be purged from the transaction
367 /// queue 383 /// queue
@@ -375,6 +391,7 @@ impl MacCommand for PurgeRequest {
375 391
376/// MLME ASSOCIATE Response used to initiate a response to an MLME-ASSOCIATE.indication 392/// MLME ASSOCIATE Response used to initiate a response to an MLME-ASSOCIATE.indication
377#[repr(C)] 393#[repr(C)]
394#[cfg_attr(feature = "defmt", derive(defmt::Format))]
378pub struct AssociateResponse { 395pub struct AssociateResponse {
379 /// extended address of the device requesting association 396 /// extended address of the device requesting association
380 pub device_address: [u8; 8], 397 pub device_address: [u8; 8],
@@ -400,6 +417,7 @@ impl MacCommand for AssociateResponse {
400 417
401/// MLME ORPHAN Response used to respond to the MLME ORPHAN Indication 418/// MLME ORPHAN Response used to respond to the MLME ORPHAN Indication
402#[repr(C)] 419#[repr(C)]
420#[cfg_attr(feature = "defmt", derive(defmt::Format))]
403pub struct OrphanResponse { 421pub struct OrphanResponse {
404 /// extended address of the orphaned device 422 /// extended address of the orphaned device
405 pub orphan_address: [u8; 8], 423 pub orphan_address: [u8; 8],
diff --git a/embassy-stm32-wpan/src/sub/mac/indications.rs b/embassy-stm32-wpan/src/sub/mac/indications.rs
index dc5ae4c44..4695f24ef 100644
--- a/embassy-stm32-wpan/src/sub/mac/indications.rs
+++ b/embassy-stm32-wpan/src/sub/mac/indications.rs
@@ -141,21 +141,25 @@ impl ParseableMacEvent for CommStatusIndication {
141 let dst_addr_mode = AddressMode::try_from(buf[3])?; 141 let dst_addr_mode = AddressMode::try_from(buf[3])?;
142 142
143 let src_address = match src_addr_mode { 143 let src_address = match src_addr_mode {
144 AddressMode::NoAddress => MacAddress::Short([0, 0]), 144 AddressMode::NoAddress => MacAddress { short: [0, 0] },
145 AddressMode::Reserved => MacAddress::Short([0, 0]), 145 AddressMode::Reserved => MacAddress { short: [0, 0] },
146 AddressMode::Short => MacAddress::Short([buf[4], buf[5]]), 146 AddressMode::Short => MacAddress {
147 AddressMode::Extended => { 147 short: [buf[4], buf[5]],
148 MacAddress::Extended([buf[4], buf[5], buf[6], buf[7], buf[8], buf[9], buf[10], buf[11]]) 148 },
149 } 149 AddressMode::Extended => MacAddress {
150 extended: [buf[4], buf[5], buf[6], buf[7], buf[8], buf[9], buf[10], buf[11]],
151 },
150 }; 152 };
151 153
152 let dst_address = match dst_addr_mode { 154 let dst_address = match dst_addr_mode {
153 AddressMode::NoAddress => MacAddress::Short([0, 0]), 155 AddressMode::NoAddress => MacAddress { short: [0, 0] },
154 AddressMode::Reserved => MacAddress::Short([0, 0]), 156 AddressMode::Reserved => MacAddress { short: [0, 0] },
155 AddressMode::Short => MacAddress::Short([buf[12], buf[13]]), 157 AddressMode::Short => MacAddress {
156 AddressMode::Extended => { 158 short: [buf[12], buf[13]],
157 MacAddress::Extended([buf[12], buf[13], buf[14], buf[15], buf[16], buf[17], buf[18], buf[19]]) 159 },
158 } 160 AddressMode::Extended => MacAddress {
161 extended: [buf[12], buf[13], buf[14], buf[15], buf[16], buf[17], buf[18], buf[19]],
162 },
159 }; 163 };
160 164
161 Ok(Self { 165 Ok(Self {
@@ -358,22 +362,26 @@ impl ParseableMacEvent for DataIndication {
358 362
359 let src_addr_mode = AddressMode::try_from(buf[4])?; 363 let src_addr_mode = AddressMode::try_from(buf[4])?;
360 let src_address = match src_addr_mode { 364 let src_address = match src_addr_mode {
361 AddressMode::NoAddress => MacAddress::Short([0, 0]), 365 AddressMode::NoAddress => MacAddress { short: [0, 0] },
362 AddressMode::Reserved => MacAddress::Short([0, 0]), 366 AddressMode::Reserved => MacAddress { short: [0, 0] },
363 AddressMode::Short => MacAddress::Short([buf[7], buf[8]]), 367 AddressMode::Short => MacAddress {
364 AddressMode::Extended => { 368 short: [buf[7], buf[8]],
365 MacAddress::Extended([buf[7], buf[8], buf[9], buf[10], buf[11], buf[12], buf[13], buf[14]]) 369 },
366 } 370 AddressMode::Extended => MacAddress {
371 extended: [buf[7], buf[8], buf[9], buf[10], buf[11], buf[12], buf[13], buf[14]],
372 },
367 }; 373 };
368 374
369 let dst_addr_mode = AddressMode::try_from(buf[15])?; 375 let dst_addr_mode = AddressMode::try_from(buf[15])?;
370 let dst_address = match dst_addr_mode { 376 let dst_address = match dst_addr_mode {
371 AddressMode::NoAddress => MacAddress::Short([0, 0]), 377 AddressMode::NoAddress => MacAddress { short: [0, 0] },
372 AddressMode::Reserved => MacAddress::Short([0, 0]), 378 AddressMode::Reserved => MacAddress { short: [0, 0] },
373 AddressMode::Short => MacAddress::Short([buf[18], buf[19]]), 379 AddressMode::Short => MacAddress {
374 AddressMode::Extended => { 380 short: [buf[18], buf[19]],
375 MacAddress::Extended([buf[18], buf[19], buf[20], buf[21], buf[22], buf[23], buf[24], buf[25]]) 381 },
376 } 382 AddressMode::Extended => MacAddress {
383 extended: [buf[18], buf[19], buf[20], buf[21], buf[22], buf[23], buf[24], buf[25]],
384 },
377 }; 385 };
378 386
379 Ok(Self { 387 Ok(Self {
@@ -424,12 +432,14 @@ impl ParseableMacEvent for PollIndication {
424 432
425 let addr_mode = AddressMode::try_from(buf[0])?; 433 let addr_mode = AddressMode::try_from(buf[0])?;
426 let request_address = match addr_mode { 434 let request_address = match addr_mode {
427 AddressMode::NoAddress => MacAddress::Short([0, 0]), 435 AddressMode::NoAddress => MacAddress { short: [0, 0] },
428 AddressMode::Reserved => MacAddress::Short([0, 0]), 436 AddressMode::Reserved => MacAddress { short: [0, 0] },
429 AddressMode::Short => MacAddress::Short([buf[1], buf[2]]), 437 AddressMode::Short => MacAddress {
430 AddressMode::Extended => { 438 short: [buf[1], buf[2]],
431 MacAddress::Extended([buf[1], buf[2], buf[3], buf[4], buf[5], buf[6], buf[7], buf[8]]) 439 },
432 } 440 AddressMode::Extended => MacAddress {
441 extended: [buf[1], buf[2], buf[3], buf[4], buf[5], buf[6], buf[7], buf[8]],
442 },
433 }; 443 };
434 444
435 Ok(Self { 445 Ok(Self {
diff --git a/embassy-stm32-wpan/src/sub/mac/mod.rs b/embassy-stm32-wpan/src/sub/mac/mod.rs
index 0524f135a..26358bf81 100644
--- a/embassy-stm32-wpan/src/sub/mac/mod.rs
+++ b/embassy-stm32-wpan/src/sub/mac/mod.rs
@@ -91,13 +91,15 @@ impl Mac {
91 .await; 91 .await;
92 } 92 }
93 93
94 pub async fn send_command<T>(&self, cmd: T) -> Result<(), MacError> 94 pub async fn send_command<T>(&self, cmd: &T) -> Result<(), MacError>
95 where 95 where
96 T: MacCommand, 96 T: MacCommand,
97 { 97 {
98 let mut payload = [0u8; MAX_PACKET_SIZE]; 98 let mut payload = [0u8; MAX_PACKET_SIZE];
99 cmd.copy_into_slice(&mut payload); 99 cmd.copy_into_slice(&mut payload);
100 100
101 debug!("sending {}", &payload[..T::SIZE]);
102
101 let response = self 103 let response = self
102 .tl_write_and_get_response(T::OPCODE as u16, &payload[..T::SIZE]) 104 .tl_write_and_get_response(T::OPCODE as u16, &payload[..T::SIZE])
103 .await; 105 .await;
diff --git a/embassy-stm32-wpan/src/sub/mac/responses.rs b/embassy-stm32-wpan/src/sub/mac/responses.rs
index ce2ca2fb2..37271ec28 100644
--- a/embassy-stm32-wpan/src/sub/mac/responses.rs
+++ b/embassy-stm32-wpan/src/sub/mac/responses.rs
@@ -27,6 +27,8 @@ impl ParseableMacEvent for AssociateConfirm {
27 const SIZE: usize = 16; 27 const SIZE: usize = 16;
28 28
29 fn try_parse(buf: &[u8]) -> Result<Self, ()> { 29 fn try_parse(buf: &[u8]) -> Result<Self, ()> {
30 debug!("{}", buf);
31
30 Self::validate(buf)?; 32 Self::validate(buf)?;
31 33
32 Ok(Self { 34 Ok(Self {
@@ -61,12 +63,14 @@ impl ParseableMacEvent for DisassociateConfirm {
61 63
62 let device_addr_mode = AddressMode::try_from(buf[1])?; 64 let device_addr_mode = AddressMode::try_from(buf[1])?;
63 let device_address = match device_addr_mode { 65 let device_address = match device_addr_mode {
64 AddressMode::NoAddress => MacAddress::Short([0, 0]), 66 AddressMode::NoAddress => MacAddress { short: [0, 0] },
65 AddressMode::Reserved => MacAddress::Short([0, 0]), 67 AddressMode::Reserved => MacAddress { short: [0, 0] },
66 AddressMode::Short => MacAddress::Short([buf[4], buf[5]]), 68 AddressMode::Short => MacAddress {
67 AddressMode::Extended => { 69 short: [buf[4], buf[5]],
68 MacAddress::Extended([buf[4], buf[5], buf[6], buf[7], buf[8], buf[9], buf[10], buf[11]]) 70 },
69 } 71 AddressMode::Extended => MacAddress {
72 extended: [buf[4], buf[5], buf[6], buf[7], buf[8], buf[9], buf[10], buf[11]],
73 },
70 }; 74 };
71 75
72 Ok(Self { 76 Ok(Self {
@@ -238,7 +242,6 @@ impl ParseableMacEvent for StartConfirm {
238 242
239 fn try_parse(buf: &[u8]) -> Result<Self, ()> { 243 fn try_parse(buf: &[u8]) -> Result<Self, ()> {
240 Self::validate(buf)?; 244 Self::validate(buf)?;
241 debug!("{:#x}", buf);
242 245
243 Ok(Self { 246 Ok(Self {
244 status: MacStatus::try_from(buf[0])?, 247 status: MacStatus::try_from(buf[0])?,
diff --git a/embassy-stm32-wpan/src/sub/mac/typedefs.rs b/embassy-stm32-wpan/src/sub/mac/typedefs.rs
index fe79b3a79..1a4c30cbc 100644
--- a/embassy-stm32-wpan/src/sub/mac/typedefs.rs
+++ b/embassy-stm32-wpan/src/sub/mac/typedefs.rs
@@ -109,18 +109,32 @@ numeric_enum! {
109} 109}
110 110
111#[derive(Clone, Copy)] 111#[derive(Clone, Copy)]
112#[cfg_attr(feature = "defmt", derive(defmt::Format))] 112pub union MacAddress {
113pub enum MacAddress { 113 pub short: [u8; 2],
114 Short([u8; 2]), 114 pub extended: [u8; 8],
115 Extended([u8; 8]), 115}
116
117#[cfg(feature = "defmt")]
118impl defmt::Format for MacAddress {
119 fn format(&self, fmt: defmt::Formatter) {
120 unsafe {
121 defmt::write!(
122 fmt,
123 "MacAddress {{ short: {}, extended: {} }}",
124 self.short,
125 self.extended
126 )
127 }
128 }
116} 129}
117 130
118impl Default for MacAddress { 131impl Default for MacAddress {
119 fn default() -> Self { 132 fn default() -> Self {
120 Self::Short([0, 0]) 133 Self { short: [0, 0] }
121 } 134 }
122} 135}
123 136
137#[cfg_attr(feature = "defmt", derive(defmt::Format))]
124pub struct GtsCharacteristics { 138pub struct GtsCharacteristics {
125 pub fields: u8, 139 pub fields: u8,
126} 140}
@@ -163,12 +177,14 @@ impl TryFrom<&[u8]> for PanDescriptor {
163 177
164 let coord_addr_mode = AddressMode::try_from(buf[2])?; 178 let coord_addr_mode = AddressMode::try_from(buf[2])?;
165 let coord_addr = match coord_addr_mode { 179 let coord_addr = match coord_addr_mode {
166 AddressMode::NoAddress => MacAddress::Short([0, 0]), 180 AddressMode::NoAddress => MacAddress { short: [0, 0] },
167 AddressMode::Reserved => MacAddress::Short([0, 0]), 181 AddressMode::Reserved => MacAddress { short: [0, 0] },
168 AddressMode::Short => MacAddress::Short([buf[4], buf[5]]), 182 AddressMode::Short => MacAddress {
169 AddressMode::Extended => { 183 short: [buf[4], buf[5]],
170 MacAddress::Extended([buf[4], buf[5], buf[6], buf[7], buf[8], buf[9], buf[10], buf[11]]) 184 },
171 } 185 AddressMode::Extended => MacAddress {
186 extended: [buf[4], buf[5], buf[6], buf[7], buf[8], buf[9], buf[10], buf[11]],
187 },
172 }; 188 };
173 189
174 Ok(Self { 190 Ok(Self {
@@ -255,7 +271,7 @@ defmt::bitflags! {
255 271
256numeric_enum! { 272numeric_enum! {
257 #[repr(u8)] 273 #[repr(u8)]
258 #[derive(Default)] 274 #[derive(Default, Clone, Copy)]
259 #[cfg_attr(feature = "defmt", derive(defmt::Format))] 275 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
260 pub enum KeyIdMode { 276 pub enum KeyIdMode {
261 #[default] 277 #[default]
@@ -285,6 +301,7 @@ numeric_enum! {
285 301
286numeric_enum! { 302numeric_enum! {
287 #[repr(u8)] 303 #[repr(u8)]
304 #[derive(Clone, Copy)]
288 #[cfg_attr(feature = "defmt", derive(defmt::Format))] 305 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
289 pub enum DisassociationReason { 306 pub enum DisassociationReason {
290 /// The coordinator wishes the device to leave the PAN. 307 /// The coordinator wishes the device to leave the PAN.
@@ -296,7 +313,7 @@ numeric_enum! {
296 313
297numeric_enum! { 314numeric_enum! {
298 #[repr(u8)] 315 #[repr(u8)]
299 #[derive(Default)] 316 #[derive(Default, Clone, Copy)]
300 #[cfg_attr(feature = "defmt", derive(defmt::Format))] 317 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
301 pub enum SecurityLevel { 318 pub enum SecurityLevel {
302 /// MAC Unsecured Mode Security 319 /// MAC Unsecured Mode Security