adafruit / Adafruit_CircuitPython_BLE

Bluetooth Low Energy (BLE) library for CircuitPython
MIT License
129 stars 58 forks source link

Async API #201

Open rvadhavk opened 3 months ago

rvadhavk commented 3 months ago

Looking through the documentation at https://docs.circuitpython.org/projects/ble/en/latest/api.htm and example code at https://learn.adafruit.com/circuitpython-nrf52840/location, it seems that you have to poll the BLERadio.connected instance variable as opposed to awaiting a central connecting to the peripheral. Is there an async API to avoid having to poll for things like new connections or writes to writable characteristics?

dhalbert commented 3 months ago

There is no async API, though you can write an async task that polls and asyncio.sleep()'s. We are gradually looking at async support for HTTPServer and the like. If you have some ideas, or like an existing API, feel free to comment.