Skip to content

Commit

Permalink
Merge pull request #265 from OpenKNX/fix_serialnumber
Browse files Browse the repository at this point in the history
fixes the serial number handling
  • Loading branch information
thelsing authored Dec 20, 2023
2 parents d44606d + 3c29d16 commit a870dd8
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 11 deletions.
10 changes: 5 additions & 5 deletions src/knx/application_layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ void ApplicationLayer::systemNetworkParameterReadResponse(Priority priority, Hop
void ApplicationLayer::domainAddressSerialNumberReadResponse(Priority priority, HopCountType hopType, const SecurityControl &secCtrl, const uint8_t* rfDoA,
const uint8_t* knxSerialNumber)
{
CemiFrame frame(11);
CemiFrame frame(13);
APDU& apdu = frame.apdu();
apdu.type(DomainAddressSerialNumberResponse);

Expand All @@ -567,19 +567,19 @@ void ApplicationLayer::domainAddressSerialNumberReadResponse(Priority priority,

//TODO: ApplicationLayer::IndividualAddressSerialNumberWriteRequest()
//TODO: ApplicationLayer::IndividualAddressSerialNumberReadRequest()
void ApplicationLayer::IndividualAddressSerialNumberReadResponse(Priority priority, HopCountType hopType, const SecurityControl &secCtrl, const uint8_t* rfDoA,
void ApplicationLayer::IndividualAddressSerialNumberReadResponse(Priority priority, HopCountType hopType, const SecurityControl &secCtrl, const uint8_t* domainAddress,
const uint8_t* knxSerialNumber)
{
CemiFrame frame(13);
CemiFrame frame(11);
APDU& apdu = frame.apdu();
apdu.type(IndividualAddressSerialNumberResponse);

uint8_t* data = apdu.data() + 1;

memcpy(data, knxSerialNumber, 6);
memcpy(data + 6, rfDoA, 6);
memcpy(data + 6, domainAddress, 2);

//apdu.printPDU();
//apdu.printPDU();

dataBroadcastRequest(AckDontCare, hopType, SystemPriority, apdu, secCtrl);
}
Expand Down
2 changes: 1 addition & 1 deletion src/knx/application_layer.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ class ApplicationLayer
uint8_t* testResult, uint16_t testResultLength);
void domainAddressSerialNumberReadResponse(Priority priority, HopCountType hopType, const SecurityControl& secCtrl, const uint8_t* rfDoA,
const uint8_t* knxSerialNumber);
void IndividualAddressSerialNumberReadResponse(Priority priority, HopCountType hopType, const SecurityControl& secCtrl, const uint8_t* rfDoA,
void IndividualAddressSerialNumberReadResponse(Priority priority, HopCountType hopType, const SecurityControl& secCtrl, const uint8_t* domainAddress,
const uint8_t* knxSerialNumber);
#pragma endregion

Expand Down
5 changes: 1 addition & 4 deletions src/knx/bau27B0.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,7 @@ void Bau27B0::domainAddressSerialNumberReadIndication(Priority priority, HopCoun

void Bau27B0::individualAddressSerialNumberReadIndication(Priority priority, HopCountType hopType, const SecurityControl &secCtrl, uint8_t* knxSerialNumber)
{
// If the received serial number matches our serial number
// then send a response with the current RF domain address stored in the RF medium object and the serial number
if (!memcmp(knxSerialNumber, _deviceObj.propertyData(PID_SERIAL_NUMBER), 6))
_appLayer.IndividualAddressSerialNumberReadResponse(priority, hopType, secCtrl, _rfMediumObj.rfDomainAddress(), knxSerialNumber);
#pragma warning "individualAddressSerialNumberReadIndication is not available for rf"
}

void Bau27B0::domainAddressSerialNumberWriteLocalConfirm(Priority priority, HopCountType hopType, const SecurityControl &secCtrl, const uint8_t* rfDoA,
Expand Down
2 changes: 1 addition & 1 deletion src/knx/bau_systemB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ void BauSystemB::individualAddressSerialNumberReadIndication(Priority priority,
// An open medium BAU has to override this method and provide a proper domain address.
if (!memcmp(knxSerialNumber, _deviceObj.propertyData(PID_SERIAL_NUMBER), 6))
{
uint8_t emptyDomainAddress[6] = {0x00};
uint8_t emptyDomainAddress[2] = {0x00};
applicationLayer().IndividualAddressSerialNumberReadResponse(priority, hopType, secCtrl, emptyDomainAddress, knxSerialNumber);
}
}
Expand Down

0 comments on commit a870dd8

Please sign in to comment.