diff --git a/src/knx/data_link_layer.h b/src/knx/data_link_layer.h index 22920d9..abcd5d8 100644 --- a/src/knx/data_link_layer.h +++ b/src/knx/data_link_layer.h @@ -29,6 +29,7 @@ class DataLinkLayer virtual void loop() = 0; virtual void enabled(bool value) = 0; virtual bool enabled() const = 0; + virtual bool isOpenMedium() const = 0; protected: void frameRecieved(CemiFrame& frame); diff --git a/src/knx/ip_data_link_layer.cpp b/src/knx/ip_data_link_layer.cpp index 2409901..06f0b6d 100644 --- a/src/knx/ip_data_link_layer.cpp +++ b/src/knx/ip_data_link_layer.cpp @@ -99,6 +99,10 @@ bool IpDataLinkLayer::enabled() const return _enabled; } +bool IpDataLinkLayer::isOpenMedium() const +{ + return false; +} bool IpDataLinkLayer::sendBytes(uint8_t* bytes, uint16_t length) { diff --git a/src/knx/ip_data_link_layer.h b/src/knx/ip_data_link_layer.h index ee0cde8..46fee6d 100644 --- a/src/knx/ip_data_link_layer.h +++ b/src/knx/ip_data_link_layer.h @@ -17,6 +17,7 @@ class IpDataLinkLayer : public DataLinkLayer void loop(); void enabled(bool value); bool enabled() const; + virtual bool isOpenMedium() const override; private: bool _enabled = false; diff --git a/src/knx/network_layer.cpp b/src/knx/network_layer.cpp index 8bd856a..a09c3b2 100644 --- a/src/knx/network_layer.cpp +++ b/src/knx/network_layer.cpp @@ -1,5 +1,6 @@ #include "network_layer.h" #include "device_object.h" +#include "data_link_layer.h" #include "tpdu.h" #include "cemi_frame.h" #include "bits.h" @@ -108,8 +109,10 @@ void NetworkLayer::broadcastIndication(AckType ack, FrameFormat format, NPDU& np { HopCountType hopType = npdu.hopCount() == 7 ? UnlimitedRouting : NetworkLayerParameter; + DataLinkLayer& dlLayer = getEntity(npdu.frame().sourceInterface()).dataLinkLayer(); + // for closed media like TP1 and IP - if (isApciSystemBroadcast(npdu.tpdu().apdu())) + if (!dlLayer.isOpenMedium() && isApciSystemBroadcast(npdu.tpdu().apdu())) { npdu.frame().systemBroadcast(SysBroadcast); _transportLayer.dataSystemBroadcastIndication(hopType, priority, source, npdu.tpdu()); diff --git a/src/knx/network_layer_entity.cpp b/src/knx/network_layer_entity.cpp index c812cc8..0fca763 100644 --- a/src/knx/network_layer_entity.cpp +++ b/src/knx/network_layer_entity.cpp @@ -14,6 +14,11 @@ void NetworkLayerEntity::dataLinkLayer(DataLinkLayer& layer) _dataLinkLayer = &layer; } +DataLinkLayer& NetworkLayerEntity::dataLinkLayer() +{ + return *_dataLinkLayer; +} + void NetworkLayerEntity::dataIndication(AckType ack, AddressType addrType, uint16_t destination, FrameFormat format, NPDU& npdu, Priority priority, uint16_t source) { npdu.frame().sourceInterface(_entityIndex); diff --git a/src/knx/network_layer_entity.h b/src/knx/network_layer_entity.h index f111365..4071612 100644 --- a/src/knx/network_layer_entity.h +++ b/src/knx/network_layer_entity.h @@ -16,6 +16,7 @@ class NetworkLayerEntity NetworkLayerEntity(NetworkLayer &netLayer, uint8_t entityIndex); void dataLinkLayer(DataLinkLayer& layer); + DataLinkLayer& dataLinkLayer(); // from data link layer void dataIndication(AckType ack, AddressType addType, uint16_t destination, FrameFormat format, NPDU& npdu, diff --git a/src/knx/rf_data_link_layer.cpp b/src/knx/rf_data_link_layer.cpp index d65be76..b8f4930 100644 --- a/src/knx/rf_data_link_layer.cpp +++ b/src/knx/rf_data_link_layer.cpp @@ -269,6 +269,11 @@ bool RfDataLinkLayer::enabled() const return _enabled; } +bool RfDataLinkLayer::isOpenMedium() const +{ + return true; +} + void RfDataLinkLayer::fillRfFrame(CemiFrame& frame, uint8_t* data) { uint16_t crc; diff --git a/src/knx/rf_data_link_layer.h b/src/knx/rf_data_link_layer.h index f944317..71902e7 100644 --- a/src/knx/rf_data_link_layer.h +++ b/src/knx/rf_data_link_layer.h @@ -25,6 +25,7 @@ class RfDataLinkLayer : public DataLinkLayer void loop(); void enabled(bool value); bool enabled() const; + virtual bool isOpenMedium() const override; private: bool _enabled = false; diff --git a/src/knx/tpuart_data_link_layer.cpp b/src/knx/tpuart_data_link_layer.cpp index 4b00aee..df6de5b 100644 --- a/src/knx/tpuart_data_link_layer.cpp +++ b/src/knx/tpuart_data_link_layer.cpp @@ -505,6 +505,11 @@ bool TpUartDataLinkLayer::enabled() const return _enabled; } +bool TpUartDataLinkLayer::isOpenMedium() const +{ + return false; +} + bool TpUartDataLinkLayer::sendSingleFrameByte() { uint8_t cmd[2]; diff --git a/src/knx/tpuart_data_link_layer.h b/src/knx/tpuart_data_link_layer.h index d49a783..3d06492 100644 --- a/src/knx/tpuart_data_link_layer.h +++ b/src/knx/tpuart_data_link_layer.h @@ -24,6 +24,7 @@ class TpUartDataLinkLayer : public DataLinkLayer void loop(); void enabled(bool value); bool enabled() const; + virtual bool isOpenMedium() const override; private: bool _enabled = false;