From f36b6515955c3e52dc337feeb41a6b8ca37e0b54 Mon Sep 17 00:00:00 2001
From: j1nx
Date: Tue, 5 Jan 2021 20:57:31 +0100
Subject: [PATCH] Bump wifi skill (again again)
---
.../skill-balena-wifi-setup/__init__.py | 68 ++++++++++---------
1 file changed, 37 insertions(+), 31 deletions(-)
diff --git a/buildroot-external/rootfs-overlay/opt/mycroft/skills/skill-balena-wifi-setup/__init__.py b/buildroot-external/rootfs-overlay/opt/mycroft/skills/skill-balena-wifi-setup/__init__.py
index 7d921e2c..8f622615 100644
--- a/buildroot-external/rootfs-overlay/opt/mycroft/skills/skill-balena-wifi-setup/__init__.py
+++ b/buildroot-external/rootfs-overlay/opt/mycroft/skills/skill-balena-wifi-setup/__init__.py
@@ -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"