forked from rsalveti/esp8266
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathboot.py
31 lines (26 loc) · 768 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
#
# Copyright: Ricardo Salveti <[email protected]>
#
# SPDX-License-Identifier: MIT
def do_connect():
import network
import utils
import machine
config = utils.Config()
sta_if = network.WLAN(network.STA_IF)
ap_if = network.WLAN(network.AP_IF)
# On board LED
led = machine.Pin(2, machine.Pin.OUT)
if ap_if.active():
print("Disabling AP...");
ap_if.active(False)
if not sta_if.isconnected():
print("Connecting to the network...")
sta_if.active(True)
sta_if.connect(config.get("wifi_ssid"),
config.get("wifi_passwd"))
while not sta_if.isconnected():
pass
print("Network configuration: ", sta_if.ifconfig())
led.low()
do_connect()