-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathboot.py
More file actions
29 lines (29 loc) · 737 Bytes
/
boot.py
File metadata and controls
29 lines (29 loc) · 737 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
from machine import Pin
import network
import time
def led_state():
p2 = Pin(2, Pin.OUT)
p2.value(0)
time.sleep_ms(500)
p2.value(1)
time.sleep_ms(500)
p2.value(0)
time.sleep_ms(500)
p2.value(1)
time.sleep_ms(500)
def do_connect():
sta_if = network.WLAN(network.STA_IF)
p2 = Pin(2, Pin.OUT)
sta_if.active(False)
if not sta_if.isconnected():
p2.value(0)
print('connecting to network...')
sta_if.active(True)
sta_if.connect('wifi_name', 'wifi_secret')
while not sta_if.isconnected():
pass
if sta_if.isconnected():
print('connect success')
led_state()
print('network config:', sta_if.ifconfig())
do_connect()