Commit graph

98 commits

Author SHA1 Message Date
21a5c93ada IPv6: improvments based on review notes
* don't enable ipv6 by default due to privacy concerns
 * move list of board support for ipv6 to socketpool documentation
 * removed wifi.supports_ipvx properties
 * throw an exception when start_dhcp_client(ipv6=True) but not supported
2024-07-23 14:18:03 -05:00
99e5e66518 socketpool: Always use getaddrinfo_raise. 2024-07-22 16:20:34 -05:00
bee32ea826 Make return value of recvfrom_into & accept right for v6 addresses
only tested recvfrom_into as can't bind() v6 addresses yet

wifi workflow may be broken by this or maybe it was broken before
2024-07-17 17:15:22 -05:00
eaa6f99d0e Add v6 address support to SocketPool.getaddrinfo (on espressif) 2024-07-17 12:18:29 -05:00
Dan Halbert
3f4d9310ff CircuitPython files: replace STATIC with static 2024-05-20 11:02:17 -04:00
Dan Halbert
950b5d09d2 guard2once -s ... 2024-05-19 20:40:44 -04:00
Dan Halbert
747b7619ea update headers of most CircuitPython-only files 2024-05-17 14:56:28 -04:00
5973c4a86c socketpool: factor out constants
This header can be used by ssl even if there's no core socketpool
2024-03-21 13:54:40 -05:00
0c1db5e0cc socketpool: add type property to Socket objects
cpython socket objects have a `type` property which gives their
type as an integer (e.g., SOCK_STREAM). Add this for compatibility with
standard Python. It's needed for ssl, which currently just grabs the
value directly from an internal structure (naughty!)
2024-03-21 13:54:40 -05:00
7e7918ea80 socketpool: alphabetize dict names 2024-03-21 13:54:40 -05:00
Scott Shawcroft
9f3987aa3c
Require explicit socket port reuse
Doing it implicitly can lead to mistaken socket leaks and reuse.
It now matches CPython.

Fixes #8443
2024-02-16 14:31:19 -08:00
2f325740c2
Merge remote-tracking branch 'origin/8.2.x' into merge-8.2.x 2023-12-29 15:05:19 -06:00
CarsonCoder
9feadb030f Fix compilation errors 2023-12-29 12:54:02 -05:00
CarsonCoder
a9585a002c Fix compilation errors 2023-12-29 12:36:20 -05:00
CarsonCoder
ed60528574 Make precommit happy 2023-12-29 11:53:56 -05:00
CarsonCoder
da92e5df85 Remove some ipproto constants 2023-12-29 11:52:00 -05:00
CarsonCoder
ba7918af2e Clean up some code 2023-12-29 10:51:10 -05:00
CarsonCoder
2ae334717a Add socketpool.SocketPool.IPPROTO_ constants 2023-12-29 10:46:22 -05:00
CarsonCoder
8c567cc6f9 fix precommit 2023-12-29 09:16:03 -05:00
CarsonCoder
fb03b856d6 Rebase 2023-12-27 12:10:24 -05:00
d0c51a497a
socketpool: add read & write stream protocol support 2023-12-24 10:50:00 -06:00
5aa203f13e
Restore CIRCUITPY-CHANGEs for stream protocols
We mark all protocols with their type using MP_PROTO_IMPLEMENT,
and checking in mp_get_stream{,_raise}.

This was not turning up as a problem in tests until a (new, not yet
commited) change to jpegio caused a segfault because a type implementing
a different protocol was passed in to mp_get_stream.

