-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathboot.py
54 lines (46 loc) · 1.23 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
import time
import utime
import network
import webrepl
import get_sensor_info
import send
# WIFI設定を記述
SSID_NAME = "*****"
SSID_PASS = "*****"
REPL_PASS = "1234"
def connect_wifi(ssid, passkey, timeout=10):
wifi= network.WLAN(network.STA_IF)
if wifi.isconnected():
print('already Connected. connect skip')
return wifi
else :
wifi.active(True)
count = 0
while count < 5:
try:
wifi.connect(ssid, passkey)
break
except:
utime.sleep(3)
count += 1
while not wifi.isconnected() and timeout > 0:
print('.')
utime.sleep(1)
timeout -= 1
if wifi.isconnected():
print('Connected')
webrepl.start(password=REPL_PASS)
return wifi
else:
print('Connection failed!')
return ''
def main():
wifi= network.WLAN(network.STA_IF)
if wifi.isconnected():
connect_wifi(SSID_NAME, SSID_PASS)
else:
connect_wifi(SSID_NAME, SSID_PASS)
send.send_start_time()
file_info = get_sensor_info.main()
if __name__ == '__main__':
main()