コード例 #1
0
    def test_L2CAP_ERM_BV_06_C(self):
        """
        L2CAP/ERM/BV-06-C [Resume Transmitting I-Frames when an I-Frame is Received]
        Verify the IUT will cease transmission of I-frames when the negotiated TxWindow is full. Verify the
        IUT will resume transmission of I-frames when an I-frame is received that acknowledges previously
        sent I-frames.
        """
        with self._dut_connection_stream() as dut_connection_stream, \
            self._dut_connection_close_stream() as dut_connection_close_stream:
            due_connection_asserts = EventAsserts(dut_connection_stream)
            due_connection_close_asserts = EventAsserts(
                dut_connection_close_stream)
            psm = 1

            self.device_under_test.l2cap.SetDynamicChannel(
                l2cap_facade_pb2.SetEnableDynamicChannelRequest(
                    psm=psm,
                    retransmission_mode=l2cap_facade_pb2.
                    RetransmissionFlowControlMode.ERTM))
            self._assert_connection_complete(due_connection_asserts)
            self.device_under_test.l2cap.SendDynamicChannelPacket(
                l2cap_facade_pb2.DynamicChannelPacket(psm=psm, payload=b'abc'))
            self.device_under_test.l2cap.SendDynamicChannelPacket(
                l2cap_facade_pb2.DynamicChannelPacket(psm=psm, payload=b'abc'))
            self._assert_connection_close(due_connection_close_asserts)
コード例 #2
0
    def test_remote_name(self):
        self.register_for_dut_event(
            hci_packets.EventCode.REMOTE_HOST_SUPPORTED_FEATURES_NOTIFICATION)

        with EventCallbackStream(self.cert_device.hci.FetchEvents(empty_proto.Empty())) as hci_event_stream, \
            EventCallbackStream(self.device_under_test.neighbor.GetRemoteNameEvents(empty_proto.Empty())) as name_event_stream:
            name_event_asserts = EventAsserts(name_event_stream)
            hci_event_asserts = EventAsserts(hci_event_stream)

            cert_name = b'Im_A_Cert'
            padded_name = cert_name
            while len(padded_name) < 248:
                padded_name = padded_name + b'\0'
            self.enqueue_hci_command(
                hci_packets.WriteLocalNameBuilder(padded_name), True)

            hci_event_asserts.assert_event_occurs(
                lambda msg: b'\x0e\x04\x01\x13\x0c' in msg.event)

            address = hci_packets.Address()

            def get_address_from_complete(packet):
                packet_bytes = packet.event
                if b'\x0e\x0a\x01\x09\x10' in packet_bytes:
                    nonlocal address
                    addr_view = hci_packets.ReadBdAddrCompleteView(
                        hci_packets.CommandCompleteView(
                            hci_packets.EventPacketView(
                                bt_packets.PacketViewLittleEndian(
                                    list(packet_bytes)))))
                    address = addr_view.GetBdAddr()
                    return True
                return False

            # DUT Enables scans and gets its address
            self.enqueue_hci_command(
                hci_packets.WriteScanEnableBuilder(
                    hci_packets.ScanEnable.INQUIRY_AND_PAGE_SCAN), True)
            self.enqueue_hci_command(hci_packets.ReadBdAddrBuilder(), True)

            hci_event_asserts.assert_event_occurs(get_address_from_complete)

            cert_address = address.encode('utf8')

            self.device_under_test.neighbor.ReadRemoteName(
                neighbor_facade.RemoteNameRequestMsg(
                    address=cert_address,
                    page_scan_repetition_mode=1,
                    clock_offset=0x6855))
            name_event_asserts.assert_event_occurs(
                lambda msg: cert_name in msg.name)
コード例 #3
0
    def test_fetch_hci_event(self):
        with EventCallbackStream(
                self.device_under_test.hal.FetchHciEvent(
                    empty_pb2.Empty())) as hci_event_stream:

            hci_event_asserts = EventAsserts(hci_event_stream)

            self.send_dut_hci_command(
                hci_packets.LeAddDeviceToWhiteListBuilder(
                    hci_packets.WhiteListAddressType.RANDOM,
                    '0C:05:04:03:02:01'))
            event = hci_packets.LeAddDeviceToWhiteListCompleteBuilder(
                1, hci_packets.ErrorCode.SUCCESS)
            hci_event_asserts.assert_event_occurs(
                lambda packet: bytes(event.Serialize()) in packet.payload)
