-
Notifications
You must be signed in to change notification settings - Fork 19
Try multiple wifi networks #65
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
Conversation
Tested this, looking good! Ran the MagTag quote example with |
Also successfully connects if |
Also successfully managed to build the MagTag frozen with this frozen in, and examples functions the same with multiple Wi-Fi setting.
|
Do I understand correctly that this means in order to utilize the second network you would need secrets to be set up like this: secrets = [{
'ssid': 'network_id',
'password': 'network_password',
'timezone': "America/New_York",
'aio_username': 'My_AIO_Username',
'aio_key': '12345abcdef',
'openweather_token': '987654321abcde',
'ifttt_key': '678910abcde',
'zip': 10011,
'totp_keys': [("Discord ", "KEY1"),
("Gmail", "KEY2"),
("GitHub", "KEY3"),
("Adafruit", "KEY4"),
("Outlook", "KEY5")]
}, {
'ssid': 'other_network_id',
'password': 'other_network_password',
'timezone': "America/New_York",
'aio_username': 'My_AIO_Username',
'aio_key': '12345abcdef',
'openweather_token': '987654321abcde',
'ifttt_key': '678910abcde',
'zip': 10011,
'totp_keys': [("Discord ", "KEY1"),
("Gmail", "KEY2"),
("GitHub", "KEY3"),
("Adafruit", "KEY4"),
("Outlook", "KEY5")]
}] If so I think we should try to adjust the behavior so that this could be used instead if possible: secrets = {
'networks': [
{
'ssid': 'network_id',
'password': 'network_password'
},
{
'ssid': 'other_network_id',
'password': 'other_network_password'
}
]
# other entries outside the list...
} Or perhaps if we'd rather not introduce the new key
I think making the
would no longer work for the list variation, if I understand correctly the code would have to change to:
With any existing index filled in for the I think we should try to keep it so that no code that needs other secrets has to change except for specifically code trying to access the ssid and password for it. All other key/values should be able to be looked up the same as they are today if possible. Using one of the other two formats here would also remove the need to duplicate all of your secret tokens and other values which would make it easier when the time comes to add / change them. |
Yup, exactly. I would be willing to introduce a new My attempted solution to keep too much from breaking (at least internally) was to have Another solution might be to have an entirely new keyword that could optionally be used in place of keys |
At least that way it won't be a breaking change |
Nice! I do like the idea of |
Sweeeeeet! I'll refactor this code to do that instead then, thanks for the feedback! |
Reworked to use a
Tested successfully on my home network using both the new |
Here's the CircuitPython build for MagTag with it as is:
|
@FoamyGuy my pleasure, thank you for testing! Just added |
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.
Looks good to me. I retested both the multiple networks and original single ssid
and password
behavior and both are working as expected on PyPortal 7.3.0beta
Updating https://github.com/adafruit/Adafruit_CircuitPython_BME680 to 3.4.3 from 3.4.2: > Merge pull request adafruit/Adafruit_CircuitPython_BME680#49 from billvanleeuwen424/main > Update Black to latest. > Fixed readthedocs build > Consolidate Documentation sections of README Updating https://github.com/adafruit/Adafruit_CircuitPython_Display_Shapes to 2.4.3 from 2.4.2: > Merge pull request adafruit/Adafruit_CircuitPython_Display_Shapes#47 from tekktrik/dev/divide-by-zero > Update Black to latest. > Merge branch 'ladyada:master' into main > Fixed readthedocs build > Post-patch cleanup Updating https://github.com/adafruit/Adafruit_CircuitPython_PortalBase to 1.12.0 from 1.11.5: > Merge pull request adafruit/Adafruit_CircuitPython_PortalBase#65 from tekktrik/dev/multiple-wifi Updating https://github.com/adafruit/Adafruit_CircuitPython_RSA to 1.2.8 from 1.2.7: > Merge pull request adafruit/Adafruit_CircuitPython_RSA#27 from tekktrik/doc/add-documentation
First stab at trying multiple Wi-Fi networks. I don't have a MagTab or anything that uses this library so will definitely need help testing.
secrets.py
should be either the usual dictionary or can be a list of valid dictionaries (that means repeating things like Adafruit IO keys as well in each dictionary).NetworkBase._secrets
stores the "active" dictionary being used, in case that access is ever needed, and it also keeps a lot of the existing code from changing. Let me know if anything needs to change.Tagging @djh1997 who submitted the issue as well.
Resolves #63.