To answer Hugo’s questions.
When I get a missing bssid, I get a runtime error, because I didn’t expect it. I’m now coding around that.
At the point that I see the trouble, the device is still reporting as connected (server.isconnected() is true, (“active” in imp.net.info()) is true). However, the onunexpecteddisconnection() event is still up to 60s away.
I think I know what is happening here.
Back when I was using imp.getbssid(), it would either return the bssid, or 12 zeroes to indicate that it had lost contact with the base station. The zeros could happen even when server.connected() still returned true. This is an early warning that the connection was about to be lost. I assumed that I should look for 12 zeroes when inspecting the wifi interface returned from imp.net.info(). Instead, the bssid field is simply not there. This can still happen (if only for a brief moment) when server.isconnected() is still true and even when an active interface is still reported.