Took a while but traced it down to this:
wifi = WLAN(WLAN.STA)
wifi would still be in WLAN.AP mode and subsequent attempts to connect would error. This is working now:
wifi = WLAN()
wifi.mode(WLAN.STA)
wifi.ifconfig( your network parameters )
wifi.connect( your ap parameters )
I always say, you learn the most by troubleshooting