By using 0 (instead of MP_QSTR_protocol_stream) as the marker for
objects implementing the standard micropython stream protocol, the
number of CIRCUITPY-CHANGEs is minimized.
2023-12-24 10:41:54 -06:00
CarsonCoder
211c307f79 At proto support for espressif port + global 2023-12-23 17:59:31 -05:00
774f6ac6ab
Switch to using MP_ERROR_TEXT instead of translate, globally 2023-10-30 09:49:06 +01:00
Dan Halbert
c0a4abc03c Fix merge bugs; remove shared/tinyusb/* 2023-10-19 16:02:42 -04:00
Scott Shawcroft
1f38293096
Fix ESP related issues 2023-10-11 14:11:29 -07:00
Scott Shawcroft
9633c4e78f
Merge remote-tracking branch 'adafruit/main' into v1.20-merge 2023-10-11 11:21:57 -07:00
Dan Halbert
4d175ab41a convert to MP_DEFINED_CONST_OBJ_TYPE() 2023-09-19 21:09:29 -04:00
c029d6a165
Merge remote-tracking branch 'origin/8.2.x' into merge-82x 2023-08-22 08:49:16 -05:00
d23ddff971
Add several constants needed to use multicast UDP
This was verified by @todbot to work on esp32 s2 and s3;
the constant should match any system that uses LWIP numbering.
2023-08-21 16:19:58 -05:00
Dan Halbert
0d2c3c3f08 wip: continuing compilation fixes; mp_obj_alloc everywhere 2023-08-07 20:45:57 -04:00
MicroDev
d9d94eacca
run updated pre-commit 2023-02-01 13:38:41 +05:30
928fb0a9c4
Make the "name or service not known" message translatable 2022-12-26 13:58:31 -06:00
297657ea9a
Refactor so that all sites of name lookup failure result in gaierror 2022-12-14 14:45:32 -06:00
aef55b7e41
Add SocketPool.gaierror
gaierror(-2) is raised in the failure case of getaddrinfo. This is
compatible with cpython's socket module.

Typical session:
```
>>> import socketpool
>>> import wifi
>>> socket = socketpool.SocketPool(wifi.radio)
>>> try: socket.getaddrinfo("boo", 0)
... except socket.gaierror as e: ee = e
...
>>> type(ee)
<class 'gaierror'>
>>> ee.errno == socket.EAI_NONAME
True
>>> ee.strerror
'Name or service not known'
>>> raise ee
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 1, in <module>
gaierror: (-2, 'Name or service not known')
```

Closes: #6941
2022-11-28 16:57:44 -06:00
Scott Shawcroft
dc20390588
Fix stubs 2022-11-22 09:04:12 -08:00
Scott Shawcroft
c3a96a63c0
Enable* web workflow for Pico W
* Except for circuitpython.local which depends on MDNS and will be
done in a follow up PR.

Progress on #7214
2022-11-21 16:24:05 -08:00
452ebe27ae
socketpool: make socket objects selectable
.. which will lead to them being usable in async contexts, pending
relevant changes in asyncio
2022-11-05 12:05:19 -05:00
de0dda989d
Ensure background tasks are serviced during a lengthy sendall 2022-10-19 11:18:29 -05:00
508c80da8d
socketpool: add sendall
The standard Python 'fix' for 'send()' returning prematurely is to
use the 'sendall()' method instead. However, this method was not
available.  adafruit_httpserver will probably need to code a version
of it for older versions or for Airlift, but when it's available
this code works (Tested on picow sending 8192 bytes) and may be more
efficient.

(implementing 'sendall' in python should take care to slice a memoryview
rather than the original buffer)
2022-10-17 19:42:09 -05:00
907c5d387f
Tweak black_bindings
Originally, black_bindings found each contiguous "//|" block and sent
it to black independently. This was slower than it needed to be.

Instead, swap the comment prefix: when running black, take off
"//|" prefixes and put "##|" prefixes on all un-prefixed lines.
Then, after black is run, do the opposite operation

This more than doubles the overall speed of "pre-commit run --all",
from 3m20s to 55s CPU time on my local machine (32.5s to under 10s
"elapsed" time)

It also causes a small amount of churn in the bindings, because
black now sees enough context to know whether one 'def' follows another
or ends the 'def's in a 'class'. In the latter case, it adds an extra
newline, which becomes a "//|" line.

I'm less sure why a trailing comma was omitted before down in
rp2pio/StateMachine.c but let's roll with it.
2022-09-30 11:18:13 -05:00
Dan Halbert
db065a299f
Merge pull request #6933 from jepler/🥧🐮
Implement a useful subset of `wifi` and `socketpool` modules on 🥧🐮
2022-09-28 18:09:24 -04:00
a7a1bd7880
Implement DNS resolution
```
>>> s = socketpool.SocketPool(wifi.radio)
>>> s.getaddrinfo("google.com", 80)
[(0, 0, 0, '', ('142.250.81.206', 80))]
```
2022-09-28 10:06:33 -05:00
b2cc8d2aad
run black_bindings across all bindings 2022-09-27 15:21:42 -05:00
Alec Delaney
85f0206fa4 Document socketpool.SocketPool.__init__() 2022-09-01 19:44:08 -04:00
Scott Shawcroft
61d0f7947b
WIP doesn't flush response before closing 2022-06-27 13:34:13 -07:00
Scott Shawcroft
301f3e0456
Start of web server 2022-06-27 13:34:13 -07:00
Scott Shawcroft
6446010753
Wi-Fi autoconnect and title bar status
This adds support for CIRCUITPY_WIFI_SSID and CIRCUITPY_WIFI_PASSWORD
in `/.env`. When both are defined, CircuitPython will attempt to
connect to the network even when user code isn't running. If the
user code attempts to a network with the same SSID, it will return
immediately. Connecting to another SSID will disconnect from the
auto-connected network. If the user code initiates the connection,
then it will be shutdown after user code exits. (Should match <8
behavior.)

This PR also reworks the default displayio terminal. It now supports
a title bar TileGrid in addition to the (newly renamed) scroll area.
The default title bar is the top row of the display and is positioned
to the right of the Blinka logo when it is enabled. The scroll area
is now below the Blinka logo.

The Wi-Fi auto-connect code now uses the title bar to show its
state including the IP address when connected. It does this through
the "standard" OSC control sequence `ESC ] 0 ; <s> ESC \` where <s>
is the title bar string. This is commonly supported by terminals
so it should work over USB and UART as well.

Related to #6174
2022-06-09 14:55:54 -07:00
Dan Halbert
ce959a9af4
Merge pull request #6342 from dhalbert/pin-hash
make Pin hashable
2022-05-03 22:43:46 -04:00
Dan Halbert
68acd14342 use generic hash routine where possible 2022-05-03 19:11:54 -04:00