-
Notifications
You must be signed in to change notification settings - Fork 83
/
main.py
31 lines (24 loc) · 869 Bytes
/
main.py
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
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/rdehuyss/micropython-ota-updater', 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()