From cdcb501342fedc83cfe332a25f2b9a8839c4822b Mon Sep 17 00:00:00 2001
From: pewapp <31062770+pewapp@users.noreply.github.com>
Date: Sat, 8 Mar 2025 00:03:29 +0100
Subject: [PATCH] user can choose if settings are saved or cleared after setup
---
src/ap_templates/index.html | 5 +++++
src/main.py | 26 ++++++++++++++------------
2 files changed, 19 insertions(+), 12 deletions(-)
diff --git a/src/ap_templates/index.html b/src/ap_templates/index.html
index bc16bb5..da9295c 100644
--- a/src/ap_templates/index.html
+++ b/src/ap_templates/index.html
@@ -34,6 +34,11 @@
Network
+
+
+
+
+
diff --git a/src/main.py b/src/main.py
index 2bcad71..4d6a0b8 100644
--- a/src/main.py
+++ b/src/main.py
@@ -62,6 +62,8 @@ def application_mode():
print("Entering application mode.")
orangeClock.setSecrets(wifi_credentials["ssid"], wifi_credentials["password"])
orangeClock.setSelectDisplay(wifi_credentials["line1"], wifi_credentials["npub"], wifi_credentials["line2"])
+ if not wifi_credentials["save"]:
+ os.remove(WIFI_FILE)
orangeClock.main()
def app_index(request):
@@ -86,18 +88,18 @@ def app_catch_all(request):
# File was found, attempt to connect to wifi...
with open(WIFI_FILE) as f:
wifi_credentials = json.load(f)
- ip_address = connect_to_wifi(wifi_credentials["ssid"], wifi_credentials["password"])
-
- if not is_connected_to_wifi():
- # Bad configuration, delete the credentials file, reboot
- # into setup mode to get new credentials from the user.
- print("Bad wifi connection!")
- print(wifi_credentials)
- os.remove(WIFI_FILE)
- machine_reset()
-
- print(f"Connected to wifi, IP address {ip_address}")
- application_mode()
+ ip_address = connect_to_wifi(wifi_credentials["ssid"], wifi_credentials["password"])
+
+ if not is_connected_to_wifi():
+ # Bad configuration, delete the credentials file, reboot
+ # into setup mode to get new credentials from the user.
+ print("Bad wifi connection!")
+ print(wifi_credentials)
+ os.remove(WIFI_FILE)
+ machine_reset()
+
+ print(f"Connected to wifi, IP address {ip_address}")
+ application_mode()
except Exception as err:
# Either no wifi configuration file found, or something went wrong,