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

Method _initial_endless_loop_sequence

wifi_manager.py:684–723  ·  view source on GitHub ↗

Handle initial Wi-Fi connection with endless loop behavior

(self)

Source from the content-addressed store, hash-verified

682 self.logger.warning(
683 f"WiFi interface(s) disappeared (unplugged?): {disappeared}"
684 )
685 if not self.wifi_connected and not self.ap_mode_active:
686 self.logger.info(
687 "USB antenna removed while disconnected — triggering WiFi reconnect"
688 )
689 threading.Thread(
690 target=self._endless_loop_wifi_search,
691 daemon=True,
692 name="wifi-reconnect-usb-unplug",
693 ).start()
694 prev_ifaces = current_ifaces
695 except Exception as e:
696 self.logger.debug(f"USB interface monitor error: {e}")
697
698 # ============================================================================
699 # WARDRIVING / WEB PORTAL COORDINATION
700 # ============================================================================
701
702 def _is_wardriving_active(self):
703 """Return True if the wardriving engine is currently running."""
704 try:
705 ragnar = getattr(self.shared_data, 'ragnar_instance', None)
706 if ragnar and hasattr(ragnar, '_wd_engine'):
707 return getattr(ragnar._wd_engine, '_running', False)
708 import webapp_modern
709 engine = getattr(webapp_modern, '_wardriving_engine', None)
710 if engine:
711 return getattr(engine, '_running', False)
712 except Exception:
713 pass
714 return self.shared_data.config.get('wardriving_on_boot', False)
715
716 def _sync_web_portal_for_wardriving(self):
717 """Stop web portal when wardriving with no WiFi; restart when WiFi returns.
718
719 Called every monitoring iteration so the portal state converges quickly
720 regardless of how wardriving was started (boot flag, API call, etc.).
721 """
722 if not self._is_wardriving_active():
723 return
724 ragnar = getattr(self.shared_data, 'ragnar_instance', None)
725 if not ragnar:
726 return

Callers 1

startMethod · 0.95

Calls 9

_set_current_ssidMethod · 0.95
get_current_ssidMethod · 0.95
infoMethod · 0.80
sleepMethod · 0.45

Tested by

no test coverage detected