micropy-light/code/boot.py
Pierrick C 6f5a713150 Wifi
2018-11-18 23:15:25 +01:00

33 lines
723 B
Python

# This file is executed on every boot (including wake-boot from deepsleep)
#import esp
#esp.osdebug(None)
import gc
import time
import network
import webrepl
from wifi_config import known_wifi_ap
# Connect to one of the known wifi AP
interface = network.WLAN(network.STA_IF)
interface.active(True)
wifi_ap_list = interface.scan()
for ap in wifi_ap_list:
if interface.isconnected():
break
ap_ssid = ap[0].decode("utf-8")
if ap_ssid in known_wifi_ap.keys():
print("Known wifi network found : {}".format(ap_ssid))
print("Try to connect...")
interface.connect(ap_ssid, known_wifi_ap[ap_ssid])
# Wait for wifi
time.sleep(5)
webrepl.start()
print("Boot.py : Done")
gc.collect()