Exemplo n.º 1
0
def hdl_wid_108(params: WIDParams):
    if params.description == 'Please start the Bonding Procedure in bondable mode.':
        btp.gap_set_bondable_on()
    else:
        # Please configure the IUT into LE Security and start pairing process.
        btp.gap_pair()
    return True
    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)
    def test_btp_GAP_CONN_DCON_1(self):
        """
        Verify the IUT1 in the Directed Connectable Mode can connect with another
        device performing the General Connection Establishment Procedure.

        The IUT1 is operating in the Peripheral role.
        """

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

        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, verify_iut1)
        future_iut2 = btp.gap_sec_level_changed_ev(self.iut2, verify_iut2)

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

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

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

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

        def verify_central(args):
            return verify_address(args, self.iut1.stack.gap.iut_addr_get())

        future_central = btp.gap_connected_ev(self.iut2, verify_central)
        future_peripheral = btp.gap_connected_ev(self.iut1)

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

        wait_futures([future_central, future_peripheral], timeout=EV_TIMEOUT)

        self.assertTrue(self.iut2.stack.gap.is_connected())
        self.assertTrue(self.iut1.stack.gap.is_connected())

        disconnection_procedure(self, central=self.iut2, peripheral=self.iut1)
    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)
    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)
Exemplo n.º 6
0
def hdl_wid_108(desc):
    btp.gap_pair()
    return True
Exemplo n.º 7
0
def hdl_wid_100(desc):
    btp.gap_conn()
    btp.gap_wait_for_connection()
    btp.gap_pair()
    return True
Exemplo n.º 8
0
def hdl_wid_109(desc):
    btp.gap_set_mitm_off()
    btp.gap_pair()
    return True
Exemplo n.º 9
0
def hdl_wid_109(_: WIDParams):
    btp.gap_set_mitm_off()
    btp.gap_pair()
    return True
Exemplo n.º 10
0
def hdl_wid_108(_: WIDParams):
    btp.gap_pair()
    return True