Files
gardentron/pico-w/src/boot.py
2023-05-21 21:24:02 +02:00

23 lines
502 B
Python

import network
import time
from config import ssid, password
wlan = network.WLAN(network.STA_IF)
wlan.active(True)
wlan.connect(ssid, password)
max_wait = 10
while max_wait > 0:
if wlan.status() < 0 or wlan.status() >= 3:
break
max_wait -= 1
print('Attempting to connect to Wifi...')
time.sleep(1)
if wlan.status() != 3:
raise RuntimeError('Wifi connection failed')
else:
print('Wifi connection established')
status = wlan.ifconfig()
print('ip:' + status[0])