aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrostie314159 <[email protected]>2023-08-28 21:32:31 +0200
committerFrostie314159 <[email protected]>2023-08-28 21:32:31 +0200
commit05ee02b5933dc8e87f3714294d272aa4cb23aefb (patch)
tree8007eb1d18dee8f36842cfbed551c1f28891be00
parent4098a61ef04e42294b182f4b0bf44ced97c706a0 (diff)
cyw43: Introduce seperate up/down functions.
Create two helper functions, for setting the interface up/down.
-rw-r--r--cyw43/src/control.rs16
1 files changed, 13 insertions, 3 deletions
diff --git a/cyw43/src/control.rs b/cyw43/src/control.rs
index c67614dd6..d2f6e4a03 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;