コード例 #4
0
    def test_loopback_hci_command(self):
        with EventCallbackStream(
                self.device_under_test.hal.FetchHciEvent(
                    empty_pb2.Empty())) as hci_event_stream:

            self.send_dut_hci_command(
                hci_packets.WriteLoopbackModeBuilder(
                    hci_packets.LoopbackMode.ENABLE_LOCAL))

            hci_event_asserts = EventAsserts(hci_event_stream)

            command = hci_packets.LeAddDeviceToWhiteListBuilder(
                hci_packets.WhiteListAddressType.RANDOM, '0C:05:04:03:02:01')
            self.send_dut_hci_command(command)
            hci_event_asserts.assert_event_occurs(
                lambda packet: bytes(command.Serialize()) in packet.payload)
コード例 #5
0
 def test_L2CAP_ERM_BV_03_C(self):
     """
     L2CAP/ERM/BV-03-C [Acknowledging Received I-Frames]
     """
     with self._dut_connection_stream() as dut_connection_stream, \
         self._dut_connection_close_stream() as dut_connection_close_stream:
         due_connection_asserts = EventAsserts(dut_connection_stream)
         due_connection_close_asserts = EventAsserts(
             dut_connection_close_stream)
         psm = 1
         retransmission_mode = l2cap_facade_pb2.RetransmissionFlowControlMode.ERTM
         self.device_under_test.l2cap.SetDynamicChannel(
             l2cap_facade_pb2.SetEnableDynamicChannelRequest(
                 psm=psm, retransmission_mode=retransmission_mode))
         self._assert_connection_complete(due_connection_asserts)
         self._assert_connection_close(due_connection_close_asserts)
コード例 #6
0
 def test_inquiry_from_dut(self):
     with EventCallbackStream(
             self.device_under_test.hal.FetchHciEvent(
                 empty_pb2.Empty())) as hci_event_stream:
         hci_event_asserts = EventAsserts(hci_event_stream)
         self.send_cert_hci_command(
             hci_packets.WriteScanEnableBuilder(
                 hci_packets.ScanEnable.INQUIRY_AND_PAGE_SCAN))
         lap = hci_packets.Lap()
         lap.lap = 0x33
         self.send_dut_hci_command(
             hci_packets.InquiryBuilder(lap, 0x30, 0xff))
         hci_event_asserts.assert_event_occurs(
             lambda packet: b'\x02\x0f' in packet.payload
             # Expecting an HCI Event (code 0x02, length 0x0f)
         )
コード例 #7
0
 def test_L2CAP_COS_CED_BV_08_C(self):
     """
     L2CAP/COS/CED/BV-08-C [Disconnect on Timeout]
     Verify that the IUT disconnects the data channel and shuts down this channel if no response occurs
     """
     with self._dut_connection_stream() as dut_connection_stream, \
         self._dut_connection_close_stream() as dut_connection_close_stream:
         due_connection_asserts = EventAsserts(dut_connection_stream)
         due_connection_close_asserts = EventAsserts(
             dut_connection_close_stream)
         psm = 1
         retransmission_mode = l2cap_facade_pb2.RetransmissionFlowControlMode.BASIC
         self.device_under_test.l2cap.SetDynamicChannel(
             l2cap_facade_pb2.SetEnableDynamicChannelRequest(
                 psm=psm, retransmission_mode=retransmission_mode))
         time.sleep(120)
コード例 #8
0
 def test_L2CAP_ERM_BV_02_C(self):
     """
     L2CAP/ERM/BV-02-C [Receive I-Frames]
     Verify the IUT can receive in-sequence valid I-frames and deliver L2CAP SDUs to the Upper Tester
     """
     with self._dut_connection_stream() as dut_connection_stream, \
         self._dut_connection_close_stream() as dut_connection_close_stream:
         due_connection_asserts = EventAsserts(dut_connection_stream)
         due_connection_close_asserts = EventAsserts(
             dut_connection_close_stream)
         psm = 1
         retransmission_mode = l2cap_facade_pb2.RetransmissionFlowControlMode.ERTM
         self.device_under_test.l2cap.SetDynamicChannel(
             l2cap_facade_pb2.SetEnableDynamicChannelRequest(
                 psm=psm, retransmission_mode=retransmission_mode))
         self._assert_connection_complete(due_connection_asserts)
         self._assert_connection_close(due_connection_close_asserts)
