diff options
| author | Jack Hogan <[email protected]> | 2024-04-15 14:11:28 -0400 |
|---|---|---|
| committer | Jack Hogan <[email protected]> | 2024-04-15 14:11:28 -0400 |
| commit | 6ffecb1250bbbdf7f1336479d8f7b7aa1fd00285 (patch) | |
| tree | 5a8972127af253dc29aec04235a750354e5718fb | |
| parent | 20110ce6c7039de5f4b138fb6baff501b91751ae (diff) | |
Added MAC address getter to cyw43 controller
| -rw-r--r-- | cyw43/src/control.rs | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/cyw43/src/control.rs b/cyw43/src/control.rs index 135b8c245..a3808f56f 100644 --- a/cyw43/src/control.rs +++ b/cyw43/src/control.rs | |||
| @@ -124,8 +124,7 @@ impl<'a> Control<'a> { | |||
| 124 | self.set_iovar_u32("apsta", 1).await; | 124 | self.set_iovar_u32("apsta", 1).await; |
| 125 | 125 | ||
| 126 | // read MAC addr. | 126 | // read MAC addr. |
| 127 | let mut mac_addr = [0; 6]; | 127 | let mac_addr = self.address().await; |
| 128 | assert_eq!(self.get_iovar("cur_etheraddr", &mut mac_addr).await, 6); | ||
| 129 | debug!("mac addr: {:02x}", Bytes(&mac_addr)); | 128 | debug!("mac addr: {:02x}", Bytes(&mac_addr)); |
| 130 | 129 | ||
| 131 | let country = countries::WORLD_WIDE_XX; | 130 | let country = countries::WORLD_WIDE_XX; |
| @@ -574,6 +573,13 @@ impl<'a> Control<'a> { | |||
| 574 | self.ioctl(IoctlType::Set, IOCTL_CMD_DISASSOC, 0, &mut []).await; | 573 | self.ioctl(IoctlType::Set, IOCTL_CMD_DISASSOC, 0, &mut []).await; |
| 575 | info!("Disassociated") | 574 | info!("Disassociated") |
| 576 | } | 575 | } |
| 576 | |||
| 577 | /// Gets the MAC address of the device | ||
| 578 | pub async fn address(&mut self) -> [u8; 6] { | ||
| 579 | let mut mac_addr = [0; 6]; | ||
| 580 | assert_eq!(self.get_iovar("cur_etheraddr", &mut mac_addr).await, 6); | ||
| 581 | mac_addr | ||
| 582 | } | ||
| 577 | } | 583 | } |
| 578 | 584 | ||
| 579 | /// WiFi network scanner. | 585 | /// WiFi network scanner. |
