Refactor Broadcast/SystemBroadcast

This commit is contained in:
Nanosonde 2020-06-08 08:56:25 +02:00
parent 506e0db468
commit e7478eac32
8 changed files with 212 additions and 179 deletions

View File

@ -77,99 +77,157 @@ void ApplicationLayer::dataGroupConfirm(AckType ack, HopCountType hopType, Prior
} }
} }
void ApplicationLayer::dataBroadcastIndication(HopCountType hopType, Priority priority, uint16_t source, APDU& apdu) void ApplicationLayer::dataBroadcastIndication(HopCountType hopType, Priority priority, uint16_t source, APDU& apdu, SystemBroadcast broadcastType)
{ {
uint8_t* data = apdu.data(); uint8_t* data = apdu.data();
switch (apdu.type())
if (broadcastType == Broadcast)
{ {
case IndividualAddressWrite: // APCI on Broadcast
switch (apdu.type())
{ {
uint16_t newAddress; case IndividualAddressWrite:
popWord(newAddress, data + 1); {
_bau.individualAddressWriteIndication(hopType, newAddress); uint16_t newAddress;
break; popWord(newAddress, data + 1);
_bau.individualAddressWriteIndication(hopType, newAddress);
break;
}
case IndividualAddressRead:
_bau.individualAddressReadIndication(hopType);
break;
case IndividualAddressResponse:
_bau.individualAddressReadAppLayerConfirm(hopType, apdu.frame().sourceAddress());
break;
case IndividualAddressSerialNumberRead:
{
uint8_t* knxSerialNumber = &data[1];
_bau.individualAddressSerialNumberReadIndication(priority, hopType, knxSerialNumber);
break;
}
case IndividualAddressSerialNumberResponse:
{
uint16_t domainAddress;
popWord(domainAddress, data + 7);
_bau.individualAddressSerialNumberReadAppLayerConfirm(hopType, data + 1, apdu.frame().sourceAddress(),
domainAddress);
break;
}
case IndividualAddressSerialNumberWrite:
{
uint8_t* knxSerialNumber = &data[1];
uint16_t newIndividualAddress;
popWord(newIndividualAddress, &data[7]);
_bau.individualAddressSerialNumberWriteIndication(priority, hopType, newIndividualAddress, knxSerialNumber);
break;
}
#if !((MEDIUM_TYPE == 5) || (MEDIUM_TYPE == 0))
default:
print("Broadcast-indication: unhandled APDU-Type: ");
println(apdu.type());
break;
} }
case IndividualAddressRead: }
_bau.individualAddressReadIndication(hopType); else if (broadcastType == SysBroadcast)
break; {
case IndividualAddressResponse: // APCI on SystemBroadcast
_bau.individualAddressReadAppLayerConfirm(hopType, apdu.frame().sourceAddress()); switch (apdu.type())
break;
case IndividualAddressSerialNumberRead:
{ {
uint8_t* knxSerialNumber = &data[1]; #endif
_bau.individualAddressSerialNumberReadIndication(priority, hopType, knxSerialNumber); // TODO: testInfo could be of any length
break; case SystemNetworkParameterRead:
{
uint16_t objectType;
uint16_t propertyId;
uint8_t testInfo[2];
popWord(objectType, data + 1);
popWord(propertyId, data + 3);
popByte(testInfo[0], data + 4);
popByte(testInfo[1], data + 5);
propertyId = (propertyId >> 4) & 0x0FFF;;
testInfo[0] &= 0x0F;
_bau.systemNetworkParameterReadIndication(priority, hopType, objectType, propertyId, testInfo, sizeof(testInfo));
break;
}
case DomainAddressSerialNumberWrite:
{
const uint8_t* knxSerialNumber = &data[1];
const uint8_t* domainAddress = &data[7];
_bau.domainAddressSerialNumberWriteIndication(priority, hopType, domainAddress, knxSerialNumber);
break;
}
case DomainAddressSerialNumberRead:
{
const uint8_t* knxSerialNumber = &data[1];
_bau.domainAddressSerialNumberReadIndication(priority, hopType, knxSerialNumber);
break;
}
#if !((MEDIUM_TYPE == 5) || (MEDIUM_TYPE == 0))
default:
if (broadcastType == SysBroadcast)
{
print("System");
}
#endif
print("Broadcast-indication: unhandled APDU-Type: ");
println(apdu.type());
break;
} }
case IndividualAddressSerialNumberResponse:
{
uint16_t domainAddress;
popWord(domainAddress, data + 7);
_bau.individualAddressSerialNumberReadAppLayerConfirm(hopType, data + 1, apdu.frame().sourceAddress(),
domainAddress);
break;
}
case IndividualAddressSerialNumberWrite:
{
uint8_t* knxSerialNumber = &data[1];
uint16_t newIndividualAddress;
popWord(newIndividualAddress, &data[7]);
_bau.individualAddressSerialNumberWriteIndication(priority, hopType, newIndividualAddress, knxSerialNumber);
break;
}
default:
print("Broadcast-indication: unhandled APDU-Type: ");
println(apdu.type());
} }
} }
void ApplicationLayer::dataBroadcastConfirm(AckType ack, HopCountType hopType, Priority priority, APDU& apdu, bool status) void ApplicationLayer::dataBroadcastConfirm(AckType ack, HopCountType hopType, Priority priority, APDU& apdu, bool status, SystemBroadcast broadcastType)
{ {
uint8_t* data = apdu.data(); uint8_t* data = apdu.data();
switch (apdu.type())
{
case IndividualAddressWrite:
{
uint16_t newAddress;
popWord(newAddress, data + 1);
_bau.individualAddressWriteLocalConfirm(ack, hopType, newAddress, status);
break;
}
case IndividualAddressRead:
_bau.individualAddressReadLocalConfirm(ack, hopType, status);
break;
case IndividualAddressResponse:
_bau.individualAddressReadResponseConfirm(ack, hopType, status);
break;
case IndividualAddressSerialNumberRead:
_bau.individualAddressSerialNumberReadLocalConfirm(ack, hopType, data + 1, status);
break;
case IndividualAddressSerialNumberResponse:
{
uint16_t domainAddress;
popWord(domainAddress, data + 7);
_bau.individualAddressSerialNumberReadResponseConfirm(ack, hopType, data + 1, domainAddress, status);
break;
}
case IndividualAddressSerialNumberWrite:
{
uint16_t newAddress;
popWord(newAddress, data + 7);
_bau.individualAddressSerialNumberWriteLocalConfirm(ack, hopType, data + 1, newAddress, status);
break;
}
default:
print("Broadcast-confirm: unhandled APDU-Type: ");
println(apdu.type());
}
}
void ApplicationLayer::dataSystemBroadcastIndication(HopCountType hopType, Priority priority, uint16_t source, APDU& apdu) if (broadcastType == Broadcast)
{
const uint8_t* data = apdu.data();
switch (apdu.type())
{ {
// TODO: testInfo could be of any length // APCI on Broadcast
switch (apdu.type())
{
case IndividualAddressWrite:
{
uint16_t newAddress;
popWord(newAddress, data + 1);
_bau.individualAddressWriteLocalConfirm(ack, hopType, newAddress, status);
break;
}
case IndividualAddressRead:
_bau.individualAddressReadLocalConfirm(ack, hopType, status);
break;
case IndividualAddressResponse:
_bau.individualAddressReadResponseConfirm(ack, hopType, status);
break;
case IndividualAddressSerialNumberRead:
_bau.individualAddressSerialNumberReadLocalConfirm(ack, hopType, data + 1, status);
break;
case IndividualAddressSerialNumberResponse:
{
uint16_t domainAddress;
popWord(domainAddress, data + 7);
_bau.individualAddressSerialNumberReadResponseConfirm(ack, hopType, data + 1, domainAddress, status);
break;
}
case IndividualAddressSerialNumberWrite:
{
uint16_t newAddress;
popWord(newAddress, data + 7);
_bau.individualAddressSerialNumberWriteLocalConfirm(ack, hopType, data + 1, newAddress, status);
break;
}
#if !((MEDIUM_TYPE == 5) || (MEDIUM_TYPE == 0))
default:
print("Broadcast-confirm: unhandled APDU-Type: ");
println(apdu.type());
break;
}
}
else if (broadcastType == SysBroadcast)
{
// APCI on SystemBroadcast
switch (apdu.type())
{
#endif
case SystemNetworkParameterRead: case SystemNetworkParameterRead:
{ {
uint16_t objectType; uint16_t objectType;
@ -181,32 +239,36 @@ void ApplicationLayer::dataSystemBroadcastIndication(HopCountType hopType, Prior
popByte(testInfo[1], data + 5); popByte(testInfo[1], data + 5);
propertyId = (propertyId >> 4) & 0x0FFF;; propertyId = (propertyId >> 4) & 0x0FFF;;
testInfo[0] &= 0x0F; testInfo[0] &= 0x0F;
_bau.systemNetworkParameterReadIndication(priority, hopType, objectType, propertyId, testInfo, sizeof(testInfo)); //TODO: _bau.systemNetworkParameterReadLocalConfirm(priority, hopType, objectType, propertyId, testInfo, sizeof(testInfo), status);
break; break;
} }
case DomainAddressSerialNumberWrite: case DomainAddressSerialNumberWrite:
{ {
const uint8_t* knxSerialNumber = &data[1]; const uint8_t* knxSerialNumber = &data[1];
const uint8_t* domainAddress = &data[7]; const uint8_t* domainAddress = &data[7];
_bau.domainAddressSerialNumberWriteIndication(priority, hopType, domainAddress, knxSerialNumber); //TODO: _bau.domainAddressSerialNumberWriteLocalConfirm(priority, hopType, domainAddress, knxSerialNumber, status);
break; break;
} }
case DomainAddressSerialNumberRead: case DomainAddressSerialNumberRead:
{ {
const uint8_t* knxSerialNumber = &data[1]; const uint8_t* knxSerialNumber = &data[1];
_bau.domainAddressSerialNumberReadIndication(priority, hopType, knxSerialNumber); //TODO: _bau.domainAddressSerialNumberReadLocalConfirm(priority, hopType, knxSerialNumber, status);
break; break;
} }
default: default:
#if !((MEDIUM_TYPE == 5) || (MEDIUM_TYPE == 0))
if (broadcastType == SysBroadcast)
{
print("System");
}
#endif
print("Broadcast-confirm: unhandled APDU-Type: ");
println(apdu.type());
break; break;
}
} }
} }
void ApplicationLayer::dataSystemBroadcastConfirm(HopCountType hopType, Priority priority, APDU& apdu, bool status)
{
}
void ApplicationLayer::dataIndividualIndication(HopCountType hopType, Priority priority, uint16_t tsap, APDU& apdu) void ApplicationLayer::dataIndividualIndication(HopCountType hopType, Priority priority, uint16_t tsap, APDU& apdu)
{ {
individualIndication(hopType, priority, tsap, apdu); individualIndication(hopType, priority, tsap, apdu);
@ -290,7 +352,7 @@ void ApplicationLayer::individualAddressWriteRequest(AckType ack, HopCountType h
apdu.type(IndividualAddressWrite); apdu.type(IndividualAddressWrite);
uint8_t* apduData = apdu.data(); uint8_t* apduData = apdu.data();
pushWord(newaddress, apduData + 1); pushWord(newaddress, apduData + 1);
_transportLayer->dataBroadcastRequest(ack, hopType, SystemPriority, apdu); _transportLayer->dataBroadcastRequest(ack, hopType, SystemPriority, apdu, Broadcast);
} }
void ApplicationLayer::individualAddressReadRequest(AckType ack, HopCountType hopType) void ApplicationLayer::individualAddressReadRequest(AckType ack, HopCountType hopType)
@ -298,7 +360,7 @@ void ApplicationLayer::individualAddressReadRequest(AckType ack, HopCountType ho
CemiFrame frame(1); CemiFrame frame(1);
APDU& apdu = frame.apdu(); APDU& apdu = frame.apdu();
apdu.type(IndividualAddressRead); apdu.type(IndividualAddressRead);
_transportLayer->dataBroadcastRequest(ack, hopType, SystemPriority, apdu); _transportLayer->dataBroadcastRequest(ack, hopType, SystemPriority, apdu, Broadcast);
} }
void ApplicationLayer::individualAddressReadResponse(AckType ack, HopCountType hopType) void ApplicationLayer::individualAddressReadResponse(AckType ack, HopCountType hopType)
@ -306,7 +368,7 @@ void ApplicationLayer::individualAddressReadResponse(AckType ack, HopCountType h
CemiFrame frame(1); CemiFrame frame(1);
APDU& apdu = frame.apdu(); APDU& apdu = frame.apdu();
apdu.type(IndividualAddressResponse); apdu.type(IndividualAddressResponse);
_transportLayer->dataBroadcastRequest(ack, hopType, SystemPriority, apdu); _transportLayer->dataBroadcastRequest(ack, hopType, SystemPriority, apdu, Broadcast);
} }
void ApplicationLayer::individualAddressSerialNumberReadRequest(AckType ack, HopCountType hopType, uint8_t * serialNumber) void ApplicationLayer::individualAddressSerialNumberReadRequest(AckType ack, HopCountType hopType, uint8_t * serialNumber)
@ -316,7 +378,7 @@ void ApplicationLayer::individualAddressSerialNumberReadRequest(AckType ack, Hop
apdu.type(IndividualAddressSerialNumberRead); apdu.type(IndividualAddressSerialNumberRead);
uint8_t* data = apdu.data() + 1; uint8_t* data = apdu.data() + 1;
memcpy(data, serialNumber, 6); memcpy(data, serialNumber, 6);
_transportLayer->dataBroadcastRequest(ack, hopType, SystemPriority, apdu); _transportLayer->dataBroadcastRequest(ack, hopType, SystemPriority, apdu, Broadcast);
} }
void ApplicationLayer::individualAddressSerialNumberReadResponse(AckType ack, HopCountType hopType, void ApplicationLayer::individualAddressSerialNumberReadResponse(AckType ack, HopCountType hopType,
@ -329,7 +391,7 @@ void ApplicationLayer::individualAddressSerialNumberReadResponse(AckType ack, Ho
memcpy(data, serialNumber, 6); memcpy(data, serialNumber, 6);
data += 6; data += 6;
pushWord(domainAddress, data); pushWord(domainAddress, data);
_transportLayer->dataBroadcastRequest(ack, hopType, SystemPriority, apdu); _transportLayer->dataBroadcastRequest(ack, hopType, SystemPriority, apdu, Broadcast);
} }
void ApplicationLayer::individualAddressSerialNumberWriteRequest(AckType ack, HopCountType hopType, uint8_t * serialNumber, void ApplicationLayer::individualAddressSerialNumberWriteRequest(AckType ack, HopCountType hopType, uint8_t * serialNumber,
@ -342,7 +404,7 @@ void ApplicationLayer::individualAddressSerialNumberWriteRequest(AckType ack, Ho
memcpy(data, serialNumber, 6); memcpy(data, serialNumber, 6);
data += 6; data += 6;
pushWord(newaddress, data); pushWord(newaddress, data);
_transportLayer->dataBroadcastRequest(ack, hopType, SystemPriority, apdu); _transportLayer->dataBroadcastRequest(ack, hopType, SystemPriority, apdu, Broadcast);
} }
void ApplicationLayer::deviceDescriptorReadRequest(AckType ack, Priority priority, HopCountType hopType, uint16_t asap, void ApplicationLayer::deviceDescriptorReadRequest(AckType ack, Priority priority, HopCountType hopType, uint16_t asap,
@ -423,7 +485,7 @@ void ApplicationLayer::systemNetworkParameterReadResponse(Priority priority, Hop
//apdu.printPDU(); //apdu.printPDU();
_transportLayer->dataSystemBroadcastRequest(AckDontCare, hopType, SystemPriority, apdu); _transportLayer->dataBroadcastRequest(AckDontCare, hopType, SystemPriority, apdu, SysBroadcast);
} }
//TODO: ApplicationLayer::domainAddressSerialNumberWriteRequest() //TODO: ApplicationLayer::domainAddressSerialNumberWriteRequest()
@ -442,7 +504,7 @@ void ApplicationLayer::domainAddressSerialNumberReadResponse(Priority priority,
//apdu.printPDU(); //apdu.printPDU();
_transportLayer->dataSystemBroadcastRequest(AckDontCare, hopType, SystemPriority, apdu); _transportLayer->dataBroadcastRequest(AckDontCare, hopType, SystemPriority, apdu, SysBroadcast);
} }
//TODO: ApplicationLayer::IndividualAddressSerialNumberWriteRequest() //TODO: ApplicationLayer::IndividualAddressSerialNumberWriteRequest()
@ -461,7 +523,7 @@ void ApplicationLayer::IndividualAddressSerialNumberReadResponse(Priority priori
//apdu.printPDU(); //apdu.printPDU();
_transportLayer->dataBroadcastRequest(AckDontCare, hopType, SystemPriority, apdu); _transportLayer->dataBroadcastRequest(AckDontCare, hopType, SystemPriority, apdu, Broadcast);
} }
void ApplicationLayer::propertyValueReadRequest(AckType ack, Priority priority, HopCountType hopType, uint16_t asap, void ApplicationLayer::propertyValueReadRequest(AckType ack, Priority priority, HopCountType hopType, uint16_t asap,
@ -919,4 +981,4 @@ void ApplicationLayer::individualSend(AckType ack, HopCountType hopType, Priorit
bool ApplicationLayer::isConnected() bool ApplicationLayer::isConnected()
{ {
return (_connectedTsap >= 0); return (_connectedTsap >= 0);
} }

View File

@ -65,10 +65,8 @@ class ApplicationLayer
*/ */
void dataGroupConfirm(AckType ack, HopCountType hopType, Priority priority, uint16_t tsap, void dataGroupConfirm(AckType ack, HopCountType hopType, Priority priority, uint16_t tsap,
APDU& apdu, bool status); APDU& apdu, bool status);
void dataBroadcastIndication(HopCountType hopType, Priority priority, uint16_t source, APDU& apdu); void dataBroadcastIndication(HopCountType hopType, Priority priority, uint16_t source, APDU& apdu, SystemBroadcast broadcastType);
void dataBroadcastConfirm(AckType ack, HopCountType hopType, Priority priority, APDU& apdu, bool status); void dataBroadcastConfirm(AckType ack, HopCountType hopType, Priority priority, APDU& apdu, bool status, SystemBroadcast broadcastType);
void dataSystemBroadcastIndication(HopCountType hopType, Priority priority, uint16_t source, APDU& apdu);
void dataSystemBroadcastConfirm(HopCountType hopType, Priority priority, APDU& apdu, bool status);
void dataIndividualIndication(HopCountType hopType, Priority priority, uint16_t source, APDU& apdu); void dataIndividualIndication(HopCountType hopType, Priority priority, uint16_t source, APDU& apdu);
void dataIndividualConfirm(AckType ack, HopCountType hopType, Priority priority, uint16_t tsap, APDU& apdu, bool status); void dataIndividualConfirm(AckType ack, HopCountType hopType, Priority priority, uint16_t tsap, APDU& apdu, bool status);
void connectIndication(uint16_t tsap); void connectIndication(uint16_t tsap);

View File

@ -41,11 +41,16 @@ void DataLinkLayer::dataRequest(AckType ack, AddressType addrType, uint16_t dest
sendTelegram(npdu, ack, destinationAddr, addrType, format, priority, Broadcast); sendTelegram(npdu, ack, destinationAddr, addrType, format, priority, Broadcast);
} }
void DataLinkLayer::systemBroadcastRequest(AckType ack, FrameFormat format, Priority priority, NPDU& npdu) void DataLinkLayer::broadcastRequest(AckType ack, FrameFormat format, Priority priority, NPDU& npdu, SystemBroadcast broadcastType)
{ {
// System Broadcast requests will always be transmitted as broadcast with KNX serial number for open media (e.g. RF medium) // System Broadcast requests will always be transmitted as broadcast with KNX serial number for open media (e.g. RF medium)
// See 3.2.5 p.22 // See 3.2.5 p.22
sendTelegram(npdu, ack, 0, GroupAddress, format, priority, SysBroadcast); #if (MEDIUM_TYPE == 5)||(MEDIUM_TYPE == 0)
(void)broadcastType; // not used on TP/IP, always normal broadcast
sendTelegram(npdu, ack, 0, GroupAddress, format, priority, Broadcast);
#else
sendTelegram(npdu, ack, 0, GroupAddress, format, priority, broadcastType);
#endif
} }
void DataLinkLayer::dataConReceived(CemiFrame& frame, bool success) void DataLinkLayer::dataConReceived(CemiFrame& frame, bool success)
@ -60,7 +65,7 @@ void DataLinkLayer::dataConReceived(CemiFrame& frame, bool success)
FrameFormat type = frame.frameType(); FrameFormat type = frame.frameType();
Priority priority = frame.priority(); Priority priority = frame.priority();
NPDU& npdu = frame.npdu(); NPDU& npdu = frame.npdu();
SystemBroadcast systemBroadcast = frame.systemBroadcast(); SystemBroadcast broadcastType = frame.systemBroadcast();
#ifdef USE_CEMI_SERVER #ifdef USE_CEMI_SERVER
// if the confirmation was caused by a tunnel request then // if the confirmation was caused by a tunnel request then
@ -73,10 +78,13 @@ void DataLinkLayer::dataConReceived(CemiFrame& frame, bool success)
#endif #endif
if (addrType == GroupAddress && destination == 0) if (addrType == GroupAddress && destination == 0)
if (systemBroadcast == SysBroadcast) {
_networkLayer.systemBroadcastConfirm(ack, type, priority, source, npdu, success); _networkLayer.broadcastConfirm(ack, type, priority, source, npdu, success, broadcastType);
else }
_networkLayer.broadcastConfirm(ack, type, priority, source, npdu, success); else if (addrType == InduvidualAddress && destination == 0)
{
_networkLayer.broadcastConfirm(ack, type, priority, source, npdu, success, broadcastType);
}
else else
_networkLayer.dataConfirm(ack, addrType, destination, type, priority, source, npdu, success); _networkLayer.dataConfirm(ack, addrType, destination, type, priority, source, npdu, success);
@ -93,7 +101,7 @@ void DataLinkLayer::frameRecieved(CemiFrame& frame)
Priority priority = frame.priority(); Priority priority = frame.priority();
NPDU& npdu = frame.npdu(); NPDU& npdu = frame.npdu();
uint16_t ownAddr = _deviceObject.induvidualAddress(); uint16_t ownAddr = _deviceObject.induvidualAddress();
SystemBroadcast systemBroadcast = frame.systemBroadcast(); SystemBroadcast broadcastType = frame.systemBroadcast();
#ifdef USE_CEMI_SERVER #ifdef USE_CEMI_SERVER
// Do not send our own message back to the tunnel // Do not send our own message back to the tunnel
@ -108,10 +116,11 @@ void DataLinkLayer::frameRecieved(CemiFrame& frame)
if (addrType == GroupAddress && destination == 0) if (addrType == GroupAddress && destination == 0)
{ {
if (systemBroadcast == SysBroadcast) _networkLayer.broadcastIndication(ack, type, npdu, priority, source, broadcastType);
_networkLayer.systemBroadcastIndication(ack, type, npdu, priority, source); }
else else if (addrType == InduvidualAddress && destination == 0)
_networkLayer.broadcastIndication(ack, type, npdu, priority, source); {
_networkLayer.broadcastIndication(ack, type, npdu, priority, source, broadcastType);
} }
else else
{ {
@ -131,7 +140,7 @@ void DataLinkLayer::frameRecieved(CemiFrame& frame)
} }
} }
bool DataLinkLayer::sendTelegram(NPDU & npdu, AckType ack, uint16_t destinationAddr, AddressType addrType, FrameFormat format, Priority priority, SystemBroadcast systemBroadcast) bool DataLinkLayer::sendTelegram(NPDU & npdu, AckType ack, uint16_t destinationAddr, AddressType addrType, FrameFormat format, Priority priority, SystemBroadcast broadcastType)
{ {
CemiFrame& frame = npdu.frame(); CemiFrame& frame = npdu.frame();
frame.messageCode(L_data_ind); frame.messageCode(L_data_ind);
@ -140,7 +149,7 @@ bool DataLinkLayer::sendTelegram(NPDU & npdu, AckType ack, uint16_t destinationA
frame.addressType(addrType); frame.addressType(addrType);
frame.priority(priority); frame.priority(priority);
frame.repetition(RepititionAllowed); frame.repetition(RepititionAllowed);
frame.systemBroadcast(systemBroadcast); frame.systemBroadcast(broadcastType);
if (npdu.octetCount() <= 15) if (npdu.octetCount() <= 15)
frame.frameType(StandardFrame); frame.frameType(StandardFrame);

View File

@ -24,7 +24,7 @@ class DataLinkLayer
// from network layer // from network layer
void dataRequest(AckType ack, AddressType addrType, uint16_t destinationAddr, FrameFormat format, void dataRequest(AckType ack, AddressType addrType, uint16_t destinationAddr, FrameFormat format,
Priority priority, NPDU& npdu); Priority priority, NPDU& npdu);
void systemBroadcastRequest(AckType ack, FrameFormat format, Priority priority, NPDU& npdu); void broadcastRequest(AckType ack, FrameFormat format, Priority priority, NPDU& npdu, SystemBroadcast broadcastType);
virtual void loop() = 0; virtual void loop() = 0;
virtual void enabled(bool value) = 0; virtual void enabled(bool value) = 0;
virtual bool enabled() const = 0; virtual bool enabled() const = 0;
@ -32,7 +32,7 @@ class DataLinkLayer
protected: protected:
void frameRecieved(CemiFrame& frame); void frameRecieved(CemiFrame& frame);
void dataConReceived(CemiFrame& frame, bool success); void dataConReceived(CemiFrame& frame, bool success);
bool sendTelegram(NPDU& npdu, AckType ack, uint16_t destinationAddr, AddressType addrType, FrameFormat format, Priority priority, SystemBroadcast systemBroadcast); bool sendTelegram(NPDU& npdu, AckType ack, uint16_t destinationAddr, AddressType addrType, FrameFormat format, Priority priority, SystemBroadcast broadcastType);
virtual bool sendFrame(CemiFrame& frame) = 0; virtual bool sendFrame(CemiFrame& frame) = 0;
uint8_t* frameData(CemiFrame& frame); uint8_t* frameData(CemiFrame& frame);
DeviceObject& _deviceObject; DeviceObject& _deviceObject;

View File

@ -43,9 +43,10 @@ void NetworkLayer::dataIndication(AckType ack, AddressType addrType, uint16_t de
_transportLayer.dataGroupIndication(destination, hopType, priority, source, npdu.tpdu()); _transportLayer.dataGroupIndication(destination, hopType, priority, source, npdu.tpdu());
return; return;
} }
// destination == 0
_transportLayer.dataBroadcastIndication(hopType, priority, source, npdu.tpdu());
// assert: programming error
// should never be reached!
// destination == 0 && (addrType == InduvidualAddress || ddrType == GroupAddress)
} }
void NetworkLayer::dataConfirm(AckType ack, AddressType addressType, uint16_t destination, FrameFormat format, Priority priority, uint16_t source, NPDU& npdu, bool status) void NetworkLayer::dataConfirm(AckType ack, AddressType addressType, uint16_t destination, FrameFormat format, Priority priority, uint16_t source, NPDU& npdu, bool status)
@ -62,32 +63,22 @@ void NetworkLayer::dataConfirm(AckType ack, AddressType addressType, uint16_t de
_transportLayer.dataGroupConfirm(ack, source, destination, hopType, priority, npdu.tpdu(), status); _transportLayer.dataGroupConfirm(ack, source, destination, hopType, priority, npdu.tpdu(), status);
return; return;
} }
// destination == 0
_transportLayer.dataBroadcastConfirm(ack, hopType, priority, npdu.tpdu(), status); // assert: programming error
// should never be reached!
// destination == 0 && (addrType == InduvidualAddress || ddrType == GroupAddress)
} }
void NetworkLayer::broadcastIndication(AckType ack, FrameFormat format, NPDU& npdu, Priority priority, uint16_t source) void NetworkLayer::broadcastIndication(AckType ack, FrameFormat format, NPDU& npdu, Priority priority, uint16_t source, SystemBroadcast broadcastType)
{ {
HopCountType hopType = npdu.hopCount() == 7 ? UnlimitedRouting : NetworkLayerParameter; HopCountType hopType = npdu.hopCount() == 7 ? UnlimitedRouting : NetworkLayerParameter;
_transportLayer.dataBroadcastIndication(hopType, priority, source, npdu.tpdu()); _transportLayer.dataBroadcastIndication(hopType, priority, source, npdu.tpdu(), broadcastType);
} }
void NetworkLayer::broadcastConfirm(AckType ack, FrameFormat format, Priority priority, uint16_t source, NPDU& npdu, bool status) void NetworkLayer::broadcastConfirm(AckType ack, FrameFormat format, Priority priority, uint16_t source, NPDU& npdu, bool status, SystemBroadcast broadcastType)
{ {
HopCountType hopType = npdu.hopCount() == 7 ? UnlimitedRouting : NetworkLayerParameter; HopCountType hopType = npdu.hopCount() == 7 ? UnlimitedRouting : NetworkLayerParameter;
_transportLayer.dataBroadcastConfirm(ack, hopType, priority, npdu.tpdu(), status); _transportLayer.dataBroadcastConfirm(ack, hopType, priority, npdu.tpdu(), status, broadcastType);
}
void NetworkLayer::systemBroadcastIndication(AckType ack, FrameFormat format, NPDU& npdu, Priority priority, uint16_t source)
{
HopCountType hopType = npdu.hopCount() == 7 ? UnlimitedRouting : NetworkLayerParameter;
_transportLayer.dataSystemBroadcastIndication(hopType, priority, source, npdu.tpdu());
}
void NetworkLayer::systemBroadcastConfirm(AckType ack, FrameFormat format, Priority priority, uint16_t source, NPDU& npdu, bool status)
{
HopCountType hopType = npdu.hopCount() == 7 ? UnlimitedRouting : NetworkLayerParameter;
_transportLayer.dataSystemBroadcastConfirm(ack, hopType, npdu.tpdu(), priority, status);
} }
void NetworkLayer::dataIndividualRequest(AckType ack, uint16_t destination, HopCountType hopType, Priority priority, TPDU& tpdu) void NetworkLayer::dataIndividualRequest(AckType ack, uint16_t destination, HopCountType hopType, Priority priority, TPDU& tpdu)
@ -119,12 +110,7 @@ void NetworkLayer::dataGroupRequest(AckType ack, uint16_t destination, HopCountT
sendDataRequest(tpdu, hopType, ack, destination, priority, GroupAddress); sendDataRequest(tpdu, hopType, ack, destination, priority, GroupAddress);
} }
void NetworkLayer::dataBroadcastRequest(AckType ack, HopCountType hopType, Priority priority, TPDU& tpdu) void NetworkLayer::dataBroadcastRequest(AckType ack, HopCountType hopType, Priority priority, TPDU& tpdu, SystemBroadcast broadcastType)
{
sendDataRequest(tpdu, hopType, ack, 0, priority, GroupAddress);
}
void NetworkLayer::dataSystemBroadcastRequest(AckType ack, HopCountType hopType, Priority priority, TPDU& tpdu)
{ {
NPDU& npdu = tpdu.frame().npdu(); NPDU& npdu = tpdu.frame().npdu();
@ -135,5 +121,5 @@ void NetworkLayer::dataSystemBroadcastRequest(AckType ack, HopCountType hopType,
FrameFormat frameFormat = npdu.octetCount() > 15 ? ExtendedFrame : StandardFrame; FrameFormat frameFormat = npdu.octetCount() > 15 ? ExtendedFrame : StandardFrame;
_dataLinkLayer->systemBroadcastRequest(ack, frameFormat, priority, npdu); _dataLinkLayer->broadcastRequest(ack, frameFormat, priority, npdu, broadcastType);
} }

View File

@ -21,17 +21,14 @@ class NetworkLayer
void dataConfirm(AckType ack, AddressType addressType, uint16_t destination, FrameFormat format, Priority priority, void dataConfirm(AckType ack, AddressType addressType, uint16_t destination, FrameFormat format, Priority priority,
uint16_t source, NPDU& npdu, bool status); uint16_t source, NPDU& npdu, bool status);
void broadcastIndication(AckType ack, FrameFormat format, NPDU& npdu, void broadcastIndication(AckType ack, FrameFormat format, NPDU& npdu,
Priority priority, uint16_t source); Priority priority, uint16_t source, SystemBroadcast broadcastType);
void broadcastConfirm(AckType ack, FrameFormat format, Priority priority, uint16_t source, NPDU& npdu, bool status); void broadcastConfirm(AckType ack, FrameFormat format, Priority priority, uint16_t source, NPDU& npdu, bool status,
void systemBroadcastIndication(AckType ack, FrameFormat format, NPDU& npdu, SystemBroadcast broadcastType);
Priority priority, uint16_t source);
void systemBroadcastConfirm(AckType ack, FrameFormat format, Priority priority, uint16_t source, NPDU& npdu, bool status);
// from transport layer // from transport layer
void dataIndividualRequest(AckType ack, uint16_t destination, HopCountType hopType, Priority priority, TPDU& tpdu); void dataIndividualRequest(AckType ack, uint16_t destination, HopCountType hopType, Priority priority, TPDU& tpdu);
void dataGroupRequest(AckType ack, uint16_t destination, HopCountType hopType, Priority priority, TPDU& tpdu); void dataGroupRequest(AckType ack, uint16_t destination, HopCountType hopType, Priority priority, TPDU& tpdu);
void dataBroadcastRequest(AckType ack, HopCountType hopType, Priority priority, TPDU& tpdu); void dataBroadcastRequest(AckType ack, HopCountType hopType, Priority priority, TPDU& tpdu, SystemBroadcast broadcastType);
void dataSystemBroadcastRequest(AckType ack, HopCountType hopType, Priority priority, TPDU& tpdu);
private: private:
void sendDataRequest(TPDU& tpdu, HopCountType hopType, AckType ack, uint16_t destination, Priority priority, AddressType addrType); void sendDataRequest(TPDU& tpdu, HopCountType hopType, AckType ack, uint16_t destination, Priority priority, AddressType addrType);

View File

@ -373,24 +373,14 @@ void TransportLayer::dataGroupConfirm(AckType ack, uint16_t source, uint16_t des
_applicationLayer.dataGroupConfirm(ack, hopType, priority, destination, tpdu.apdu(), status); _applicationLayer.dataGroupConfirm(ack, hopType, priority, destination, tpdu.apdu(), status);
} }
void TransportLayer::dataBroadcastIndication(HopCountType hopType, Priority priority, uint16_t source, TPDU& tpdu) void TransportLayer::dataBroadcastIndication(HopCountType hopType, Priority priority, uint16_t source, TPDU& tpdu, SystemBroadcast broadcastType)
{ {
_applicationLayer.dataBroadcastIndication(hopType, priority, source, tpdu.apdu()); _applicationLayer.dataBroadcastIndication(hopType, priority, source, tpdu.apdu(), broadcastType);
} }
void TransportLayer::dataBroadcastConfirm(AckType ack, HopCountType hopType, Priority priority, TPDU& tpdu, bool status) void TransportLayer::dataBroadcastConfirm(AckType ack, HopCountType hopType, Priority priority, TPDU& tpdu, bool status, SystemBroadcast broadcastType)
{ {
_applicationLayer.dataBroadcastConfirm(ack, hopType, priority, tpdu.apdu(), status); _applicationLayer.dataBroadcastConfirm(ack, hopType, priority, tpdu.apdu(), status, broadcastType);
}
void TransportLayer::dataSystemBroadcastIndication(HopCountType hopType, Priority priority, uint16_t source, TPDU& tpdu)
{
_applicationLayer.dataSystemBroadcastIndication(hopType, priority, source, tpdu.apdu());
}
void TransportLayer::dataSystemBroadcastConfirm(AckType ack, HopCountType hopType, TPDU& tpdu, Priority priority, bool status)
{
_applicationLayer.dataSystemBroadcastConfirm(hopType, priority, tpdu.apdu(), status);
} }
void TransportLayer::dataGroupRequest(AckType ack, HopCountType hopType, Priority priority, uint16_t tsap, APDU& apdu) void TransportLayer::dataGroupRequest(AckType ack, HopCountType hopType, Priority priority, uint16_t tsap, APDU& apdu)
@ -400,16 +390,10 @@ void TransportLayer::dataGroupRequest(AckType ack, HopCountType hopType, Priorit
_networkLayer->dataGroupRequest(ack, groupAdress, hopType, priority, tpdu); _networkLayer->dataGroupRequest(ack, groupAdress, hopType, priority, tpdu);
} }
void TransportLayer::dataBroadcastRequest(AckType ack, HopCountType hopType, Priority priority, APDU& apdu) void TransportLayer::dataBroadcastRequest(AckType ack, HopCountType hopType, Priority priority, APDU& apdu, SystemBroadcast broadcastType)
{ {
TPDU& tpdu = apdu.frame().tpdu(); TPDU& tpdu = apdu.frame().tpdu();
_networkLayer->dataBroadcastRequest(ack, hopType, priority, tpdu); _networkLayer->dataBroadcastRequest(ack, hopType, priority, tpdu, broadcastType);
}
void TransportLayer::dataSystemBroadcastRequest(AckType ack, HopCountType hopType, Priority priority, APDU& apdu)
{
TPDU& tpdu = apdu.frame().tpdu();
return _networkLayer->dataSystemBroadcastRequest(ack, hopType, priority, tpdu);
} }
void TransportLayer::dataIndividualRequest(AckType ack, HopCountType hopType, Priority priority, uint16_t destination, APDU& apdu) void TransportLayer::dataIndividualRequest(AckType ack, HopCountType hopType, Priority priority, uint16_t destination, APDU& apdu)