コード例 #9
0
 def test_L2CAP_COS_CED_BV_09_C(self):
     """
     L2CAP/COS/CED/BV-09-C [Receive Multi-Command Packet]
     Verify that the IUT is able to receive more than one signaling command in one L2CAP packet.
     """
     with self._dut_connection_stream() as dut_connection_stream, \
         self._dut_connection_close_stream() as dut_connection_close_stream:
         due_connection_asserts = EventAsserts(dut_connection_stream)
         due_connection_close_asserts = EventAsserts(
             dut_connection_close_stream)
         psm = 1
         retransmission_mode = l2cap_facade_pb2.RetransmissionFlowControlMode.BASIC
         self.device_under_test.l2cap.SetDynamicChannel(
             l2cap_facade_pb2.SetEnableDynamicChannelRequest(
                 psm=psm, retransmission_mode=retransmission_mode))
         self._assert_connection_complete(due_connection_asserts)
         self._assert_connection_close(due_connection_close_asserts)
コード例 #10
0
 def test_L2CAP_COS_CFD_BV_03_C(self):
     """
     L2CAP/COS/CFD/BV-03-C [Send Requested Options]
     Verify that the IUT can receive a configuration request with no options and send the requested
     options to the Lower Tester
     """
     with self._dut_connection_stream() as dut_connection_stream, \
         self._dut_connection_close_stream() as dut_connection_close_stream:
         due_connection_asserts = EventAsserts(dut_connection_stream)
         due_connection_close_asserts = EventAsserts(
             dut_connection_close_stream)
         psm = 1
         retransmission_mode = l2cap_facade_pb2.RetransmissionFlowControlMode.BASIC
         self.device_under_test.l2cap.SetDynamicChannel(
             l2cap_facade_pb2.SetEnableDynamicChannelRequest(
                 psm=psm, retransmission_mode=retransmission_mode))
         self._assert_connection_close(due_connection_close_asserts)
コード例 #11
0
 def test_L2CAP_COS_CED_BV_11_C(self):
     """
     L2CAP/COS/CED/BV-11-C [Configure MTU Size]
     Verify that the IUT is able to configure the supported MTU size
     """
     with self._dut_connection_stream() as dut_connection_stream, \
         self._dut_connection_close_stream() as dut_connection_close_stream:
         due_connection_asserts = EventAsserts(dut_connection_stream)
         due_connection_close_asserts = EventAsserts(
             dut_connection_close_stream)
         psm = 1
         retransmission_mode = l2cap_facade_pb2.RetransmissionFlowControlMode.BASIC
         self.device_under_test.l2cap.SetDynamicChannel(
             l2cap_facade_pb2.SetEnableDynamicChannelRequest(
                 psm=psm, retransmission_mode=retransmission_mode))
         self._assert_connection_complete(due_connection_asserts)
         self._assert_connection_close(due_connection_close_asserts)
コード例 #12
0
 def test_L2CAP_COS_CED_BI_01_C(self):
     """
     L2CAP/COS/CED/BI-01-C [Reject Unknown Command]
     Verify that the IUT rejects an unknown signaling command.
     """
     with self._dut_connection_stream() as dut_connection_stream, \
         self._dut_connection_close_stream() as dut_connection_close_stream:
         due_connection_asserts = EventAsserts(dut_connection_stream)
         due_connection_close_asserts = EventAsserts(
             dut_connection_close_stream)
         psm = 1
         retransmission_mode = l2cap_facade_pb2.RetransmissionFlowControlMode.BASIC
         self.device_under_test.l2cap.SetDynamicChannel(
             l2cap_facade_pb2.SetEnableDynamicChannelRequest(
                 psm=psm, retransmission_mode=retransmission_mode))
         self._assert_connection_complete(due_connection_asserts)
         time.sleep(5)
