# Buggy code
async def get_services(self) -> dict:
    """Get all services registered for this GATT server.

    Returns:
        Dictionary of all service UUIDs as keys and
        service object's properties as values.

    """
    if self.services:
        return self.services

    while True:
        properties = await self._get_device_properties()
        services_resolved = properties.get("ServicesResolved", False)
        if services_resolved:
            break
        await asyncio.sleep(0.02, loop=self.loop)

    logger.debug("Get Services...")
    objs = await get_managed_objects(
        self._bus, self.loop, self._device_path + "/service"
    )
    self.services = {}
    self.characteristics = {}
    self._descriptors = {}
    for object_path, interfaces in objs.items():
        logger.debug(utils.format_GATT_object(object_path, interfaces))
        if defs.GATT_SERVICE_INTERFACE in interfaces:
            service = interfaces.get(defs.GATT_SERVICE_INTERFACE)
            self.services[service.get("UUID")] = service
            self.services[service.get("UUID")]["Path"] = object_path
        elif defs.GATT_CHARACTERISTIC_INTERFACE in interfaces:
            char = interfaces.get(defs.GATT_CHARACTERISTIC_INTERFACE)
            self.characteristics[char.get("UUID")] = char
            self.characteristics[char.get("UUID")]["Path"] = object_path
            self._char_path_to_uuid[object_path] = char.get("UUID")
        elif defs.GATT_DESCRIPTOR_INTERFACE in interfaces:
            desc = interfaces.get(defs.GATT_DESCRIPTOR_INTERFACE)
            self._descriptors[desc.get("UUID")] = desc
            self._descriptors[desc.get("UUID")]["Path"] = object_path

    self._services_resolved = True
    return self.services


# 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 get_services(self) -> BleakGATTServiceCollection:
    """Get all services registered for this GATT server.

    Returns:
       A :py:class:`bleak.backends.service.BleakGATTServiceCollection` with this device's services tree.

    """
    if self._services_resolved:
        return self.services

    while True:
        properties = await self._get_device_properties()
        services_resolved = properties.get("ServicesResolved", False)
        if services_resolved:
            break
        await asyncio.sleep(0.02, loop=self.loop)

    logger.debug("Get Services...")
    objs = await get_managed_objects(
        self._bus, self.loop, self._device_path + "/service"
    )

    for object_path, interfaces in objs.items():
        logger.debug(utils.format_GATT_object(object_path, interfaces))
        if defs.GATT_SERVICE_INTERFACE in interfaces:
            service = interfaces.get(defs.GATT_SERVICE_INTERFACE)
            self.services.add_service(BleakGATTServiceBlueZDBus(service, object_path))
        elif defs.GATT_CHARACTERISTIC_INTERFACE in interfaces:
            char = interfaces.get(defs.GATT_CHARACTERISTIC_INTERFACE)
            _service = list(filter(lambda x: x.path == char["Service"], self.services))
            self.services.add_characteristic(
                BleakGATTCharacteristicBlueZDBus(char, object_path, _service[0].uuid)
            )
            self._char_path_to_uuid[object_path] = char.get("UUID")
        elif defs.GATT_DESCRIPTOR_INTERFACE in interfaces:
            desc = interfaces.get(defs.GATT_DESCRIPTOR_INTERFACE)
            _characteristic = list(
                filter(
                    lambda x: x.path == desc["Characteristic"],
                    self.services.characteristics.values(),
                )
            )
            self.services.add_descriptor(
                BleakGATTDescriptorBlueZDBus(desc, object_path, _characteristic[0].uuid)
            )

    self._services_resolved = True
    return self.services