-
Notifications
You must be signed in to change notification settings - Fork 21
Validate wifi credentials #116
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
"'networks' must be a list/tuple of dicts of 'ssid' and 'password'" | ||
) | ||
|
||
self._wifi_credentials = list( |
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.
This looks good, couple questions:
- what about APs with no password?
- to
isinstance
is faster and generally better then type can we use those? - can we add tests?
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.
Got you on 1 and 2, but I'm not very familiar with pytest. Let me know if I got it right.
By the way, I totally forgot that APs could have empty passwords. 😆
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'll look at the tests tomorrow. I'll make suggestions for anything to add/change
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.
And right - who would want something without a password? But people still complain when they can't connect because of it ...
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.
@justmobilize I think I've got the test figured out now, but let me know if it needs any adjustment.
If a device hasn't been configured properly either with
CIRCUITPY_WIFI_SSID
andCIRCUITPY_WIFI_PASSWORD
or the "networks" setting,adafruit_portalbase.network.NetworkBase.connect
will result in an obscureTypeError
from theadafruit_esp32spi
library.This update filters the
adafruit_portalbase.network.NetworkBase._wifi_credentials
list to ensure that it includes valid ssid/password pairs. If no valid credentials are available, it will trigger anOSError
exception with a descriptive message.I am testing using the following program written for the Adafruit Fruit Jam with the
adafruit_fruitjam
library. The device has no WiFi credentials configured.Here is the REPL output before this update:
Here's the REPL output after this update:
Note: I felt that
OSError
was appropriate for this exception because it is related to the device configuration before a request is made, butConnectionError
may follow the relative CPython implementation more closely.