コード例 #13
0
 def test_L2CAP_COS_CED_BV_07_C(self):
     """
     L2CAP/COS/CED/BV-07-C [Accept Disconnect]
     Verify that the IUT is able to respond to the request to disconnect the data channel.
     """
     with self._dut_connection_stream() as dut_connection_stream, \
         self._dut_connection_close_stream() as dut_connection_close_stream:
         due_connection_asserts = EventAsserts(dut_connection_stream)
         due_connection_close_asserts = EventAsserts(
             dut_connection_close_stream)
         psm = 1
         retransmission_mode = l2cap_facade_pb2.RetransmissionFlowControlMode.BASIC
         self.device_under_test.l2cap.SetDynamicChannel(
             l2cap_facade_pb2.SetEnableDynamicChannelRequest(
                 psm=psm, retransmission_mode=retransmission_mode))
         self._assert_connection_complete(due_connection_asserts)
         self._assert_connection_close(due_connection_close_asserts)
コード例 #14
0
 def test_inquiry_rssi_from_dut(self):
     inquiry_msg = neighbor_facade.InquiryMsg(
         inquiry_mode=neighbor_facade.DiscoverabilityMode.GENERAL,
         result_mode=neighbor_facade.ResultMode.RSSI,
         length_1_28s=3,
         max_results=0)
     with EventCallbackStream(
             self.device_under_test.neighbor.SetInquiryMode(
                 inquiry_msg)) as inquiry_event_stream:
         hci_event_asserts = EventAsserts(inquiry_event_stream)
         self.enqueue_hci_command(
             hci_packets.WriteScanEnableBuilder(
                 hci_packets.ScanEnable.INQUIRY_AND_PAGE_SCAN), True)
         hci_event_asserts.assert_event_occurs(
             lambda msg: b'\x22\x0f' in msg.packet
             # Expecting an HCI Event (code 0x22, length 0x0f)
         )
コード例 #15
0
 def test_L2CAP_ERM_BI_01_C(self):
     """
     L2CAP/ERM/BI-01-C [S-Frame [REJ] Lost or Corrupted]
     Verify the IUT can handle receipt of an S-=frame [RR] Poll = 1 if the S-frame [REJ] sent from the IUT
     is lost.
     """
     with self._dut_connection_stream() as dut_connection_stream, \
         self._dut_connection_close_stream() as dut_connection_close_stream:
         due_connection_asserts = EventAsserts(dut_connection_stream)
         due_connection_close_asserts = EventAsserts(
             dut_connection_close_stream)
         psm = 1
         retransmission_mode = l2cap_facade_pb2.RetransmissionFlowControlMode.ERTM
         self.device_under_test.l2cap.SetDynamicChannel(
             l2cap_facade_pb2.SetEnableDynamicChannelRequest(
                 psm=psm, retransmission_mode=retransmission_mode))
         self._assert_connection_complete(due_connection_asserts)
         self._assert_connection_close(due_connection_close_asserts)
コード例 #16
0
 def test_L2CAP_ERM_BV_09_C(self):
     """
     L2CAP/ERM/BV-09-C [Send S-frame [RR] with Final Bit Set]
     Verify the IUT responds with an S-frame [RR] with the Final bit set after receiving an S-frame [RR]
     with the Poll bit set.
     """
     with self._dut_connection_stream() as dut_connection_stream, \
         self._dut_connection_close_stream() as dut_connection_close_stream:
         due_connection_asserts = EventAsserts(dut_connection_stream)
         due_connection_close_asserts = EventAsserts(
             dut_connection_close_stream)
         psm = 1
         retransmission_mode = l2cap_facade_pb2.RetransmissionFlowControlMode.ERTM
         self.device_under_test.l2cap.SetDynamicChannel(
             l2cap_facade_pb2.SetEnableDynamicChannelRequest(
                 psm=psm, retransmission_mode=retransmission_mode))
         self._assert_connection_complete(due_connection_asserts)
         self._assert_connection_close(due_connection_close_asserts)
