示例#1
0
    def test_btp_GATT_CL_GAW_2(self):
        """
        Verify that a Generic Attribute Profile client can write a long
        Characteristic Value selected by handle.
        """

        connection_procedure(self, central=self.iut1, peripheral=self.iut2)

        btp.gattc_disc_chrc_uuid(self.iut1, self.iut2.stack.gap.iut_addr_get(),
                                 0x0001, 0xffff, PTS_DB.LONG_CHR_READ_WRITE)

        db = GattDB()
        btp.gattc_disc_chrc_uuid_rsp(self.iut1, db)

        db.print_db()

        chr = db.find_chr_by_uuid(PTS_DB.LONG_CHR_READ_WRITE)
        self.assertIsNotNone(chr)

        new_value = "FF" * 100
        btp.gattc_write_long(self.iut1, self.iut2.stack.gap.iut_addr_get(),
                             chr.value_handle, 0, new_value)

        future_iut2 = btp.gatts_attr_value_changed_ev(self.iut2)

        val = GattValue()
        btp.gattc_write_long_rsp(self.iut1, val)
        self.assertEqual(val.att_rsp, "No error")

        wait_futures([future_iut2], timeout=EV_TIMEOUT)

        hdl, data = future_iut2.result()
        self.assertEqual(data, new_value)

        disconnection_procedure(self, central=self.iut1, peripheral=self.iut2)
示例#2
0
    def test_btp_GATT_CL_GAW_4(self):
        """
        Verify that a Generic Attribute Profile client can write a long
        characteristic descriptor selected by handle.
        """

        connection_procedure(self, central=self.iut1, peripheral=self.iut2)

        btp.gattc_disc_prim_uuid(self.iut1, self.iut2.stack.gap.iut_addr_get(),
                                 PTS_DB.SVC)

        db = GattDB()
        btp.gattc_disc_prim_uuid_rsp(self.iut1, db)

        svc = db.find_svc_by_uuid(PTS_DB.SVC)
        self.assertIsNotNone(svc)

        start_hdl, end_hdl = svc.handle, svc.end_hdl

        btp.gattc_disc_all_chrc(self.iut1, self.iut2.stack.gap.iut_addr_get(),
                                start_hdl, end_hdl)

        btp.gattc_disc_all_chrc_rsp(self.iut1, db)

        db.print_db()

        chr = db.find_chr_by_uuid(PTS_DB.CHR_READ_WRITE)
        self.assertIsNotNone(chr)

        end_hdl = db.find_characteristic_end(chr.handle)
        self.assertIsNotNone(end_hdl)

        btp.gattc_disc_all_desc(self.iut1, self.iut2.stack.gap.iut_addr_get(),
                                chr.value_handle + 1, end_hdl)

        btp.gattc_disc_all_desc_rsp(self.iut1, db)

        db.print_db()

        dsc = db.find_dsc_by_uuid(PTS_DB.LONG_DSC_READ_WRITE)
        self.assertIsNotNone(dsc)

        new_value = "FF" * 100
        btp.gattc_write_long(self.iut1, self.iut2.stack.gap.iut_addr_get(),
                             dsc.handle, 0, new_value)

        future_iut2 = btp.gatts_attr_value_changed_ev(self.iut2)

        val = GattValue()
        btp.gattc_write_long_rsp(self.iut1, val)
        self.assertEqual(val.att_rsp, "No error")

        wait_futures([future_iut2], timeout=EV_TIMEOUT)

        hdl, data = future_iut2.result()
        self.assertEqual(data, new_value)

        disconnection_procedure(self, central=self.iut1, peripheral=self.iut2)
示例#3
0
def hdl_wid_76_no_rsp_check(desc):
    pattern = re.compile("'([0-9a-fA-F]+)'")
    params = pattern.findall(desc)
    if not params:
        logging.error("parsing error")
        return False

    handle = params[0]
    off = int(params[1])

    btp.gattc_write_long(btp.pts_addr_type_get(), btp.pts_addr_get(), handle,
                         off, '12', None)

    return True
示例#4
0
def hdl_wid_76(desc):
    pattern = re.compile("'([0-9a-fA-F]+)'")
    params = pattern.findall(desc)
    if not params:
        logging.error("parsing error")
        return False

    handle = params[0]
    size = int(params[1])

    btp.gattc_write_long(btp.pts_addr_type_get(None), btp.pts_addr_get(None),
                         handle, 0, '12', size)
    btp.gattc_write_long_rsp(True)

    return True
示例#5
0
def hdl_wid_69(desc):
    pattern = re.compile("(handle|size)\s?=\s?'([0-9a-fA-F]+)'")
    params = pattern.findall(desc)
    if not params:
        logging.error("parsing error")
        return False

    params = dict(params)

    handle = int(params.get('handle'), 16)
    size = int(params.get('size'), 16)
    btp.gattc_write_long(btp.pts_addr_type_get(None), btp.pts_addr_get(None), handle, 0, '12', size)
    btp.gattc_write_long_rsp()

    return True
示例#6
0
def hdl_wid_69(desc):
    MMI.reset()
    MMI.parse_description(desc)

    if not MMI.args:
        logging.error("parsing error")
        return False

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

    btp.gattc_write_long(btp.pts_addr_type_get(None), btp.pts_addr_get(None),
                         handle, 0, '12', size)
    btp.gattc_write_long_rsp()

    return True
示例#7
0
def hdl_wid_81(desc):
    MMI.reset()
    MMI.parse_description(desc)

    hdl = MMI.args[0]
    val_mtp = MMI.args[1]

    if not hdl or not val_mtp:
        logging.error("parsing error")
        return False

    btp.gattc_write_long(btp.pts_addr_type_get(), btp.pts_addr_get(), hdl, 0,
                         '1234', val_mtp)

    btp.gattc_write_long_rsp(True)

    return True
示例#8
0
def hdl_wid_77(desc):
    MMI.reset()
    MMI.parse_description(desc)

    hdl = MMI.args[0]
    offset = int(MMI.args[1])

    if not hdl or not offset:
        logging.error("parsing error")
        return False

    btp.gattc_write_long(btp.pts_addr_type_get(), btp.pts_addr_get(), hdl,
                         offset, '12', None)

    btp.gattc_write_long_rsp(True)

    return True
示例#9
0
def hdl_wid_76(params: WIDParams):
    pattern = re.compile("'([0-9a-fA-F]+)'")
    command_params = pattern.findall(params.description)
    if not command_params:
        logging.error("parsing error")
        return False

    handle = command_params[0]
    off = int(command_params[1])

    btp.gattc_write_long(btp.pts_addr_type_get(), btp.pts_addr_get(), handle,
                         off, '12', None)
    no_rsp_check_tests = ["GATT/CL/GAW/BV-10-C", "GATT/CL/GAW/BI-37-C"]

    if params.test_case_name in no_rsp_check_tests:
        return True

    btp.gattc_write_long_rsp(True)
    return True