aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2023-01-02 21:36:17 +0100
committerDario Nieuwenhuis <[email protected]>2023-01-02 21:36:51 +0100
commita2bae33d8460eee6c3af6f20a790f725cf2c5602 (patch)
treebb102787f330a0b327500ae5327d1447b3de2e42 /src
parent001610f0d0b94859b8c8800dcdfa255343f2ea05 (diff)
Add separate function to set power management mode.
Diffstat (limited to 'src')
-rw-r--r--src/lib.rs29
1 files changed, 13 insertions, 16 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 884cb082b..5733506ac 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -228,7 +228,7 @@ impl PowerManagementMode {
228} 228}
229 229
230impl<'a> Control<'a> { 230impl<'a> Control<'a> {
231 pub async fn init(&mut self, clm: &[u8], power_save_mode: PowerManagementMode) { 231 pub async fn init(&mut self, clm: &[u8]) {
232 const CHUNK_SIZE: usize = 1024; 232 const CHUNK_SIZE: usize = 1024;
233 233
234 info!("Downloading CLM..."); 234 info!("Downloading CLM...");
@@ -323,21 +323,6 @@ impl<'a> Control<'a> {
323 323
324 Timer::after(Duration::from_millis(100)).await; 324 Timer::after(Duration::from_millis(100)).await;
325 325
326 // power save mode
327 if power_save_mode != PowerManagementMode::None {
328 let mode = power_save_mode.mode();
329 if mode == 2 {
330 self.set_iovar_u32("pm2_sleep_ret", power_save_mode.sleep_ret_ms() as u32)
331 .await;
332 self.set_iovar_u32("bcn_li_bcn", power_save_mode.beacon_period() as u32)
333 .await;
334 self.set_iovar_u32("bcn_li_dtim", power_save_mode.dtim_period() as u32)
335 .await;
336 self.set_iovar_u32("assoc_listen", power_save_mode.assoc() as u32).await;
337 }
338 self.ioctl_set_u32(86, 0, mode).await;
339 }
340
341 self.ioctl_set_u32(110, 0, 1).await; // SET_GMODE = auto 326 self.ioctl_set_u32(110, 0, 1).await; // SET_GMODE = auto
342 self.ioctl_set_u32(142, 0, 0).await; // SET_BAND = any 327 self.ioctl_set_u32(142, 0, 0).await; // SET_BAND = any
343 328
@@ -349,6 +334,18 @@ impl<'a> Control<'a> {
349 info!("INIT DONE"); 334 info!("INIT DONE");
350 } 335 }
351 336
337 pub async fn set_power_management(&mut self, mode: PowerManagementMode) {
338 // power save mode
339 let mode_num = mode.mode();
340 if mode_num == 2 {
341 self.set_iovar_u32("pm2_sleep_ret", mode.sleep_ret_ms() as u32).await;
342 self.set_iovar_u32("bcn_li_bcn", mode.beacon_period() as u32).await;
343 self.set_iovar_u32("bcn_li_dtim", mode.dtim_period() as u32).await;
344 self.set_iovar_u32("assoc_listen", mode.assoc() as u32).await;
345 }
346 self.ioctl_set_u32(86, 0, mode_num).await;
347 }
348
352 pub async fn join_open(&mut self, ssid: &str) { 349 pub async fn join_open(&mut self, ssid: &str) {
353 self.set_iovar_u32("ampdu_ba_wsize", 8).await; 350 self.set_iovar_u32("ampdu_ba_wsize", 8).await;
354 351