diff --git a/src/knx/data_link_layer.cpp b/src/knx/data_link_layer.cpp index 058dee50..e111566a 100644 --- a/src/knx/data_link_layer.cpp +++ b/src/knx/data_link_layer.cpp @@ -230,7 +230,7 @@ bool DataLinkLayer::sendTelegram(NPDU & npdu, AckType ack, uint16_t destinationA // a) we are the secondary interface (e.g. TP) AND // b) destination == PA of a Tunnel (TODO) - if(_networkLayerEntity.getEntityIndex() == 1) // don't send to tp if we are the secondary (TP) interface AND the destination is a tunnel + if(_networkLayerEntity.getEntityIndex() == 1 && addrType == AddressType::IndividualAddress) // don't send to tp if we are the secondary (TP) interface AND the destination is a tunnel-PA { if(isTunnelingPA(destinationAddr)) sendTheFrame = false; @@ -274,21 +274,29 @@ bool DataLinkLayer::isTunnelingPA(uint16_t pa) { uint8_t num = KNX_TUNNELING; uint32_t len = 0; - uint8_t** data = nullptr; - _bau.propertyValueRead(OT_IP_PARAMETER, 0, PID_ADDITIONAL_INDIVIDUAL_ADDRESSES, num, 1, data, len); + uint8_t* data = nullptr; + _bau.propertyValueRead(OT_IP_PARAMETER, 0, PID_ADDITIONAL_INDIVIDUAL_ADDRESSES, num, 1, &data, len); //printHex("isTunnelingPA, PID_ADDITIONAL_INDIVIDUAL_ADDRESSES: ", *data, len); if(len != KNX_TUNNELING * 2) { println("Tunnel PAs unkwnown"); + if(data != nullptr) + delete[] data; return false; } for(uint8_t i = 0; i < KNX_TUNNELING; i++) { uint16_t tunnelpa; - popWord(tunnelpa, (*data)+i*2); + popWord(tunnelpa, (data)+i*2); if(pa == tunnelpa) + { + if(data != nullptr) + delete[] data; return true; + } } + if(data != nullptr) + delete[] data; return false; } diff --git a/src/knx/ip_data_link_layer.cpp b/src/knx/ip_data_link_layer.cpp index ff35c79c..3fe45b99 100644 --- a/src/knx/ip_data_link_layer.cpp +++ b/src/knx/ip_data_link_layer.cpp @@ -803,41 +803,39 @@ void IpDataLinkLayer::loopHandleConnectRequest(uint8_t* buffer, uint16_t length, tun->PortData = srcPort; tun->PortCtrl = connRequest.hpaiCtrl().ipPortNumber()?connRequest.hpaiCtrl().ipPortNumber():srcPort; -#ifdef KNX_LOG_TUNNELING - print(">>> new tunnel["); + print("New Tunnel-Connection["); print(tunIdx); - print("]: 0x"); + print("], Channel: 0x"); print(tun->ChannelId, 16); - print("/"); + print(" PA: "); print(tun->IndividualAddress >> 12); print("."); print((tun->IndividualAddress >> 8) & 0xF); print("."); - println(tun->IndividualAddress & 0xFF); + print(tun->IndividualAddress & 0xFF); - print(">>> Data Endpoint: "); - ip = tun->IpAddress; - print(ip >> 24); + print(" with "); + print(tun->IpAddress >> 24); print("."); - print((ip >> 16) & 0xFF); + print((tun->IpAddress >> 16) & 0xFF); print("."); - print((ip >> 8) & 0xFF); + print((tun->IpAddress >> 8) & 0xFF); print("."); - print(ip & 0xFF); + print(tun->IpAddress & 0xFF); print(":"); - println(tun->PortData); - print(">>> Ctrl Endpoint: "); - ip = tun->IpAddress; - print(ip >> 24); - print("."); - print((ip >> 16) & 0xFF); - print("."); - print((ip >> 8) & 0xFF); - print("."); - print(ip & 0xFF); - print(":"); - println(tun->PortCtrl); -#endif + print(tun->PortData); + if(tun->PortData != tun->PortCtrl) + { + print(" (Ctrlport: "); + print(tun->PortCtrl); + print(")"); + } + if(tun->IsConfig) + { + print(" (Config-Channel)"); + } + println(); + KnxIpConnectResponse connRes(_ipParameters, tun->IndividualAddress, 3671, tun->ChannelId, connRequest.cri().type()); _platform.sendBytesUniCast(tun->IpAddress, tun->PortCtrl, connRes.data(), connRes.totalLength());