-
Notifications
You must be signed in to change notification settings - Fork 396
Prefer the Ssid type over Strings and byte arrays #4953
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
base: main
Are you sure you want to change the base?
Conversation
|
/hil full |
|
Triggered full HIL run for #4953. Run: https://github.com/esp-rs/esp-hal/actions/runs/21873593677 Status update: ✅ HIL (full) run succeeded. |
| pub(crate) fn new(ssid: &str) -> Self { | ||
| let mut ssid_bytes = [0u8; 32]; | ||
| let bytes = ssid.as_bytes(); | ||
| let len = usize::min(32, bytes.len()); | ||
| ssid_bytes[..len].copy_from_slice(bytes); | ||
|
|
||
| Self { | ||
| ssid: ssid_bytes, | ||
| len: len as u8, | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this use Ssid::from_raw(ssid, len) internally to reduce logic deduplication?
| ssid: ssid_bytes, | ||
| len: len as u8, | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure what is the proper fix for this (if there's any), but this code currently allows passing UTF-8 strings with double / triple octets characters (like é or emojis), which could be silently truncated at 32 chars.
That being said this isn't unique to this implementation, but rather to how the wifi standards specifies 32 octets, and not 32 chars.
Closes #4924
(this also updates the hard-coded IP address used in examples until #4927 lands)