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

Method enable_ap_mode_from_web

wifi_manager.py:2290–2308  ·  view source on GitHub ↗

Enable AP mode from web interface - uses endless loop behavior

(self)

Source from the content-addressed store, hash-verified

2288 result = subprocess.run(['hostapd_cli', '-i', self.ap_interface, 'list_sta'],
2289 capture_output=True, text=True, timeout=5)
2290 if result.returncode == 0:
2291 clients = [line.strip() for line in result.stdout.strip().split('\n') if line.strip()]
2292 client_count = len(clients)
2293
2294 # Log client changes
2295 if client_count != getattr(self, 'last_client_count', 0):
2296 if client_count > 0:
2297 self.ap_logger.info(f"AP clients detected: {client_count}")
2298 self.ap_logger.info(f"Connected clients: {clients}")
2299 else:
2300 self.ap_logger.info("No clients connected to AP")
2301 self.last_client_count = client_count
2302
2303 self.ap_clients_count = client_count
2304 self.ap_clients_connected = client_count > 0
2305 return client_count
2306
2307 # Method 2: Check DHCP leases
2308 self.ap_logger.debug("Hostapd_cli not available, checking DHCP leases...")
2309 dhcp_leases_file = '/var/lib/dhcp/dhcpd.leases'
2310 if os.path.exists(dhcp_leases_file):
2311 with open(dhcp_leases_file, 'r') as f:

Callers 1

enable_wifi_ap_modeFunction · 0.80

Calls 5

disconnect_wifiMethod · 0.95
stop_ap_modeMethod · 0.95
start_ap_modeMethod · 0.95
infoMethod · 0.80

Tested by

no test coverage detected