diff options
| -rw-r--r-- | cyw43/src/consts.rs | 1 | ||||
| -rw-r--r-- | cyw43/src/control.rs | 21 | ||||
| -rw-r--r-- | cyw43/src/lib.rs | 2 |
3 files changed, 20 insertions, 4 deletions
diff --git a/cyw43/src/consts.rs b/cyw43/src/consts.rs index 1f6551589..4e2836f3b 100644 --- a/cyw43/src/consts.rs +++ b/cyw43/src/consts.rs | |||
| @@ -96,6 +96,7 @@ pub(crate) const IOCTL_CMD_UP: u32 = 2; | |||
| 96 | pub(crate) const IOCTL_CMD_DOWN: u32 = 3; | 96 | pub(crate) const IOCTL_CMD_DOWN: u32 = 3; |
| 97 | pub(crate) const IOCTL_CMD_SET_SSID: u32 = 26; | 97 | pub(crate) const IOCTL_CMD_SET_SSID: u32 = 26; |
| 98 | pub(crate) const IOCTL_CMD_SET_CHANNEL: u32 = 30; | 98 | pub(crate) const IOCTL_CMD_SET_CHANNEL: u32 = 30; |
| 99 | pub(crate) const IOCTL_CMD_DISASSOC: u32 = 52; | ||
| 99 | pub(crate) const IOCTL_CMD_ANTDIV: u32 = 64; | 100 | pub(crate) const IOCTL_CMD_ANTDIV: u32 = 64; |
| 100 | pub(crate) const IOCTL_CMD_SET_AP: u32 = 118; | 101 | pub(crate) const IOCTL_CMD_SET_AP: u32 = 118; |
| 101 | pub(crate) const IOCTL_CMD_SET_VAR: u32 = 263; | 102 | pub(crate) const IOCTL_CMD_SET_VAR: u32 = 263; |
diff --git a/cyw43/src/control.rs b/cyw43/src/control.rs index c67614dd6..a6d1f0bf5 100644 --- a/cyw43/src/control.rs +++ b/cyw43/src/control.rs | |||
| @@ -124,7 +124,7 @@ impl<'a> Control<'a> { | |||
| 124 | Timer::after(Duration::from_millis(100)).await; | 124 | Timer::after(Duration::from_millis(100)).await; |
| 125 | 125 | ||
| 126 | // set wifi up | 126 | // set wifi up |
| 127 | self.ioctl(IoctlType::Set, IOCTL_CMD_UP, 0, &mut []).await; | 127 | self.up().await; |
| 128 | 128 | ||
| 129 | Timer::after(Duration::from_millis(100)).await; | 129 | Timer::after(Duration::from_millis(100)).await; |
| 130 | 130 | ||
| @@ -138,6 +138,16 @@ impl<'a> Control<'a> { | |||
| 138 | debug!("INIT DONE"); | 138 | debug!("INIT DONE"); |
| 139 | } | 139 | } |
| 140 | 140 | ||
| 141 | /// Set the WiFi interface up. | ||
| 142 | async fn up(&mut self) { | ||
| 143 | self.ioctl(IoctlType::Set, IOCTL_CMD_UP, 0, &mut []).await; | ||
| 144 | } | ||
| 145 | |||
| 146 | /// Set the interface down. | ||
| 147 | async fn down(&mut self) { | ||
| 148 | self.ioctl(IoctlType::Set, IOCTL_CMD_DOWN, 0, &mut []).await; | ||
| 149 | } | ||
| 150 | |||
| 141 | pub async fn set_power_management(&mut self, mode: PowerManagementMode) { | 151 | pub async fn set_power_management(&mut self, mode: PowerManagementMode) { |
| 142 | // power save mode | 152 | // power save mode |
| 143 | let mode_num = mode.mode(); | 153 | let mode_num = mode.mode(); |
| @@ -256,13 +266,13 @@ impl<'a> Control<'a> { | |||
| 256 | } | 266 | } |
| 257 | 267 | ||
| 258 | // Temporarily set wifi down | 268 | // Temporarily set wifi down |
| 259 | self.ioctl(IoctlType::Set, IOCTL_CMD_DOWN, 0, &mut []).await; | 269 | self.down().await; |
| 260 | 270 | ||
| 261 | // Turn off APSTA mode | 271 | // Turn off APSTA mode |
| 262 | self.set_iovar_u32("apsta", 0).await; | 272 | self.set_iovar_u32("apsta", 0).await; |
| 263 | 273 | ||
| 264 | // Set wifi up again | 274 | // Set wifi up again |
| 265 | self.ioctl(IoctlType::Set, IOCTL_CMD_UP, 0, &mut []).await; | 275 | self.up().await; |
| 266 | 276 | ||
| 267 | // Turn on AP mode | 277 | // Turn on AP mode |
| 268 | self.ioctl_set_u32(IOCTL_CMD_SET_AP, 0, 1).await; | 278 | self.ioctl_set_u32(IOCTL_CMD_SET_AP, 0, 1).await; |
| @@ -423,6 +433,11 @@ impl<'a> Control<'a> { | |||
| 423 | events: &self.events, | 433 | events: &self.events, |
| 424 | } | 434 | } |
| 425 | } | 435 | } |
| 436 | /// Leave the wifi, with which we are currently associated. | ||
| 437 | pub async fn leave(&mut self) { | ||
| 438 | self.ioctl(IoctlType::Set, IOCTL_CMD_DISASSOC, 0, &mut []).await; | ||
| 439 | info!("Disassociated") | ||
| 440 | } | ||
| 426 | } | 441 | } |
| 427 | 442 | ||
| 428 | pub struct Scanner<'a> { | 443 | pub struct Scanner<'a> { |
diff --git a/cyw43/src/lib.rs b/cyw43/src/lib.rs index 30a3d5f26..6b124cf7f 100644 --- a/cyw43/src/lib.rs +++ b/cyw43/src/lib.rs | |||
| @@ -27,7 +27,7 @@ use ioctl::IoctlState; | |||
| 27 | 27 | ||
| 28 | use crate::bus::Bus; | 28 | use crate::bus::Bus; |
| 29 | pub use crate::bus::SpiBusCyw43; | 29 | pub use crate::bus::SpiBusCyw43; |
| 30 | pub use crate::control::{Control, Error as ControlError}; | 30 | pub use crate::control::{Control, Error as ControlError, Scanner}; |
| 31 | pub use crate::runner::Runner; | 31 | pub use crate::runner::Runner; |
| 32 | pub use crate::structs::BssInfo; | 32 | pub use crate::structs::BssInfo; |
| 33 | 33 | ||
