connecting to open wifi access point?

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
Capstan
Posts: 117
Joined: Sun Jan 29, 2017 4:03 pm
Location: Texas, USA

connecting to open wifi access point?

Post by Capstan » Mon Jan 30, 2017 4:44 pm

I can connect to access points that have passwords with no problem;
wlan.connect('theSSID', 'password')

However when I try this on an access point that doesn't have a password it doesn't ever seem to be connecting. As in wlan.isconnected() is always false. I am trying it with password as an empty string. Maybe that's not the right thing to do?

wlan.connect('theSSID', '')

KrishanCA
Posts: 12
Joined: Tue Jan 31, 2017 12:26 am

Re: connecting to open wifi access point?

Post by KrishanCA » Tue Jan 31, 2017 12:31 am

Did you try without any password.

Capstan
Posts: 117
Joined: Sun Jan 29, 2017 4:03 pm
Location: Texas, USA

Re: connecting to open wifi access point?

Post by Capstan » Tue Jan 31, 2017 2:15 pm

I've tried it with no password argument and it appears to loop inside the method and continuously trying to connect. With a blank password it does return, but remains in the 'connecting' state indefinitely.

User avatar
kfricke
Posts: 342
Joined: Mon May 05, 2014 9:13 am
Location: Germany

Re: connecting to open wifi access point?

Post by kfricke » Tue Jan 31, 2017 7:27 pm

I did have a look at the sources (esp8266/modnetwork.c) and do not see any possible reason for that behavior. In both cases an empty string is passed to the underlying SDK method (wifi_station_set_config).

A quick online search did yield some issues with the ESP SDK toolchain wich has had such issues with empty passwords. What are the surrounding parameters like the wireless security parameters?

Capstan
Posts: 117
Joined: Sun Jan 29, 2017 4:03 pm
Location: Texas, USA

Re: connecting to open wifi access point?

Post by Capstan » Tue Jan 31, 2017 10:41 pm

Thanks very much for looking. I'm just using the example code shown here with whatever parameters are the default;
https://docs.micropython.org/en/latest/ ... asics.html

Any suggestions as to different parameters to try?

>>> import network
>>> wlan = network.WLAN(network.STA_IF)
>>> wlan.active(True)
>>> wlan.scan()

... using the SSID shown from wlan.scan() and null string for password. This is what happens;

>>> wlan.connect('SSID-name', '')
>>> scandone
state: 0 -> 2 (b0)
state: 2 -> 3 (0)
state: 3 -> 5 (10)
add 0
aid 2

connected with SSID-name, channel 10
dhcp client start...
cnt
>>> wlan.isconnected()
False

>>> wlan.status()
1

User avatar
kfricke
Posts: 342
Joined: Mon May 05, 2014 9:13 am
Location: Germany

Re: connecting to open wifi access point?

Post by kfricke » Wed Feb 01, 2017 12:31 am

The ESP vendor API caches the SSID and password up to 5 different WiFi connections without further notice. It seems to do this in the way that when connecting with no (or an empty) password it simply (and quietly) looks up the last credential from the mentioned cache.

Maybe you have the SSID in this cache with a wrong credential?

Capstan
Posts: 117
Joined: Sun Jan 29, 2017 4:03 pm
Location: Texas, USA

Re: connecting to open wifi access point?

Post by Capstan » Wed Feb 01, 2017 5:17 pm

I presume this cache is in memory? I get the same results when attempting to connect after a reset or a power cycle.

I am looking at what I assume is the state transitions being printed out after "scandone". I am guessing these correspond to the states shown in the wifi.status() section of the docs; https://docs.micropython.org/en/latest/ ... twork.html

state: 0 -> 2 (b0)
state: 2 -> 3 (0)
state: 3 -> 5 (10)

If that's the case it is going from IDLE to WRONG_PASSWORD to NO_AP_FOUND to GOT_IP, which seems peculiar, and a "connected with" message is actually printed. But afterwards wlan.status() shows a status of 1 which would be CONNECTING.

Maybe this is something about the access point itself, I'll find a different one to try.

torwag
Posts: 220
Joined: Fri Dec 13, 2013 9:25 am

Re: connecting to open wifi access point?

Post by torwag » Wed Feb 01, 2017 5:37 pm

connection data is stored in permanent flash memory. A reboot or power cycle will not help.
To proof kfrickes thesis, rename the AP ssid to something new and definitively unknown before and try again.

User avatar
kfricke
Posts: 342
Joined: Mon May 05, 2014 9:13 am
Location: Germany

Re: connecting to open wifi access point?

Post by kfricke » Wed Feb 01, 2017 5:41 pm

I am just trying to lead to some details which might help us to identify resolve this issue...
Capstan wrote:I presume this cache is in memory? I get the same results when attempting to connect after a reset or a power cycle
No, the cache is in flash memory of your ESP board/module. I'd suggest you try to manually connect to 6 different fantasy SSIDs and then again to your password-less one (6 to avoid an off by one error in the docs i found). Maybe you have the cache polluted with an old password. Yes that should lead to another state when connecting.
Maybe this is something about the access point itself, I'll find a different one to try.
Might help to locate the reason of the issue.

Trying another ESP as a different access point might not yield a reasonable answer ;)

User avatar
kfricke
Posts: 342
Joined: Mon May 05, 2014 9:13 am
Location: Germany

Re: connecting to open wifi access point?

Post by kfricke » Wed Feb 01, 2017 5:42 pm

torwag wrote:connection data is stored in permanent flash memory. A reboot or power cycle will not help.
To proof kfrickes thesis, rename the AP ssid to something new and definitively unknown before and try again.
Of course this is the better way!

Post Reply