Get cached page data, refreshing if older than ttl seconds.
(self, key, fetch_fn, ttl=10)
| 775 | try: |
| 776 | result = subprocess.run(['hostapd_cli', '-i', self._wifi_iface, 'list_sta'], |
| 777 | capture_output=True, text=True, timeout=2) |
| 778 | if result.returncode == 0: |
| 779 | clients = [line.strip() for line in result.stdout.strip().split('\n') if line.strip()] |
| 780 | client_count = len(clients) |
| 781 | if client_count > 0: |
| 782 | return f"AP: {client_count} client{'s' if client_count != 1 else ''}" |
| 783 | else: |
| 784 | return "AP: No clients" |
| 785 | else: |
| 786 | return "AP: Active" |
| 787 | except: |
| 788 | return "AP: Active" |
| 789 | |
| 790 | logger.debug(f"[STATUS] WiFi not detected by any method") |
| 791 | return "WiFi: Disconnected" |
| 792 | |
| 793 | except Exception as e: |
| 794 | logger.error(f"Error getting WiFi status text: {e}") |
no test coverage detected