From 2d7075037811d3b1fed809a10734ecce02f865e1 Mon Sep 17 00:00:00 2001 From: Nanosonde <2073569+nanosonde@users.noreply.github.com> Date: Fri, 29 May 2020 18:14:59 +0200 Subject: [PATCH] Rework --- src/knx/application_layer.cpp | 32 ++++++++++++++++---------------- src/knx/data_link_layer.cpp | 30 +++++++++++++++--------------- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/src/knx/application_layer.cpp b/src/knx/application_layer.cpp index 547873a..844c6c6 100644 --- a/src/knx/application_layer.cpp +++ b/src/knx/application_layer.cpp @@ -118,7 +118,7 @@ void ApplicationLayer::dataBroadcastIndication(HopCountType hopType, Priority pr break; } default: -#if (defined(USE_TP)||defined(USE_IP)) +#if (MEDIUM_TYPE == 5)||(MEDIUM_TYPE == 0) dataSystemBroadcastIndication(hopType, priority, source, apdu); #else print("Broadcast-indication: unhandled APDU-Type: "); @@ -163,7 +163,7 @@ void ApplicationLayer::dataBroadcastConfirm(AckType ack, HopCountType hopType, P break; } default: -#if (defined(USE_TP)||defined(USE_IP)) +#if (MEDIUM_TYPE == 5)||(MEDIUM_TYPE == 0) dataSystemBroadcastConfirm(hopType, priority, apdu, status); #else print("Broadcast-confirm: unhandled APDU-Type: "); @@ -206,14 +206,14 @@ void ApplicationLayer::dataSystemBroadcastIndication(HopCountType hopType, Prior break; } default: -#if !(defined(USE_TP)||defined(USE_IP)) - // For open media (e.g. PL, RF) - print("SystemBroadcast-indication: unhandled APDU-Type: "); - println(apdu.type()); +#if (MEDIUM_TYPE == 5)||(MEDIUM_TYPE == 0) + // For closed media + print("Broadcast-indication: unhandled APDU-Type: "); + println(apdu.type()); #else - // For closed media - print("Broadcast-indication: unhandled APDU-Type: "); - println(apdu.type()); + // For open media (e.g. PL, RF) + print("SystemBroadcast-indication: unhandled APDU-Type: "); + println(apdu.type()); #endif break; } @@ -252,14 +252,14 @@ void ApplicationLayer::dataSystemBroadcastConfirm(HopCountType hopType, Priority break; } default: -#if !(defined(USE_TP)||defined(USE_IP)) - // For open media (e.g. PL, RF) - print("SystemBroadcast-confirm: unhandled APDU-Type: "); - println(apdu.type()); +#if (MEDIUM_TYPE == 5)||(MEDIUM_TYPE == 0) + // For closed media + print("Broadcast-confirm: unhandled APDU-Type: "); + println(apdu.type()); #else - // For closed media - print("Broadcast-confirm: unhandled APDU-Type: "); - println(apdu.type()); + // For open media (e.g. PL, RF) + print("SystemBroadcast-confirm: unhandled APDU-Type: "); + println(apdu.type()); #endif break; } diff --git a/src/knx/data_link_layer.cpp b/src/knx/data_link_layer.cpp index afa3256..4130f51 100644 --- a/src/knx/data_link_layer.cpp +++ b/src/knx/data_link_layer.cpp @@ -45,10 +45,10 @@ void DataLinkLayer::systemBroadcastRequest(AckType ack, FrameFormat format, Prio { // System Broadcast requests will always be transmitted as broadcast with KNX serial number for open media (e.g. RF medium) // See 3.2.5 p.22 -#if !(defined(USE_TP)||defined(USE_IP)) - sendTelegram(npdu, ack, 0, GroupAddress, format, priority, SysBroadcast); -#else +#if (MEDIUM_TYPE == 5)||(MEDIUM_TYPE == 0) sendTelegram(npdu, ack, 0, GroupAddress, format, priority, Broadcast); +#else + sendTelegram(npdu, ack, 0, GroupAddress, format, priority, SysBroadcast); #endif } @@ -78,13 +78,13 @@ void DataLinkLayer::dataConReceived(CemiFrame& frame, bool success) if (addrType == GroupAddress && destination == 0) { -#if !(defined(USE_TP)||defined(USE_IP)) - if (systemBroadcast == SysBroadcast) - _networkLayer.systemBroadcastConfirm(ack, type, priority, source, npdu, success); - else - _networkLayer.broadcastConfirm(ack, type, priority, source, npdu, success); +#if (MEDIUM_TYPE == 5)||(MEDIUM_TYPE == 0) + (void) systemBroadcast; // not used + _networkLayer.broadcastConfirm(ack, type, priority, source, npdu, success); #else - (void) systemBroadcast; // not used + if (systemBroadcast == SysBroadcast) + _networkLayer.systemBroadcastConfirm(ack, type, priority, source, npdu, success); + else _networkLayer.broadcastConfirm(ack, type, priority, source, npdu, success); #endif } @@ -119,14 +119,14 @@ void DataLinkLayer::frameRecieved(CemiFrame& frame) if (addrType == GroupAddress && destination == 0) { -#if !(defined(USE_TP)||defined(USE_IP)) - if (systemBroadcast == SysBroadcast) - _networkLayer.systemBroadcastIndication(ack, type, npdu, priority, source); - else - _networkLayer.broadcastIndication(ack, type, npdu, priority, source); -#else +#if (MEDIUM_TYPE == 5)||(MEDIUM_TYPE == 0) (void) systemBroadcast; // not used _networkLayer.broadcastIndication(ack, type, npdu, priority, source); +#else + if (systemBroadcast == SysBroadcast) + _networkLayer.systemBroadcastIndication(ack, type, npdu, priority, source); + else + _networkLayer.broadcastIndication(ack, type, npdu, priority, source); #endif } else