Commit Graph

433 Commits

Author SHA1 Message Date
Ted Hess 9825b7fbb7 Web Workflow sockets and threads handling improvements.
Fixes polling thread looping forever hangs preventing new connections.
Don't lose listening sockets on mp resets and re-init.
Keep better separation of "system" and "user" sockets.
Track socket states to prevent re-use of sockets before closed.
Close REST socket when transaction completes. No post-init.
Remove unnecessary state flags.
2023-04-05 13:50:42 -04:00
Dan Halbert 5c429320a8 Add wifi.radio.connected, wifi.radio.ap_active 2023-03-31 17:57:53 -04:00
Gregory Neverov 173bc198c6 don't set tcp_err callback for listen sockets 2023-03-29 11:49:32 -07:00
hathach 8c1095b268
Merge branch 'main' into add-codespell 2023-03-23 14:09:57 +07:00
Jeff Epler e05f0ba3b2
Revert "Correctly raise OS error in socketpool_socket_recv_into()"
This reverts commit 7e6e824d56.

Fixes #7770

The change in #7623 needs to be revered; the raise-site added in #7632
is the correct one and the one in socketpool needs to be reverted.

This is not affecting 8.0.x because #7623 was not back-ported to there
before we realized it was not a full fix.

Both #7770 and #7606 should be re-tested. I didn't test.
2023-03-22 14:32:06 -05:00
hathach fecc1bdedb
fix typos (partial) detected by codepell 2023-03-18 22:17:02 +07:00
Dan Halbert 859a48723f
Merge pull request #7633 from tannewt/fix_imx_pwm
Fix `pwmio` on iMX RT.
2023-02-28 14:11:06 -05:00
Dan Halbert f9831b3bbc
Merge pull request #7639 from adafruit/8.0.x
Merge 8.0.x up to main
2023-02-24 19:32:09 -05:00
Scott Shawcroft 1acf65ee22
Fix `pwmio` on iMX RT.
It now handles deinit, never_reset and sharing tracking. PWM
now runs in the WAIT state as well during a time.sleep().

_reset_ok() was removed because it was called in one spot right
before deinit().

Some PWMOut were also switched to a bitmap for use instead of
reference count. That way init and deinit are idempotent.

Fixes #6589. Fixes #4841. Fixes #4541.
2023-02-22 11:22:39 -08:00
Jeff Epler de9233f84a
raspberrypi: SSLSocket: raise OSError when appropriate
Rather than returning the negative error value.

This is intended to close #7606, though I did not test with mqtt.
Instead, I created a simple standalone test program:
```python
import wifi, socketpool, ssl, time
#wifi.radio.connect(<omitted>)
import socketpool
socket = socketpool.SocketPool(wifi.radio)
ctx = ssl.create_default_context()

b = bytearray(8)

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sss = ctx.wrap_socket(s, server_hostname='example.com')
sss.connect(('example.com', 443))
sss.setblocking(False)
r = sss.recv_into(b)
print(r, b)  # prints 4294967285 which is -11 as unsigned
sss.close()
```

Before the change, r was the out of range value 4294967285. After the
change, the recv_into call raises OSError instead.

This is comparable to the behavior on standard Python, though an
SSLWantReadError is raised instead.

The original (mis)behavior seems to match what was uncovered deep inside
minimqtt by adding logging:
```
370.578: DEBUG - PKT: _sock_exact_recv: recv_len = 4294967285
```
2023-02-22 10:07:48 -06:00
root 7e6e824d56 Correctly raise OS error in socketpool_socket_recv_into() 2023-02-21 13:38:29 -06:00
MicroDev 508f2015b6
Merge pull request #7605 from Neradoc/pico-uart-in-use-error
Tweak the UART in use message on RP2040
2023-02-18 08:35:52 +05:30
Neradoc 13716c9c30 tweak the UART in use message on RP2040 2023-02-17 23:29:44 +01:00
Dan Halbert bbadc00599
Merge pull request #7577 from dhalbert/safemode-py
Implement safemode.py
2023-02-16 14:15:20 -05:00
MicroDev 32d86c3ea3
Merge pull request #7580 from adafruit/8.0.x
Merge 8.0.x up to main
2023-02-15 09:16:51 +05:30
Gregory Neverov 98b61279e4 Add function common_hal_busio_uart_never_reset for rp2 2023-02-14 09:05:24 -08:00
Dan Halbert d8231f1588 Implement safemode.py 2023-02-13 18:26:38 -05:00
Jeff Epler b9f689adf4 Use lowest drive level for PIO 2023-02-08 16:18:58 -06:00
Gregory Neverov 77c6daf4b8 don't throw exception 2023-02-01 16:33:22 -08:00
Dan Halbert 13338df9f1
Merge pull request #7462 from tannewt/fix_rp2_reset_reason
Tweak RP2040 reset reason
2023-01-19 21:10:57 -05:00
Scott Shawcroft 82a313065e
Tweak RP2040 reset reason
Watchdogs are used to reboot out of the bootloader. There is a
scratch register for user watchdogs. So use sdk functions to better
distinguish these.

