-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathboot.py
42 lines (35 loc) · 1013 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
40
41
42
# This file is executed on every boot (including wake-boot from deepsleep)
print('Booting...')
#import uos
#uos.dupterm(None, 1) # disable REPL on UART(0)
from machine import Pin
# free up memory
import esp
esp.osdebug(None)
import gc
gc.collect()
#import webrepl
#webrepl.start()
import config
def ap_connect():
# open access point
ap = network.WLAN(network.AP_IF)
ap.active(True)
ap.config(essid=config.AP_SSID,
authmode=network.AUTH_WPA_WPA2_PSK,
password=config.AP_PASSWORD)
def wifi_connect():
# connect to wifi network / station interface
import network
sta_if = network.WLAN(network.STA_IF)
if not sta_if.isconnected():
print('Connecting to network...')
sta_if.active(True)
try:
sta_if.connect(config.WIFI_SSID, config.WIFI_PASSWORD)
except:
print("Defined SSID not found.")
while not sta_if.isconnected():
pass
print('Network config:', sta_if.ifconfig())
wifi_connect()