Basically I query google.com, and if I got an empty string it means that i'm not connected to the internet (or google is down ) then reconnect
if wget("www.google.com") == "" then
gosub [reconnect]
....
[reconnect]
dim c_inf(2) as string
c_inf(1) = read("WIFIname")
c_inf(2) = read("WIFIpass")
wifi.connect(c_inf(1),c_inf(2))
undim c_inf
return
Not sure if is the best method..