def test_btp_GATT_CL_GAR_2(self): """ Verify that a Generic Attribute Profile client can read a Characteristic Value by selected handle. The Characteristic Value length is unknown to the client and might be long. """ 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) btp.gattc_read_long(self.iut1, self.iut2.stack.gap.iut_addr_get(), chr.value_handle, 0) val = GattValue() btp.gattc_read_long_rsp(self.iut1, val) self.assertEqual(val.att_rsp, "No error") # self.assertEqual(val.value, value) disconnection_procedure(self, central=self.iut1, peripheral=self.iut2)
def test_btp_GATT_CL_GAR_4(self): """ Verify that a Generic Attribute Profile client can read a characteristic descriptor by selected handle. The Characteristic Descriptor length is unknown to the client and might be long. """ 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) btp.gattc_read_long(self.iut1, self.iut2.stack.gap.iut_addr_get(), dsc.handle, 0) val = GattValue() btp.gattc_read_long_rsp(self.iut1, val) self.assertEqual(val.att_rsp, "No error") disconnection_procedure(self, central=self.iut1, peripheral=self.iut2)
def hdl_wid_53(desc): MMI.reset() MMI.parse_description(desc) read_hdl = MMI.args[0] offset = MMI.args[1] if not read_hdl or not offset: logging.debug("parsing error") return False btp.gattc_read_long(btp.pts_addr_type_get(), btp.pts_addr_get(), read_hdl, offset, 1) btp.gattc_read_long_rsp(True, False) return True
def hdl_wid_48(desc): MMI.reset() MMI.parse_description(desc) hdl = MMI.args[0] if not hdl: logging.debug("parsing error") return False btp.gattc_read_long(btp.pts_addr_type_get(None), btp.pts_addr_get(None), hdl, 0, 1) try: btp.gattc_read_long_rsp(True, True) except socket.timeout: pass return True
def test_ATT_Client_Read_Long_Attribute_Value(self, iut, valid): btp.gap_conn(iut, self.config.tester_addr) btp.gap_wait_for_connection(iut) btp.gattc_read_long(iut, self.config.tester_addr, self.config.tester_read_hdl, 0) tuple_hdr, tuple_data = iut.btp_worker.read() try: btp.btp_hdr_check(tuple_hdr, defs.BTP_SERVICE_ID_GATT, defs.GATT_READ_LONG) except BTPErrorInvalidStatus: pass try: # In some test cases Defensics won't disconnect # so we have to try to disconnect ourselves btp.gap_disconn(iut, self.config.tester_addr) except BTPErrorInvalidStatus: pass
def hdl_wid_48(params: WIDParams): MMI.reset() MMI.parse_description(params.description) hdl = MMI.args[0] if not hdl: logging.debug("parsing error") return False no_read_long_tests = [ "GATT/CL/GAR/BI-01-C", "GATT/CL/GAR/BI-02-C", "GATT/CL/GAR/BI-03-C", "GATT/CL/GAR/BI-04-C", "GATT/CL/GAR/BI-05-C", "GATT/CL/GAR/BI-11-C", "GATT/CL/GAR/BI-35-C", "GATT/CL/GAR/BV-01-C", ] no_btp_reply_tests = [ "GATT/CL/GAT/BV-01-C", ] if params.test_case_name in no_read_long_tests: btp.gattc_read(btp.pts_addr_type_get(), btp.pts_addr_get(), hdl) btp.gattc_read_rsp(False, True) return True if params.test_case_name in no_btp_reply_tests: btp.gattc_read(btp.pts_addr_type_get(), btp.pts_addr_get(), hdl) return True btp.gattc_read_long(btp.pts_addr_type_get(), btp.pts_addr_get(), hdl, 0, 1) btp.gattc_read_long_rsp(False, True) return True