(self, mode: Optional[str] = None, focus_interface: Optional[str] = None)
| 448 | ) |
| 449 | |
| 450 | def update_scan_mode(self, mode: Optional[str] = None, focus_interface: Optional[str] = None) -> Dict: |
| 451 | requested_mode = self.get_scan_mode() |
| 452 | if mode is not None: |
| 453 | normalized = str(mode).strip().lower() |
| 454 | if normalized not in (self.MODE_SINGLE, self.MODE_MULTI): |
| 455 | raise ValueError("mode must be 'single' or 'multi'") |
| 456 | requested_mode = normalized |
| 457 | |
| 458 | focus_provided = focus_interface is not None |
| 459 | sanitized_focus = None |
| 460 | if focus_provided: |
| 461 | sanitized_focus = self._sanitize_interface_name(focus_interface) |
| 462 | |
| 463 | changed = False |
| 464 | if self.shared_data.config.get('wifi_multi_scan_mode') != requested_mode: |
| 465 | self.shared_data.config['wifi_multi_scan_mode'] = requested_mode |
| 466 | changed = True |
| 467 | |
| 468 | desired_multi_flag = (requested_mode == self.MODE_MULTI) |
| 469 | if bool(self.shared_data.config.get('wifi_multi_network_scans_enabled', False)) != desired_multi_flag: |
| 470 | self.shared_data.config['wifi_multi_network_scans_enabled'] = desired_multi_flag |
| 471 | changed = True |
| 472 | |
| 473 | if focus_provided: |
| 474 | self.shared_data.config['wifi_multi_scan_focus_interface'] = sanitized_focus or '' |
| 475 | changed = True |
| 476 | elif requested_mode == self.MODE_SINGLE and not self.get_focus_interface(): |
| 477 | auto_focus = self._auto_focus_interface() or '' |
| 478 | self.shared_data.config['wifi_multi_scan_focus_interface'] = auto_focus |
| 479 | changed = True |
| 480 | |
| 481 | if changed: |
| 482 | try: |
| 483 | self.shared_data.save_config() |
| 484 | except Exception as exc: |
| 485 | logger.warning(f"Unable to persist multi-interface scan mode: {exc}") |
| 486 | |
| 487 | self._refresh_focus_flags() |
| 488 | return self.get_state_payload() |
| 489 | |
| 490 | # ------------------------------------------------------------------ |
| 491 | # Helpers |
no test coverage detected