def test_btp_GATT_CL_GAR_1(self): """ Verify that a Generic Attribute Profile client can read a 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.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.CHR_READ_WRITE) self.assertIsNotNone(chr) btp.gattc_read(self.iut1, self.iut2.stack.gap.iut_addr_get(), chr.value_handle) val = GattValue() btp.gattc_read_rsp(self.iut1, val) self.assertEqual(val.att_rsp, "No error") disconnection_procedure(self, central=self.iut1, peripheral=self.iut2)
def gap_wid_hdl_failed_read(wid, description, test_case_name): log("%s, %r, %r, %s", gap_wid_hdl.__name__, wid, description, test_case_name) module = sys.modules[__name__] if wid == 112: bd_addr = btp.pts_addr_get() bd_addr_type = btp.pts_addr_type_get() handle = btp.parse_handle_description(description) if not handle: return False try: btp.gattc_read(bd_addr_type, bd_addr, handle) btp.gattc_read_rsp() except socket.timeout: pass return True else: try: handler = getattr(module, "hdl_wid_%d" % wid) return handler(description) except AttributeError as e: logging.exception(e)
def hdl_wid_112(desc): bd_addr = btp.pts_addr_get() bd_addr_type = btp.pts_addr_type_get() handle = btp.parse_handle_description(desc) if not handle: return False btp.gattc_read(bd_addr_type, bd_addr, handle) btp.gattc_read_rsp() return True
def hdl_wid_112(desc): bd_addr = btp.pts_addr_get() bd_addr_type = btp.pts_addr_type_get() handle = btp.parse_handle_description(desc) if not handle: return False btp.gattc_read(bd_addr_type, bd_addr, handle) # PTS doesn't respond to read req if we do not respond to this WID # btp.gattc_read_rsp() return True
def test_ATT_Client_Read_Attribute_Value(self, iut, valid): btp.gap_conn(iut, self.config.tester_addr) btp.gap_wait_for_connection(iut) btp.gattc_read(iut, self.config.tester_addr, self.config.tester_read_hdl) tuple_hdr, tuple_data = iut.btp_worker.read() try: btp.btp_hdr_check(tuple_hdr, defs.BTP_SERVICE_ID_GATT, defs.GATT_READ) except BTPErrorInvalidStatus: pass
def test_btp_GATT_CL_GAR_3(self): """ Verify that a Generic Attribute Profile client can read a 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.DSC_READ_WRITE) self.assertIsNotNone(dsc) btp.gattc_read(self.iut1, self.iut2.stack.gap.iut_addr_get(), dsc.handle) val = GattValue() btp.gattc_read_rsp(self.iut1, val) self.assertEqual(val.att_rsp, "No error") disconnection_procedure(self, central=self.iut1, peripheral=self.iut2)
def hdl_wid_112(desc): bd_addr = btp.pts_addr_get() bd_addr_type = btp.pts_addr_type_get() btp.gattc_disc_all_chrc(bd_addr_type, bd_addr, 0x0001, 0xffff) attrs = btp.gattc_disc_all_chrc_rsp() for attr in attrs: if attr.prop & Prop.read: btp.gattc_read(bd_addr_type, bd_addr, attr.value_handle) btp.gattc_read_rsp() return True return False
def hdl_wid_112_timeout(desc): bd_addr = btp.pts_addr_get() bd_addr_type = btp.pts_addr_type_get() handle = btp.parse_handle_description(desc) if not handle: return False try: btp.gattc_read(bd_addr_type, bd_addr, handle) btp.gattc_read_rsp() except socket.timeout: pass return True
def hdl_wid_58(desc): MMI.reset() MMI.parse_description(desc) hdl = MMI.args[0] if not hdl: logging.error("parsing error") return False btp.gattc_read(btp.pts_addr_type_get(), btp.pts_addr_get(), hdl) btp.gattc_read_rsp(True, True) return True
def hdl_wid_48_no_long_read(desc): MMI.reset() MMI.parse_description(desc) hdl = MMI.args[0] if not hdl: logging.debug("parsing error") return False btp.gattc_read(btp.pts_addr_type_get(), btp.pts_addr_get(), hdl) try: btp.gattc_read_rsp(True, True) except socket.timeout: pass return True
def gap_wid_hdl_failed_read(wid, description, test_case_name): log("%s, %r, %r, %s", gap_wid_hdl.__name__, wid, description, test_case_name) if wid == 112: bd_addr = btp.pts_addr_get() bd_addr_type = btp.pts_addr_type_get() handle = btp.parse_handle_description(description) if not handle: return False try: btp.gattc_read(bd_addr_type, bd_addr, handle) btp.gattc_read_rsp() except socket.timeout: pass return True return gap_wid_hdl(wid, description, test_case_name)
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
def hdl_wid_150(params: WIDParams): """ Please send an ATT_Write_Request to Client Support Features handle = 'XXXX'O to enable Multiple Handle Value Notifications. Discover all characteristics if needed. """ MMI.reset() MMI.parse_description(params.description) hdl = MMI.args[0] # First read the existing value in Client Supported Features. btp.gattc_read(btp.pts_addr_type_get(), btp.pts_addr_get(), hdl) btp.gattc_read_rsp(False, True) client_support_features = int(btp.get_verify_values()[0]) # Set Multiple Handle Value Notifications bit in features. multi_hvn_bit = 4 value = client_support_features | multi_hvn_bit btp.gattc_write(btp.pts_addr_type_get(), btp.pts_addr_get(), hdl, f'{value:02x}') btp.gattc_write_rsp() return True