mirror of
https://github.com/OpenVoiceOS/OpenVoiceOS
synced 2025-02-09 08:28:50 +01:00
Upgrade wifi-connect methodology + skill (wip)
This commit is contained in:
parent
2b7ea2deb9
commit
9b6bd35506
5
.gitmodules
vendored
5
.gitmodules
vendored
@ -12,3 +12,8 @@
|
||||
path = buildroot-external/rootfs-overlay/opt/mycroft/skills/skill-mycroftos-gui
|
||||
url = https://github.com/j1nx/skill-mycroftos-gui.git
|
||||
branch = master
|
||||
|
||||
[submodule "skill-balena-wifi-setup"]
|
||||
path = buildroot-external/rootfs-overlay/opt/mycroft/skills/skill-balena-wifi-setup
|
||||
url = https://github.com/OpenVoiceOS/skill-balena-wifi-setup.git
|
||||
branch = master
|
||||
|
@ -20,7 +20,7 @@ index 3afad7a..456fb67 100644
|
||||
-const DEFAULT_SSID: &str = "WiFi Connect";
|
||||
+const DEFAULT_GATEWAY: &str = "172.16.127.1";
|
||||
+const DEFAULT_DHCP_RANGE: &str = "172.16.127.2,172.16.127.27";
|
||||
+const DEFAULT_SSID: &str = "MYCROFT";
|
||||
+const DEFAULT_SSID: &str = "OpenVoiceOS";
|
||||
const DEFAULT_ACTIVITY_TIMEOUT: &str = "0";
|
||||
const DEFAULT_UI_DIRECTORY: &str = "ui";
|
||||
const DEFAULT_LISTENING_PORT: &str = "80";
|
||||
|
@ -1,14 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
export DBUS_SYSTEM_BUS_ADDRESS=unix:path=/run/dbus/system_bus_socket
|
||||
sleep 15
|
||||
|
||||
iwgetid -r
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
printf 'Skipping WiFi Connect\n'
|
||||
else
|
||||
printf 'Starting WiFi Connect\n'
|
||||
/usr/local/sbin/wifi-connect
|
||||
fi
|
||||
|
||||
rm /etc/wifi-connect
|
@ -32,12 +32,4 @@ define WIFI_CONNECT_INSTALL_TARGET_CMDS
|
||||
$(TARGET_DIR)/usr/local/sbin/wifi-connect
|
||||
endef
|
||||
|
||||
define WIFI_CONNECT_INSTALL_INIT_SYSTEMD
|
||||
$(INSTALL) -D -m 0644 $(BR2_EXTERNAL_OPENVOICEOS_PATH)/package/wifi-connect/wifi-connect.service \
|
||||
$(TARGET_DIR)/usr/lib/systemd/system/wifi-connect.service
|
||||
$(INSTALL) -D -m 0755 $(BR2_EXTERNAL_OPENVOICEOS_PATH)/package/wifi-connect/start-wifi-connect \
|
||||
$(TARGET_DIR)/usr/local/sbin/start-wifi-connect
|
||||
touch $(TARGET_DIR)/etc/wifi-connect
|
||||
endef
|
||||
|
||||
$(eval $(generic-package))
|
||||
|
@ -1,12 +0,0 @@
|
||||
[Unit]
|
||||
Description=OpenVoiceOS wifi-connect service
|
||||
After=NetworkManager.service
|
||||
ConditionPathIsReadWrite=/etc
|
||||
ConditionPathExists=/etc/wifi-connect
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStart=/usr/local/sbin/start-wifi-connect
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
5
buildroot-external/rootfs-overlay/opt/mycroft/skills/skill-balena-wifi-setup/.gitignore
vendored
Normal file
5
buildroot-external/rootfs-overlay/opt/mycroft/skills/skill-balena-wifi-setup/.gitignore
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
__pycache__/
|
||||
*.qmlc
|
||||
*.idea
|
||||
settings.json
|
||||
|
@ -0,0 +1,202 @@
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
@ -0,0 +1,21 @@
|
||||
# <img src="https://raw.githack.com/FortAwesome/Font-Awesome/master/svgs/solid/wifi.svg" card_color="#40DBB0" width="50" height="50" style="vertical-align:bottom"/> Wifi Connect
|
||||
Connect your mycroft device to Wifi
|
||||
|
||||
## About
|
||||
Provides the audio and visual elements for Connecting to Wifi via a secondary mobile device or computer.
|
||||
|
||||
## Examples
|
||||
|
||||
## Credits
|
||||
JarbasAI
|
||||
|
||||
## Category
|
||||
**Configuration**
|
||||
|
||||
## Tags
|
||||
#Wifi
|
||||
#Network
|
||||
#Internet
|
||||
#Connection
|
||||
#Connect
|
||||
|
@ -0,0 +1,277 @@
|
||||
from mycroft import MycroftSkill, intent_handler
|
||||
from mycroft.util import create_daemon, connected
|
||||
from mycroft.configuration import LocalConf, USER_CONFIG
|
||||
import subprocess
|
||||
import pexpect
|
||||
from time import sleep
|
||||
|
||||
|
||||
class WifiConnect(MycroftSkill):
|
||||
def __init__(self):
|
||||
MycroftSkill.__init__(self)
|
||||
self.monitoring = False
|
||||
self.in_setup = False
|
||||
self.wifi_process = None
|
||||
self.debug = False # dev setting, VERY VERBOSE DIALOGS
|
||||
# TODO skill settings
|
||||
self.ssid = "OVOS"
|
||||
self.pswd = None
|
||||
self.time_between_checks = 30 # seconds
|
||||
self.wifi_command = "sudo /usr/local/sbin/wifi-connect --portal-ssid {ssid}"
|
||||
if self.pswd:
|
||||
self.wifi_command += " --portal-passphrase {pswd}"
|
||||
|
||||
def initialize(self):
|
||||
self.make_priority()
|
||||
self.add_event("mycroft.internet.connected",
|
||||
self.handle_internet_connected)
|
||||
self.start_internet_check()
|
||||
|
||||
def make_priority(self):
|
||||
if not self.skill_id:
|
||||
# might not be set yet....
|
||||
return
|
||||
# load the current list of already blacklisted skills
|
||||
priority_list = self.config_core["skills"]["priority_skills"]
|
||||
|
||||
# add the skill to the blacklist
|
||||
if self.skill_id not in priority_list:
|
||||
priority_list.insert(0, self.skill_id)
|
||||
|
||||
# load the user config file (~/.mycroft/mycroft.conf)
|
||||
conf = LocalConf(USER_CONFIG)
|
||||
if "skills" not in conf:
|
||||
conf["skills"] = {}
|
||||
|
||||
# update the blacklist field
|
||||
conf["skills"]["priority_skills"] = priority_list
|
||||
|
||||
# save the user config file
|
||||
conf.store()
|
||||
|
||||
# internet watchdog
|
||||
def start_internet_check(self):
|
||||
create_daemon(self._watchdog)
|
||||
|
||||
def stop_internet_check(self):
|
||||
self.monitoring = False
|
||||
|
||||
def _watchdog(self):
|
||||
self.monitoring = True
|
||||
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!!")
|
||||
sleep(self.time_between_checks)
|
||||
|
||||
# wifi setup
|
||||
@staticmethod
|
||||
def get_wifi_ssid():
|
||||
SSID = None
|
||||
try:
|
||||
SSID = subprocess.check_output(["iwgetid", "-r"]).strip()
|
||||
except subprocess.CalledProcessError:
|
||||
# If there is no connection subprocess throws a 'CalledProcessError'
|
||||
pass
|
||||
return SSID
|
||||
|
||||
@staticmethod
|
||||
def is_connected_to_wifi():
|
||||
return WifiConnect.get_wifi_ssid() is not None
|
||||
|
||||
def launch_wifi_setup(self):
|
||||
self.stop_setup()
|
||||
self.in_setup = True
|
||||
self.wifi_process = pexpect.spawn(
|
||||
self.wifi_command.format(ssid=self.ssid)
|
||||
)
|
||||
# https://github.com/pexpect/pexpect/issues/462
|
||||
self.wifi_process.delayafterclose = 1
|
||||
self.wifi_process.delayafterterminate = 1
|
||||
prev = ""
|
||||
restart = False
|
||||
if self.debug:
|
||||
self.speak_dialog("start_setup")
|
||||
while self.in_setup:
|
||||
try:
|
||||
out = self.wifi_process.readline().decode("utf-8").strip()
|
||||
if out == prev:
|
||||
continue
|
||||
prev = out
|
||||
if out.startswith("Access points: "):
|
||||
aps = list(out.split("Access points: ")[-1])
|
||||
self.log.info(out)
|
||||
if self.debug:
|
||||
self.speak_dialog("wifi_scanned")
|
||||
elif out.startswith("Starting access point..."):
|
||||
if self.debug:
|
||||
self.speak_dialog("ap_start")
|
||||
elif out.startswith("Access point ") and \
|
||||
out.endswith("created"):
|
||||
self.prompt_to_join_ap()
|
||||
if self.debug:
|
||||
self.speak_dialog("ap_created")
|
||||
elif out.startswith("Starting HTTP server on"):
|
||||
self.log.debug(out)
|
||||
if self.debug:
|
||||
self.speak_dialog("http_started")
|
||||
elif out.startswith("Stopping access point"):
|
||||
if self.debug:
|
||||
self.speak_dialog("ap_stop")
|
||||
elif out.startswith("Access point ") and \
|
||||
out.endswith("stopped"):
|
||||
if self.debug:
|
||||
self.speak_dialog("ap_stopped")
|
||||
elif out == "User connected to the captive portal":
|
||||
self.log.info(out)
|
||||
self.prompt_to_select_network()
|
||||
if self.debug:
|
||||
self.speak_dialog("user_connected")
|
||||
elif out.startswith("Connecting to access point"):
|
||||
if self.debug:
|
||||
self.speak_dialog("connecting")
|
||||
elif out.startswith("Internet connectivity established"):
|
||||
self.log.info(out)
|
||||
self.report_setup_complete()
|
||||
if self.debug:
|
||||
self.speak_dialog("wifi_connected")
|
||||
elif "Error" in out or "[Errno" in out:
|
||||
self.log.error(out)
|
||||
self.report_setup_failed()
|
||||
|
||||
# TODO figure out at least the errors handled gracefully
|
||||
accepted_errors = [
|
||||
"Password length should be at least 8 characters"
|
||||
]
|
||||
for e in accepted_errors:
|
||||
if e in out:
|
||||
continue
|
||||
else:
|
||||
restart = True
|
||||
break
|
||||
|
||||
if self.debug:
|
||||
self.log.debug(out)
|
||||
except pexpect.exceptions.EOF:
|
||||
# exited
|
||||
self.log.info("Exited wifi setup process")
|
||||
break
|
||||
except pexpect.exceptions.TIMEOUT:
|
||||
# nothing happened for a while
|
||||
pass
|
||||
except KeyboardInterrupt:
|
||||
break
|
||||
except Exception as e:
|
||||
self.log.exception(e)
|
||||
break
|
||||
self.stop_setup()
|
||||
if restart:
|
||||
# handle bugs in balena, sometimes it fails to come back up
|
||||
# seems to happen on
|
||||
# Error: Getting access points failed
|
||||
self.launch_wifi_setup()
|
||||
elif self.debug:
|
||||
self.speak_dialog("end_setup")
|
||||
|
||||
# intents
|
||||
@intent_handler("launch_setup.intent")
|
||||
def wifi_intent(self, message):
|
||||
self.launch_wifi_setup()
|
||||
|
||||
# bus events
|
||||
def handle_internet_connected(self, message=None):
|
||||
"""System came online later after booting."""
|
||||
self.enclosure.mouth_reset()
|
||||
self.stop_setup() # just in case
|
||||
self.gui.release()
|
||||
|
||||
# GUI events
|
||||
def prompt_to_join_ap(self, message=None):
|
||||
"""Provide instructions for setting up wifi."""
|
||||
self.gui.remove_page("status.qml")
|
||||
self.gui["phone_image"] = "1_phone_connect-to-ap.png"
|
||||
self.gui["prompt"] = "Connect to the \nWifi network"
|
||||
self.gui["highlight"] = self.ssid
|
||||
self.gui.show_page("prompt.qml")
|
||||
# allow GUI to linger around for a bit, will block the wifi setup loop
|
||||
sleep(2)
|
||||
|
||||
def prompt_to_select_network(self, message=None):
|
||||
"""Prompt user to select network and login."""
|
||||
self.gui.remove_page("status.qml")
|
||||
self.gui.clear()
|
||||
self.gui["phone_image"] = "3_phone_choose-wifi.png"
|
||||
self.gui["prompt"] = "Choose the \nWifi network to \nconnect your \ndevice"
|
||||
self.gui["highlight"] = ""
|
||||
self.gui.show_page("prompt.qml")
|
||||
# allow GUI to linger around for a bit, will block the wifi setup loop
|
||||
sleep(2)
|
||||
|
||||
def report_setup_complete(self, message=None):
|
||||
"""Wifi setup complete, network is connected."""
|
||||
self.gui.remove_page("prompt.qml")
|
||||
self.gui.clear()
|
||||
self.gui["icon"] = "check-circle.svg"
|
||||
self.gui["label"] = "Connected"
|
||||
self.gui["bgColor"] = "#40DBB0"
|
||||
self.gui.remove_page("prompt.qml")
|
||||
self.gui.show_page("status.qml")
|
||||
# allow GUI to linger around for a bit, will block the wifi setup loop
|
||||
sleep(3)
|
||||
self.gui.release()
|
||||
|
||||
def report_setup_failed(self, message=None):
|
||||
"""Wifi setup failed"""
|
||||
self.speak_dialog("wifi_error")
|
||||
self.gui.remove_page("prompt.qml")
|
||||
self.gui.clear()
|
||||
self.gui["icon"] = "times-circle.svg"
|
||||
self.gui["label"] = "Connection Failed"
|
||||
self.gui["bgColor"] = "#FF0000"
|
||||
self.gui.show_page("status.qml")
|
||||
# allow GUI to linger around for a bit, will block the wifi setup loop
|
||||
sleep(2)
|
||||
|
||||
# cleanup
|
||||
def stop_setup(self):
|
||||
if self.wifi_process is not None:
|
||||
try:
|
||||
if self.wifi_process.isalive():
|
||||
self.log.debug("terminating wifi setup process")
|
||||
self.wifi_process.sendcontrol('c')
|
||||
sleep(1)
|
||||
self.wifi_process.close()
|
||||
sleep(1)
|
||||
if self.wifi_process.isalive():
|
||||
self.log.warning('wifi setup did not exit gracefully.')
|
||||
self.wifi_process.close(force=True)
|
||||
sleep(1)
|
||||
if self.wifi_process.isalive():
|
||||
self.log.warning('trying to terminate wifi setup process')
|
||||
self.wifi_process.terminate()
|
||||
sleep(1)
|
||||
else:
|
||||
self.log.debug('wifi setup exited gracefully.')
|
||||
except Exception as e:
|
||||
self.log.exception(e)
|
||||
self.wifi_process = None
|
||||
self.in_setup = False
|
||||
|
||||
def shutdown(self):
|
||||
self.monitoring = False
|
||||
self.stop_setup()
|
||||
|
||||
|
||||
def create_skill():
|
||||
return WifiConnect()
|
@ -0,0 +1 @@
|
||||
access point created
|
@ -0,0 +1 @@
|
||||
starting captive portal
|
@ -0,0 +1 @@
|
||||
stopping captive portal
|
@ -0,0 +1 @@
|
||||
captive portal stopped
|
@ -0,0 +1 @@
|
||||
Connecting to selected wifi, see logs
|
@ -0,0 +1 @@
|
||||
wifi setup finished
|
@ -0,0 +1 @@
|
||||
started http server
|
@ -0,0 +1,4 @@
|
||||
launch wifi connect
|
||||
launch wifi setup
|
||||
change wifi network
|
||||
add wifi network
|
@ -0,0 +1 @@
|
||||
wifi setup started
|
@ -0,0 +1 @@
|
||||
user connected to captive portal
|
@ -0,0 +1 @@
|
||||
Connected to wifi
|
@ -0,0 +1 @@
|
||||
failed to connect to wifi, verify credentials and try again
|
@ -0,0 +1 @@
|
||||
I have scanned for access points, see logs for results
|
@ -0,0 +1 @@
|
||||
pexpect
|
Binary file not shown.
After Width: | Height: | Size: 13 KiB |
Binary file not shown.
After Width: | Height: | Size: 18 KiB |
@ -0,0 +1,52 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
inkscape:version="0.92.3 (2405546, 2018-03-11)"
|
||||
sodipodi:docname="check-circle.svg"
|
||||
id="svg4"
|
||||
version="1.1"
|
||||
viewBox="0 0 512 512">
|
||||
<metadata
|
||||
id="metadata10">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<defs
|
||||
id="defs8" />
|
||||
<sodipodi:namedview
|
||||
inkscape:current-layer="svg4"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:window-y="30"
|
||||
inkscape:window-x="0"
|
||||
inkscape:cy="255.3616"
|
||||
inkscape:cx="157.36658"
|
||||
inkscape:zoom="1.5664062"
|
||||
showgrid="false"
|
||||
id="namedview6"
|
||||
inkscape:window-height="1017"
|
||||
inkscape:window-width="1920"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:pageopacity="0"
|
||||
guidetolerance="10"
|
||||
gridtolerance="10"
|
||||
objecttolerance="10"
|
||||
borderopacity="1"
|
||||
bordercolor="#666666"
|
||||
pagecolor="#ffffff" />
|
||||
<path
|
||||
style="fill:#ffffff;fill-opacity:1"
|
||||
id="path2"
|
||||
d="M504 256c0 136.967-111.033 248-248 248S8 392.967 8 256 119.033 8 256 8s248 111.033 248 248zM227.314 387.314l184-184c6.248-6.248 6.248-16.379 0-22.627l-22.627-22.627c-6.248-6.249-16.379-6.249-22.628 0L216 308.118l-70.059-70.059c-6.248-6.248-16.379-6.248-22.628 0l-22.627 22.627c-6.248 6.248-6.248 16.379 0 22.627l104 104c6.249 6.249 16.379 6.249 22.628.001z" />
|
||||
</svg>
|
After Width: | Height: | Size: 1.8 KiB |
@ -0,0 +1,52 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
viewBox="0 0 512 512"
|
||||
version="1.1"
|
||||
id="svg4"
|
||||
sodipodi:docname="info-circle.svg"
|
||||
inkscape:version="0.92.3 (2405546, 2018-03-11)">
|
||||
<metadata
|
||||
id="metadata10">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<defs
|
||||
id="defs8" />
|
||||
<sodipodi:namedview
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1"
|
||||
objecttolerance="10"
|
||||
gridtolerance="10"
|
||||
guidetolerance="10"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:window-width="724"
|
||||
inkscape:window-height="480"
|
||||
id="namedview6"
|
||||
showgrid="false"
|
||||
inkscape:zoom="0.4609375"
|
||||
inkscape:cx="256"
|
||||
inkscape:cy="256"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-y="30"
|
||||
inkscape:window-maximized="0"
|
||||
inkscape:current-layer="svg4" />
|
||||
<path
|
||||
d="M256 8C119.043 8 8 119.083 8 256c0 136.997 111.043 248 248 248s248-111.003 248-248C504 119.083 392.957 8 256 8zm0 448c-110.532 0-200-89.431-200-200 0-110.495 89.472-200 200-200 110.491 0 200 89.471 200 200 0 110.53-89.431 200-200 200zm0-338c23.196 0 42 18.804 42 42s-18.804 42-42 42-42-18.804-42-42 18.804-42 42-42zm56 254c0 6.627-5.373 12-12 12h-88c-6.627 0-12-5.373-12-12v-24c0-6.627 5.373-12 12-12h12v-64h-12c-6.627 0-12-5.373-12-12v-24c0-6.627 5.373-12 12-12h64c6.627 0 12 5.373 12 12v100h12c6.627 0 12 5.373 12 12v24z"
|
||||
id="path2"
|
||||
style="fill:#ffffff" />
|
||||
</svg>
|
After Width: | Height: | Size: 2.0 KiB |
@ -0,0 +1,52 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
inkscape:version="0.92.3 (2405546, 2018-03-11)"
|
||||
sodipodi:docname="times-circle.svg"
|
||||
id="svg4"
|
||||
version="1.1"
|
||||
viewBox="0 0 512 512">
|
||||
<metadata
|
||||
id="metadata10">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<defs
|
||||
id="defs8" />
|
||||
<sodipodi:namedview
|
||||
inkscape:current-layer="svg4"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:window-y="30"
|
||||
inkscape:window-x="0"
|
||||
inkscape:cy="255.3616"
|
||||
inkscape:cx="157.36658"
|
||||
inkscape:zoom="1.5664062"
|
||||
showgrid="false"
|
||||
id="namedview6"
|
||||
inkscape:window-height="1017"
|
||||
inkscape:window-width="1920"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:pageopacity="0"
|
||||
guidetolerance="10"
|
||||
gridtolerance="10"
|
||||
objecttolerance="10"
|
||||
borderopacity="1"
|
||||
bordercolor="#666666"
|
||||
pagecolor="#ffffff" />
|
||||
<path
|
||||
style="fill:#ffffff;fill-opacity:1"
|
||||
id="path2"
|
||||
d="M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm121.6 313.1c4.7 4.7 4.7 12.3 0 17L338 377.6c-4.7 4.7-12.3 4.7-17 0L256 312l-65.1 65.6c-4.7 4.7-12.3 4.7-17 0L134.4 338c-4.7-4.7-4.7-12.3 0-17l65.6-65-65.6-65.1c-4.7-4.7-4.7-12.3 0-17l39.6-39.6c4.7-4.7 12.3-4.7 17 0l65 65.7 65.1-65.6c4.7-4.7 12.3-4.7 17 0l39.6 39.6c4.7 4.7 4.7 12.3 0 17L312 256l65.6 65.1z" />
|
||||
</svg>
|
After Width: | Height: | Size: 1.8 KiB |
@ -0,0 +1,78 @@
|
||||
/*
|
||||
* Copyright 2018 by Aditya Mehra <aix.m@outlook.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
import QtQuick.Layouts 1.4
|
||||
import QtQuick 2.4
|
||||
import QtQuick.Controls 2.0
|
||||
import org.kde.kirigami 2.4 as Kirigami
|
||||
|
||||
import Mycroft 1.0 as Mycroft
|
||||
|
||||
Mycroft.ProportionalDelegate {
|
||||
id: root
|
||||
property var spacingUnit: 30
|
||||
property var phone: sessionData.phone_image
|
||||
property var prompt: sessionData.prompt
|
||||
property var highlight: sessionData.highlight
|
||||
|
||||
Row {
|
||||
spacing: spacingUnit
|
||||
Image {
|
||||
id: img
|
||||
source: Qt.resolvedUrl(phone)
|
||||
Layout.fillHeight: true
|
||||
height: root.height * 0.8
|
||||
fillMode: Image.PreserveAspectFit
|
||||
verticalAlignment: Image.AlignBottom
|
||||
anchors.bottom: parent.bottom
|
||||
}
|
||||
ColumnLayout {
|
||||
Kirigami.Heading {
|
||||
id: sentence
|
||||
Layout.fillWidth: true
|
||||
Layout.alignment: Qt.AlignLeft
|
||||
Layout.leftMargin: spacingUnit
|
||||
Layout.topMargin: 80
|
||||
horizontalAlignment: Text.AlignHLeft
|
||||
wrapMode: Text.WordWrap
|
||||
elide: Text.ElideRight
|
||||
font.family: "Noto Sans"
|
||||
font.bold: true
|
||||
font.weight: Font.Bold
|
||||
font.pixelSize: 38
|
||||
visible: !content.visible
|
||||
text: prompt
|
||||
}
|
||||
Kirigami.Heading {
|
||||
id: url
|
||||
Layout.fillWidth: true
|
||||
Layout.alignment: Qt.AlignLeft
|
||||
Layout.leftMargin: spacingUnit
|
||||
horizontalAlignment: Text.AlignHLeft
|
||||
wrapMode: Text.WordWrap
|
||||
elide: Text.ElideRight
|
||||
font.family: "Noto Sans"
|
||||
font.bold: true
|
||||
font.weight: Font.Bold
|
||||
font.pixelSize: 36
|
||||
visible: !content.visible
|
||||
color: "#22a7f0"
|
||||
text: highlight
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
import QtQuick.Layouts 1.4
|
||||
import QtQuick 2.4
|
||||
import QtQuick.Controls 2.0
|
||||
import org.kde.kirigami 2.4 as Kirigami
|
||||
|
||||
import Mycroft 1.0 as Mycroft
|
||||
|
||||
Mycroft.ProportionalDelegate {
|
||||
id: root
|
||||
skillBackgroundColorOverlay: sessionData.bgColor
|
||||
|
||||
ColumnLayout {
|
||||
id: grid
|
||||
anchors.centerIn: parent
|
||||
|
||||
Image {
|
||||
id: statusIcon
|
||||
visible: true
|
||||
enabled: true
|
||||
anchors.horizontalCenter: grid.horizontalCenter
|
||||
Layout.preferredWidth: proportionalGridUnit * 50
|
||||
Layout.preferredHeight: proportionalGridUnit * 50
|
||||
source: Qt.resolvedUrl(`icons/${sessionData.icon}`)
|
||||
}
|
||||
|
||||
/* Add some spacing between icon and text */
|
||||
Item {
|
||||
height: Kirigami.Units.largeSpacing
|
||||
}
|
||||
|
||||
Label {
|
||||
id: statusLabel
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
font.pixelSize: 65
|
||||
wrapMode: Text.WordWrap
|
||||
renderType: Text.NativeRendering
|
||||
font.family: "Noto Sans Display"
|
||||
font.styleName: "Black"
|
||||
font.capitalization: Font.AllUppercase
|
||||
text: sessionData.label
|
||||
color: "white"
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user