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

correct Radio.connect() and .start_ap() signatures; clean up some code #7249

Merged
merged 1 commit into from
Nov 23, 2022

Conversation

dhalbert
Copy link
Collaborator

In the course of testing #6897 (could not reproduce), I found that the signatures for wifi.Radio.connect() and wifi.Radio.start_ap() did not correspond exactly to what these functions took, and that arg validation could use some improvement.

  • Corrected type annotations for wifi.Radio.connect() and wifi.Radio.start_ap().
  • Use b"" and None where appropriate in those methods, rather than MP_OBJ_NULL, which doesn't have a direct analog.
  • Use bitmask values for wifi.AuthMode instead of shifting the integer values.
  • Use uint32_t instead of uint8_t for passing around combinations of AuthMode, in case there are more than 8 bits in the future. It may be less code anyway.

Right now you give multiple AuthModes by putting them in a tuple. But they could be or'd (|) together instead now that they are or'able flags. Maybe in the future that should be the preferred way. We could also add combo AuthModes for the combinations Espressif supports, and what CYW43 supports.

I used b"" as the default empty string value. Internally it is mp_const_empty_bytes. Surprisingly there is no mp_const_empty_str.

I tested connect() with a local open access point. I tested start_ap() as an open and a password-protected AP. I was able to connect and ping it from a laptop in both cases.

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 good! Thank you!

@tannewt tannewt merged commit 3056365 into adafruit:main Nov 23, 2022
@dhalbert dhalbert deleted the wifi-connect-ap-api branch November 29, 2022 14:22
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 this pull request may close these issues.

None yet

2 participants