-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathboot.py
More file actions
39 lines (33 loc) · 1010 Bytes
/
boot.py
File metadata and controls
39 lines (33 loc) · 1010 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
36
37
38
39
import sota
import machine
import network
import time
from machine import Pin
status_led = Pin(2, Pin.OUT)
wlan = network.WLAN(network.STA_IF)
wlan.active(True)
GITHUB_URL = "https://raw.githubusercontent.com/macraj/upyota/master"
OTA = sota.Senko(None, None, url=GITHUB_URL, files=["boot.py", "main.py"])
# Connect to Wi-Fi network.
def sta_connect():
if not wlan.isconnected():
# connecting to network...
wlan.connect("ray-S", "D75AB729AS7")
ctime = time.time()
while not wlan.isconnected():
if time.time() - ctime > 30:
# print('WLAN timeout!')
return False
time.sleep(0.5)
status_led.value(not status_led.value())
return True
print('network config:', wlan.ifconfig())
sta_connect()
if OTA.update():
print("Updated to the latest version! Rebooting...")
machine.reset()
# if OTA.fetch():
# print("A newer version is available!")
# else:
# print("Up to date!")
OTA = None