-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
35 lines (28 loc) · 896 Bytes
/
main.py
File metadata and controls
35 lines (28 loc) · 896 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
def connectToWifiAndUpdate():
import time, machine, network, gc, app.secrets as secrets
time.sleep(1)
print("Memory free", gc.mem_free())
from app.ota_updater import OTAUpdater
sta_if = network.WLAN(network.STA_IF)
if not sta_if.isconnected():
print("connecting to network...")
sta_if.active(True)
sta_if.connect(secrets.WIFI_SSID, secrets.WIFI_PASSWORD)
while not sta_if.isconnected():
pass
print("network config:", sta_if.ifconfig())
otaUpdater = OTAUpdater(
"https://github.com/FunPythonEC/fish_tank_lights",
main_dir="app",
secrets_file="secrets.py",
)
hasUpdated = otaUpdater.install_update_if_available()
if hasUpdated:
machine.reset()
else:
del otaUpdater
gc.collect()
def startApp():
import app.start
connectToWifiAndUpdate()
startApp()