Remove a network from Ragnar's known networks list AND delete the system NetworkManager profile
(self, ssid)
| 2075 | # Get signal strength if available |
| 2076 | signal_strength = None |
| 2077 | try: |
| 2078 | for net in self.available_networks: |
| 2079 | if net['ssid'] == ssid: |
| 2080 | signal_strength = net.get('signal') |
| 2081 | break |
| 2082 | except: |
| 2083 | pass |
| 2084 | |
| 2085 | if result.returncode == 0: |
| 2086 | # Wait a moment and verify connection |
| 2087 | self.logger.info(f"Connection command succeeded, verifying connection...") |
| 2088 | time.sleep(5) |
| 2089 | connected = self.check_wifi_connection() |
| 2090 | |
| 2091 | # Log connection attempt to database |
| 2092 | if self.db: |
| 2093 | try: |
| 2094 | conn_id = self.db.log_wifi_connection_attempt( |
| 2095 | ssid=ssid, |
| 2096 | success=connected, |
| 2097 | failure_reason=None if connected else "Verification failed", |
| 2098 | signal_strength=signal_strength, |
| 2099 | network_profile_existed=profile_exists, |
| 2100 | from_ap_mode=self.ap_mode_active |
| 2101 | ) |
| 2102 | if connected: |
| 2103 | self.current_connection_id = conn_id |
| 2104 | except Exception as db_err: |
| 2105 | self.logger.warning(f"Failed to log connection attempt: {db_err}") |
| 2106 | |
| 2107 | if connected: |
| 2108 | self.logger.info(f"Successfully connected to {ssid}") |
| 2109 | # Immediately propagate the network change so the |
| 2110 | # per-network database is switched before any scan |
| 2111 | # cycle can write hosts into the wrong store. |
| 2112 | self.wifi_connected = True |
| 2113 | self.shared_data.wifi_connected = True |
| 2114 | self._set_current_ssid(ssid) |
| 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 |
no test coverage detected