-
Notifications
You must be signed in to change notification settings - Fork 41
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
Standalone example somewhere? #63
Comments
Yes, this is what I came up with: import asyncio, logging
from ble_serial.bluetooth.ble_interface import BLE_interface
def receive_callback(value: bytes):
print("Received:", value)
async def hello_sender(ble: BLE_interface):
while True:
await asyncio.sleep(3.0)
print("Sending...")
ble.queue_send(b"Hello world\n")
async def main():
# None uses default/autodetection, insert values if needed
ADAPTER = "hci0"
SERVICE_UUID = None
WRITE_UUID = None
READ_UUID = None
DEVICE = "20:91:48:4C:4C:54"
ble = BLE_interface(ADAPTER, SERVICE_UUID)
ble.set_receiver(receive_callback)
try:
await ble.connect(DEVICE, "public", 10.0)
await ble.setup_chars(WRITE_UUID, READ_UUID, "rw")
await asyncio.gather(ble.send_loop(), hello_sender(ble))
finally:
await ble.disconnect()
if __name__ == "__main__":
logging.basicConfig(level=logging.INFO)
asyncio.run(main()) Does that help? |
Thank you for answering so quickly. |
After a while I got your example working today. |
I would like to use your library without the com0com component.
Just directly from a python application on windows.
Do you have any sample code which you could share?
I am working with an nRF52840 board with CircuitPython installed and would like to communicate over the Nordic UART characteristic to send and receive data.
Looking at my device with an Bluetooth tool I see the characteristic UUID' which you just added.
Thanks
Thomas
The text was updated successfully, but these errors were encountered: