Get current network identifier
(self)
| 143 | self.logger.error(f"Error saving intelligence data: {e}") |
| 144 | |
| 145 | def get_current_network_id(self) -> Optional[str]: |
| 146 | """Get current network identifier""" |
| 147 | try: |
| 148 | # Try to get SSID from WiFi manager |
| 149 | if (hasattr(self.shared_data, 'ragnar_instance') and |
| 150 | hasattr(self.shared_data.ragnar_instance, 'wifi_manager')): |
| 151 | |
| 152 | wifi_mgr = self.shared_data.ragnar_instance.wifi_manager |
| 153 | if hasattr(wifi_mgr, 'current_ssid') and wifi_mgr.current_ssid: |
| 154 | return self.create_network_id(wifi_mgr.current_ssid) |
| 155 | |
| 156 | # Fallback to get_current_ssid method |
| 157 | if hasattr(wifi_mgr, 'get_current_ssid'): |
| 158 | ssid = wifi_mgr.get_current_ssid() |
| 159 | if ssid: |
| 160 | return self.create_network_id(ssid) |
| 161 | |
| 162 | # If no WiFi manager or SSID, return default network |
| 163 | return "default_network" |
| 164 | |
| 165 | except Exception as e: |
| 166 | self.logger.error(f"Error getting current network ID: {e}") |
| 167 | return "default_network" |
| 168 | |
| 169 | def create_network_id(self, ssid: str) -> str: |
| 170 | """Create a stable network identifier from SSID""" |
no test coverage detected