Skip to content
Snippets Groups Projects

Add w1f1 app & replace wifi in settings menu

Merged ave requested to merge ave/flow3r-firmware:add-wifi-app into main
5 unresolved threads
2 files
+ 9
4
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -13,6 +13,7 @@ from .k3yboard import TextInputModel, KeyboardView
class WifiApp(Application):
WIFI_CONFIG_FILE = "/flash/w1f1_config.json"
SETTINGS_JSON_FILE = "/flash/settings.json"
def __init__(self, app_ctx: ApplicationContext) -> None:
super().__init__(app_ctx)
@@ -140,8 +141,12 @@ class WifiApp(Application):
print(self._nearby_wlans)
def update_settings_json(self, ssid: str, psk: str) -> None:
with open("/flash/settings.json") as f:
settings_json = json.load(f)
# weirdo case
if os.path.exists(self.SETTINGS_JSON_FILE):
with open(self.SETTINGS_JSON_FILE) as f:
settings_json = json.load(f)
else:
settings_json = {"system": {}}
if "wifi" not in settings_json["system"]:
settings_json["system"]["wifi"] = {
@@ -156,7 +161,7 @@ class WifiApp(Application):
settings_json["system"]["wifi"]["ssid"] = ssid
settings_json["system"]["wifi"]["psk"] = psk
with open("/flash/settings.json", "w") as f:
with open(self.SETTINGS_JSON_FILE, "w") as f:
json.dump(settings_json, f)
def add_to_config_json(self, ssid: str, psk: str) -> None:
Loading