Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/perbu/dgram
Async UDP server in Micropython using the new uasyncio lib
https://github.com/perbu/dgram
micropython uasyncio udp
Last synced: 2 months ago
JSON representation
Async UDP server in Micropython using the new uasyncio lib
- Host: GitHub
- URL: https://github.com/perbu/dgram
- Owner: perbu
- License: mit
- Created: 2020-04-08T15:40:13.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-09T16:48:08.000Z (about 2 years ago)
- Last Synced: 2024-04-22T00:24:14.339Z (9 months ago)
- Topics: micropython, uasyncio, udp
- Language: Python
- Size: 18.6 KB
- Stars: 20
- Watchers: 3
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Simple UDP listening service for uasyncio
Super simple UDP-listener for the new (April 2020) uasyncio library. It invokes a callback. The return value of the callback (if any) is sent as a response to the client. If None is turned nothing is sent to the client.
Sending is sync.
Not sure if I should have a zero timeout on the poll. I've defaulted to 1ms which is good enough for me. Opinions welcome.
Usage:
```
from dgram import UDPServer
import uasyncio
(..)port=12345
def cb(msg, adr):
print('Got:', msg)
return 'ack'.encode('ascii')def main():
s = UDPServer()
l = uasyncio.get_event_loop()
l.run_until_complete(s.serve(cb, '0.0.0.0', port))```