# Path: bluetooth_low_energy/api/descriptor.py
# class Descriptor(object):
#     """ Descriptor """
# 
#     def __init__(self, uuid, value,
#                  perms=PERM_NONE,
#                  acc=ACC_NO_ACCESS,
#                  mask=MASK_DONT_NOTIFY_EVENTS,
#                  is_variable=True):
#         if not isinstance(uuid, UUID):
#             raise TypeError("uuid must be of type UUID")
#         if not isinstance(acc, int):
#             raise TypeError("acc must be of type int")
#         if not isinstance(perms, int):
#             raise TypeError("perms must be of type int")
#         if not isinstance(mask, int):
#             raise TypeError("mask must be of type int")
# 
#         self.service_handle = None
#         self.char_handle = None
#         self.handle = None
#         self.uuid = uuid
#         self.value = value
#         self.perms = perms
#         self.acc = acc
#         self.mask = mask
#         self.is_variable = is_variable
# 
#     def __properties__(self, service_handle=None, char_handle=None):
#         self.service_handle = service_handle
#         self.char_handle = char_handle
#         return dict(
#             service_handle=self.service_handle,
#             char_handle=self.char_handle,
#             desc_uuid_type=self.uuid.uuid_type,
#             uuid=self.uuid.value,
#             desc_value_max_len=len(self.value),
#             desc_value_len=len(self.value),
#             desc_value=self.value,
#             sec_permissions=self.perms,
#             acc_permissions=self.acc,
#             gatt_evt_mask=self.mask,
#             encry_key_size=st_constant.MAX_ENCRY_KEY_SIZE,
#             is_variable=self.is_variable
#         )
# 
#     def __str__(self):
#         return "<Descriptor uuid={!s}>".format(self.uuid)
# 
#     def __write_proprerties__(self, buffer=None, offset=0):
#         if not isinstance(buffer, (bytes, bytearray, memoryview)):
#             raise TypeError("buffer must of type bytes or bytearray.")
#         return dict(
#             serv_handle=self.service_handle,
#             char_handle=self.char_handle,
#             char_desc_handle=self.handle,
#             char_desc_val_offset=offset,
#             char_desc_value_len=len(buffer),
#             char_desc_value=buffer
#         )
# 
# Path: bluetooth_low_energy/api/uuid.py
# class UUID(object):
#     """ UUID """
# 
#     def __init__(self, value):
#         if isinstance(value, (str, UUID)):
#             value = str(value).replace('-', '')
#         else:
#             raise TypeError("value must be of type UUID or str.")
#         self.value = unhexlify(value)
#         if len(self.value) not in (2, 16):
#             raise ValueError(
#                 "UUID must be 2 or 16 bytes, got {:d} bytes".format(
#                     len(self.value)
#                 )
#             )
#         self.value = bytes(reversed(self.value))
#         self.uuid_type = UUID_16_BIT if len(self.value) == 2 else UUID_128_BIT
# 
#     def __properties__(self):
#         return dict(
#             uuid_type=self.uuid_type,
#             value=self.value,
#         )
# 
#     def __str__(self):
#         value = hexlify(bytes(reversed(self.value)))
#         return (
#             b'-'.join(
#                 [
#                     value[0:8],
#                     value[8:12],
#                     value[12:16],
#                     value[16:20],
#                     value[20:32]
#                 ]
#             ) if len(self.value) == 16 else value
#         ).decode('ascii')
# 
#     def __eq__(self, other):
#         return self.value == UUID(other).value
# 
#     def __hash__(self):
#         return hash(self.value)


from bluetooth_low_energy.api.constants import *
from bluetooth_low_energy.api.descriptor import Descriptor
from bluetooth_low_energy.api.uuid import UUID

    def __properties__(self, service_handle=None, char_value_len=20):
        self.service_handle = service_handle
        self.char_value_len = char_value_len
        return dict(
            service_handle=self.service_handle,
            char_uuid_type=self.uuid.uuid_type,
            char_uuid=self.uuid.value,
            char_value_len=self.char_value_len,
            char_properties=self.props,
            sec_permissions=self.perms,
            gatt_evt_mask=self.mask,
            encry_key_size=st_constant.MAX_ENCRY_KEY_SIZE,
            is_variable=self.is_variable
        )

    def __str__(self):
        descriptors = self.get_descriptors()
        return "<Characteristic uuid={!s} handle={:02x} descriptors=[{:s}]".format(
            self.uuid,
            self.handle or 0,
            "".join(
                "{!s}{:s}".format(
                    c, (", " if i < len(descriptors) - 1 else "")
                ) for i, c in enumerate(descriptors)
            )
        )

    def add_descriptor(self, descriptor):
        """ add_descriptor """

