Ejemplo n.º 1
0
    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
Ejemplo n.º 2
0
    def test_btp_GAP_CONN_PAIR_2(self):
        """
        Verify the IUT1 can perform the authenticated pairing procedure
        (Numeric Comparison) as the initiator.

        The IUT1 is operating in the Central role and is the initiator
        performing the pairing procedure; the IUT2
        is operating in the Peripheral role and is the responder.
        """

        btp.gap_set_io_cap(self.iut1, IOCap.display_yesno)
        btp.gap_set_io_cap(self.iut2, IOCap.display_yesno)

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

        btp.gap_pair(self.iut1, self.iut2.stack.gap.iut_addr_get())

        future_master = btp.gap_passkey_confirm_req_ev(self.iut1)
        future_slave = btp.gap_passkey_confirm_req_ev(self.iut2)

        wait_futures([future_master, future_slave], timeout=EV_TIMEOUT)

        results_master = future_master.result()
        results_slave = future_slave.result()

        pk_iut1 = results_master[1]
        self.assertIsNotNone(pk_iut1)
        pk_iut2 = results_slave[1]
        self.assertIsNotNone(pk_iut2)
        self.assertEqual(pk_iut1, pk_iut2)

        btp.gap_passkey_confirm(self.iut1, self.iut2.stack.gap.iut_addr_get(),
                                1)

        btp.gap_passkey_confirm(self.iut2, self.iut1.stack.gap.iut_addr_get(),
                                1)

        future_master = btp.gap_sec_level_changed_ev(self.iut1)
        future_slave = btp.gap_sec_level_changed_ev(self.iut2)

        wait_futures([future_master, future_slave], timeout=EV_TIMEOUT)

        _, level = future_master.result()
        self.assertEqual(level, 3)

        _, level = future_slave.result()
        self.assertEqual(level, 3)

        disconnection_procedure(self, central=self.iut1, peripheral=self.iut2)
Ejemplo n.º 3
0
    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
Ejemplo n.º 4
0
    def test_btp_GAP_CONN_PAIR_3(self):
        """
        Verify the IUT1 can perform the authenticated pairing procedure
        (Keyboard Input) as the initiator.

        The IUT1 is operating in the Central role and is the initiator
        performing the pairing procedure; the IUT2
        is operating in the Peripheral role and is the responder.
        """

        btp.gap_set_io_cap(self.iut1, IOCap.keyboard_only)
        btp.gap_set_io_cap(self.iut2, IOCap.display_only)

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

        btp.gap_pair(self.iut1, self.iut2.stack.gap.iut_addr_get())

        iut2_addr = self.iut2.stack.gap.iut_addr_get()

        future_slave = btp.gap_passkey_disp_ev(self.iut2)
        future_master = btp.gap_passkey_entry_req_ev(self.iut1)

        wait_futures([future_master, future_slave], timeout=EV_TIMEOUT)
        results_slave = future_slave.result()
        pk_iut2 = results_slave[1]
        self.assertIsNotNone(pk_iut2)

        btp.gap_passkey_entry_rsp(self.iut1, iut2_addr, pk_iut2)

        future_master = btp.gap_sec_level_changed_ev(self.iut1)
        future_slave = btp.gap_sec_level_changed_ev(self.iut2)

        wait_futures([future_master, future_slave], timeout=EV_TIMEOUT)

        _, level = future_master.result()
        self.assertEqual(level, 3)

        _, level = future_slave.result()
        self.assertEqual(level, 3)

        disconnection_procedure(self, central=self.iut1, peripheral=self.iut2)
Ejemplo n.º 5
0
    def test_btp_GAP_CONN_PAIR_1(self):
        """
        Verify the IUT1 can perform the unauthenticated pairing procedure
        (Just Works) as the initiator.

        The IUT1 is operating in the Central role and is the initiator
        performing the pairing procedure; the IUT2
        is operating in the Peripheral role and is the responder.
        """

        btp.gap_set_io_cap(self.iut2, IOCap.no_input_output)
        connection_procedure(self, central=self.iut1, peripheral=self.iut2)

        iut_addr = self.iut1.stack.gap.iut_addr_get()
        iut2_addr = self.iut2.stack.gap.iut_addr_get()

        def verify_iut1(args):
            return verify_address(args, iut2_addr)

        def verify_iut2(args):
            return verify_address(args, iut_addr)

        future_iut1 = btp.gap_sec_level_changed_ev(self.iut1)
        future_iut2 = btp.gap_sec_level_changed_ev(self.iut2)

        btp.gap_pair(self.iut1, self.iut2.stack.gap.iut_addr_get())

        wait_futures([future_iut1, future_iut2], timeout=EV_TIMEOUT)

        _, level = future_iut1.result()
        self.assertEqual(level, 1)

        _, level = future_iut2.result()
        self.assertEqual(level, 1)

        disconnection_procedure(self, central=self.iut1, peripheral=self.iut2)
Ejemplo n.º 6
0
def hdl_wid_4(desc):
    btp.gap_set_io_cap(IOCap.no_input_output)
    return True
Ejemplo n.º 7
0
 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)
Ejemplo n.º 8
0
 def test_SMP_Server_SC_Just_Works(self, iut, valid):
     btp.gap_set_io_cap(iut, IOCap.keyboard_display)
     btp.gap_set_conn(iut)
     btp.gap_set_gendiscov(iut)
     btp.gap_adv_ind_on(iut)
Ejemplo n.º 9
0
def hdl_wid_4(_: WIDParams):
    btp.gap_set_io_cap(IOCap.no_input_output)
    return True
Ejemplo n.º 10
0
def hdl_wid_241(_: WIDParams):
    # confirm IUT in sec mode 1 level 3
    btp.gap_set_io_cap(IOCap.keyboard_display)
    return True
Ejemplo n.º 11
0
def hdl_wid_240(_: WIDParams):
    # confirm IUT in sec mode 1 level 2
    btp.gap_set_io_cap(IOCap.no_input_output)
    return True