View File

@ -24,10 +24,8 @@ public:
void dataIndividualConfirm(AckType ack, uint16_t destination, HopCountType hopType, Priority priority, TPDU& tpdu, bool status); void dataIndividualConfirm(AckType ack, uint16_t destination, HopCountType hopType, Priority priority, TPDU& tpdu, bool status);
void dataGroupIndication(uint16_t destination, HopCountType hopType, Priority priority, uint16_t source, TPDU& tpdu); void dataGroupIndication(uint16_t destination, HopCountType hopType, Priority priority, uint16_t source, TPDU& tpdu);
void dataGroupConfirm(AckType ack, uint16_t source, uint16_t destination, HopCountType hopType, Priority priority, TPDU& tpdu, bool status); void dataGroupConfirm(AckType ack, uint16_t source, uint16_t destination, HopCountType hopType, Priority priority, TPDU& tpdu, bool status);
void dataBroadcastIndication(HopCountType hopType, Priority priority, uint16_t source, TPDU& tpdu); void dataBroadcastIndication(HopCountType hopType, Priority priority, uint16_t source, TPDU& tpdu, SystemBroadcast broadcastType);
void dataBroadcastConfirm(AckType ack, HopCountType hopType, Priority priority, TPDU& tpdu, bool status); void dataBroadcastConfirm(AckType ack, HopCountType hopType, Priority priority, TPDU& tpdu, bool status, SystemBroadcast broadcastType);
void dataSystemBroadcastIndication(HopCountType hopType, Priority priority, uint16_t source, TPDU& tpdu);
void dataSystemBroadcastConfirm(AckType ack, HopCountType hopType, TPDU& tpdu, Priority priority, bool status);
#pragma endregion #pragma endregion
#pragma region from application layer #pragma region from application layer
@ -48,8 +46,7 @@ public:
* @param ack Did we want a DataLinkLayer acknowledgement? See ::AckType. * @param ack Did we want a DataLinkLayer acknowledgement? See ::AckType.
*/ */
void dataGroupRequest(AckType ack, HopCountType hopType, Priority priority, uint16_t tsap, APDU& apdu); void dataGroupRequest(AckType ack, HopCountType hopType, Priority priority, uint16_t tsap, APDU& apdu);
void dataBroadcastRequest(AckType ack, HopCountType hopType, Priority priority, APDU& apdu); void dataBroadcastRequest(AckType ack, HopCountType hopType, Priority priority, APDU& apdu, SystemBroadcast broadcastType);
void dataSystemBroadcastRequest(AckType ack, HopCountType hopType, Priority priority, APDU& apdu);
void dataIndividualRequest(AckType ack, HopCountType hopType, Priority priority, uint16_t destination, APDU& apdu); void dataIndividualRequest(AckType ack, HopCountType hopType, Priority priority, uint16_t destination, APDU& apdu);
void connectRequest(uint16_t destination, Priority priority); void connectRequest(uint16_t destination, Priority priority);