Skip to content
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

ESP32S2: Allow connecting to specific bssid #3433

Merged
merged 5 commits into from
Sep 19, 2020

Conversation

astrobokonon
Copy link

Closes #3403

I couldn't figure out a way to avoid doing a last minute conditional check in common-hal/wifi/Radio.c because the bssid_set flag needs to be set only if you're specifying a specific MAC. If you're not passing in a bssid, but you happen to still set the bssid_set flag, the connection will fail and you'll end up returning WIFI_RADIO_ERROR_NO_AP_FOUND so that's no good (and a bit confusing).

I needed a way to check the bssid length as an initial sanity check against someone passing it in as a string (with colons) rather than the actual bytes, so I just dropped in #define MAC_ADDRESS_LEN when/where needed. I could have just hardcoded it but I saw that done elsewhere so I just did the same. It raises a ValueError but I wasn't sure if there was a better/more preferred type.

I don't see a way to get the vital statistics of the currently-connected AP, so that's the final thing to look at before I'd call this good to go. But it compiled and the initial tests worked as expected, which was frankly a surprise.

@tannewt tannewt self-requested a review September 17, 2020 18:54
@tannewt tannewt added espressif applies to multiple Espressif chips enhancement labels Sep 17, 2020
Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One small potential bug. Otherwise this looks really good! What is left to do?

ports/esp32s2/common-hal/wifi/Radio.c Show resolved Hide resolved
@tannewt tannewt added this to the 6.x.0 - Features milestone Sep 17, 2020
@astrobokonon
Copy link
Author

@tannewt the only thing I'd like to do is to look at the set of parameters exposed after a connection is established to check/verify the details of the connection and know that you're connected where you think you are - right now there's really just common_hal_wifi_radio_get_ipv4_address to get the assigned IPv4 address, from which you can infer the subnet, but it'd be nice to have the gateway and the explicit subnet since they're all from the same esp_netif_ip_info_t struct.

@tannewt
Copy link
Member

tannewt commented Sep 17, 2020

@astrobokonon What do you think about doing that in a follow up PR? This looks good as-is.

@astrobokonon
Copy link
Author

@tannewt Yeah, I can do that in a different PR for sure.

@astrobokonon astrobokonon marked this pull request as ready for review September 17, 2020 22:53
Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Thank you! I'll let @dhalbert merge.

@dhalbert dhalbert merged commit dfd09bb into adafruit:main Sep 19, 2020
@astrobokonon astrobokonon deleted the esp32s2-bssid branch September 19, 2020 02:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement espressif applies to multiple Espressif chips
Projects
None yet
Development

Successfully merging this pull request may close these issues.

WiFi Association with specific BSSID
3 participants