SSID length

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
Atze
New user
Posts: 1
Joined: 25 Jan 2023, 20:06

SSID length

#1 Post by Atze » 25 Jan 2023, 20:15

Hello, I'm new to the forum and I've only been dealing with a D1 for a short time.
I've been trying to flash a Wemos D1 with ESP Easy for two days now and integrate my WLAN. Flashing is no problem, but the integration into the WLAN fails.
In my opinion, it is due to the length of the SSID. As far as I know, the SSID can be 32 characters long. It's the same with my WiFi. Change my WiFi SSID to 31 characters, this is how the D1 connects to WiFi. With 32 characters, the connection fails.
Is there a reason why only 31 characters can be used?
Can you expect an extension to the usual 32 characters?
Or am I doing something fundamentally wrong?
Many greetings
Torsten

User avatar
Ath
Normal user
Posts: 3415
Joined: 10 Jun 2018, 12:06
Location: NL

Re: SSID length

#2 Post by Ath » 25 Jan 2023, 20:38

Hm, that smells like an oversight, made when the project started, umpteen years ago. The char array used to store the WiFi SSID is declared at 32 chars, but it should have been 33, to also store the terminating null (\0) character. That's the reason only 31 are accepted. Classic off-by-one error :(

AFAIR, this limit hasn't been reported before, and I don't think it's easy to fix, as this setting is surrounded by other settings, so no spare-bytes to expand.
/Ton (PayPal.me)

User avatar
Ath
Normal user
Posts: 3415
Joined: 10 Jun 2018, 12:06
Location: NL

Re: SSID length

#3 Post by Ath » 25 Jan 2023, 20:44

Atze wrote: 25 Jan 2023, 20:15 Is there a reason why only 31 characters can be used?
Can you expect an extension to the usual 32 characters?
Or am I doing something fundamentally wrong?
This Serverfault answer to that question has sort of an explanation: https://serverfault.com/questions/45439 ... oints-ssid
Some access point/router firmware versions use null-terminated strings and accept only 31 characters.
Maybe that could be an explanation (though not an excuse).
/Ton (PayPal.me)

TD-er
Core team member
Posts: 8642
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: SSID length

#4 Post by TD-er » 25 Jan 2023, 21:16

I think we can store the 32 bytes in there, as we already use special functions to get/set the string instead of relying on the 0 termination.
But I know for a fact that other libraries also have this limit as this exact "bug" has been fixed not too long ago in the Arduino libraries as well.
Anyway it does require changes in code and lots and lots of testing as we have no idea where else this may break. It may even break in libraries we can't easily patch. For example the ESP WiFi code is not open source and we only can use some pre-compiled binary blob and just this blob is something I suspect may not always handle these kinds of things very well.

So completely against my usual motto of "I won't take 'cannot be done' as an answer", I will now -in this case of using WiFi- say: "Won't fix".

If you search through the issues here, and also on any other ESP related firmware, you will find lots and lots of issues which now have been fixed related to hard to reproduce issues with WiFi.
And changing a wifi ssid array to a different length does have a good chance to open up a few of Pandora's boxes.

Also what Ton said, there is a good chance some Access Points also will not handle these max length SSIDs well.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot] and 17 guests