Brilliant! Finally got something to work...
bleak works on my laptop.
The example gives the impression that the mac address of the BangleJS is good enough to connect to it, but that didn't work. So instead I commented out the command
run and used the discover
run to first get the address. It came out as a long set of strings for all the nearby BLE devices, thankfully it identified Bangle as follows (I've mangled the last 5 characters).
0DB07D6F-8F0F-4CB3-A801-0D9A868XX9XX: Bangle.js ed8a
I then used this as the address and the following code came back with a list of files though it is still a bit mangled, but it's a start.
from bleak import discover
from bleak import BleakClient
address = "0DB07D6F-8F0F-4CB3-A801-0D9A868XX9XX"
UUID_NORDIC_TX = "6e400002-b5a3-f393-e0a9-e50e24dcca9e"
UUID_NORDIC_RX = "6e400003-b5a3-f393-e0a9-e50e24dcca9e"
command = b"\x03\x10var f = require('Storage')\n\x10 print(f.list())\n\x10print('Hello World')\n"
def uart_data_received(sender, data):
# You can scan for devices with:
# async def run():
# devices = await discover()
# for d in devices:
async def run(address, loop):
async with BleakClient(address, loop=loop) as client:
await client.start_notify(UUID_NORDIC_RX, uart_data_received)
await client.write_gatt_char(UUID_NORDIC_TX, bytearray(c[0:20]), True)
c = c[20:]
print("Waiting for data")
await asyncio.sleep(1.0, loop=loop) # wait for a response
loop = asyncio.get_event_loop()