Related to #7346
2023-01-17 16:12:08 -08:00
Scott Shawcroft 683e393878
Add comments for MDNS code 2023-01-17 14:07:30 -08:00
Scott Shawcroft ee2fe993dd
Fix repeated MDNS use on Pico W 2023-01-12 14:56:06 -08:00
Scott Shawcroft 5c517b7e5a
Handle MDNS deinited better. 2023-01-12 11:24:20 -08:00
Scott Shawcroft 78c2fa5b28
Merge pull request #7437 from dhalbert/improve-type-checking-error-msgs
Improve type validation error messages, especially for pins
2023-01-11 10:54:22 -08:00
Jeff Epler e817563ca0
Update cyw43-driver, fix no-password wifi
Now, open wifi works on Pico W, so this closes #7438.

For the web workflow it's now OK to either
 * specify an empty password string (as before)
 * not have the CIRCUITPY_WIFI_PASSWORD key at all (new functionality)
2023-01-10 15:07:17 -06:00
Dan Halbert a974402542 Improve type validation errors messages, especially for pins 2023-01-10 15:02:55 -05:00
Dan Halbert a3adcf0e1a clarify read-only mac address; reuse translate msgs 2023-01-02 10:13:20 -05:00
Jeff Epler 928fb0a9c4
Make the "name or service not known" message translatable 2022-12-26 13:58:31 -06:00
Dan Halbert 66efed5ba5 fix AuthMode printing regression 2022-12-15 15:49:58 -05:00
Jeff Epler 297657ea9a
Refactor so that all sites of name lookup failure result in gaierror 2022-12-14 14:45:32 -06:00
Jeff Epler 243ecc2502
remove debugging prints 2022-12-08 14:18:22 -06:00
Jeff Epler 1fe05cb8cd
pico w: re-use previous connection if ssid matches 2022-12-08 12:44:34 -06:00
Scott Shawcroft d7874e65c2
Merge pull request #7299 from BooleanMattock/main
Fix to Issue #7224 - Servo update slow due to PWM channel duty cycle update busy-wait
2022-12-05 12:54:41 -08:00
BooleanMattock afb5301cef Fix to Issue #7224 - tested 2022-12-02 20:21:40 -05:00
Scott Shawcroft 4c064c263e
Merge pull request #7294 from tannewt/analogbufio_rework
Rework the analogbufio API.
2022-12-02 14:53:16 -08:00
Scott Shawcroft f7504ff857
Tweaks based on review comments 2022-12-02 10:19:31 -08:00
Scott Shawcroft 255e997345
Rework the analogbufio API.
* read() is now readinto() and takes the buffer to write into.
* readinto() returns the number of valid samples.
* readinto() can be interrupted by ctrl-c.
* readinto() API doesn't support signed numbers because it never did.
* sample_rate is now required in the constructor because supported
  values will vary per-port.
* 16 bit values are full range. 12 bit samples from RP2040 are stretched
  in the same way they are for AnalogIn.

Fixes #7226
2022-12-01 17:46:07 -08:00
Bill Sideris f8070d2141
Change comment, and logic on dhcpserver 2022-11-30 21:51:50 +02:00
Bill Sideris 44d5326d4c
fix picow-ap 2022-11-30 19:36:00 +02:00
Bill Sideris 362018dcca
Merge branch 'main' into picow-ap 2022-11-30 19:11:03 +02:00
Scott Shawcroft c13ca95da1
Add MDNS support to Pico W
This adds both cpy-MAC.local and circuitpython.local support.

Fixes #7214
2022-11-28 16:15:28 -08:00
Scott Shawcroft ad2d190507
Merge pull request #7247 from tannewt/picow_web_workflow
Enable* web workflow for Pico W
2022-11-28 14:19:42 -08:00
Dan Halbert 17be447c4b correct Radio.connect() and .start_ap() signatures; clean up some code 2022-11-22 17:11:03 -05: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
Bill Sideris b40facd0b4
Error msg changes 2022-11-22 01:00:34 +02:00
Dan Halbert 1611cf98da have clock start high in SPI mode 3 2022-11-18 18:27:38 -05:00
Bill Sideris 88bd9ef6b8
just change the ap error 2022-11-18 22:51:05 +02:00
Bill Sideris b8cd6c093f
picow-ap progress 2022-11-17 21:47:39 +02:00
Bill Sideris a234b74e87
Merge branch 'adafruit:main' into picow-ap 2022-11-16 21:32:46 +02:00