Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/ap_templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ <h2>Network</h2>
<label for="password">Password</label>
<input type="password" id="password" name="password" placeholder="Password">
</div>
<div style="margin-top:0.5rem;">
<input type="hidden" name="save" value="">
<input type="checkbox" id="save" name="save" value="save">
<label for="save" title="save the network settings in plaintext on device">save</label><br>
</div>
</div>
<hr />
<div>
Expand Down
26 changes: 14 additions & 12 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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,
Expand Down