Python Forum

Full Version: Using Bleck to write
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hey everyone,


does anyone have experience using bleak?

I am trying to write to a device using this:

async def run(address):
    async with BleakClient(address) as client:
        answer = await client.write_gatt_char('00001001-0000-1000-8000-00805f9b34fb', b'stringValue', response=True)
        print(answer)
and I get:
txdbus.error.MarshallingError: List, Tuple, Bytearray, or Dictionary required for DBus array.  Received:
I try encoding the text as follows:

async def run(address):
    async with BleakClient(address) as client:
        answer = await client.write_gatt_char('00001001-0000-1000-8000-00805f9b34fb', bytearray('stringValue', 'utf-8'), response=True)
        print(answer)
and it return's none, and the device doesn't do what it is supposed to

when I send the same value using an iPhone Gatt app, it has no problem. what am I doing wrong? is it the encoding I picked?

Thanks