MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / _endless_loop_start_ap_mode

Method _endless_loop_start_ap_mode

wifi_manager.py:808–829  ·  view source on GitHub ↗

Start AP mode as part of endless loop. Skipped when wardriving is enabled — wardriving needs wlan0 for scanning and AP mode (hostapd) would take over the interface.

(self)

Source from the content-addressed store, hash-verified

806
807 # Enable WiFi and let Linux/NetworkManager auto-reconnect to known networks
808 self.logger.info("Endless Loop: Enabling WiFi mode - system will auto-reconnect to known networks")
809
810 try:
811 # Hand the CLIENT radio to NetworkManager. On a single-radio box
812 # that is the AP interface being taken back out of AP mode; with a
813 # dongle it is the dongle, and the AP interface is deliberately left
814 # alone so hostapd keeps running on the built-in radio throughout.
815 client_iface = self._client_wifi_interface()
816 subprocess.run(['sudo', 'nmcli', 'dev', 'set', client_iface, 'managed', 'yes'],
817 capture_output=True, text=True, timeout=10)
818 if client_iface != self.ap_interface:
819 self.logger.info(
820 f"Endless Loop: connecting on {client_iface}; AP stays up on {self.ap_interface}")
821
822 # Enable WiFi radio (equivalent to user toggling WiFi on)
823 subprocess.run(['sudo', 'nmcli', 'radio', 'wifi', 'on'],
824 capture_output=True, text=True, timeout=10)
825
826 self.logger.info("Endless Loop: WiFi enabled - waiting up to 60 seconds for auto-connection")
827
828 except Exception as e:
829 self.logger.error(f"Error enabling WiFi: {e}")
830
831 # Wait up to 60 seconds for automatic connection (check every 5 seconds)
832 timeout = 60 # 1 minute to connect

Calls 6

start_ap_modeMethod · 0.95
infoMethod · 0.80
errorMethod · 0.80
getMethod · 0.45
sleepMethod · 0.45

Tested by

no test coverage detected