コード例 #17
0
 def test_L2CAP_ERM_BV_10_C(self):
     """
   L2CAP/ERM/BV-10-C [Retransmit S-Frame [RR] with Poll Bit Set]
   Verify the IUT will retransmit the S-frame [RR] with the Poll bit set when the Monitor Timer expires.
   """
     with self._dut_connection_stream() as dut_connection_stream, \
         self._dut_connection_close_stream() as dut_connection_close_stream:
         due_connection_asserts = EventAsserts(dut_connection_stream)
         due_connection_close_asserts = EventAsserts(
             dut_connection_close_stream)
         psm = 1
         retransmission_mode = l2cap_facade_pb2.RetransmissionFlowControlMode.ERTM
         self.device_under_test.l2cap.SetDynamicChannel(
             l2cap_facade_pb2.SetEnableDynamicChannelRequest(
                 psm=psm, retransmission_mode=retransmission_mode))
         self._assert_connection_complete(due_connection_asserts)
         self.device_under_test.l2cap.SendDynamicChannelPacket(
             l2cap_facade_pb2.DynamicChannelPacket(psm=psm, payload=b'abc'))
         self._assert_connection_close(due_connection_close_asserts)
コード例 #18
0
ファイル: direct_hci_test.py プロジェクト: GZOSP/system_bt
    def test_inquiry_from_dut(self):
        self.register_for_event(hci_packets.EventCode.INQUIRY_RESULT)
        with EventCallbackStream(
                self.device_under_test.hci.FetchEvents(
                    empty_proto.Empty())) as hci_event_stream:

            hci_event_asserts = EventAsserts(hci_event_stream)

            self.send_hal_hci_command(
                hci_packets.WriteScanEnableBuilder(
                    hci_packets.ScanEnable.INQUIRY_AND_PAGE_SCAN))
            lap = hci_packets.Lap()
            lap.lap = 0x33
            self.enqueue_hci_command(
                hci_packets.InquiryBuilder(lap, 0x30, 0xff), False)
            hci_event_asserts.assert_event_occurs(
                lambda packet: b'\x02\x0f' in packet.event
                # Expecting an HCI Event (code 0x02, length 0x0f)
            )
コード例 #19
0
 def test_L2CAP_ERM_BV_20_C(self):
     """
     L2CAP/ERM/BV-20-C [Enter Remote Busy Condition]
     Verify the IUT will not retransmit any I-frames when it receives a remote busy indication from the
     Lower Tester (S-frame [RNR]).
     """
     with self._dut_connection_stream() as dut_connection_stream, \
         self._dut_connection_close_stream() as dut_connection_close_stream:
         due_connection_asserts = EventAsserts(dut_connection_stream)
         due_connection_close_asserts = EventAsserts(
             dut_connection_close_stream)
         psm = 1
         retransmission_mode = l2cap_facade_pb2.RetransmissionFlowControlMode.ERTM
         self.device_under_test.l2cap.SetDynamicChannel(
             l2cap_facade_pb2.SetEnableDynamicChannelRequest(
                 psm=psm, retransmission_mode=retransmission_mode))
         self._assert_connection_complete(due_connection_asserts)
         self.device_under_test.l2cap.SendDynamicChannelPacket(
             l2cap_facade_pb2.DynamicChannelPacket(psm=psm, payload=b'abc'))
         self._assert_connection_close(due_connection_close_asserts)
コード例 #20
0
    def test_L2CAP_ERM_BV_16_C(self):
        """
         L2CAP/ERM/BV-16-C [Send S-Frame [REJ]]
        Verify the IUT can send an S-frame [REJ] after receiving out of sequence I-frames.
        """
        with self._dut_connection_stream() as dut_connection_stream, \
            self._dut_connection_close_stream() as dut_connection_close_stream:
            due_connection_asserts = EventAsserts(dut_connection_stream)
            due_connection_close_asserts = EventAsserts(
                dut_connection_close_stream)
            psm = 1

            self.device_under_test.l2cap.SetDynamicChannel(
                l2cap_facade_pb2.SetEnableDynamicChannelRequest(
                    psm=psm,
                    retransmission_mode=l2cap_facade_pb2.
                    RetransmissionFlowControlMode.ERTM))
            self._assert_connection_complete(due_connection_asserts)
            self._assert_connection_close(
                due_connection_close_asserts, timeout=60)
