kevincar / bless

Cross-platform Bluetooth Low Energy Server Python Library
MIT License
86 stars 28 forks source link

Initial values in gatt_tree not used #67

Closed WouterJD closed 2 years ago

WouterJD commented 2 years ago

The problem Initial values in gatt_tree not used

Reproduction Run gattserver.py

Expected behavior Provide a clear and concise description of what you expected to happen.

Screenshots Not applicable

Desktop (please complete the following information):

Additional context gattserver.py:

    gatt: Dict = {
            "A07498CA-AD5B-474E-940D-16F1FBE7E8CD": {
                "51FF12BB-3ED8-46E5-B4F9-D64E2FEC021B": {
                    "Properties": (GATTCharacteristicProperties.read |
                                   GATTCharacteristicProperties.write |
                                   GATTCharacteristicProperties.indicate),
                    "Permissions": (GATTAttributePermissions.readable |
                                    GATTAttributePermissions.writeable),
                    "Value": None
                    }
                }
            }

server.py: value is in lowercase

    async def add_gatt(self, gatt_tree: Dict):
        """
        Uses the provided dictionary add all the services and characteristics

        Parameters
        ----------
        gatt_tree : Dict
            A dictionary of services and characteristics where the keys are the
            uuids and the attributes are the properties
        """
        for service_uuid, service_info in gatt_tree.items():
            await self.add_new_service(service_uuid)
            for char_uuid, char_info in service_info.items():
                await self.add_new_characteristic(
                        service_uuid, char_uuid, char_info.get("Properties"),
                        char_info.get("value"), char_info.get("Permissions")
                        )
kevincar commented 2 years ago

merged #68