-
Notifications
You must be signed in to change notification settings - Fork 0
/
boot.py
46 lines (40 loc) · 1021 Bytes
/
boot.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# This file is executed on every boot (including wake-boot from deepsleep)
#import esp
#esp.osdebug(None)
import machine
#uos.dupterm(None, 1) # disable REPL on UART(0)
import gc
import webrepl
import network
import os
import time
webrepl.start()
gc.collect()
machine.freq(160000000)
print("boot from memory...")
SSID=[put your own wifi ssid here]
PASSWD=[put maches passwd here]
wlan=network.WLAN(network.STA_IF)
wlan.active(True)
print(wlan.scan())
which=0
while not wlan.isconnected():
if which>=len(SSID):
which=0
t=0
while t<5 and not wlan.isconnected():
print("connecting",SSID[which])
wlan.connect(SSID[which],PASSWD[which])
if wlan.isconnected():
break
t=t+1
time.sleep(5)
if not wlan.isconnected():
print("conn fail,SSID:",SSID[which],wlan.isconnected())
else:
break
time.sleep(5)
which=which+1
print("network config:\n",wlan.ifconfig())
from main import main
main(wlan,SSID,PASSWD)