Tweak UI for NTP checking
Withe the NTP checks in place, the sequence of visual and audio queues was a little clunky. This refines it slightly for normal use and to play better with the pairing process.pull/1371/head
parent
5541c4717f
commit
26444c9c5f
|
@ -144,14 +144,13 @@ class EnclosureReader(Thread):
|
||||||
self.ws.emit(Message("system.wifi.setup", {'lang': self.lang}))
|
self.ws.emit(Message("system.wifi.setup", {'lang': self.lang}))
|
||||||
|
|
||||||
if "unit.factory-reset" in data:
|
if "unit.factory-reset" in data:
|
||||||
self.ws.emit(Message("enclosure.eyes.spin"))
|
self.ws.emit(Message("speak", {
|
||||||
|
'utterance': mycroft.dialog.get("reset to factory defaults")}))
|
||||||
subprocess.call(
|
subprocess.call(
|
||||||
'rm ~/.mycroft/identity/identity2.json',
|
'rm ~/.mycroft/identity/identity2.json',
|
||||||
shell=True)
|
shell=True)
|
||||||
self.ws.emit(Message("system.wifi.reset"))
|
self.ws.emit(Message("system.wifi.reset"))
|
||||||
self.ws.emit(Message("system.ssh.disable"))
|
self.ws.emit(Message("system.ssh.disable"))
|
||||||
self.ws.emit(Message("speak", {
|
|
||||||
'utterance': mycroft.dialog.get("reset to factory defaults")}))
|
|
||||||
wait_while_speaking()
|
wait_while_speaking()
|
||||||
self.ws.emit(Message("enclosure.mouth.reset"))
|
self.ws.emit(Message("enclosure.mouth.reset"))
|
||||||
self.ws.emit(Message("enclosure.eyes.spin"))
|
self.ws.emit(Message("enclosure.eyes.spin"))
|
||||||
|
@ -298,9 +297,6 @@ class Enclosure(object):
|
||||||
# receive the "speak". This was sometimes happening too
|
# receive the "speak". This was sometimes happening too
|
||||||
# quickly and the user wasn't notified what to do.
|
# quickly and the user wasn't notified what to do.
|
||||||
Timer(5, self._do_net_check).start()
|
Timer(5, self._do_net_check).start()
|
||||||
else:
|
|
||||||
# Indicate we are checking for updates from the internet now...
|
|
||||||
self.writer.write("mouth.text=< < < UPDATING < < < ")
|
|
||||||
|
|
||||||
Timer(60, self._hack_check_for_duplicates).start()
|
Timer(60, self._hack_check_for_duplicates).start()
|
||||||
|
|
||||||
|
@ -425,9 +421,6 @@ class Enclosure(object):
|
||||||
# Kick off wifi-setup automatically
|
# Kick off wifi-setup automatically
|
||||||
data = {'allow_timeout': False, 'lang': self.lang}
|
data = {'allow_timeout': False, 'lang': self.lang}
|
||||||
self.ws.emit(Message('system.wifi.setup', data))
|
self.ws.emit(Message('system.wifi.setup', data))
|
||||||
else:
|
|
||||||
# Indicate we are checking for updates from the internet now...
|
|
||||||
self.writer.write("mouth.text=< < < UPDATING < < < ")
|
|
||||||
|
|
||||||
def _hack_check_for_duplicates(self):
|
def _hack_check_for_duplicates(self):
|
||||||
# TEMPORARY HACK: Look for multiple instance of the
|
# TEMPORARY HACK: Look for multiple instance of the
|
||||||
|
|
|
@ -128,6 +128,11 @@ class EnclosureAPI:
|
||||||
"""Restore the eyes to their default (ready) state."""
|
"""Restore the eyes to their default (ready) state."""
|
||||||
self.ws.emit(Message("enclosure.eyes.reset"))
|
self.ws.emit(Message("enclosure.eyes.reset"))
|
||||||
|
|
||||||
|
def eyes_spin(self):
|
||||||
|
"""Make the eyes 'roll'
|
||||||
|
"""
|
||||||
|
self.ws.emit(Message("enclosure.eyes.spin"))
|
||||||
|
|
||||||
def eyes_timed_spin(self, length):
|
def eyes_timed_spin(self, length):
|
||||||
"""Make the eyes 'roll' for the given time.
|
"""Make the eyes 'roll' for the given time.
|
||||||
Args:
|
Args:
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
SYNC CLOCK...
|
< < < SYNC < < <
|
|
@ -0,0 +1 @@
|
||||||
|
< < < UPDATING < < <
|
|
@ -105,10 +105,13 @@ def check_connection():
|
||||||
if connected():
|
if connected():
|
||||||
enclosure = EnclosureAPI(ws)
|
enclosure = EnclosureAPI(ws)
|
||||||
|
|
||||||
|
if is_paired():
|
||||||
|
# Skip the sync message when unpaired because the prompt to go to
|
||||||
|
# home.mycrof.ai will be displayed by the pairing skill
|
||||||
|
enclosure.mouth_text(mycroft.dialog.get("message_synching.clock"))
|
||||||
# Force a sync of the local clock with the internet
|
# Force a sync of the local clock with the internet
|
||||||
enclosure.mouth_text(mycroft.dialog.get("message_synching.clock"))
|
|
||||||
ws.emit(Message("system.ntp.sync"))
|
ws.emit(Message("system.ntp.sync"))
|
||||||
time.sleep(10) # TODO: Generate/listen for a message response...
|
time.sleep(15) # TODO: Generate/listen for a message response...
|
||||||
|
|
||||||
# Check if the time skewed significantly. If so, reboot
|
# Check if the time skewed significantly. If so, reboot
|
||||||
skew = abs((monotonic.monotonic() - start_ticks) -
|
skew = abs((monotonic.monotonic() - start_ticks) -
|
||||||
|
@ -124,10 +127,10 @@ def check_connection():
|
||||||
# provide visual indicators of the reboot
|
# provide visual indicators of the reboot
|
||||||
enclosure.mouth_text(mycroft.dialog.get("message_rebooting"))
|
enclosure.mouth_text(mycroft.dialog.get("message_rebooting"))
|
||||||
enclosure.eyes_color(70, 65, 69) # soft gray
|
enclosure.eyes_color(70, 65, 69) # soft gray
|
||||||
enclosure.eyes_timed_spin(None)
|
enclosure.eyes_spin()
|
||||||
|
|
||||||
# give the system time to finish processing enclosure messages
|
# give the system time to finish processing enclosure messages
|
||||||
time.sleep(0.5)
|
time.sleep(1.0)
|
||||||
|
|
||||||
# reboot
|
# reboot
|
||||||
ws.emit(Message("system.reboot"))
|
ws.emit(Message("system.reboot"))
|
||||||
|
@ -143,6 +146,11 @@ def check_connection():
|
||||||
}
|
}
|
||||||
ws.emit(Message("recognizer_loop:utterance", payload))
|
ws.emit(Message("recognizer_loop:utterance", payload))
|
||||||
else:
|
else:
|
||||||
|
if is_paired():
|
||||||
|
# Skip the message when unpaired because the prompt to go
|
||||||
|
# to home.mycrof.ai will be displayed by the pairing skill
|
||||||
|
enclosure.mouth_text(mycroft.dialog.get("message_updating"))
|
||||||
|
|
||||||
from mycroft.api import DeviceApi
|
from mycroft.api import DeviceApi
|
||||||
api = DeviceApi()
|
api = DeviceApi()
|
||||||
api.update_version()
|
api.update_version()
|
||||||
|
|
Loading…
Reference in New Issue