Closed FoamyGuy closed 7 months ago
Most of this was also done in #139. with the latest commits I've merged main and resolved conflicts as well as one tweak that resolves #141 so that the library can be successfully initialized.
Re-tested successfully on a Feather RP2040 although I've noticed with my setup it consistently fails if my ethernet featherwing is connected to an ethernet switch rather than directly to the router. I have a PC and RasPi on that same switch that work fine but the microcontroller + Ethernet featherwing and this library do not. I suspect that is something specific to my environment and not an issue with this library.
This PR has two primary chagnes:
1) make recv() function timeout with the same behavior as CPython sockets, and ESP32SPI socket from the changes in: https://github.com/adafruit/Adafruit_CircuitPython_ESP32SPI/pull/167
This change is necessary in order to have the MiniMQTT library function as expected. Without this change when you call mqtt_client.loop() it will never return until actual data has been recieved. But it should be returning sooner based on the timeout behavior when there is no data.
This comment: https://github.com/adafruit/Adafruit_CircuitPython_ESP32SPI/pull/167#issuecomment-1597596851 contains CPython code snippets that illustrate the timeout behavior of the socket. The changes in this PR will make the wiznet socket behave the same.
The CPython socket has a custom exception class called
timeout
which I've added as well. There were a few other unrelated function arguments that already had the nametimeout
so pylint started complaining about overwriting from outer scope. I've changed those arguments to have leading underscores.I tested this change succesfully using an Ethernet Featherwing with a Feather ESP32-S3 TFT
8.2.0-beta.0
I tested with simpletest, simpleserver, and aio_post examples from this repo, the ethernet adafruitio example in the MiniMQTT library, as well as the new HTTPServer example added and explained below.2) Add an example that shows how to use this library with: https://github.com/adafruit/Adafruit_CircuitPython_HTTPServer I also opened: https://github.com/adafruit/Adafruit_CircuitPython_HTTPServer/pull/59 over there adding this same example code in that repo. I think it makes sense to exist in both places because I could easily imagine people discovering it in either while researching possibilities.