-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
top: Common network hostname/country configuration. #10635
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
Code size report:
|
4276bc0
to
5db9012
Compare
This removes |
It might be... the default |
5db9012
to
e32e84a
Compare
OK. I've added a "no-op" version of pyb.country for boards that don't have networking support so that existing boards with the default boot.py don't break. I've also updated the default boot.py to use network.country and network.hostname instead. It seems unnecessary to add the whole network module for non-networking boards just to have a .country method that does nothing. |
Codecov Report
📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
e32e84a
to
dc72ad7
Compare
Updated the submodule, including removing the cyw43_resource.o handling in favour of the firmware header files. Note that this breaks Pico W until the next Pico SDK update (at which point I will update this PR). |
See #10764 which does the update to pico-sdk. |
Please rebase on latest master to get the new pico-sdk (and cyw43-driver). |
dc72ad7
to
8754696
Compare
Done. |
This now passes the CI. I tested BLE and WiFi on PYBD-SF2W and it looks good, but I want to do more tests. |
aed882d
to
d810895
Compare
44aee8f
to
4598fa8
Compare
Addressed all comments. |
This provides a standard interface to setting the global networking config for all interfaces and interface types. For ports that already use either a static hostname (mimxrt, rp2) they will now use the configured value. The default is configured by the port (or optionally the board). For interfaces that previously supported .config(hostname), this is still supported but now implemented using the global network.hostname. Similarly, pyb.country and rp2.country are now deprecated, but the methods still exist (and forward to network.hostname). Because ESP32/ESP8266 do not use extmod/modnetwork.c they are not affected by this commit. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
This allows for a port (e.g. esp8266/esp32) to use extmod/modnetwork.c and provide the globals dict, rather than just a list of interfaces. When this is used, the default implementation of `network.route` and the NIC list is not enabled. Also splits out the LWIP-specific helpers from modnetwork.c into network_lwip.c. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Rather than duplicating the implementation of `network`, this allows ESP32 to use the shared one in extmod. In particular this gains access to network.hostname and network.country. Set default hostnames for various ESP32 boards. Other than adding these two methods and the change to the default hostname, there is no other user-visible change. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Rather than duplicating the implementation of `network`, this allows ESP8266 to use the shared one in extmod. In particular this gains access to network.hostname and network.country. Other than adding these two methods, there is no other user-visible change. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
This removes the previous WiFi driver from drivers/cyw43 (but leaves behind the BT driver), and makes the stm32 port (i.e. PYBD and Portenta) use the new "lib/cyw43-driver" open-source driver already in use by the rp2 port. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Signed-off-by: Damien George <damien@micropython.org>
Also marks wlan.config(hostname) as deprecated. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
This is for boards without networking support so that the default boot.py continues to work. Also update boot.py to use network.country and network.hostname instead. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Signed-off-by: Damien George <damien@micropython.org>
4598fa8
to
36ae5d3
Compare
Thank you, this looks good now. I rebased and updated some of the commit messages (minor changes) and force pushed to this PR branch. |
Thanks @jimmo. That was quite a piece of work, and needed. |
PR micropython#10635 introduced this limit which seems rather arbirtrary and wildly insufficient to me. A 16 bytes length limits means a 15 character string limit, which even `ubinascii.hexlify(machine.unique_id())` on most ports will break. And then assuming you just supply a random 15 byte hex string, most people won't be able to identify the hosts function in a list on their wifi routers. I wanted to set my hostname to `rpi-fan-controller-{hex_uid}` and just got a ValueError without explanation. It took me 2 hours to figure what went wrong. Because of this I added a note about the exception and limitation to the documentation. Since I didn't really understand the reason for 16 bytes I set the new limit to the size used in all involved protocols: DHCP 64 bytes, DNS 63 "octets" (characters) plus length byte, and mDNS which points to the DNS RFC. I can imagine that some ports for small boards might want to decrease the size of this statically allocated buffer, and from what I gathered from the C code it would be a simple as defining `MICROPY_PY_NETWORK_HOSTNAME_MAX_LEN`, so I mentioned this possibility for end users in the documentation as well. Signed-off-by: Simon Lutz Brüggen <micropython@m3t0r.de>
PR micropython#10635 introduced this limit which seems rather arbitrary and wildly insufficient to me. A 16 bytes length limits means a 15 character string limit, which even `ubinascii.hexlify(machine.unique_id())` on most ports will break. And then assuming you just supply a random 15 byte hex string, most people won't be able to identify the hosts function in a list on their wifi routers. I wanted to set my hostname to `rpi-fan-controller-{hex_uid}` and just got a ValueError without explanation. It took me 2 hours to figure what went wrong. Because of this I added a note about the exception and limitation to the documentation. Since I didn't really understand the reason for 16 bytes I set the new limit to the size used in all involved protocols: DHCP 64 bytes, DNS 63 "octets" (characters) plus length byte, and mDNS which points to the DNS RFC. I can imagine that some ports for small boards might want to decrease the size of this statically allocated buffer, and from what I gathered from the C code it would be a simple as defining `MICROPY_PY_NETWORK_HOSTNAME_MAX_LEN`, so I mentioned this possibility for end users in the documentation as well. Signed-off-by: Simon Lutz Brüggen <micropython@m3t0r.de>
The overall goal is to allow configuration of the hostname on Pico W, but also unify the way networking works across ports. Fixes #8906, #10397
This PR adds
network.hostname()
andnetwork.country()
to globally set the device hostname (for all interfaces) and country (for radio compliance). For interfaces that previously supportednic.config(hostname)
this will continue to work, as willpyb.country()
(andrp2.country()
).Additionally configure the default hostname on a per-port and per-board basis. We may want to remove this change if it's considered a breaking change to change the default hostname?
It also updates the stm32 port to use the new cyw43-driver (in the lib/cyw43-driver submodule) and removes the old version from drivers. This relies on georgerobotics/cyw43-driver#58.
Next steps (separate PR):