Skip to content
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 espressif port #7946

Merged
merged 5 commits into from
May 12, 2023
Merged

Allow Access Point static IPv4 on the espressif port #7946

merged 5 commits into from
May 12, 2023

Conversation

anecdata
Copy link
Member

@anecdata anecdata commented May 8, 2023

Relevant to Issue #7931

AP:

Adafruit CircuitPython 8.1.0-beta.2-12-g018f15de9-dirty on 2023-05-08; ESP32-S2-DevKitC-1-N4R2 with ESP32S2
>>> import wifi
>>> import ipaddress
>>> 
>>> ipv4 = ipaddress.IPv4Address("192.168.251.2")
>>> netmask = ipaddress.IPv4Address("255.255.255.0")
>>> gateway = ipaddress.IPv4Address("192.168.251.1")
>>> wifi.radio.ipv4_address_ap
>>> 
>>> wifi.radio.set_ipv4_address_ap(ipv4=ipv4, netmask=netmask, gateway=gateway)
>>> wifi.radio.ipv4_address_ap
>>> 
>>> wifi.radio.start_ap("Bob", "YourUncle")
>>> wifi.radio.ipv4_address_ap
192.168.251.2
>>> 

Station (separate device):

>>> import wifi
>>> wifi.radio.ipv4_address
>>> wifi.radio.connect(ssid="Bob", password="YourUncle")
>>> wifi.radio.ipv4_address
192.168.251.3
>>> 

Tested by connecting to the AP from another CircuitPython device and from a desktop computer. Also ran a TCP echo server on the circuitpython AP, and sent packets to it from the circuitpython TCP station and from a desktop Python TCP client.

Note that connecting stations will be assigned IP addresses sequentially starting with the AP static IPv4 + 1.

@anecdata
Copy link
Member Author

anecdata commented May 8, 2023

looks like it's applying a new formatting rule to old code, do I edit the old code?

@anecdata
Copy link
Member Author

anecdata commented May 8, 2023

several languages not building on PicoW variants

edit: oh, I guess I need to stub out the PicoW common-hal or do Not Implemented exceptions or something...

@anecdata
Copy link
Member Author

anecdata commented May 10, 2023

This is ready to go.

I'll try PicoW as a separate PR after this one is merged since: I don't know much about those internals; I haven't set up to build raspberrypi yet, and; PicoW wifi can be quirky. I looked at the code and I think I know what needs to be done, but if there are challenges with a straight-forward implementation modeled after station, then outcome is uncertain. If someone else wants to do PicoW, that's fine too.

Copy link
Member

@tannewt tannewt left a 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. Do you think we should split this in 9.0 into two objects? One for station and one for ap.

@anecdata
Copy link
Member Author

anecdata commented May 11, 2023

Do you think we should split this in 9.0 into two objects? One for station and one for ap.

The properties and methods keep growing, and we've known for some time that the naming can be confusing (e.g., get_ap_info is for station, but the AP things generally have an _ap suffix). Most things should separate easily into two buckets, but wifi.radio.enabled affects both. I think hostname does also.

The ability to enable and disable wifi completely independently from starting or stopping station or AP can be pretty powerful (current CYW43 limitations aside), I don't think we want to mess that up.

Maybe an issue for discussion is a good place to start.

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.

None yet

2 participants