-
Notifications
You must be signed in to change notification settings - Fork 37
/
boot.py
66 lines (44 loc) · 1.15 KB
/
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import gc
import webrepl
webrepl.start()
gc.collect()
import network
import time
import machine
sta_if = network.WLAN(network.STA_IF); sta_if.active(True)
try:
with open("passwords.txt") as f:
connections = f.readlines()
except OSError:
print("No passwords.txt file!")
connections = []
for connection in connections:
station, password = connection.split()
print("Connecting to {}.".format(station))
sta_if.connect(station, password)
for i in range(15):
print(".")
if sta_if.isconnected():
break
time.sleep(1)
if sta_if.isconnected():
break
else:
print("Connection could not be made.\n")
builtin_led = machine.Pin(16, machine.Pin.OUT)
def blink(length):
builtin_led.value(0)
time.sleep(length)
builtin_led.value(1)
if sta_if.isconnected():
ip = sta_if.ifconfig()[0].split('.')[3]
print("Connected as: {}".format(ip))
for digit in ip:
blink(.1)
time.sleep(.1)
blink(.1)
time.sleep(2)
for i in range(int(digit)):
blink(.5)
time.sleep(.5)
time.sleep(2)