12 _netLayerEntities { {*
this, kPrimaryIfIndex}, {*
this, kSecondaryIfIndex} }
14 _currentAddress = deviceObj.individualAddress();
15 evaluateCouplerType();
20 return _netLayerEntities[0];
25 return _netLayerEntities[1];
30 _rtObjPrimary = &
rtObj;
31 _rtObjSecondary =
nullptr;
44 void NetworkLayerCoupler::evaluateCouplerType()
54 _couplerType = BackboneCoupler;
59 _couplerType = LineCoupler;
80 bool NetworkLayerCoupler::isGroupAddressInFilterTable(uint16_t groupAddress)
82 if (_rtObjSecondary ==
nullptr)
97 if (sourceInterfaceIndex == kPrimaryIfIndex)
108 if (prop_lcgrpconfig)
109 prop_lcgrpconfig->
read(lcgrpconfig);
112 prop_lcconfig->
read(lcconfig);
115 if (groupAddress < 0x7000)
126 if (isGroupAddressInFilterTable(groupAddress))
151 if (isGroupAddressInFilterTable(groupAddress))
175 evaluateCouplerType();
189 uint16_t ZS = individualAddress & 0xFF00;
190 uint16_t Z = individualAddress & 0xF000;
193 if (_couplerType == LineCoupler)
196 if (srcIfIndex == kPrimaryIfIndex)
206 else if (srcIfIndex == kSecondaryIfIndex)
224 else if (_couplerType == BackboneCoupler)
227 if (srcIfIndex == kPrimaryIfIndex)
236 else if (srcIfIndex == kSecondaryIfIndex)
261 SystemBroadcast broadcastType, uint8_t sourceInterfaceIndex, uint16_t source)
263 uint8_t interfaceIndex = (sourceInterfaceIndex == kSecondaryIfIndex) ? kPrimaryIfIndex : kSecondaryIfIndex;
270 if (sourceInterfaceIndex == kPrimaryIfIndex)
281 if (prop_lcgrpconfig)
282 prop_lcgrpconfig->
read(lcgrpconfig);
285 prop_lcconfig->
read(lcconfig);
296 if ((_rtObjPrimary !=
nullptr) && (_rtObjSecondary !=
nullptr) && (sourceInterfaceIndex == kSecondaryIfIndex))
330 #ifdef KNX_LOG_COUPLER
332 if (sourceInterfaceIndex == 0)
333 print(
"Routing from P->S: ");
335 print(
"Routing from S->P: ");
339 print(destination, HEX);
345 bool doNotRepeat =
false;
352 _netLayerEntities[interfaceIndex].sendDataRequest(npdu, ack, destination, source, priority, addrType, broadcastType, doNotRepeat);
357 void NetworkLayerCoupler::routeDataIndividual(
AckType ack, uint16_t destination,
NPDU& npdu,
Priority priority, uint16_t source, uint8_t srcIfIndex)
374 if (srcIfIndex == kLocalIfIndex)
379 if (_couplerType == CouplerType::BackboneCoupler)
382 Z = destination & 0xF000;
384 else if (_couplerType == CouplerType::LineCoupler)
387 Z = destination & 0xFF00;
397 uint8_t destIfidx = (Z != netaddr) ? kPrimaryIfIndex : kSecondaryIfIndex;
400 if (destIfidx == kPrimaryIfIndex)
401 if (isTunnelAddress(destination))
402 destIfidx = kSecondaryIfIndex;
414 if (srcIfIndex == kPrimaryIfIndex)
420 prop_lcconfig->
read(lcconfig);
457 routeDataIndividual(ack, destination, npdu, priority, source, srcIfIdx);
468 sendMsgHopCount(ack, addrType, destination, npdu, priority,
Broadcast, srcIfIdx, source);
514 if (srcIfIdx == kPrimaryIfIndex)
520 prop_lcconfig->
read(lcconfig);
527 void NetworkLayerCoupler::broadcastConfirm(
AckType ack,
FrameFormat format,
Priority priority, uint16_t source,
NPDU& npdu,
bool status, uint8_t srcIfIdx)
540 void NetworkLayerCoupler::systemBroadcastIndication(
AckType ack,
FrameFormat format,
NPDU& npdu,
Priority priority, uint16_t source, uint8_t srcIfIdx)
551 if (srcIfIdx == kPrimaryIfIndex)
557 prop_lcconfig->
read(lcconfig);
564 void NetworkLayerCoupler::systemBroadcastConfirm(
AckType ack,
FrameFormat format,
Priority priority, uint16_t source,
NPDU& npdu,
bool status, uint8_t srcIfIdx)
603 if (isGroupAddressInFilterTable(destination))
651 bool NetworkLayerCoupler::isTunnelAddress(uint16_t destination)
654 return _netLayerEntities[kPrimaryIfIndex].
dataLinkLayer().isTunnelAddress(destination);
void printPDU()
Print the contents of the APDU to console.
SystemBroadcast systemBroadcast() const
uint16_t individualAddress()
Property * property(PropertyID id)
Gets property with PropertyID id if it exists and nullptr otherwise.
NetworkLayerEntity & getSecondaryInterface()
void rtObjSecondary(RouterObject &rtObjSecondary)
void dataBroadcastRequest(AckType ack, HopCountType hopType, Priority priority, TPDU &tpdu) override
void dataGroupRequest(AckType ack, uint16_t destination, HopCountType hopType, Priority priority, TPDU &tpdu) override
bool isRoutedIndividualAddress(uint16_t individualAddress, uint8_t srcIfIndex)
void rtObjPrimary(RouterObject &rtObjPrimary)
NetworkLayerCoupler(DeviceObject &deviceObj, TransportLayer &layer)
void rtObj(RouterObject &rtObj)
void dataSystemBroadcastRequest(AckType ack, HopCountType hopType, Priority priority, TPDU &tpdu) override
NetworkLayerEntity & getPrimaryInterface()
bool isRoutedGroupAddress(uint16_t groupAddress, uint8_t sourceInterfaceIndex)
void dataIndividualRequest(AckType ack, uint16_t destination, HopCountType hopType, Priority priority, TPDU &tpdu) override
void dataLinkLayer(DataLinkLayer &layer)
DptMedium mediumType() const
DeviceObject & _deviceObj
bool isApciSystemBroadcast(APDU &apdu)
TransportLayer & _transportLayer
virtual uint8_t read(uint16_t start, uint8_t count, uint8_t *data) const =0
bool isGroupAddressInFilterTable(uint16_t groupAddress)
void dataSystemBroadcastConfirm(AckType ack, HopCountType hopType, TPDU &tpdu, Priority priority, bool status)
void dataIndividualIndication(uint16_t destination, HopCountType hopType, Priority priority, uint16_t source, TPDU &tpdu)
void dataIndividualConfirm(AckType ack, uint16_t destination, HopCountType hopType, Priority priority, TPDU &tpdu, bool status)
void dataSystemBroadcastIndication(HopCountType hopType, Priority priority, uint16_t source, TPDU &tpdu)
void dataBroadcastConfirm(AckType ack, HopCountType hopType, Priority priority, TPDU &tpdu, bool status)
void dataBroadcastIndication(HopCountType hopType, Priority priority, uint16_t source, TPDU &tpdu)
@ UnlimitedRouting
NPDU::hopCount is set to 7. This means that the frame never expires. This could be a problem if your ...
@ NetworkLayerParameter
use NetworkLayer::hopCount as NPDU::hopCount