aboutsummaryrefslogtreecommitdiff
path: root/cyw43/src/control.rs
diff options
context:
space:
mode:
Diffstat (limited to 'cyw43/src/control.rs')
-rw-r--r--cyw43/src/control.rs21
1 files changed, 18 insertions, 3 deletions
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
428pub struct Scanner<'a> { 443pub struct Scanner<'a> {