Exemple #1
0
 def test_tunnelling_ack(self):
     """Test string representation of KNX/IP TunnellingAck."""
     tunnelling_ack = TunnellingAck()
     tunnelling_ack.communication_channel_id = 23
     tunnelling_ack.sequence_counter = 42
     assert (
         str(tunnelling_ack) ==
         '<TunnellingAck communication_channel_id="23" sequence_counter="42" status_code="ErrorCode.E_NO_ERROR" />'
     )
Exemple #2
0
 def test_tunnelling_ack(self):
     """Test string representation of KNX/IP TunnellingAck."""
     xknx = XKNX(loop=self.loop)
     tunnelling_ack = TunnellingAck(xknx)
     tunnelling_ack.communication_channel_id = 23
     tunnelling_ack.sequence_counter = 42
     self.assertEqual(
         str(tunnelling_ack),
         '<TunnellingAck communication_channel_id="23" sequence_counter="42" status_code="ErrorCode.E_NO_ERROR" />')
Exemple #3
0
 def test_tunnelling_ack(self):
     """Test string representation of KNX/IP TunnellingAck."""
     xknx = XKNX(loop=self.loop)
     tunnelling_ack = TunnellingAck(xknx)
     tunnelling_ack.communication_channel_id = 23
     tunnelling_ack.sequence_counter = 42
     self.assertEqual(
         str(tunnelling_ack),
         '<TunnellingAck communication_channel_id="23" sequence_counter="42" status_code="ErrorCode.E_NO_ERROR" />')
Exemple #4
0
    async def test_tunnel_wait_for_l2_confirmation(self, time_travel):
        """Test tunnel waits for L_DATA.con before sending another L_DATA.req."""
        self.tunnel.transport.send = Mock()
        self.tunnel.communication_channel = 1

        test_telegram = Telegram(payload=GroupValueWrite(DPTArray((1,))))
        test_ack = KNXIPFrame.init_from_body(TunnellingAck(sequence_counter=23))
        confirmation = KNXIPFrame.init_from_body(
            TunnellingRequest(
                communication_channel_id=1,
                sequence_counter=23,
                cemi=CEMIFrame.init_from_telegram(
                    test_telegram, code=CEMIMessageCode.L_DATA_CON
                ),
            )
        )
        task = asyncio.create_task(self.tunnel.send_telegram(test_telegram))
        await time_travel(0)
        self.tunnel.transport.handle_knxipframe(test_ack, HPAI())
        await time_travel(0)
        assert not task.done()
        assert self.tunnel.transport.send.call_count == 1
        self.tunnel.transport.handle_knxipframe(confirmation, HPAI())
        await time_travel(0)
        assert task.done()
        # one call for the outgoing request and one for the ACK for the confirmation
        assert self.tunnel.transport.send.call_count == 2
        await task
Exemple #5
0
 def send_ack(self, communication_channel_id, sequence_counter):
     """Send tunnelling ACK after tunnelling request received."""
     ack = TunnellingAck(
         self.xknx,
         communication_channel_id=communication_channel_id,
         sequence_counter=sequence_counter,
     )
     self.udp_client.send(KNXIPFrame.init_from_body(ack))
Exemple #6
0
 def _send_tunnelling_ack(self, communication_channel_id: int,
                          sequence_counter: int) -> None:
     """Send tunnelling ACK after tunnelling request received."""
     ack = TunnellingAck(
         communication_channel_id=communication_channel_id,
         sequence_counter=sequence_counter,
     )
     self.transport.send(KNXIPFrame.init_from_body(ack),
                         addr=self._data_endpoint_addr)
Exemple #7
0
    def test_connect_request(self):
        """Test parsing and streaming tunneling ACK KNX/IP packet."""
        raw = (0x06, 0x10, 0x04, 0x21, 0x00, 0x0A, 0x04, 0x2A, 0x17, 0x00)
        xknx = XKNX()
        knxipframe = KNXIPFrame(xknx)
        knxipframe.from_knx(raw)

        assert isinstance(knxipframe.body, TunnellingAck)
        assert knxipframe.body.communication_channel_id == 42
        assert knxipframe.body.sequence_counter == 23
        assert knxipframe.body.status_code == ErrorCode.E_NO_ERROR

        tunnelling_ack = TunnellingAck(xknx,
                                       communication_channel_id=42,
                                       sequence_counter=23)
        knxipframe2 = KNXIPFrame.init_from_body(tunnelling_ack)

        assert knxipframe2.to_knx() == list(raw)