コード例 #21
0
    def test_L2CAP_COS_CED_BV_01_C(self):
        """
        L2CAP/COS/CED/BV-01-C [Request Connection]
        Verify that the IUT is able to request the connection establishment for an L2CAP data channel and
        initiate the configuration procedure.
        """
        with self._dut_connection_stream() as dut_connection_stream, \
            self._dut_connection_close_stream() as dut_connection_close_stream:
            due_connection_asserts = EventAsserts(dut_connection_stream)
            due_connection_close_asserts = EventAsserts(
                dut_connection_close_stream)
            psm = 1
            self.device_under_test.l2cap.OpenChannel(
                l2cap_facade_pb2.OpenChannelRequest(
                    remote=self.pts_address, psm=psm))
            self._assert_connection_complete(due_connection_asserts)

            self.device_under_test.l2cap.CloseChannel(
                l2cap_facade_pb2.CloseChannelRequest(psm=psm))
            self._assert_connection_close(due_connection_close_asserts)
コード例 #22
0
    def test_L2CAP_COS_CFD_BV_08_C(self):
        """
        L2CAP/COS/CFD/BV-08-C [Non-blocking Config Response]
        Verify that the IUT does not block transmitting L2CAP_ConfigRsp while waiting for L2CAP_ConfigRsp
        from the Lower Tester.
        """
        with self._dut_connection_stream() as dut_connection_stream, \
            self._dut_connection_close_stream() as dut_connection_close_stream:
            due_connection_asserts = EventAsserts(dut_connection_stream)
            due_connection_close_asserts = EventAsserts(
                dut_connection_close_stream)
            psm = 1

            self.device_under_test.l2cap.OpenChannel(
                l2cap_facade_pb2.OpenChannelRequest(
                    remote=self.pts_address, psm=psm))
            self._assert_connection_complete(due_connection_asserts)
            self.device_under_test.l2cap.CloseChannel(
                l2cap_facade_pb2.CloseChannelRequest(psm=psm))
            self._assert_connection_close(due_connection_close_asserts)
コード例 #23
0
 def test_L2CAP_ERM_BV_19_C(self):
     """
     L2CAP/ERM/BV-19-C [Receive I-Frame Final Bit = 1]
     Verify the IUT will retransmit any previously sent I-frames unacknowledged by receipt of an I-frame
     with the final bit set.
     """
     with self._dut_connection_stream() as dut_connection_stream, \
         self._dut_connection_close_stream() as dut_connection_close_stream:
         due_connection_asserts = EventAsserts(dut_connection_stream)
         due_connection_close_asserts = EventAsserts(
             dut_connection_close_stream)
         psm = 1
         retransmission_mode = l2cap_facade_pb2.RetransmissionFlowControlMode.ERTM
         self.device_under_test.l2cap.SetDynamicChannel(
             l2cap_facade_pb2.SetEnableDynamicChannelRequest(
                 psm=psm, retransmission_mode=retransmission_mode))
         self._assert_connection_complete(due_connection_asserts)
         self.device_under_test.l2cap.SendDynamicChannelPacket(
             l2cap_facade_pb2.DynamicChannelPacket(psm=psm, payload=b'abc'))
         self._assert_connection_close(due_connection_close_asserts)
コード例 #24
0
    def test_le_ad_scan_dut_scans(self):
        with EventCallbackStream(
                # DUT Scans
                self.device_under_test.hci_le_scanning_manager.StartScan(
                    empty_proto.Empty())) as advertising_event_stream:

            hci_event_asserts = EventAsserts(advertising_event_stream)

            # CERT Advertises
            gap_name = hci_packets.GapData()
            gap_name.data_type = hci_packets.GapDataType.COMPLETE_LOCAL_NAME
            gap_name.data = list(bytes(b'Im_The_CERT!'))
            gap_data = le_advertising_facade.GapDataMsg(
                data=bytes(gap_name.Serialize()))
            config = le_advertising_facade.AdvertisingConfig(
                advertisement=[gap_data],
                random_address=common.BluetoothAddress(
                    address=bytes(b'A6:A5:A4:A3:A2:A1')),
                interval_min=512,
                interval_max=768,
                event_type=le_advertising_facade.AdvertisingEventType.ADV_IND,
                address_type=common.RANDOM_DEVICE_ADDRESS,
                peer_address_type=common.PUBLIC_DEVICE_OR_IDENTITY_ADDRESS,
                peer_address=common.BluetoothAddress(
                    address=bytes(b'0C:05:04:03:02:01')),
                channel_map=7,
                filter_policy=le_advertising_facade.AdvertisingFilterPolicy.
                ALL_DEVICES)
            request = le_advertising_facade.CreateAdvertiserRequest(
                config=config)

            create_response = self.cert_device.hci_le_advertising_manager.CreateAdvertiser(
                request)

            hci_event_asserts.assert_event_occurs(
                lambda packet: b'Im_The_CERT' in packet.event)

            remove_request = le_advertising_facade.RemoveAdvertiserRequest(
                advertiser_id=create_response.advertiser_id)
            self.cert_device.hci_le_advertising_manager.RemoveAdvertiser(
                remove_request)
