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
penrods 2018-01-18 14:44:53 -06:00
parent 5541c4717f
commit 26444c9c5f
5 changed files with 21 additions and 14 deletions

View File

@ -144,14 +144,13 @@ class EnclosureReader(Thread):
self.ws.emit(Message("system.wifi.setup", {'lang': self.lang}))
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(
'rm ~/.mycroft/identity/identity2.json',
shell=True)
self.ws.emit(Message("system.wifi.reset"))
self.ws.emit(Message("system.ssh.disable"))
self.ws.emit(Message("speak", {
'utterance': mycroft.dialog.get("reset to factory defaults")}))
wait_while_speaking()
self.ws.emit(Message("enclosure.mouth.reset"))
self.ws.emit(Message("enclosure.eyes.spin"))
@ -298,9 +297,6 @@ class Enclosure(object):
# receive the "speak". This was sometimes happening too
# quickly and the user wasn't notified what to do.
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()
@ -425,9 +421,6 @@ class Enclosure(object):
# Kick off wifi-setup automatically
data = {'allow_timeout': False, 'lang': self.lang}
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):
# TEMPORARY HACK: Look for multiple instance of the

View File

@ -128,6 +128,11 @@ class EnclosureAPI:
"""Restore the eyes to their default (ready) state."""
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):
"""Make the eyes 'roll' for the given time.
Args:

View File

@ -1 +1 @@
SYNC CLOCK...
< < < SYNC < < <

View File

@ -0,0 +1 @@
< < < UPDATING < < <

View File

@ -105,10 +105,13 @@ def check_connection():
if connected():
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
enclosure.mouth_text(mycroft.dialog.get("message_synching.clock"))
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
skew = abs((monotonic.monotonic() - start_ticks) -
@ -124,10 +127,10 @@ def check_connection():
# provide visual indicators of the reboot
enclosure.mouth_text(mycroft.dialog.get("message_rebooting"))
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
time.sleep(0.5)
time.sleep(1.0)
# reboot
ws.emit(Message("system.reboot"))
@ -143,6 +146,11 @@ def check_connection():
}
ws.emit(Message("recognizer_loop:utterance", payload))
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
api = DeviceApi()
api.update_version()