-
Notifications
You must be signed in to change notification settings - Fork 2
/
boot.py
39 lines (32 loc) · 941 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
import network
import utime
import ntptime
import urequests
import config
import webcam
# Connect to WiFi according to config file
def do_connect():
sta_if = network.WLAN(network.STA_IF)
start = utime.time()
timed_out = False
if not sta_if.isconnected():
print("connecting to network...")
sta_if.active(True)
sta_if.connect(config.wifi_config["ssid"],
config.wifi_config["password"])
while not sta_if.isconnected() and not timed_out:
if utime.time() - start >= 20:
timed_out = True
else:
pass
if sta_if.isconnected():
ntptime.settime()
print("network config:", sta_if.ifconfig())
r = urequests.get("http://icanhazip.com")
print(r.text)
else:
print("internet not available")
do_connect()
# Send a pic instead of running webcam
# webcam.run()
send_pic(ip_addr)