Wifi problem with release='1.20.2.rc9'
Our fipy has become reluctant to connect to wifi since we updated it to 1.20.2.rc9 While trying to find a reason for this new found reluctance to connect we stumbled across a problem with our wifi code
try: from network import WLAN wlan=WLAN(mode=WLAN.STA, antenna=WLAN.INT_ANT); nets=wlan.scan(); ss='??'; AP='our_router'; pwd='our_pwd' for net in nets: if AP==net: ss=net; print('ss =', ss) if not wlan.isconnected(): wlan.connect(AP, auth=(WLAN.WPA2, pwd), timeout=5000) while not wlan.isconnected(): pycom.rgbled(white); time.sleep(.5); pycom.rgbled(off); time.sleep(.5) print(' wifi connected') except TimeoutError as e: sys.print_exception as e
the problem is the code throws a 'TimeoutError: Connection to AP Timeout!' after 5s without connection but the except doesn't catch it, says TimeoutError is undefined. How can micropython throw an error that is undefined?
Thanks, I believe this is a bug that has gone unnoticed for a very long time. The timeouterror is defined in the C-interface only, but not ported over to a micropython object, meaning throwing the error works, as that happens in C, but reading it as a micropython object does not work. I now added it in micropython
I will submit the fix internally and it should be fixed by the next version!
Though, note that 1.20.2.rc9 is an older release, and, even though 1.20.2.r4 also has this bug, the next release will include the fix and we will no longer update the release candidates from the past.