-
Notifications
You must be signed in to change notification settings - Fork 4
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
Use new SocketPool for ESP32SPI and WIZNET5K #11
Use new SocketPool for ESP32SPI and WIZNET5K #11
Conversation
0447e9f
to
85713ef
Compare
Some day soon, I expect I'll be wiring up some monstrosity with native wifi and multiple ethernets and multiple ESP32SPIs ;-) |
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 is working as expected.
Test code here.
Config with a native wifi, a WIZnet, and an ESP32SPI. Each radio has a socketpool, each pool is managed by a unique ConnectionManager. HTTP sessions were observed at the router from each radio's IP address, corresponding to the serial output sequence.
P.S. SSL also works on all links in this config when using 20240425-main-PR8954-c92bb9b.uf2
(or newer) ...native ssl
on native wifi and WIZnet; SSL via NINA on ESP32SPI.
Open question we were discussing on Discord is whether this PR is intended to handle multiple radios of the same class (native wifi, eth, or esp). Code to loop and append to lists the multiple radios-pools-contexts-requests for each similar device works if I manually create the socketpools fed to Requests: radios.append(ESP_SPIcontrol(spi, esp32_cs, esp32_ready, esp32_reset))
# -----------v
pools.append(socketpool.SocketPool(radio[i]))
ssl_contexts.append(adafruit_connection_manager.get_radio_ssl_context(radios[i]))
requestss.append(adafruit_requests.Session(pools[i], ssl_contexts[i]))
connection_managers.append(adafruit_connection_manager.get_connection_manager(pools[i])) In that case, each radio, pool, context, requests, and connection manager is unique, and the router sees requests from each device's IP address. If ConnectionManager creates the socketpools fed to Requests, each radio is still unique, but the pools and connection managers are the same for all devices in the same class, and only the first radio gets used: radios.append(ESP_SPIcontrol(spi, esp32_cs, esp32_ready, esp32_reset))
# -----------v
pools.append(adafruit_connection_manager.get_radio_socketpool(radios[i]))
ssl_contexts.append(adafruit_connection_manager.get_radio_ssl_context(radios[i]))
requestss.append(adafruit_requests.Session(pools[i], ssl_contexts[i]))
connection_managers.append(adafruit_connection_manager.get_connection_manager(pools[i])) Full code here. |
@anecdata if you are up for a retest, I just pushed a fix for getting a new pool for a different radio. The |
@justmobilize On which chips does Adafruit CircuitPython 9.0.0-alpha.2 on 2023-10-27; Adafruit Feather ESP32-S2 Reverse TFT with ESP32S2
>>> import wifi
>>> hash(wifi.radio)
1073582920 |
@dhalbert interesting... If you do: x = {wifi.radio: 1} It raises: TypeError: unsupported type for __hash__: 'Radio' So maybe it's an issue with I can test using a manual hash key, since that would be cleaner. |
>>> { wifi.radio: 1 }
{<Radio>: 1} Which board are you testing on, with which version of CPy? |
@dhalbert, scrolled through my tests (because I remembered this from when I built CM) - it's a CP8 issue: |
Those hashing changes did the trick. Thanks @justmobilize! |
@anecdata when you have time (you've tested this so much for me already, thank you!) will you pull down the latest of all 3 branches. Had some conflicts and tweaks, and although I don't expect anything to not work, it's worth a quick check. |
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.
Confirmed everything still works as before. Tested HTTP and HTTPS URLs.
Libraries::
Adafruit_CircuitPython_ConnectionManager Use new SocketPool for ESP32SPI and WIZNET5K #11
Merge branch 'main' into esp32spi-and-wiznet5k-socketpool cd9f892
Adafruit_CircuitPython_Wiznet5k Convert to SocketPool #159
Merge branch 'main' into convert-to-socketpool e1c0ac7
Adafruit_CircuitPython_ESP32SPI Convert to SocketPool #198
Use standard super() for __new__ 06281a5
Hardware:
Tested on a config with native wifi, ethernet, and esp32spi (1 each), on a config with 3 ethernets, and on a config with 3 esp32spis. Each device gets a unique SocketPool and a unique ConnectionManager, repeated Requests are successful, and sessions / IP addresses of each device show up appropriately at the router..
@dhalbert limiting notifications, but this and the 2 PRs in the description are ready for review |
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.
I asked some questions.
@dhalbert updated. Have you also looked at adafruit/Adafruit_CircuitPython_Wiznet5k#159 and adafruit/Adafruit_CircuitPython_ESP32SPI#198 yet? |
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.
Ok, thanks for your patience, and thanks @anecdata for testing.
Updating https://github.com/adafruit/Adafruit_CircuitPython_ESP32SPI to 8.0.0 from 7.1.0: > Merge pull request adafruit/Adafruit_CircuitPython_ESP32SPI#198 from justmobilize/convert-to-socketpool Updating https://github.com/adafruit/Adafruit_CircuitPython_Wiznet5k to 7.0.0 from 6.0.0: > Merge pull request adafruit/Adafruit_CircuitPython_Wiznet5k#159 from justmobilize/convert-to-socketpool Updating https://github.com/adafruit/Adafruit_CircuitPython_ConnectionManager to 2.0.0 from 1.2.1: > Merge pull request adafruit/Adafruit_CircuitPython_ConnectionManager#11 from justmobilize/esp32spi-and-wiznet5k-socketpool Updating https://github.com/adafruit/Adafruit_CircuitPython_Bundle/circuitpython_library_list.md to NA from NA: > Updated download stats for the libraries
For use with: adafruit/Adafruit_CircuitPython_Wiznet5k#159 and adafruit/Adafruit_CircuitPython_ESP32SPI#198