Skip to content

WiFi.softAP("apname", "") not working #1924

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jeroenst opened this issue Oct 3, 2018 · 8 comments · Fixed by #1925
Closed

WiFi.softAP("apname", "") not working #1924

jeroenst opened this issue Oct 3, 2018 · 8 comments · Fixed by #1925

Comments

@jeroenst
Copy link

jeroenst commented Oct 3, 2018

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)) {
@MarkusAD
Copy link
Contributor

MarkusAD commented Oct 4, 2018

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.

@MarkusAD
Copy link
Contributor

MarkusAD commented Oct 4, 2018

@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:

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

@jeroenst
Copy link
Author

jeroenst commented Oct 4, 2018

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

@jeroenst
Copy link
Author

jeroenst commented Oct 4, 2018

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

@MarkusAD
Copy link
Contributor

MarkusAD commented Oct 4, 2018

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

@jeroenst
Copy link
Author

jeroenst commented Oct 4, 2018

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

@MarkusAD
Copy link
Contributor

MarkusAD commented Oct 4, 2018

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. :)

@solroshan
Copy link

I got same error on my serial monitor. Compiler builds with any error but serial monitor prints;
[E][WiFiSTA.cpp:219] begin(): connect failed! [E][WiFiAP.cpp:109] softAP(): passphrase too short!
How can I rearrange passphrase as ">8" ?

MrBreakNFix added a commit to MrBreakNFix/M5Projects that referenced this issue Jun 15, 2024
espressif/arduino-esp32#1924

Limits PSK to >= 8 chars -- thats why the PSK was not updating.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants