You need to read up on Python packages. The server example I gave you is organised as a package, and the import is from __init__.py. However I wouldn't spend time trying to follow the application code.
I suggest you look at the _send and _read methods as examples of how to write to and to read from nonblocking sockets. The key point is that an operation on a nonblocking socket returns immediately whether or not it has completed the job it was given. A read may return partial data or none, and a write may not write everything. So your code has to handle those conditions as well as coping with errors.
The other part which might be of interest is the _run method which performs the initial connection to one or more clients.
ESP32 Debouncing Switches & Relays: IRQ Timer vs Simple Code vs ASYNC
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: ESP32 Debouncing Switches & Relays: IRQ Timer vs Simple Code vs ASYNC
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
Re: ESP32 Debouncing Switches & Relays: IRQ Timer vs Simple Code vs ASYNC
Hi Peter, thank you very much for your reply; it is very much appreciated.
I will follow your advice and study the Python syntax. My main problem was the de-bouncing, and that async approach of yours works like a charm.
Best Regards, AB
I will follow your advice and study the Python syntax. My main problem was the de-bouncing, and that async approach of yours works like a charm.
Best Regards, AB