-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Allow Access Point static IPv4 on the raspberrypi port #7976
Conversation
Turns out that lwip only provides the DHCP client. The DHCP server comes from shared/netutils, and it is inited only once, deep in the cyw43 driver when wifi is inited: |
Turns out that the netutils DHCP server can be turned off and back on again without obvious side effects. AP: Adafruit CircuitPython 8.1.0-beta.2-32-gcf124ab85 on 2023-05-14; Raspberry Pi Pico W with rp2040
>>> import wifi, ipaddress
>>>
>>> ipv4 = ipaddress.IPv4Address("192.168.251.2")
>>> netmask = ipaddress.IPv4Address("255.255.255.0")
>>> gateway = ipaddress.IPv4Address("192.168.251.1")
>>> wifi.radio.start_ap("Bob", "YourUncle")
>>> wifi.radio.set_ipv4_address_ap(ipv4=ipv4, netmask=netmask, gateway=gateway)
>>> wifi.radio.ipv4_address_ap
192.168.251.2 Station (separate device): >>> import wifi
>>> wifi.radio.ipv4_address
>>>
>>> wifi.radio.connect("Bob", "YourUncle")
>>> wifi.radio.ipv4_address
192.168.251.16 Tested by connecting to the AP from another CircuitPython device and from a desktop computer. Also ran a TCP echo server on the static IPv4 PicoW AP, and sent packets to it from a TCP client on the connected CircuitPython station: Output from TCP server on the AP...
Output from TCP client on the station...
I don't know why the station IP address jumps to I'd appreciate careful review, this is my first dive into the depths of the PicoW internals. |
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 have only fumbled a little bit with lwip (back when I did AP), but looks good to me.
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'm fine merging as-is. I don't know a ton about the LWIP internals either but if it works, then it should be ok.
The changes are isolated to the affected API, so there should be minimal risk to code that is not using I realized I didn't put in the |
Like #7946 but for
raspberrypi
. The two PRs together should fully address #7931.Draft for now... took a first stab at PicoW AP static IPv4. A couple of oddities...
espressif
, AP needs to be started before the IPv4 address can be set:This means that there will be an interval where something could connect to the AP with the wrong IP range, and that address could conflict with another network.