Remember which interface received the cemi frame

This commit is contained in:
Nanosonde 2020-07-10 16:49:02 +02:00
parent a4599f4f9d
commit 373d44d29b
6 changed files with 28 additions and 4 deletions

View File

@ -380,3 +380,14 @@ bool CemiFrame::valid() const
return true; return true;
} }
void CemiFrame::sourceInterface(uint8_t index)
{
_sourceInterfaceIndex = index;
}
uint8_t CemiFrame::sourceInterface()
{
return _sourceInterfaceIndex;
}

View File

@ -57,6 +57,9 @@ class CemiFrame
uint16_t destinationAddress() const; uint16_t destinationAddress() const;
void destinationAddress(uint16_t value); void destinationAddress(uint16_t value);
void sourceInterface(uint8_t index);
uint8_t sourceInterface();
#ifdef USE_RF #ifdef USE_RF
// only for RF medium // only for RF medium
uint8_t* rfSerialOrDoA() const; uint8_t* rfSerialOrDoA() const;
@ -89,4 +92,6 @@ class CemiFrame
uint8_t _rfInfo = 0; uint8_t _rfInfo = 0;
uint8_t _rfLfn = 0xFF; // RF Data Link layer frame number uint8_t _rfLfn = 0xFF; // RF Data Link layer frame number
#endif #endif
};
uint8_t _sourceInterfaceIndex;
};

View File

@ -5,7 +5,7 @@
#include "bits.h" #include "bits.h"
NetworkLayer::NetworkLayer(DeviceObject &deviceObj, TransportLayer& layer) : NetworkLayer::NetworkLayer(DeviceObject &deviceObj, TransportLayer& layer) :
_netLayerEntities {*this, *this}, _netLayerEntities { {*this, 0}, {*this, 1} },
_transportLayer(layer), _transportLayer(layer),
_deviceObj(deviceObj) _deviceObj(deviceObj)
{ {

View File

@ -38,6 +38,7 @@ class NetworkLayer
private: private:
uint8_t _hopCount = 6; uint8_t _hopCount = 6;
// Support a maximum of two physical interfaces
NetworkLayerEntity _netLayerEntities[2]; NetworkLayerEntity _netLayerEntities[2];
TransportLayer& _transportLayer; TransportLayer& _transportLayer;

View File

@ -5,7 +5,7 @@
#include "data_link_layer.h" #include "data_link_layer.h"
#include "bits.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) 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); _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) 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); _netLayer.dataConfirm(ack, addressType, destination, format, priority, source, npdu, status);
} }
void NetworkLayerEntity::broadcastIndication(AckType ack, FrameFormat format, NPDU& npdu, Priority priority, uint16_t source) 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); _netLayer.broadcastIndication(ack, format, npdu, priority, source);
} }
void NetworkLayerEntity::broadcastConfirm(AckType ack, FrameFormat format, Priority priority, uint16_t source, NPDU& npdu, bool status) 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); _netLayer.broadcastConfirm(ack, format, priority, source, npdu, status);
} }
void NetworkLayerEntity::systemBroadcastIndication(AckType ack, FrameFormat format, NPDU& npdu, Priority priority, uint16_t source) 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); _netLayer.systemBroadcastIndication(ack, format, npdu, priority, source);
} }
void NetworkLayerEntity::systemBroadcastConfirm(AckType ack, FrameFormat format, Priority priority, uint16_t source, NPDU& npdu, bool status) 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); _netLayer.systemBroadcastConfirm(ack, format, priority, source, npdu, status);
} }

View File

@ -10,7 +10,7 @@ class NetworkLayer;
class NetworkLayerEntity class NetworkLayerEntity
{ {
public: public:
NetworkLayerEntity(NetworkLayer &netLayer); NetworkLayerEntity(NetworkLayer &netLayer, uint8_t entityIndex);
void dataLinkLayer(DataLinkLayer& layer); void dataLinkLayer(DataLinkLayer& layer);
@ -35,4 +35,5 @@ class NetworkLayerEntity
private: private:
DataLinkLayer* _dataLinkLayer = 0; DataLinkLayer* _dataLinkLayer = 0;
NetworkLayer& _netLayer; NetworkLayer& _netLayer;
uint8_t _entityIndex;
}; };