-
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
Attempt at pi cow ap #7101
Attempt at pi cow ap #7101
Conversation
This is normal in Also, I'm not really clear on how the cyw43 api works, but in |
Oh sorry I didn't phrase it very well. |
OK, sorry, missed that this was in draft. I'm excited about the feature :-) |
Outside of running both AP and STA modes at the same time. The AP is working really nice. I have made a few tweaks outside of what @bill88t has done here.
I have the changes that I've made here: https://github.com/paul-1/circuitpython/tree/picow-AP-mode-with-DHCP-server |
…uture improvements to allow country code setting.
Updated my local branch, cherry-picked the commits from paul-1's fork, thanks @paul-1! |
Not sure if you or anyone has some advice about the country code commit. I know we are initializing the wifi chip early, so that the digital pins are available for general use. That appears to be the only time we can set the country code. The default wifi country is a global wifi policy. Perhaps before wifi init we should use getenv to look at see if the user has a valid country code defined in the .env file? |
That sounds like a good use for |
I cannot get the ap to stop no matter what I do.. Looking at the respective micropython code we can see, they haven't implemented it either. I will continue implementing the AP, without |
What happens if Do we have any API to access |
Stays on original ssid and accepts no connections.
Aren't some pins controlled from the wifi chip? Note: I have not touched any of the early-boot cyw43 code. |
Now, The error messages I added are very much suboptimal. I would very much appreciate some suggestions. |
TBH, I'm not sure there is significant value top stop the AP during a running program. Changing the AP SSID/password, then restarting the code worked fine when I previously tested. I think there are things that just requires the radio to be hard power cycled. For example, once the AP is started the channel assignment will not change without a hard power cycle. I looked at the error messages. "cannot be stopped" has the connotation that something is preventing it from stopping. IMO, "Stopping AP is not supported" is a better choice. |
I have an application (on ESP32-S*) that sets up different SSIDs at different times during a run. We are (hopefully) trying to have a single consistent |
Hopefully as cyw43 is updated, this stuff will be fixed. |
"Significant Value" was a poor choice of words, on my part. I agree with common api within CP. Since we have to wait for SDK/firmware improvements, I propose we just stick with the current state of the AP development. Cleanup and merge for 8.0.0, and add an open issue or milestone to re-evaluate for future releases. |
Actually |
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.
Differences from espressif
, from above and from testing:
- Station and AP can’t operate simultaneously
-- if device AP is started, device Station can't connect to an external AP (RuntimeError: Already in access point mode.RuntimeError: Wifi is in access point mode.
)
-- If device Station is connected to an external AP, device AP can't be started (RuntimeError: Already connected to station.RuntimeError: Wifi is in station mode.
) - once an AP is started, it can't be stopped without a power cycle or
microcontroller.reset()
- AP channel (edit: and other AP settings) can only be set once after a power cycle or
microcontroller.reset()
wifi.radio.enabled
is not implemented (AttributeError: 'Radio' object has no attribute 'enabled'
), so to disconnect from an external AP, usewifi.radio.stop_station()
--> EDIT: this has now been implemented --> EDIT 2:.enabled
isn't fully implemented, but is checked when trying to start a station or AP..
Thanks!
Addendum:
- wifi country is set to global wifi policy
Or even have its settings changed. |
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.
Everything I've tried is working as expected. Just ran an adafruit_httpserver
on the wifi AP, and connected with a CircuitPython client and got served. I'm going to approve this and defer to one of the core devs to decide to merge. It would be nice to get this out there for more folks to poke at it :-)
Just in case anyone cares about free board storage. |
Built and tested locally.
One thing I noticed however, these messages pop up whenever a device connects. |
|
perhaps diff --git a/shared/netutils/dhcpserver.c b/shared/netutils/dhcpserver.c
index a61501c93c..d396a2ba56 100644
--- a/shared/netutils/dhcpserver.c
+++ b/shared/netutils/dhcpserver.c
@@ -265,9 +265,9 @@ static void dhcp_server_process(void *arg, struct udp_pcb *upcb, struct pbuf *p,
d->lease[yi].expiry = (mp_hal_ticks_ms() + DEFAULT_LEASE_TIME_S * 1000) >> 16;
dhcp_msg.yiaddr[3] = DHCPS_BASE_IP + yi;
opt_write_u8(&opt, DHCP_OPT_MSG_TYPE, DHCPACK);
- printf("DHCPS: client connected: MAC=%02x:%02x:%02x:%02x:%02x:%02x IP=%u.%u.%u.%u\n",
+ LWIP_DEBUGF(DHCP_DEBUG, ("DHCPS: client connected: MAC=%02x:%02x:%02x:%02x:%02x:%02x IP=%u.%u.%u.%u\n",
dhcp_msg.chaddr[0], dhcp_msg.chaddr[1], dhcp_msg.chaddr[2], dhcp_msg.chaddr[3], dhcp_msg.chaddr[4], dhcp_msg.chaddr[5],
- dhcp_msg.yiaddr[0], dhcp_msg.yiaddr[1], dhcp_msg.yiaddr[2], dhcp_msg.yiaddr[3]);
+ dhcp_msg.yiaddr[0], dhcp_msg.yiaddr[1], dhcp_msg.yiaddr[2], dhcp_msg.yiaddr[3]));
break;
}
|
Oh I thought it was a submodule. Thankfully it is not. |
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.
Thanks for working on this! No testing performed.
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.
Thank you again!
Now when |
shared/netutils/dhcpserver.h
Outdated
@@ -31,6 +31,10 @@ | |||
#define DHCPS_BASE_IP (16) | |||
#define DHCPS_MAX_IP (8) | |||
|
|||
#ifndef DHCP_DEBUG | |||
#define DHCP_DEBUG LWIP_DBG_ON |
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.
won't this turn the debug messages back on? is that what you intended?
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.
When DEBUG=0
the user shouldn't see them.
When DEBUG=1
you probably want them.
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.
It builds (w & wo/ debug) but doesn't work though, and I am not sure why.
Idk how to fix it, and it really doesn't matter. |
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.
Thanks! I do not have a strong opinion about that dhcp debug message, it can be fixed in the future with a fresh PR.
This is an attempt to implement access point functionallity for the pi cow.
The access point itself works.
However:
(This is due to CYW43_LINK_UP)