Arduino-esp32: WiFi.softAP("apname", "") not working

Created on 3 Oct 2018  路  7Comments  路  Source: espressif/arduino-esp32

WiFi.softAP only works when passphrase is 0, in esp8266 it also works when passphrase is "".

In WiFiAP.cpp on line 104 should change from:

if(passphrase && (strlen(passphrase) > 63 || strlen(passphrase) < 8)) {

to:

if(passphrase && (strlen(passphrase) > 63 || strlen(passphrase) < 8 || strlen(passphrase) == 0)) {

All 7 comments

WiFi.softAP only works when passphrase is 0

What you probably mean is "WiFi.softAP() only works when the length of passphrase is >= 8 characters, which is true. The whole routine fails if passphrase is too long or too short. It also fails if ssid is too long.

if(passphrase && (strlen(passphrase) > 63 || strlen(passphrase) < 8 || strlen(passphrase) == 0)) {

This doesn't help much because its already testing for strlen(passphrase) < 8.

What would make this routine more robust would be:

  • If passphrase or ssid is too long, truncate them to an appropriate length.
  • If passphrase is too short or empty, fall back to using WIFI_AUTH_OPEN like it does about 12 lines down where it sets conf.ap.authmode.
  • fail only if ssid is not given or AP not enabled.

@jeroenst you are correct that 0 length passphrases were failing when they should have just set an open AP. I put up a pull request that should fix it. In the meantime you can try replacing the one line with the following:
```c++
if(passphrase && strlen(passphrase) > 0 && (strlen(passphrase) > 63 || strlen(passphrase) < 8)) {

You're right, my proposed fix was wrong. Thanx for the solution!

Tested your fix, and it accepts passphrase "" now.

Yes it should have been checking strlen(passphrase) > 0 first. Please close if this solves the issue.

Shouldn't I wait with closing until this issue has been solved in the master branch?

Either way, it'll get fixed if my pull request gets accepted, but that may be awhile. The devs are very busy with lots of projects and we don't want to annoy them because they bring us lots of shiny new features to play with. :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ladyada picture ladyada  路  104Comments

jh83 picture jh83  路  124Comments

cyberman54 picture cyberman54  路  102Comments

muktillc picture muktillc  路  57Comments

PhilColbert picture PhilColbert  路  125Comments