# Buggy code
async def write_gatt_char(
    self, _uuid: str, data: bytearray, response: bool = False
) -> Any:
    """Perform a write operation of the specified characteristic.

    Args:
        _uuid (str or UUID): The uuid of the characteristics to start notification on.
        data (bytes or bytearray): The data to send.
        response (bool): If write response is desired.

    """
    characteristic = self.characteristics.get(str(_uuid))
    if not characteristic:
        raise BleakError("Characteristic {0} was not found!".format(_uuid))

    write_results = await wrap_Task(
        self._bridge.WriteCharacteristicValueAsync(characteristic, data, response),
        loop=self.loop,
    )
    if write_results == GattCommunicationStatus.Success:
        logger.debug("Write Characteristic {0} : {1}".format(_uuid, data))
    else:
        raise BleakError(
            "Could not write value {0} to characteristic {1}: {2}",
            data,
            characteristic.Uuid.ToString(),
            write_results,
        )


# Traceback (bleak.exc.BleakError)
Traceback (most recent call last):
File "/home/jonas/Schreibtisch/TMRTFlib.py", line 572, in <module>
loop.run_until_complete(connect_device_bleak(address, loop))
File "/usr/lib/python3.6/asyncio/base_events.py", line 473, in run_until_complete
return future.result()
File "/home/jonas/Schreibtisch/TMRTFlib.py", line 552, in connect_device_bleak
async with BleakClient(address, loop=loop) as client:
File "/home/jonas/.local/lib/python3.6/site-packages/bleak/backends/client.py", line 35, in __aenter__
await self.connect()
File "/home/jonas/.local/lib/python3.6/site-packages/bleak/backends/bluezdbus/client.py", line 76, in connect
raise BleakError(str(e))
bleak.exc.BleakError: org.freedesktop.DBus.Error.UnknownObject: Method "Connect" with signature "" on interface "org.bluez.Device1" doesn't exist

# Fixed code
async def write_gatt_char(
    self, _uuid: str, data: bytearray, response: bool = False
) -> Any:
    """Perform a write operation of the specified characteristic.

    Args:
        _uuid (str or UUID): The uuid of the characteristics to write to.
        data (bytes or bytearray): The data to send.
        response (bool): If write response is desired.

    """
    characteristic = self.services.get_characteristic(str(_uuid))
    if not characteristic:
        raise BleakError("Characteristic {0} was not found!".format(_uuid))

    writer = DataWriter()
    writer.WriteBytes(Array[Byte](data))
    if response:
        write_result = await wrap_IAsyncOperation(
            IAsyncOperation[GattWriteResult](
                characteristic.obj.WriteValueWithResultAsync(writer.DetachBuffer())
            ),
            return_type=GattWriteResult,
            loop=self.loop,
        )
        status = write_result.Status
    else:
        write_result = await wrap_IAsyncOperation(
            IAsyncOperation[GattCommunicationStatus](
                characteristic.obj.WriteValueAsync(writer.DetachBuffer())
            ),
            return_type=GattCommunicationStatus,
            loop=self.loop,
        )
        status = write_result
    if status == GattCommunicationStatus.Success:
        logger.debug("Write Characteristic {0} : {1}".format(_uuid, data))
    else:
        raise BleakError(
            "Could not write value {0} to characteristic {1}: {2}".format(
                data, characteristic.uuid, write_result.Status
            )
        )