# This file is executed on every boot (including wake-boot from deepsleep)
#import esp
#esp.osdebug(None)
#import webrepl

default_ssid = "SSID"
default_pw = "PASSWORD"


def connect(ssid=default_ssid, password=default_pw):
    import network
    wlan = network.WLAN(network.STA_IF)
    wlan.active(True)
    if not wlan.isconnected():
        print('connecting to network...')
        wlan.connect(ssid, password)
        # while the below while loop is part of the standard recommended approach,
        # I found it could hang the device if run with connect() on boot
        while not wlan.isconnected():
            pass
    print('network config:', wlan.ifconfig())

def showip():
    import network
    wlan = network.WLAN(network.STA_IF)
    print('network config:', wlan.ifconfig())


#webrepl.start()

# the connect() line can be uncommented if you want the ESP to connect
# to WiFi automatically when it boots. If you uncomment this, be sure
# you have tested it first with your network.
#
# connect()
