-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Implement a useful subset of wifi
and socketpool
modules on 🥧🐮
#6933
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
The head ref may contain hidden characters: "\u{1F967}\u{1F42E}"
Conversation
i am getting an error trying to get the patch compiled
|
Do you have cmake installed? |
whoops... i thought that it was a part of build-essential. but i guess not. Installed and the compile works now :) |
cmake is a new requirement. It's used to build pioasm from pico-sdk, which wasn't needed before. |
This is great, actually useful already! Do you want to hear about issues yet at this very early stage, and if so... where? |
Result of overnight ping DNS & ping test:
I suspect that this test stopped overnight when my wifi router resets, not because of a problem with the pico w itself. This is a revised version of do_dns_ping that does the DNS query before each ping. |
The gpio changes took away enough code space that it doesn't fit.
My pings go out, and then they come back ```py import os import wifi import ipaddress wifi.radio.connect(os.getenv('WIFI_SSID'), os.getenv('WIFI_PASSWORD')) ipv4 = ipaddress.ip_address("8.8.4.4") print("Ping google.com: %f ms" % (wifi.radio.ping(ipv4)*1000)) ```
``` >>> s = socketpool.SocketPool(wifi.radio) >>> s.getaddrinfo("google.com", 80) [(0, 0, 0, '', ('142.250.81.206', 80))] ```
I rebased this to have a prettier history (intermediate commits may still not build, I didn't test this). The original history is preserved as https://github.com/jepler/circuitpython/compare/picow-v1?expand=1 I fixed a bug which caused open sockets to not be correctly tracked. As a consequence, things would stop working after 8 sockets had been opened, until reboot. Tests performed:
This is ready for review, and we can get "the rest" in future PRs. |
thanks for all your hard work its greatly appreciated! Next is ssl and server support I presume? |
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.
This looks very nice! I didn't look at the network code in great detail.
Submodules that need updating to what is in adafruit/circuitpython
main
, it It looks like:
frozen/circuitpython-stage
ports/espressif/esp32-camera
this was verbatim-copied from micropython
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.
Great! One of us can merge after the builds finish.
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.
Although the connection to the wifi AP is maintained, there is usually a disruption of the network after several minutes. Trying a socket operation in a loop with 5-minute delay gives an exception, whereas I have CircuitPython code that's been running since yesterday that pings every minute to keep the network alive but does HTTP only once an hour.
code:
cp_test.py.txt
output:
cp_out.txt
MicroPython has similar behavior:
code:
up_test.py.txt
output:
up_out.txt
Not definitive, but if one of those mystery packets come in:
[CYW43] got unexpected packet -9
this will delay when the network becomes inaccessible.
Also, initial testing with the MicroPython wlan.config(pm = 0xa11140)
toggle described here seems to extend the duration of network accessibility. A test underway is still running after 90-minute interval between network operations. So I suspect the disruptions may be due to the power-saving mode:
3.6.3. Power-saving mode
By default the wireless chip will active power-saving mode when it is idle, which might lead it to being less responsive. If you are running a server or need more responsiveness, you can change this by toggling the power mode.
@anecdata I also reproduced something similar on circuitpython. In my case, I got to 300 but failed on the next run.
Since you first encountered this and now reproduced it micropython and circuitpython, can you open an issue with both us and them, and mention the micropython bug in the circuitpython bug so they're linked together? On the other hand if you're not fully comfortable filing issues on micropython let me know and I'll do it. Ideally, micropython will be able to resolve the problem or make an effective bug report 'upstream' to raspberry pi since they have a more official standing it seems like. It seems like it may be some kind of bug in the power saving code inside the wifi module, and we (adafruit) don't have access to that code to investigate or modify it. |
@jepler I goofed with my math in the earlier comment... MicroPython ran for 9 minutes (not 90!) between intervals, but got OSError: -2 after 10 minutes with no network activity, and Thonny doesn't recover the connection to the device after it's reset, so more uP testing is needed. I'll open a CP issue, and if / when I have enough data, I'll open a uP issue. It's possible, though not intuitive, that it's by design in uP and there's some command needed to "wake" the network from the local side before a new operation can happen after a delay, even with power-save off. I should also be able to test whether the local side can be kept alive from incoming activity from an external device. |
With do_ntp I keep getting the error from tm = ntp.datetime
after varying numbers of calls every 30 seconds. |
ntp uses udp which is an unreliable protocol. packets can get lost. if you wrap this in a try/except, can your program continue and have success on the next request? |
Also supported:
board.LED
can be used with DigitalInOut and worksNot (yet) supported:
wifi.radio
listen
,bind
,accept
are not implemented (no servers)Also these modules/features are not supported or enabled yet:
At this point, it passes a couple of very simple tests (ntp and plaintext http with adafruit_requests), but is probably not particularly robust.
A big shout out to pico-sdk for providing a great basis for work, and micropython for modlwip, large portions of which were copied verbatim into CircuitPython, with attribution.
Todo:
It's my view that this can probably be merged independent of ssl/mdns/web workflow, though requests is not too useful in 2022 without ssl support.
Test script
do_dns_ping.py
:Test script:
do_ntp
:Test script:
do_requests_http.py
:Closes: #6558
Closes: #6628