local function wait_for_connection(timeout_ms) local start = tmr.now() local now local timeout = timeout_ms * 1000 repeat local ip = wifi.sta.getip() print("ip="..tostring(ip)) if ip then -- and ip ~= "0.0.0.0" then return ip end tmr.wdclr() now = tmr.now() until (now - start) > timeout return false end function wlan_init(ssid, password) print("WLAN: connecting to SSID:"..ssid..", password="..password) wifi.setmode(wifi.STATION) wifi.sta.config(ssid, password) local ip = wait_for_connection(10 * 1000) if not ip then panic("Could not establish wlan connection, restarting") end print("WLAN: Configured, ip="..ip) end