I set a ESP8266 D1 pro to scan and test functionality of few wifi AP's in the building.
I need to test both wifi connection and internet availability in separate way .
Basically the system works except the following:
if I disconnect the internet cable from the AP while its wifi is active, the sta_if routine says that wifi is not available; on the other hand, sta_if.scan() shows the wifi ssid.
Code: Select all
oldtime = utime.ticks_ms() station.active(True) station.connect(SSID, PW) try: while not station.isconnected(): p2.off() lapse = utime.ticks_diff(utime.ticks_ms(), oldtime)/1000 if lapse > 20: raise Exception("niente WiFi") continue if station.isconnected(): lista[FLAG+1]="WIFI_SI" msg1="wifi connesso" pingo() except Exception as e: msg1="niente wifi" lista[FLAG+1]="WIFI_NO" pingo() station.disconnect() p2.on()
I'm sure I'm wrong somewhere but: where?