Enable AP mode from web interface - uses endless loop behavior
(self)
| 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: |
no test coverage detected