-
Notifications
You must be signed in to change notification settings - Fork 489
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
sdk_wifi_station_scan not working properly for 32 character SSID #682
Comments
printf function prints until '\0' is found. Since the SSID is exact 32 and the char array to store is also 32, the print function goes beyond and prints from memory location after the end of the variable. Hence the garbage characters are printed. |
I know how printf works and probably why the extra characters are printed. My problems are:
I guess that ssid string is only null terminated if it has fewer then 32 bytes, and for length of 32 it relies on cutting it by |
|
Ok, so I was mistaken with printf format for cutting. This doesn't change the fact that That being said |
Yeah, well. There are weirder things than this one. When I stumbled over this my thought was that the "null terminated string" comment in the struct sdk_station_confg is just wrong. It's an array of bytes, not a string. Edit: remove scan function I posted here earlier, it was from different SDK. I'll post a copy of my scan function for the esp-open-rtos later. |
So it seems that ssids in sdk are null terminated only when less then 32 bytes in length. This leaves the user with limiting ssid's length. That's fine, but then the usages are wrong - two that i know of are wifi_scan example and |
I'm not sure if this is a bug or not, but sdk_wifi_station_scan doesn't seem to work properly for 32 character SSID's. Example output from wifi_scan example:
Second wifi name should be "7GPowerOverWifi_MSDos_compatible", but there are extra unprintable characters at the end.
Connection to said wifi works fine, but the extra characters are printed on connection:
connected with 7GPowerOverWifi_MSDos_compatible␃␅␃, channel 6
One of the causes is probably in include/espressif/esp_sta.h:
All ssids are stored as uint8_t[32], which means that the 32 byte ssid shouldn't fit.
Another thing is the fact that in wifi_scan example any characters after 32 should be cut by:
printf("%32s (" MACSTR ") RSSI: %02d, security: %s\n", ssid, MAC2STR(bss->bssid), bss->rssi, auth_modes[bss->authmode]);
This means that printf string limiting isn't working. Indeed
printf("%2s","0123456789");
outputs
0123456789
However
%.*s
format seems to be working as expected.
The text was updated successfully, but these errors were encountered: