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

Method check_ap_clients

wifi_manager.py:2117–2188  ·  view source on GitHub ↗

Check how many clients are connected to the AP

(self)

Source from the content-addressed store, hash-verified

2115 self._trigger_initial_ping_sweep(ssid)
2116 else:
2117 self.logger.warning(f"Connection command succeeded but verification failed for {ssid}")
2118 return connected
2119 else:
2120 error_msg = result.stderr.strip()
2121 self.logger.error(f"nmcli connection failed for {ssid}: {error_msg}")
2122
2123 # Parse common errors
2124 failure_reason = error_msg
2125 if "Secrets were required, but not provided" in error_msg:
2126 self.logger.error("Password was required but not provided or incorrect")
2127 failure_reason = "Incorrect password"
2128 elif "No network with SSID" in error_msg:
2129 self.logger.error(f"Network {ssid} not found in range")
2130 failure_reason = "Network not in range"
2131
2132 # Log failed connection attempt
2133 if self.db:
2134 try:
2135 self.db.log_wifi_connection_attempt(
2136 ssid=ssid,
2137 success=False,
2138 failure_reason=failure_reason,
2139 signal_strength=signal_strength,
2140 network_profile_existed=profile_exists,
2141 from_ap_mode=self.ap_mode_active
2142 )
2143 except Exception as db_err:
2144 self.logger.warning(f"Failed to log connection failure: {db_err}")
2145
2146 return False
2147
2148 except subprocess.TimeoutExpired:
2149 self.logger.error(f"Connection attempt to {ssid} timed out after 30 seconds")
2150 if self.db:
2151 try:
2152 self.db.log_wifi_connection_attempt(
2153 ssid=ssid,
2154 success=False,
2155 failure_reason="Connection timeout",
2156 network_profile_existed=profile_exists,
2157 from_ap_mode=self.ap_mode_active
2158 )
2159 except:
2160 pass
2161 return False
2162 except Exception as e:
2163 self.logger.error(f"Error connecting to {ssid}: {e}")
2164 import traceback
2165 self.logger.error(traceback.format_exc())
2166 if self.db:
2167 try:
2168 self.db.log_wifi_connection_attempt(
2169 ssid=ssid,
2170 success=False,
2171 failure_reason=f"Exception: {str(e)}",
2172 network_profile_existed=profile_exists,
2173 from_ap_mode=self.ap_mode_active
2174 )

Callers 1

Calls 6

debugMethod · 0.80
infoMethod · 0.80
countMethod · 0.80
warningMethod · 0.80
runMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected