• Hi, the code below should work to send the time to the device: it opens the connection, sends the command to update date, and then closes the connection.

    import asyncio
    from time import time
    from bleak import BleakClient
    
    
    UUID_NORDIC_TX = "6e400002-b5a3-f393-e0a9-e50e24dcca9e"
    UUID_NORDIC_RX = "6e400003-b5a3-f393-e0a9-e50e24dcca9e"
    
    
    async def main(address):
        buffer_size = 20
    
        print(f"Connecting to {address}...")
    
        async def send_command(command):
            c = command
            while len(c) > 0:
                await client.write_gatt_char(UUID_NORDIC_TX, bytearray(c[0:buffer_size]), True)
                c = c[buffer_size:]
    
        async with BleakClient(address) as client:
            print("Connected")
            print(f"Time: {time()}")
            await send_command(bytes(f"setTime({time()});\­n", "utf-8"))
    
    asyncio.run(main("d8:ee:7c:31:a9:c0"))
    

    I'm using something similar to this to periodically sync weather data and my personal agenda with the device

  • Does that require that Bangle.js 2 is not connected to phone or computer, as it can handle only one Bluetooth connection at a time?

About

Avatar for malaire @malaire started