コード例 #25
0
    def test_L2CAP_COS_CED_BV_03_C(self):
        """
        L2CAP/COS/CED/BV-03-C [Send Data]
        Verify that the IUT is able to send DATA.
        """
        with self._dut_connection_stream() as dut_connection_stream, \
            self._dut_connection_close_stream() as dut_connection_close_stream:
            due_connection_asserts = EventAsserts(dut_connection_stream)
            due_connection_close_asserts = EventAsserts(
                dut_connection_close_stream)
            psm = 1
            retransmission_mode = l2cap_facade_pb2.RetransmissionFlowControlMode.BASIC
            self.device_under_test.l2cap.SetDynamicChannel(
                l2cap_facade_pb2.SetEnableDynamicChannelRequest(
                    psm=psm, retransmission_mode=retransmission_mode))
            self._assert_connection_complete(due_connection_asserts)

            self.device_under_test.l2cap.SendDynamicChannelPacket(
                l2cap_facade_pb2.DynamicChannelPacket(
                    psm=psm, payload=b'abc' * 34))
            self._assert_connection_close(due_connection_close_asserts)
コード例 #26
0
ファイル: direct_hci_test.py プロジェクト: GZOSP/system_bt
    def test_local_hci_cmd_and_event(self):
        # Loopback mode responds with ACL and SCO connection complete
        self.register_for_event(hci_packets.EventCode.CONNECTION_COMPLETE)
        self.register_for_event(hci_packets.EventCode.LOOPBACK_COMMAND)
        self.register_for_event(
            hci_packets.EventCode.CONNECTION_PACKET_TYPE_CHANGED)
        with EventCallbackStream(
                self.device_under_test.hci.FetchEvents(
                    empty_proto.Empty())) as hci_event_stream:
            hci_event_asserts = EventAsserts(hci_event_stream)

            self.enqueue_hci_command(
                hci_packets.WriteLoopbackModeBuilder(
                    hci_packets.LoopbackMode.ENABLE_LOCAL), True)

            cmd2loop = hci_packets.ReadLocalNameBuilder()
            self.enqueue_hci_command(cmd2loop, True)

            looped_bytes = bytes(cmd2loop.Serialize())
            hci_event_asserts.assert_event_occurs(
                lambda packet: looped_bytes in packet.event)
コード例 #27
0
    def test_L2CAP_ERM_BI_03_C(self):
        """
        L2CAP/ERM/BI-03-C [Handle Duplicate S-Frame [SREJ]]
        """
        with self._dut_connection_stream() as dut_connection_stream, \
            self._dut_connection_close_stream() as dut_connection_close_stream:
            due_connection_asserts = EventAsserts(dut_connection_stream)
            due_connection_close_asserts = EventAsserts(
                dut_connection_close_stream)
            psm = 1

            self.device_under_test.l2cap.SetDynamicChannel(
                l2cap_facade_pb2.SetEnableDynamicChannelRequest(
                    psm=psm,
                    retransmission_mode=l2cap_facade_pb2.
                    RetransmissionFlowControlMode.ERTM))
            self._assert_connection_complete(due_connection_asserts)
            self.device_under_test.l2cap.SendDynamicChannelPacket(
                l2cap_facade_pb2.DynamicChannelPacket(psm=psm, payload=b'abc'))
            self.device_under_test.l2cap.SendDynamicChannelPacket(
                l2cap_facade_pb2.DynamicChannelPacket(psm=psm, payload=b'abc'))
            self._assert_connection_close(due_connection_close_asserts)
