예제 #1
0
def hdl_wid_24(params: WIDParams):
    if params.test_case_name.startswith('GATT/CL'):
        return btp.verify_description(params.description)

    MMI.reset()
    MMI.parse_description(params.description)

    db = gatt_server_fetch_db()

    if not MMI.args:
        return False

    incl_handle = int(MMI.args[1], 16)
    attr = db.attr_lookup_handle(incl_handle)
    if attr is None or not isinstance(attr, GattService):
        logging.error("service not found")
        return False

    incl_uuid = attr.uuid
    attr = db.attr_lookup_handle(int(MMI.args[0], 16))
    if attr is None or not isinstance(attr, GattServiceIncluded):
        logging.error("included not found")
        return False

    if attr.end_grp_hdl != int(MMI.args[2], 16) \
            or incl_uuid != MMI.args[3]:
        logging.error("end group handle not found")
        return False

    return True
예제 #2
0
def hdl_wid_52(params: WIDParams):
    if params.test_case_name.startswith('GATT/CL'):
        return btp.verify_description(params.description)

    MMI.reset()
    MMI.parse_description(params.description)

    handle = int(MMI.args[0], 16)
    value = MMI.args[1]

    db = gatt_server_fetch_db()
    attr = db.attr_lookup_handle(handle)
    if attr is None:
        return False

    if not isinstance(attr, GattCharacteristicDescriptor):
        return False

    if attr.uuid == UUID.CEP:
        (value_read, ) = struct.unpack("<H", attr.value)
        value_read = '{0:04x}'.format(value_read)
    else:
        value_read = hexlify(attr.value).upper()

    value_read = value_read.decode('utf-8')
    if value_read != value:
        return False

    return True
예제 #3
0
def hdl_wid_17(params: WIDParams):
    if params.test_case_name.startswith('GATT/CL'):
        return btp.verify_description(params.description)

    MMI.reset()
    MMI.parse_description(params.description)
    pts_services = MMI.args
    if not pts_services:
        logging.error("%s parsing error", hdl_wid_17.__name__)
        return False

    iut_services = []

    # Get all primary services
    attrs = btp.gatts_get_attrs(type_uuid='2800')
    for attr in attrs:
        handle, perm, type_uuid = attr
        (_, uuid_len, uuid) = btp.gatts_get_attr_val(btp.pts_addr_type_get(),
                                                     btp.pts_addr_get(),
                                                     handle)
        uuid = btp.btp2uuid(uuid_len, uuid)
        iut_services.append(uuid)

    # Verification
    for service in pts_services:
        if service in iut_services:
            iut_services.remove(service)
            logging.debug("Service %s found", service)
            continue
        logging.error("Service %s not found", service)
        return False
    return True
예제 #4
0
def hdl_wid_67(desc):
    return btp.verify_description(desc)
예제 #5
0
def hdl_wid_67(params: WIDParams):
    return btp.verify_description(params.description)