Skip to content

Commit

Permalink
added ack for tunneling
Browse files Browse the repository at this point in the history
  • Loading branch information
thewhobox committed Feb 12, 2024
1 parent 6e61636 commit bb94e63
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 12 deletions.
17 changes: 5 additions & 12 deletions src/knx/bau091A.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,9 @@ TPAckType Bau091A::isAckRequired(uint16_t address, bool isGrpAddr)
else
// all are ACKED
ack = TPAckType::AckReqAck;

if(_dlLayerPrimary.isAckRequired(address, isGrpAddr))
ack = TPAckType::AckReqAck;
}
else
{
Expand All @@ -197,18 +200,8 @@ TPAckType Bau091A::isAckRequired(uint16_t address, bool isGrpAddr)
ack = TPAckType::AckReqNone;

#ifdef KNX_TUNNELING
const uint8_t *addresses = _ipParameters.propertyData(PID_ADDITIONAL_INDIVIDUAL_ADDRESSES);
for(int i = 0; i < KNX_TUNNELING; i++)
{
uint16_t pa = 0;
popWord(pa, addresses + (i*2));

if(address == pa)
{
ack = TPAckType::AckReqAck;
break;
}
}
if(_dlLayerPrimary.isAckRequired(address, isGrpAddr))
ack = TPAckType::AckReqAck;
#endif

}
Expand Down
16 changes: 16 additions & 0 deletions src/knx/ip_data_link_layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,22 @@ bool IpDataLinkLayer::isTunnelAddress(uint16_t addr)

return false;
}

bool IpDataLinkLayer::isAckRequired(uint16_t address, bool isGrpAddr)
{
if(isGrpAddr)
{
for(int i = 0; i < KNX_TUNNELING; i++)
if(tunnels[i].ChannelId != 0)
return true;
return false;
} else {
for(int i = 0; i < KNX_TUNNELING; i++)
if(tunnels[i].ChannelId != 0 && tunnels[i].IndividualAddress == address)
return true;
return false;
}
}
#endif

void IpDataLinkLayer::loop()
Expand Down
1 change: 1 addition & 0 deletions src/knx/ip_data_link_layer.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class IpDataLinkLayer : public DataLinkLayer
void dataConfirmationToTunnel(CemiFrame& frame) override;
void dataIndicationToTunnel(CemiFrame& frame) override;
bool isTunnelAddress(uint16_t addr) override;
bool isAckRequired(uint16_t address, bool isGrpAddr);
#endif

private:
Expand Down

0 comments on commit bb94e63

Please sign in to comment.