Skip to content

Commit

Permalink
Merge pull request #283 from tonylu00/fix/cemi-server-failed-without-rf
Browse files Browse the repository at this point in the history
Fix: build for cemi_server on platform without RF support will failed
  • Loading branch information
thelsing authored Jun 21, 2024
2 parents 57b5b05 + 9a46d7b commit 8a31e90
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/knx/cemi_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ void CemiServer::dataConfirmationToTunnel(CemiFrame& frame)

void CemiServer::dataIndicationToTunnel(CemiFrame& frame)
{
#ifdef USE_RF
bool isRf = _dataLinkLayer->mediumType() == DptMedium::KNX_RF;
uint8_t data[frame.dataLength() + (isRf ? 10 : 0)];

Expand All @@ -74,6 +75,10 @@ void CemiServer::dataIndicationToTunnel(CemiFrame& frame)
{
memcpy(&data[0], frame.data(), frame.dataLength());
}
#else
uint8_t data[frame.dataLength()];
memcpy(&data[0], frame.data(), frame.dataLength());
#endif

CemiFrame tmpFrame(data, sizeof(data));

Expand Down Expand Up @@ -102,7 +107,7 @@ void CemiServer::frameReceived(CemiFrame& frame)
{
frame.sourceAddress(_clientAddress);
}

#ifdef USE_RF
if (isRf)
{
// Check if we have additional info for RF
Expand Down Expand Up @@ -133,7 +138,7 @@ void CemiServer::frameReceived(CemiFrame& frame)
_frameNumber = (_frameNumber + 1) & 0x7;
}
}

#endif
print("L_data_req: src: ");
print(frame.sourceAddress(), HEX);
print(" dst: ");
Expand Down
2 changes: 2 additions & 0 deletions src/knx/data_link_layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,11 @@ bool DataLinkLayer::sendTelegram(NPDU & npdu, AckType ack, uint16_t destinationA
// We can just copy the pointer for rfSerialOrDoA as sendFrame() sets
// a pointer to const uint8_t data in either device object (serial) or
// RF medium object (domain address)
#ifdef USE_RF
tmpFrame.rfSerialOrDoA(frame.rfSerialOrDoA());
tmpFrame.rfInfo(frame.rfInfo());
tmpFrame.rfLfn(frame.rfLfn());
#endif
tmpFrame.confirm(ConfirmNoError);
_cemiServer->dataIndicationToTunnel(tmpFrame);
#endif
Expand Down

0 comments on commit 8a31e90

Please sign in to comment.