예제 #1
0
    def test_local_hci_cmd_and_event(self):
        # Loopback mode responds with ACL and SCO connection complete
        self.dut_hci.register_for_events(
            hci_packets.EventCode.LOOPBACK_COMMAND)

        self.dut_hci.send_command_with_complete(
            hci_packets.WriteLoopbackModeBuilder(
                hci_packets.LoopbackMode.ENABLE_LOCAL))

        cmd2loop = hci_packets.ReadLocalNameBuilder()
        self.dut_hci.send_command_with_complete(cmd2loop)

        looped_bytes = bytes(cmd2loop.Serialize())
        assertThat(self.dut_hci.get_event_stream()).emits(
            lambda packet: looped_bytes in packet.event)
예제 #2
0
    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 EventStream(self.dut.hci.FetchEvents(
                empty_proto.Empty())) as 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_stream.assert_event_occurs(
                lambda packet: looped_bytes in packet.event)