コード例 #28
0
    def test_L2CAP_ERM_BI_05_C(self):
        """
        L2CAP/ERM/BI-05-C [Handle receipt of S-Frame [REJ] and I-Frame [F=1] that
        Both Require Retransmission of the Same I-Frames]
        """
        with self._dut_connection_stream() as dut_connection_stream, \
            self._dut_connection_close_stream() as dut_connection_close_stream:
            due_connection_asserts = EventAsserts(dut_connection_stream)
            due_connection_close_asserts = EventAsserts(
                dut_connection_close_stream)
            psm = 1

            self.device_under_test.l2cap.SetDynamicChannel(
                l2cap_facade_pb2.SetEnableDynamicChannelRequest(
                    psm=psm,
                    retransmission_mode=l2cap_facade_pb2.
                    RetransmissionFlowControlMode.ERTM))
            self._assert_connection_complete(due_connection_asserts)
            self.device_under_test.l2cap.SendDynamicChannelPacket(
                l2cap_facade_pb2.DynamicChannelPacket(psm=psm, payload=b'abc'))
            self.device_under_test.l2cap.SendDynamicChannelPacket(
                l2cap_facade_pb2.DynamicChannelPacket(psm=psm, payload=b'abc'))
            self._assert_connection_close(due_connection_close_asserts)
コード例 #29
0
 def test_L2CAP_ERM_BV_01_C(self):
     """
     L2CAP/ERM/BV-01-C [Transmit I-frames]
     Verify the IUT can send correctly formatted sequential I-frames with valid values for the enhanced
     control fields (SAR, F-bit, ReqSeq, TxSeq).
     """
     with self._dut_connection_stream() as dut_connection_stream, \
         self._dut_connection_close_stream() as dut_connection_close_stream:
         due_connection_asserts = EventAsserts(dut_connection_stream)
         due_connection_close_asserts = EventAsserts(
             dut_connection_close_stream)
         psm = 1
         retransmission_mode = l2cap_facade_pb2.RetransmissionFlowControlMode.ERTM
         self.device_under_test.l2cap.SetDynamicChannel(
             l2cap_facade_pb2.SetEnableDynamicChannelRequest(
                 psm=psm, retransmission_mode=retransmission_mode))
         self._assert_connection_complete(due_connection_asserts)
         self.device_under_test.l2cap.SendDynamicChannelPacket(
             l2cap_facade_pb2.DynamicChannelPacket(psm=psm, payload=b'abc'))
         self.device_under_test.l2cap.SendDynamicChannelPacket(
             l2cap_facade_pb2.DynamicChannelPacket(psm=psm, payload=b'abc'))
         self.device_under_test.l2cap.SendDynamicChannelPacket(
             l2cap_facade_pb2.DynamicChannelPacket(psm=psm, payload=b'abc'))
         self._assert_connection_close(due_connection_close_asserts)
コード例 #30
0
    def test_inquiry_extended_from_dut(self):
        name_string = b'Im_A_Cert'
        gap_name = hci_packets.GapData()
        gap_name.data_type = hci_packets.GapDataType.COMPLETE_LOCAL_NAME
        gap_name.data = list(bytes(name_string))
        gap_data = list([gap_name])

        self.enqueue_hci_command(
            hci_packets.WriteExtendedInquiryResponseBuilder(
                hci_packets.FecRequired.NOT_REQUIRED, gap_data), True)
        inquiry_msg = neighbor_facade.InquiryMsg(
            inquiry_mode=neighbor_facade.DiscoverabilityMode.GENERAL,
            result_mode=neighbor_facade.ResultMode.EXTENDED,
            length_1_28s=3,
            max_results=0)
        with EventCallbackStream(
                self.device_under_test.neighbor.SetInquiryMode(
                    inquiry_msg)) as inquiry_event_stream:
            hci_event_asserts = EventAsserts(inquiry_event_stream)
            self.enqueue_hci_command(
                hci_packets.WriteScanEnableBuilder(
                    hci_packets.ScanEnable.INQUIRY_AND_PAGE_SCAN), True)
            hci_event_asserts.assert_event_occurs(
                lambda msg: name_string in msg.packet)