# Path: bluetooth_low_energy/api/descriptor.py
# class Descriptor(object):
#     """ Descriptor """
# 
#     def __init__(self, uuid, value,
#                  perms=PERM_NONE,
#                  acc=ACC_NO_ACCESS,
#                  mask=MASK_DONT_NOTIFY_EVENTS,
#                  is_variable=True):
#         if not isinstance(uuid, UUID):
#             raise TypeError("uuid must be of type UUID")
#         if not isinstance(acc, int):
#             raise TypeError("acc must be of type int")
#         if not isinstance(perms, int):
#             raise TypeError("perms must be of type int")
#         if not isinstance(mask, int):
#             raise TypeError("mask must be of type int")
# 
#         self.service_handle = None
#         self.char_handle = None
#         self.handle = None
#         self.uuid = uuid
#         self.value = value
#         self.perms = perms
#         self.acc = acc
#         self.mask = mask
#         self.is_variable = is_variable
# 
#     def __properties__(self, service_handle=None, char_handle=None):
#         self.service_handle = service_handle
#         self.char_handle = char_handle
#         return dict(
#             service_handle=self.service_handle,
#             char_handle=self.char_handle,
#             desc_uuid_type=self.uuid.uuid_type,
#             uuid=self.uuid.value,
#             desc_value_max_len=len(self.value),
#             desc_value_len=len(self.value),
#             desc_value=self.value,
#             sec_permissions=self.perms,
#             acc_permissions=self.acc,
#             gatt_evt_mask=self.mask,
#             encry_key_size=st_constant.MAX_ENCRY_KEY_SIZE,
#             is_variable=self.is_variable
#         )
# 
#     def __str__(self):
#         return "<Descriptor uuid={!s}>".format(self.uuid)
# 
#     def __write_proprerties__(self, buffer=None, offset=0):
#         if not isinstance(buffer, (bytes, bytearray, memoryview)):
#             raise TypeError("buffer must of type bytes or bytearray.")
#         return dict(
#             serv_handle=self.service_handle,
#             char_handle=self.char_handle,
#             char_desc_handle=self.handle,
#             char_desc_val_offset=offset,
#             char_desc_value_len=len(buffer),
#             char_desc_value=buffer
#         )
# 
# Path: bluetooth_low_energy/api/uuid.py
# class UUID(object):
#     """ UUID """
# 
#     def __init__(self, value):
#         if isinstance(value, (str, UUID)):
#             value = str(value).replace('-', '')
#         else:
#             raise TypeError("value must be of type UUID or str.")
#         self.value = unhexlify(value)
#         if len(self.value) not in (2, 16):
#             raise ValueError(
#                 "UUID must be 2 or 16 bytes, got {:d} bytes".format(
#                     len(self.value)
#                 )
#             )
#         self.value = bytes(reversed(self.value))
#         self.uuid_type = UUID_16_BIT if len(self.value) == 2 else UUID_128_BIT
# 
#     def __properties__(self):
#         return dict(
#             uuid_type=self.uuid_type,
#             value=self.value,
#         )
# 
#     def __str__(self):
#         value = hexlify(bytes(reversed(self.value)))
#         return (
#             b'-'.join(
#                 [
#                     value[0:8],
#                     value[8:12],
#                     value[12:16],
#                     value[16:20],
#                     value[20:32]
#                 ]
#             ) if len(self.value) == 16 else value
#         ).decode('ascii')
# 
#     def __eq__(self, other):
#         return self.value == UUID(other).value
# 
#     def __hash__(self):
#         return hash(self.value)


# Path: bluetooth_low_energy/api/characteristic.py
from bluetooth_low_energy.api.constants import *
from bluetooth_low_energy.api.descriptor import Descriptor
from bluetooth_low_energy.api.uuid import UUID


    def __properties__(self, service_handle=None, char_value_len=20):
        self.service_handle = service_handle
        self.char_value_len = char_value_len
        return dict(
            service_handle=self.service_handle,
            char_uuid_type=self.uuid.uuid_type,
            char_uuid=self.uuid.value,
            char_value_len=self.char_value_len,
            char_properties=self.props,
            sec_permissions=self.perms,
            gatt_evt_mask=self.mask,
            encry_key_size=st_constant.MAX_ENCRY_KEY_SIZE,
            is_variable=self.is_variable
        )

    def __str__(self):
        descriptors = self.get_descriptors()
        return "<Characteristic uuid={!s} handle={:02x} descriptors=[{:s}]".format(
            self.uuid,
            self.handle or 0,
            "".join(
                "{!s}{:s}".format(
                    c, (", " if i < len(descriptors) - 1 else "")
                ) for i, c in enumerate(descriptors)
            )
        )

    def add_descriptor(self, descriptor):
        """ add_descriptor """

        if isinstance(descriptor, Descriptor):