Skip to content

modified wifi.py to use wifi.json files containing lists of networks#82

Open
prehensile wants to merge 8 commits into
emfcamp:masterfrom
prehensile:master
Open

modified wifi.py to use wifi.json files containing lists of networks#82
prehensile wants to merge 8 commits into
emfcamp:masterfrom
prehensile:master

Conversation

@prehensile
Copy link
Copy Markdown

@prehensile prehensile commented Aug 10, 2016

Allows connections to wifi networks in >1 locations (say, home + work) without having to update wifi.json every time.

Requires a small modification to wifi.json: the root entity is now a list of dicts, rather than just a dict, e.g.
[{"ssid": "emfcamp-insecure"},{"ssid": "home-insecure"}]
(still supports the original format, though)

Has a corresponding PR on emfcamp/micropython to support the new format during bootstrap.

@mattbrejza
Copy link
Copy Markdown
Collaborator

Thanks for looking at this, its one thing we've been meaning to do.

Does this work on the home screen where connect() is used in a non-blocking way? Here, connect() is called, and is exited before the wifi gets a chance to complete the connect proceedure.

@thibault-ml
Copy link
Copy Markdown

thibault-ml commented Aug 10, 2016

Also, this is a bit brute force, where it's trying to connect to all known SSIDs until it manages to connect to a known one.

I think a better way would be to use list_aps() and lookup the SSID of each returned AP, and connecting to it if the SSID is one we have in wifi.json.

Comment thread lib/wifi.py
networks = connection_details()

exc = None
for details in networks:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

could we check the list of currently visible ssids first and filter the ones out that are not in there?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Agreed (this is also what I suggested in the PR conversation tab)

@prehensile
Copy link
Copy Markdown
Author

prehensile commented Aug 10, 2016

@thibault-ml @marekventur yep, I was going to have a look at comparing with a list of visible ssids in the next iteration :) This way works for now, depends if we want to wait 'til the ssid checking is done to have multiple APs.

@mattbrejza it does work on the home screen, but it's a good point about the blocking calls - I haven't specifically tested that, maybe it happens to work at the moment by accident!

@thibault-ml
Copy link
Copy Markdown

I think it'd be good to have the code going through known APs only rather than connecting to all those we know about even if they are out of range. But then I'm not a maintainer of this repo, so not my decision. Just my 2cts.

@prehensile
Copy link
Copy Markdown
Author

OK, I've made a few improvements. Should be safer for the non-blocking uses now (@mattbrejza) , and uses the list of visible ssids from list_aps() (thanks, @thibault-ml!).

I've also amended create_default_config() to write in the new format, and amended bootstrap.py to use the new format, and use visible ssids in the same way.

@prehensile
Copy link
Copy Markdown
Author

Note there are some currently some wider issues with merging this into the firmware that are discussed in the PR on emfcamp/micropython.

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.

4 participants