def test_ATT_Client_Discover_Characteristic_Descriptors(self, iut, valid): btp.gap_conn(iut, self.config.tester_addr) btp.gap_wait_for_connection(iut) db = GattDB() btp.gattc_disc_prim_svcs(iut, self.config.tester_addr) btp.gattc_disc_prim_svcs_rsp(iut, db) for svc in db.get_services(): start, end = svc.handle, svc.end_hdl btp.gattc_disc_all_chrc(iut, self.config.tester_addr, start, end) btp.gattc_disc_all_chrc_rsp(iut, db) for char in db.get_characteristics(): start_hdl = char.value_handle + 1 end_hdl = db.find_characteristic_end(char.handle) if not end_hdl: # There are no descriptors there so continue continue # Defensics expects to receive a Request with start handle == end handle if end_hdl == 0xffff: end_hdl = start_hdl btp.gattc_disc_all_desc(iut, self.config.tester_addr, start_hdl, end_hdl) tuple_hdr, tuple_data = iut.btp_worker.read() try: btp.btp_hdr_check(tuple_hdr, defs.BTP_SERVICE_ID_GATT, defs.GATT_DISC_ALL_DESC) except BTPErrorInvalidStatus: pass
def hdl_wid_77(_: WIDParams): try: btp.gap_wait_for_connection(5) btp.gap_disconn() except types.BTPError: logging.debug("Ignoring expected error on disconnect") return True
def hdl_wid_22(_: WIDParams): """ Implements: TSC_MMI_iut_disable_acl_connection description: Initiate an ACL disconnection from the IUT to the PTS. """ btp.gap_wait_for_connection() btp.gap_disconn() return True
def test_ATT_Client_Exchange_MTU(self, iut, valid): btp.gap_conn(iut, self.config.tester_addr) btp.gap_wait_for_connection(iut) btp.gattc_exchange_mtu(iut, self.config.tester_addr) tuple_hdr, tuple_data = iut.btp_worker.read() try: btp.btp_hdr_check(tuple_hdr, defs.BTP_SERVICE_ID_GATT, defs.GATT_EXCHANGE_MTU) except BTPErrorInvalidStatus: pass
def hdl_wid_22(desc): """ Implements: TSC_MMI_iut_disable_acl_connection :param desc: Initiate an ACL disconnection from the IUT to the PTS. :return: """ btp.gap_wait_for_connection() btp.gap_disconn() return True
def test_ATT_Client_Write_Attribute_Value(self, iut, valid): btp.gap_conn(iut, self.config.tester_addr) btp.gap_wait_for_connection(iut) btp.gattc_write(iut, self.config.tester_addr, self.config.tester_write_hdl, '00') tuple_hdr, tuple_data = iut.btp_worker.read() try: btp.btp_hdr_check(tuple_hdr, defs.BTP_SERVICE_ID_GATT, defs.GATT_WRITE) except BTPErrorInvalidStatus: pass
def test_ATT_Client_Discover_Service_by_uuid(self, iut, valid): btp.gap_conn(iut, self.config.tester_addr) btp.gap_wait_for_connection(iut) btp.gattc_disc_prim_uuid(iut, self.config.tester_addr, self.config.tester_service_uuid) tuple_hdr, tuple_data = iut.btp_worker.read() try: btp.btp_hdr_check(tuple_hdr, defs.BTP_SERVICE_ID_GATT, defs.GATT_DISC_PRIM_UUID) except BTPErrorInvalidStatus: pass
def test_SMP_Client_SC_Passkey_Entry(self, iut, valid): btp.gap_set_io_cap(iut, IOCap.keyboard_display) btp.gap_conn(iut, self.config.tester_addr) btp.gap_wait_for_connection(iut) future = btp.gap_passkey_entry_req_ev(iut) try: wait_futures([future], timeout=EV_TIMEOUT) btp.gap_passkey_entry_rsp(iut, self.config.tester_addr, self.config.tester_passkey) except (TimeoutError, BTPErrorInvalidStatus) as e: if valid: raise e
def test_ATT_Client_Discover_All_Characteristics(self, iut, valid): btp.gap_conn(iut, self.config.tester_addr) btp.gap_wait_for_connection(iut) btp.gattc_disc_all_chrc(iut, self.config.tester_addr, start_hdl=1, stop_hdl=0xffff) tuple_hdr, tuple_data = iut.btp_worker.read() try: btp.btp_hdr_check(tuple_hdr, defs.BTP_SERVICE_ID_GATT, defs.GATT_DISC_ALL_CHRC) except BTPErrorInvalidStatus: pass
def test_SMP_Client_SC_Numeric_Comparison(self, iut, valid): btp.gap_set_io_cap(iut, IOCap.keyboard_display) btp.gap_conn(iut, self.config.tester_addr) btp.gap_wait_for_connection(iut) future = btp.gap_passkey_confirm_req_ev(iut) try: wait_futures([future], timeout=EV_TIMEOUT) results = future.result() pk_iut = results[1] assert (pk_iut is not None) btp.gap_passkey_confirm(iut, self.config.tester_addr, 1) except (TimeoutError, BTPErrorInvalidStatus) as e: if valid: raise e
def test_ATT_Client_Discover_Primary_Services(self, iut, valid): btp.gap_conn(iut, self.config.tester_addr) btp.gap_wait_for_connection(iut) btp.gattc_disc_prim_svcs(iut, self.config.tester_addr) tuple_hdr, tuple_data = iut.btp_worker.read() try: btp.btp_hdr_check(tuple_hdr, defs.BTP_SERVICE_ID_GATT, defs.GATT_DISC_PRIM_SVCS) 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 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_46(desc): """ :param desc: Please send an L2CAP Connection Parameter Update request using valid parameters. :return: """ btp.gap_wait_for_connection() stack = get_stack() bd_addr = btp.pts_addr_get() bd_addr_type = btp.pts_addr_type_get() new_params = copy.deepcopy(stack.gap.conn_params.data) new_params.conn_latency += 1 btp.gap_conn_param_update(bd_addr, bd_addr_type, new_params.conn_itvl, new_params.conn_itvl, new_params.conn_latency, new_params.supervision_timeout) return True
def hdl_wid_148(desc): btp.gap_conn() return not btp.gap_wait_for_connection(10)
def hdl_wid_256(desc): btp.gap_wait_for_connection() return True
def hdl_wid_100(desc): btp.gap_conn() btp.gap_wait_for_connection() btp.gap_pair() return True
def hdl_wid_46(desc): btp.gap_wait_for_connection() bd_addr = btp.pts_addr_get() bd_addr_type = btp.pts_addr_type_get() btp.gap_conn_param_update(bd_addr, bd_addr_type, 200, 300, 0, 200) return True
def test_SMP_Client_SC_Just_Works(self, iut, valid): btp.gap_set_io_cap(iut, IOCap.keyboard_display) btp.gap_conn(iut, self.config.tester_addr) btp.gap_wait_for_connection(iut)
def hdl_wid_256(_: WIDParams): btp.gap_wait_for_connection() return True
def hdl_wid_148(_: WIDParams): btp.gap_conn() return not btp.gap_wait_for_connection(10)