mirror of
https://github.com/OpenVoiceOS/OpenVoiceOS
synced 2025-04-13 18:12:01 +02:00
Bump wifi skill (again again)
This commit is contained in:
parent
74ca185bc0
commit
f36b651595
@ -26,8 +26,8 @@ class WifiConnect(MycroftSkill):
|
||||
self.settings["color"] = "#FF0000"
|
||||
if "stop_on_internet" not in self.settings:
|
||||
self.settings["stop_on_internet"] = False
|
||||
if "increase_timeout_on_internet" not in self.settings:
|
||||
self.settings["increase_timeout_on_internet"] = 60
|
||||
if "timeout_after_internet" not in self.settings:
|
||||
self.settings["timeout_after_internet"] = 90
|
||||
|
||||
def initialize(self):
|
||||
self.make_priority()
|
||||
@ -65,36 +65,36 @@ class WifiConnect(MycroftSkill):
|
||||
self.monitoring = False
|
||||
|
||||
def _watchdog(self):
|
||||
self.monitoring = True
|
||||
output = subprocess.check_output("nmcli connection show | grep wifi",
|
||||
shell=True).decode("utf-8")
|
||||
if output.strip():
|
||||
self.log.info("Detected previously configured wifi, starting "
|
||||
"grace period to allow it to connect")
|
||||
sleep(self.grace_period)
|
||||
while self.monitoring:
|
||||
if self.in_setup:
|
||||
sleep(1) # let setup do it's thing
|
||||
continue
|
||||
try:
|
||||
self.monitoring = True
|
||||
self.log.info("Wifi watchdog started")
|
||||
output = subprocess.check_output("nmcli connection show",
|
||||
shell=True).decode("utf-8")
|
||||
self.log.warning(output)
|
||||
if "wifi" in output:
|
||||
self.log.info("Detected previously configured wifi, starting "
|
||||
"grace period to allow it to connect")
|
||||
sleep(self.grace_period)
|
||||
while self.monitoring:
|
||||
if self.in_setup:
|
||||
sleep(1) # let setup do it's thing
|
||||
continue
|
||||
|
||||
if not connected():
|
||||
self.log.info("NO INTERNET")
|
||||
if not self.is_connected_to_wifi():
|
||||
self.log.info("LAUNCH SETUP")
|
||||
try:
|
||||
self.launch_wifi_setup() # blocking
|
||||
except Exception as e:
|
||||
self.log.exception(e)
|
||||
else:
|
||||
self.log.warning("CONNECTED TO WIFI, BUT NO INTERNET!!")
|
||||
elif not self.connected:
|
||||
# once first connected to internet increase time between checks
|
||||
self.connected = True
|
||||
self.time_between_checks += self.settings["increase_timeout_on_internet"]
|
||||
# stop watchdog on internet connection
|
||||
if self.settings["stop_on_internet"]:
|
||||
self.monitoring = False
|
||||
sleep(self.time_between_checks)
|
||||
if not connected():
|
||||
self.log.info("NO INTERNET")
|
||||
if not self.is_connected_to_wifi():
|
||||
self.log.info("LAUNCH SETUP")
|
||||
try:
|
||||
self.launch_wifi_setup() # blocking
|
||||
except Exception as e:
|
||||
self.log.exception(e)
|
||||
else:
|
||||
self.log.warning("CONNECTED TO WIFI, BUT NO INTERNET!!")
|
||||
|
||||
sleep(self.time_between_checks)
|
||||
except Exception as e:
|
||||
self.log.error("Wifi watchdog crashed unexpectedly")
|
||||
self.log.exception(e)
|
||||
|
||||
# wifi setup
|
||||
@staticmethod
|
||||
@ -243,6 +243,12 @@ class WifiConnect(MycroftSkill):
|
||||
|
||||
def report_setup_complete(self, message=None):
|
||||
"""Wifi setup complete, network is connected."""
|
||||
# once first connected to internet increase time between checks
|
||||
self.connected = True
|
||||
self.time_between_checks = self.settings["timeout_after_internet"]
|
||||
# stop watchdog on internet connection
|
||||
if self.settings["stop_on_internet"]:
|
||||
self.monitoring = False
|
||||
self.gui.remove_page("prompt.qml")
|
||||
self.gui.clear()
|
||||
self.gui["icon"] = "check-circle.svg"
|
||||
|
Loading…
x
Reference in New Issue
Block a user