diff --git a/src/knx/cemi_frame.cpp b/src/knx/cemi_frame.cpp index 13e7c79..58b1385 100644 --- a/src/knx/cemi_frame.cpp +++ b/src/knx/cemi_frame.cpp @@ -380,3 +380,14 @@ bool CemiFrame::valid() const return true; } + +void CemiFrame::sourceInterface(uint8_t index) +{ + _sourceInterfaceIndex = index; +} + +uint8_t CemiFrame::sourceInterface() +{ + return _sourceInterfaceIndex; +} + diff --git a/src/knx/cemi_frame.h b/src/knx/cemi_frame.h index fc21501..b394d4b 100644 --- a/src/knx/cemi_frame.h +++ b/src/knx/cemi_frame.h @@ -57,6 +57,9 @@ class CemiFrame uint16_t destinationAddress() const; void destinationAddress(uint16_t value); + void sourceInterface(uint8_t index); + uint8_t sourceInterface(); + #ifdef USE_RF // only for RF medium uint8_t* rfSerialOrDoA() const; @@ -89,4 +92,6 @@ class CemiFrame uint8_t _rfInfo = 0; uint8_t _rfLfn = 0xFF; // RF Data Link layer frame number #endif -}; \ No newline at end of file + + uint8_t _sourceInterfaceIndex; +}; diff --git a/src/knx/network_layer.cpp b/src/knx/network_layer.cpp index 02455b2..01b509b 100644 --- a/src/knx/network_layer.cpp +++ b/src/knx/network_layer.cpp @@ -5,7 +5,7 @@ #include "bits.h" NetworkLayer::NetworkLayer(DeviceObject &deviceObj, TransportLayer& layer) : - _netLayerEntities {*this, *this}, + _netLayerEntities { {*this, 0}, {*this, 1} }, _transportLayer(layer), _deviceObj(deviceObj) { diff --git a/src/knx/network_layer.h b/src/knx/network_layer.h index 42e1287..d120b4a 100644 --- a/src/knx/network_layer.h +++ b/src/knx/network_layer.h @@ -38,6 +38,7 @@ class NetworkLayer private: uint8_t _hopCount = 6; + // Support a maximum of two physical interfaces NetworkLayerEntity _netLayerEntities[2]; TransportLayer& _transportLayer; diff --git a/src/knx/network_layer_entity.cpp b/src/knx/network_layer_entity.cpp index ebdc5bf..c812cc8 100644 --- a/src/knx/network_layer_entity.cpp +++ b/src/knx/network_layer_entity.cpp @@ -5,7 +5,7 @@ #include "data_link_layer.h" #include "bits.h" -NetworkLayerEntity::NetworkLayerEntity(NetworkLayer &netLayer) : _netLayer(netLayer) +NetworkLayerEntity::NetworkLayerEntity(NetworkLayer &netLayer, uint8_t entityIndex) : _netLayer(netLayer), _entityIndex(entityIndex) { } @@ -16,31 +16,37 @@ void NetworkLayerEntity::dataLinkLayer(DataLinkLayer& layer) void NetworkLayerEntity::dataIndication(AckType ack, AddressType addrType, uint16_t destination, FrameFormat format, NPDU& npdu, Priority priority, uint16_t source) { + npdu.frame().sourceInterface(_entityIndex); _netLayer.dataIndication(ack, addrType, destination, format, npdu, priority, source); } void NetworkLayerEntity::dataConfirm(AckType ack, AddressType addressType, uint16_t destination, FrameFormat format, Priority priority, uint16_t source, NPDU& npdu, bool status) { + npdu.frame().sourceInterface(_entityIndex); _netLayer.dataConfirm(ack, addressType, destination, format, priority, source, npdu, status); } void NetworkLayerEntity::broadcastIndication(AckType ack, FrameFormat format, NPDU& npdu, Priority priority, uint16_t source) { + npdu.frame().sourceInterface(_entityIndex); _netLayer.broadcastIndication(ack, format, npdu, priority, source); } void NetworkLayerEntity::broadcastConfirm(AckType ack, FrameFormat format, Priority priority, uint16_t source, NPDU& npdu, bool status) { + npdu.frame().sourceInterface(_entityIndex); _netLayer.broadcastConfirm(ack, format, priority, source, npdu, status); } void NetworkLayerEntity::systemBroadcastIndication(AckType ack, FrameFormat format, NPDU& npdu, Priority priority, uint16_t source) { + npdu.frame().sourceInterface(_entityIndex); _netLayer.systemBroadcastIndication(ack, format, npdu, priority, source); } void NetworkLayerEntity::systemBroadcastConfirm(AckType ack, FrameFormat format, Priority priority, uint16_t source, NPDU& npdu, bool status) { + npdu.frame().sourceInterface(_entityIndex); _netLayer.systemBroadcastConfirm(ack, format, priority, source, npdu, status); } diff --git a/src/knx/network_layer_entity.h b/src/knx/network_layer_entity.h index 576883a..ec4b683 100644 --- a/src/knx/network_layer_entity.h +++ b/src/knx/network_layer_entity.h @@ -10,7 +10,7 @@ class NetworkLayer; class NetworkLayerEntity { public: - NetworkLayerEntity(NetworkLayer &netLayer); + NetworkLayerEntity(NetworkLayer &netLayer, uint8_t entityIndex); void dataLinkLayer(DataLinkLayer& layer); @@ -35,4 +35,5 @@ class NetworkLayerEntity private: DataLinkLayer* _dataLinkLayer = 0; NetworkLayer& _netLayer; + uint8_t _entityIndex; };