save work

This commit is contained in:
Nanosonde 2020-06-08 14:15:22 +02:00
parent 332663897f
commit 54d8a009cf
22 changed files with 345 additions and 331 deletions

View File

@ -31,6 +31,7 @@ add_executable(knx-linux
../../src/knx/cemi_frame.cpp ../../src/knx/cemi_frame.cpp
../../src/knx/cemi_frame.h ../../src/knx/cemi_frame.h
../../src/knx/cemi_server.cpp ../../src/knx/cemi_server.cpp
../../src/knx/cemi_server.h
../../src/knx/cemi_server_object.cpp ../../src/knx/cemi_server_object.cpp
../../src/knx/cemi_server_object.h ../../src/knx/cemi_server_object.h
../../src/knx/data_link_layer.cpp ../../src/knx/data_link_layer.cpp
@ -55,13 +56,21 @@ add_executable(knx-linux
../../src/knx/ip_parameter_object.cpp ../../src/knx/ip_parameter_object.cpp
../../src/knx/ip_parameter_object.h ../../src/knx/ip_parameter_object.h
../../src/knx/knx_ip_device_information_dib.cpp ../../src/knx/knx_ip_device_information_dib.cpp
../../src/knx/knx_ip_device_information_dib.h
../../src/knx/knx_ip_dib.cpp ../../src/knx/knx_ip_dib.cpp
../../src/knx/knx_ip_dib.h
../../src/knx/knx_ip_frame.cpp ../../src/knx/knx_ip_frame.cpp
../../src/knx/knx_ip_frame.h
../../src/knx/knx_ip_routing_indication.cpp ../../src/knx/knx_ip_routing_indication.cpp
../../src/knx/knx_ip_routing_indication.h
../../src/knx/knx_ip_search_request.cpp ../../src/knx/knx_ip_search_request.cpp
../../src/knx/knx_ip_search_request.h
../../src/knx/knx_ip_search_response.cpp ../../src/knx/knx_ip_search_response.cpp
../../src/knx/knx_ip_search_response.h
../../src/knx/knx_ip_supported_service_dib.cpp ../../src/knx/knx_ip_supported_service_dib.cpp
../../src/knx/knx_ip_supported_service_dib.h
../../src/knx/ip_host_protocol_address_information.cpp ../../src/knx/ip_host_protocol_address_information.cpp
../../src/knx/ip_host_protocol_address_information.h
../../src/knx/knx_value.cpp ../../src/knx/knx_value.cpp
../../src/knx/knx_value.h ../../src/knx/knx_value.h
../../src/knx/memory.cpp ../../src/knx/memory.cpp
@ -93,6 +102,7 @@ add_executable(knx-linux
../../src/knx/transport_layer.cpp ../../src/knx/transport_layer.cpp
../../src/knx/transport_layer.h ../../src/knx/transport_layer.h
../../src/knx/usb_tunnel_interface.cpp ../../src/knx/usb_tunnel_interface.cpp
../../src/knx/usb_tunnel_interface.h
../../src/knx_facade.cpp ../../src/knx_facade.cpp
../../src/knx_facade.h ../../src/knx_facade.h
../../src/linux_platform.cpp ../../src/linux_platform.cpp

View File

@ -77,9 +77,13 @@ 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();
if (broadcastType == Broadcast)
{
// APCI on Broadcast
switch (apdu.type()) switch (apdu.type())
{ {
case IndividualAddressWrite: case IndividualAddressWrite:
@ -117,19 +121,68 @@ void ApplicationLayer::dataBroadcastIndication(HopCountType hopType, Priority pr
_bau.individualAddressSerialNumberWriteIndication(priority, hopType, newIndividualAddress, knxSerialNumber); _bau.individualAddressSerialNumberWriteIndication(priority, hopType, newIndividualAddress, knxSerialNumber);
break; break;
} }
#if !((MEDIUM_TYPE == 5) || (MEDIUM_TYPE == 0))
default: default:
#if (MEDIUM_TYPE == 5)||(MEDIUM_TYPE == 0)
dataSystemBroadcastIndication(hopType, priority, source, apdu);
#else
print("Broadcast-indication: unhandled APDU-Type: "); print("Broadcast-indication: unhandled APDU-Type: ");
println(apdu.type()); println(apdu.type());
break;
}
}
else if (broadcastType == SysBroadcast)
{
// APCI on SystemBroadcast
switch (apdu.type())
{
#endif #endif
// TODO: testInfo could be of any length
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;
}
} }
} }
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();
if (broadcastType == Broadcast)
{
// APCI on Broadcast
switch (apdu.type()) switch (apdu.type())
{ {
case IndividualAddressWrite: case IndividualAddressWrite:
@ -162,68 +215,19 @@ void ApplicationLayer::dataBroadcastConfirm(AckType ack, HopCountType hopType, P
_bau.individualAddressSerialNumberWriteLocalConfirm(ack, hopType, data + 1, newAddress, status); _bau.individualAddressSerialNumberWriteLocalConfirm(ack, hopType, data + 1, newAddress, status);
break; break;
} }
#if !((MEDIUM_TYPE == 5) || (MEDIUM_TYPE == 0))
default: default:
#if (MEDIUM_TYPE == 5)||(MEDIUM_TYPE == 0)
dataSystemBroadcastConfirm(hopType, priority, apdu, status);
#else
print("Broadcast-confirm: unhandled APDU-Type: "); print("Broadcast-confirm: unhandled APDU-Type: ");
println(apdu.type()); println(apdu.type());
#endif break;
} }
} }
else if (broadcastType == SysBroadcast)
void ApplicationLayer::dataSystemBroadcastIndication(HopCountType hopType, Priority priority, uint16_t source, APDU& apdu) {
{ // APCI on SystemBroadcast
const uint8_t* data = apdu.data();
switch (apdu.type()) switch (apdu.type())
{ {
// TODO: testInfo could be of any length
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;
}
default:
#if (MEDIUM_TYPE == 5)||(MEDIUM_TYPE == 0)
// For closed media
print("Broadcast-indication: unhandled APDU-Type: ");
println(apdu.type());
#else
// For open media (e.g. PL, RF)
print("SystemBroadcast-indication: unhandled APDU-Type: ");
println(apdu.type());
#endif #endif
break;
}
}
void ApplicationLayer::dataSystemBroadcastConfirm(HopCountType hopType, Priority priority, APDU& apdu, bool status)
{
const uint8_t* data = apdu.data();
switch (apdu.type())
{
case SystemNetworkParameterRead: case SystemNetworkParameterRead:
{ {
uint16_t objectType; uint16_t objectType;
@ -252,17 +256,17 @@ void ApplicationLayer::dataSystemBroadcastConfirm(HopCountType hopType, Priority
break; break;
} }
default: default:
#if (MEDIUM_TYPE == 5)||(MEDIUM_TYPE == 0) #if !((MEDIUM_TYPE == 5) || (MEDIUM_TYPE == 0))
// For closed media if (broadcastType == SysBroadcast)
{
print("System");
}
#endif
print("Broadcast-confirm: unhandled APDU-Type: "); print("Broadcast-confirm: unhandled APDU-Type: ");
println(apdu.type()); println(apdu.type());
#else
// For open media (e.g. PL, RF)
print("SystemBroadcast-confirm: unhandled APDU-Type: ");
println(apdu.type());
#endif
break; break;
} }
}
} }
void ApplicationLayer::dataIndividualIndication(HopCountType hopType, Priority priority, uint16_t tsap, APDU& apdu) void ApplicationLayer::dataIndividualIndication(HopCountType hopType, Priority priority, uint16_t tsap, APDU& apdu)
@ -553,7 +557,7 @@ void ApplicationLayer::propertyValueWriteRequest(AckType ack, Priority priority,
} }
void ApplicationLayer::functionPropertyStateResponse(AckType ack, Priority priority, HopCountType hopType, uint16_t asap, void ApplicationLayer::functionPropertyStateResponse(AckType ack, Priority priority, HopCountType hopType, uint16_t asap,
uint8_t objectIndex, uint8_t propertyId, uint8_t returnCode, uint8_t* resultData, uint8_t resultLength) uint8_t objectIndex, uint8_t propertyId, uint8_t* resultData, uint8_t resultLength)
{ {
CemiFrame frame(3 + resultLength + 1); CemiFrame frame(3 + resultLength + 1);
APDU& apdu = frame.apdu(); APDU& apdu = frame.apdu();
@ -562,9 +566,8 @@ void ApplicationLayer::functionPropertyStateResponse(AckType ack, Priority prior
data[0] = objectIndex; data[0] = objectIndex;
data[1] = propertyId; data[1] = propertyId;
data[2] = returnCode;
if (resultLength > 0) if (resultLength > 0)
memcpy(&data[3], resultData, resultLength); memcpy(&data[2], resultData, resultLength);
if (asap == _connectedTsap) if (asap == _connectedTsap)
dataConnectedRequest(asap, priority, apdu); dataConnectedRequest(asap, priority, apdu);
@ -1011,11 +1014,11 @@ void ApplicationLayer::dataGroupRequest(AckType ack, HopCountType hopType, Prior
} }
void ApplicationLayer::dataBroadcastRequest(AckType ack, HopCountType hopType, Priority priority, APDU& apdu) void ApplicationLayer::dataBroadcastRequest(AckType ack, HopCountType hopType, Priority priority, APDU& apdu)
{ {
_transportLayer->dataBroadcastRequest(ack, hopType, SystemPriority, apdu); _transportLayer->dataBroadcastRequest(ack, hopType, SystemPriority, apdu, Broadcast);
} }
void ApplicationLayer::dataSystemBroadcastRequest(AckType ack, HopCountType hopType, Priority priority, APDU& apdu) void ApplicationLayer::dataSystemBroadcastRequest(AckType ack, HopCountType hopType, Priority priority, APDU& apdu)
{ {
_transportLayer->dataSystemBroadcastRequest(AckDontCare, hopType, SystemPriority, apdu); _transportLayer->dataBroadcastRequest(ack, hopType, SystemPriority, apdu, SysBroadcast);
} }
void ApplicationLayer::dataIndividualRequest(AckType ack, HopCountType hopType, Priority priority, uint16_t destination, APDU& apdu) void ApplicationLayer::dataIndividualRequest(AckType ack, HopCountType hopType, Priority priority, uint16_t destination, APDU& apdu)
{ {

View File

@ -65,10 +65,8 @@ class ApplicationLayer
*/ */
virtual void dataGroupConfirm(AckType ack, HopCountType hopType, Priority priority, uint16_t tsap, virtual void dataGroupConfirm(AckType ack, HopCountType hopType, Priority priority, uint16_t tsap,
APDU& apdu, bool status); APDU& apdu, bool status);
virtual void dataBroadcastIndication(HopCountType hopType, Priority priority, uint16_t source, APDU& apdu); virtual void dataBroadcastIndication(HopCountType hopType, Priority priority, uint16_t source, APDU& apdu, SystemBroadcast broadcastType);
virtual void dataBroadcastConfirm(AckType ack, HopCountType hopType, Priority priority, APDU& apdu, bool status); virtual void dataBroadcastConfirm(AckType ack, HopCountType hopType, Priority priority, APDU& apdu, bool status, SystemBroadcast broadcastType);
virtual void dataSystemBroadcastIndication(HopCountType hopType, Priority priority, uint16_t source, APDU& apdu);
virtual void dataSystemBroadcastConfirm(HopCountType hopType, Priority priority, APDU& apdu, bool status);
virtual void dataIndividualIndication(HopCountType hopType, Priority priority, uint16_t source, APDU& apdu); virtual void dataIndividualIndication(HopCountType hopType, Priority priority, uint16_t source, APDU& apdu);
virtual void dataIndividualConfirm(AckType ack, HopCountType hopType, Priority priority, uint16_t tsap, APDU& apdu, bool status); virtual void dataIndividualConfirm(AckType ack, HopCountType hopType, Priority priority, uint16_t tsap, APDU& apdu, bool status);
virtual void connectIndication(uint16_t tsap); virtual void connectIndication(uint16_t tsap);
@ -106,7 +104,7 @@ class ApplicationLayer
void propertyValueWriteRequest(AckType ack, Priority priority, HopCountType hopType, uint16_t asap, uint8_t objectIndex, void propertyValueWriteRequest(AckType ack, Priority priority, HopCountType hopType, uint16_t asap, uint8_t objectIndex,
uint8_t propertyId, uint8_t numberOfElements, uint16_t startIndex, uint8_t* data, uint8_t length); uint8_t propertyId, uint8_t numberOfElements, uint16_t startIndex, uint8_t* data, uint8_t length);
void functionPropertyStateResponse(AckType ack, Priority priority, HopCountType hopType, uint16_t asap, void functionPropertyStateResponse(AckType ack, Priority priority, HopCountType hopType, uint16_t asap,
uint8_t objectIndex, uint8_t propertyId, uint8_t returnCode, uint8_t *data, uint8_t length); uint8_t objectIndex, uint8_t propertyId, uint8_t *resultData, uint8_t resultLength);
void propertyDescriptionReadRequest(AckType ack, Priority priority, HopCountType hopType, uint16_t asap, void propertyDescriptionReadRequest(AckType ack, Priority priority, HopCountType hopType, uint16_t asap,
uint8_t objectIndex, uint8_t propertyId, uint8_t propertyIndex); uint8_t objectIndex, uint8_t propertyId, uint8_t propertyIndex);
void propertyDescriptionReadResponse(AckType ack, Priority priority, HopCountType hopType, uint16_t asap, void propertyDescriptionReadResponse(AckType ack, Priority priority, HopCountType hopType, uint16_t asap,

View File

@ -20,6 +20,9 @@ Bau07B0::Bau07B0(Platform& platform)
_dlLayer.cemiServer(_cemiServer); _dlLayer.cemiServer(_cemiServer);
_memory.addSaveRestore(&_cemiServerObject); _memory.addSaveRestore(&_cemiServerObject);
#endif #endif
#ifdef USE_DATASECURE
_memory.addSaveRestore(&_secIfObj);
#endif
// Set Mask Version in Device Object depending on the BAU // Set Mask Version in Device Object depending on the BAU
_deviceObj.maskVersion(0x07B0); _deviceObj.maskVersion(0x07B0);
@ -33,7 +36,12 @@ Bau07B0::Bau07B0(Platform& platform)
prop->write(3, OT_ASSOC_TABLE); prop->write(3, OT_ASSOC_TABLE);
prop->write(4, OT_GRP_OBJ_TABLE); prop->write(4, OT_GRP_OBJ_TABLE);
prop->write(5, OT_APPLICATION_PROG); prop->write(5, OT_APPLICATION_PROG);
#ifdef USE_CEMI_SERVER #if defined(USE_DATASECURE) && defined(USE_CEMI_SERVER)
prop->write(6, OT_SECURITY);
prop->write(7, OT_CEMI_SERVER);
#elif defined(USE_DATASECURE)
prop->write(6, OT_SECURITY);
#elif defined(USE_CEMI_SERVER)
prop->write(6, OT_CEMI_SERVER); prop->write(6, OT_CEMI_SERVER);
#endif #endif
} }
@ -54,9 +62,17 @@ InterfaceObject* Bau07B0::getInterfaceObject(uint8_t idx)
return &_appProgram; return &_appProgram;
case 5: // would be app_program 2 case 5: // would be app_program 2
return nullptr; return nullptr;
#ifdef USE_CEMI_SERVER #if defined(USE_DATASECURE) && defined(USE_CEMI_SERVER)
case 6:
return &_secIfObj;
case 7:
return &_cemiServerObject;
#elif defined(USE_CEMI_SERVER)
case 6: case 6:
return &_cemiServerObject; return &_cemiServerObject;
#elif defined(USE_DATASECURE)
case 6:
return &_secIfObj;
#endif #endif
default: default:
return nullptr; return nullptr;
@ -81,6 +97,10 @@ InterfaceObject* Bau07B0::getInterfaceObject(ObjectType objectType, uint8_t obje
return &_groupObjTable; return &_groupObjTable;
case OT_APPLICATION_PROG: case OT_APPLICATION_PROG:
return &_appProgram; return &_appProgram;
#ifdef USE_DATASECURE
case OT_SECURITY:
return &_secIfObj;
#endif
#ifdef USE_CEMI_SERVER #ifdef USE_CEMI_SERVER
case OT_CEMI_SERVER: case OT_CEMI_SERVER:
return &_cemiServerObject; return &_cemiServerObject;

View File

@ -20,6 +20,9 @@ Bau27B0::Bau27B0(Platform& platform)
_dlLayer.cemiServer(_cemiServer); _dlLayer.cemiServer(_cemiServer);
_memory.addSaveRestore(&_cemiServerObject); _memory.addSaveRestore(&_cemiServerObject);
#endif #endif
#ifdef USE_DATASECURE
_memory.addSaveRestore(&_secIfObj);
#endif
// Set Mask Version in Device Object depending on the BAU // Set Mask Version in Device Object depending on the BAU
_deviceObj.maskVersion(0x27B0); _deviceObj.maskVersion(0x27B0);
@ -41,7 +44,12 @@ Bau27B0::Bau27B0(Platform& platform)
prop->write(4, OT_GRP_OBJ_TABLE); prop->write(4, OT_GRP_OBJ_TABLE);
prop->write(5, OT_APPLICATION_PROG); prop->write(5, OT_APPLICATION_PROG);
prop->write(6, OT_RF_MEDIUM); prop->write(6, OT_RF_MEDIUM);
#ifdef USE_CEMI_SERVER #if defined(USE_DATASECURE) && defined(USE_CEMI_SERVER)
prop->write(7, OT_SECURITY);
prop->write(8, OT_CEMI_SERVER);
#elif defined(USE_DATASECURE)
prop->write(7, OT_SECURITY);
#elif defined(USE_CEMI_SERVER)
prop->write(7, OT_CEMI_SERVER); prop->write(7, OT_CEMI_SERVER);
#endif #endif
} }
@ -65,9 +73,17 @@ InterfaceObject* Bau27B0::getInterfaceObject(uint8_t idx)
return nullptr; return nullptr;
case 6: case 6:
return &_rfMediumObj; return &_rfMediumObj;
#ifdef USE_CEMI_SERVER #if defined(USE_DATASECURE) && defined(USE_CEMI_SERVER)
case 7:
return &_secIfObj;
case 8:
return &_cemiServerObject;
#elif defined(USE_CEMI_SERVER)
case 7: case 7:
return &_cemiServerObject; return &_cemiServerObject;
#elif defined(USE_DATASECURE)
case 7:
return &_secIfObj;
#endif #endif
default: default:
return nullptr; return nullptr;
@ -94,6 +110,10 @@ InterfaceObject* Bau27B0::getInterfaceObject(ObjectType objectType, uint8_t obje
return &_appProgram; return &_appProgram;
case OT_RF_MEDIUM: case OT_RF_MEDIUM:
return &_rfMediumObj; return &_rfMediumObj;
#ifdef USE_DATASECURE
case OT_SECURITY:
return &_secIfObj;
#endif
#ifdef USE_CEMI_SERVER #ifdef USE_CEMI_SERVER
case OT_CEMI_SERVER: case OT_CEMI_SERVER:
return &_cemiServerObject; return &_cemiServerObject;

View File

@ -22,6 +22,9 @@ Bau57B0::Bau57B0(Platform& platform)
_cemiServer.dataLinkLayer(_dlLayer); _cemiServer.dataLinkLayer(_dlLayer);
_dlLayer.cemiServer(_cemiServer); _dlLayer.cemiServer(_cemiServer);
_memory.addSaveRestore(&_cemiServerObject); _memory.addSaveRestore(&_cemiServerObject);
#endif
#ifdef USE_DATASECURE
_memory.addSaveRestore(&_secIfObj);
#endif #endif
_memory.addSaveRestore(&_ipParameters); _memory.addSaveRestore(&_ipParameters);
@ -38,7 +41,12 @@ Bau57B0::Bau57B0(Platform& platform)
prop->write(4, OT_GRP_OBJ_TABLE); prop->write(4, OT_GRP_OBJ_TABLE);
prop->write(5, OT_APPLICATION_PROG); prop->write(5, OT_APPLICATION_PROG);
prop->write(6, OT_IP_PARAMETER); prop->write(6, OT_IP_PARAMETER);
#ifdef USE_CEMI_SERVER #if defined(USE_DATASECURE) && defined(USE_CEMI_SERVER)
prop->write(7, OT_SECURITY);
prop->write(8, OT_CEMI_SERVER);
#elif defined(USE_DATASECURE)
prop->write(7, OT_SECURITY);
#elif defined(USE_CEMI_SERVER)
prop->write(7, OT_CEMI_SERVER); prop->write(7, OT_CEMI_SERVER);
#endif #endif
} }
@ -61,6 +69,18 @@ InterfaceObject* Bau57B0::getInterfaceObject(uint8_t idx)
return nullptr; return nullptr;
case 6: case 6:
return &_ipParameters; return &_ipParameters;
#if defined(USE_DATASECURE) && defined(USE_CEMI_SERVER)
case 7:
return &_secIfObj;
case 8:
return &_cemiServerObject;
#elif defined(USE_CEMI_SERVER)
case 7:
return &_cemiServerObject;
#elif defined(USE_DATASECURE)
case 7:
return &_secIfObj;
#endif
default: default:
return nullptr; return nullptr;
} }
@ -86,6 +106,14 @@ InterfaceObject* Bau57B0::getInterfaceObject(ObjectType objectType, uint8_t obje
return &_appProgram; return &_appProgram;
case OT_IP_PARAMETER: case OT_IP_PARAMETER:
return &_ipParameters; return &_ipParameters;
#ifdef USE_DATASECURE
case OT_SECURITY:
return &_secIfObj;
#endif
#ifdef USE_CEMI_SERVER
case OT_CEMI_SERVER:
return &_cemiServerObject;
#endif
default: default:
return nullptr; return nullptr;
} }

View File

@ -243,29 +243,27 @@ void BauSystemB::propertyValueReadIndication(Priority priority, HopCountType hop
void BauSystemB::functionPropertyCommandIndication(Priority priority, HopCountType hopType, uint16_t asap, uint8_t objectIndex, void BauSystemB::functionPropertyCommandIndication(Priority priority, HopCountType hopType, uint16_t asap, uint8_t objectIndex,
uint8_t propertyId, uint8_t* data, uint8_t length) uint8_t propertyId, uint8_t* data, uint8_t length)
{ {
uint8_t returnCode = 0xFF;
uint8_t resultLength = 0; uint8_t resultLength = 0;
uint8_t resultData[32]; uint8_t resultData[32];
InterfaceObject* obj = getInterfaceObject(objectIndex); InterfaceObject* obj = getInterfaceObject(objectIndex);
if(obj) if(obj)
returnCode = obj->command((PropertyID)propertyId, data, length, resultData, resultLength); obj->command((PropertyID)propertyId, data, length, resultData, resultLength);
_appLayer.functionPropertyStateResponse(AckRequested, priority, hopType, asap, objectIndex, propertyId, returnCode, resultData, resultLength); _appLayer.functionPropertyStateResponse(AckRequested, priority, hopType, asap, objectIndex, propertyId, resultData, resultLength);
} }
void BauSystemB::functionPropertyStateIndication(Priority priority, HopCountType hopType, uint16_t asap, uint8_t objectIndex, void BauSystemB::functionPropertyStateIndication(Priority priority, HopCountType hopType, uint16_t asap, uint8_t objectIndex,
uint8_t propertyId, uint8_t* data, uint8_t length) uint8_t propertyId, uint8_t* data, uint8_t length)
{ {
uint8_t returnCode = 0xFF;
uint8_t resultLength = 0; uint8_t resultLength = 0;
uint8_t resultData[32]; uint8_t resultData[32];
InterfaceObject* obj = getInterfaceObject(objectIndex); InterfaceObject* obj = getInterfaceObject(objectIndex);
if(obj) if(obj)
returnCode = obj->state((PropertyID)propertyId, data, length, resultData, resultLength); obj->state((PropertyID)propertyId, data, length, resultData, resultLength);
_appLayer.functionPropertyStateResponse(AckRequested, priority, hopType, asap, objectIndex, propertyId, returnCode, resultData, resultLength); _appLayer.functionPropertyStateResponse(AckRequested, priority, hopType, asap, objectIndex, propertyId, resultData, resultLength);
} }
void BauSystemB::individualAddressReadIndication(HopCountType hopType) void BauSystemB::individualAddressReadIndication(HopCountType hopType)

View File

@ -6,6 +6,7 @@
#include "address_table_object.h" #include "address_table_object.h"
#include "association_table_object.h" #include "association_table_object.h"
#include "group_object_table_object.h" #include "group_object_table_object.h"
#include "security_interface_object.h"
#include "application_program_object.h" #include "application_program_object.h"
#include "application_layer.h" #include "application_layer.h"
#include "secure_application_layer.h" #include "secure_application_layer.h"
@ -98,6 +99,7 @@ class BauSystemB : protected BusAccessUnit
Platform& _platform; Platform& _platform;
#ifdef USE_DATASECURE #ifdef USE_DATASECURE
SecureApplicationLayer _appLayer; SecureApplicationLayer _appLayer;
SecurityInterfaceObject _secIfObj;
#else #else
ApplicationLayer _appLayer; ApplicationLayer _appLayer;
#endif #endif

View File

@ -41,14 +41,15 @@ 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
#if (MEDIUM_TYPE == 5)||(MEDIUM_TYPE == 0) #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); sendTelegram(npdu, ack, 0, GroupAddress, format, priority, Broadcast);
#else #else
sendTelegram(npdu, ack, 0, GroupAddress, format, priority, SysBroadcast); sendTelegram(npdu, ack, 0, GroupAddress, format, priority, broadcastType);
#endif #endif
} }
@ -64,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
@ -78,15 +79,11 @@ void DataLinkLayer::dataConReceived(CemiFrame& frame, bool success)
if (addrType == GroupAddress && destination == 0) if (addrType == GroupAddress && destination == 0)
{ {
#if (MEDIUM_TYPE == 5)||(MEDIUM_TYPE == 0) _networkLayer.broadcastConfirm(ack, type, priority, source, npdu, success, broadcastType);
(void) systemBroadcast; // not used }
_networkLayer.broadcastConfirm(ack, type, priority, source, npdu, success); else if (addrType == InduvidualAddress && destination == 0)
#else {
if (systemBroadcast == SysBroadcast) _networkLayer.broadcastConfirm(ack, type, priority, source, npdu, success, broadcastType);
_networkLayer.systemBroadcastConfirm(ack, type, priority, source, npdu, success);
else
_networkLayer.broadcastConfirm(ack, type, priority, source, npdu, success);
#endif
} }
else else
_networkLayer.dataConfirm(ack, addrType, destination, type, priority, source, npdu, success); _networkLayer.dataConfirm(ack, addrType, destination, type, priority, source, npdu, success);
@ -104,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
@ -119,15 +116,11 @@ void DataLinkLayer::frameRecieved(CemiFrame& frame)
if (addrType == GroupAddress && destination == 0) if (addrType == GroupAddress && destination == 0)
{ {
#if (MEDIUM_TYPE == 5)||(MEDIUM_TYPE == 0) _networkLayer.broadcastIndication(ack, type, npdu, priority, source, broadcastType);
(void) systemBroadcast; // not used }
_networkLayer.broadcastIndication(ack, type, npdu, priority, source); else if (addrType == InduvidualAddress && destination == 0)
#else {
if (systemBroadcast == SysBroadcast) _networkLayer.broadcastIndication(ack, type, npdu, priority, source, broadcastType);
_networkLayer.systemBroadcastIndication(ack, type, npdu, priority, source);
else
_networkLayer.broadcastIndication(ack, type, npdu, priority, source);
#endif
} }
else else
{ {
@ -147,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);
@ -156,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

@ -8,8 +8,8 @@ template <class T> class FunctionProperty : public Property
{ {
public: public:
FunctionProperty(T* io, PropertyID id, uint8_t access, FunctionProperty(T* io, PropertyID id, uint8_t access,
uint8_t (*commandCallback)(T*, uint8_t*, uint8_t, uint8_t*, uint8_t&), void (*commandCallback)(T*, uint8_t*, uint8_t, uint8_t*, uint8_t&),
uint8_t (*stateCallback)(T*, uint8_t*, uint8_t, uint8_t*, uint8_t&)) void (*stateCallback)(T*, uint8_t*, uint8_t, uint8_t*, uint8_t&))
: Property(id, false, PDT_FUNCTION, 1, access), _interfaceObject(io), _commandCallback(commandCallback), _stateCallback(stateCallback) : Property(id, false, PDT_FUNCTION, 1, access), _interfaceObject(io), _commandCallback(commandCallback), _stateCallback(stateCallback)
/* max_elements is set to 1, see 3.3.7 Application Layer p.68 */ /* max_elements is set to 1, see 3.3.7 Application Layer p.68 */
{} {}
@ -24,24 +24,28 @@ template <class T> class FunctionProperty : public Property
return 0; return 0;
} }
virtual uint8_t command(uint8_t* data, uint8_t length, uint8_t* resultData, uint8_t& resultLength) override virtual void command(uint8_t* data, uint8_t length, uint8_t* resultData, uint8_t& resultLength) override
{ {
if (length == 0 || _commandCallback == nullptr ) if (length == 0 || _commandCallback == nullptr )
return 0xFF; {
resultLength = 0;
return _commandCallback(_interfaceObject, data, length, resultData, resultLength); return;
}
_commandCallback(_interfaceObject, data, length, resultData, resultLength);
} }
virtual uint8_t state(uint8_t* data, uint8_t length, uint8_t* resultData, uint8_t& resultLength) override virtual void state(uint8_t* data, uint8_t length, uint8_t* resultData, uint8_t& resultLength) override
{ {
if (length == 0 || _stateCallback == nullptr ) if (length == 0 || _stateCallback == nullptr )
return 0xFF; {
resultLength = 0;
return _stateCallback(_interfaceObject, data, length, resultData, resultLength); return;
}
_stateCallback(_interfaceObject, data, length, resultData, resultLength);
} }
private: private:
T* _interfaceObject = nullptr; T* _interfaceObject = nullptr;
uint8_t (*_commandCallback)(T*, uint8_t*, uint8_t, uint8_t*, uint8_t&) = nullptr; void (*_commandCallback)(T*, uint8_t*, uint8_t, uint8_t*, uint8_t&) = nullptr;
uint8_t (*_stateCallback)(T*, uint8_t*, uint8_t, uint8_t*, uint8_t&) = nullptr; void (*_stateCallback)(T*, uint8_t*, uint8_t, uint8_t*, uint8_t&) = nullptr;
}; };

View File

@ -137,26 +137,28 @@ uint8_t InterfaceObject::propertySize(PropertyID id)
return prop->ElementSize(); return prop->ElementSize();
} }
uint8_t InterfaceObject::command(PropertyID id, uint8_t* data, uint8_t length, uint8_t* resultData, uint8_t& resultLength) void InterfaceObject::command(PropertyID id, uint8_t* data, uint8_t length, uint8_t* resultData, uint8_t& resultLength)
{ {
Property* prop = property(id); Property* prop = property(id);
if (prop == nullptr) if (prop == nullptr)
{ {
return 0xFF; resultLength = 0;
return;;
} }
return prop->command(data, length, resultData, resultLength); prop->command(data, length, resultData, resultLength);
} }
uint8_t InterfaceObject::state(PropertyID id, uint8_t* data, uint8_t length, uint8_t* resultData, uint8_t resultLength) void InterfaceObject::state(PropertyID id, uint8_t* data, uint8_t length, uint8_t* resultData, uint8_t resultLength)
{ {
Property* prop = property(id); Property* prop = property(id);
if (prop == nullptr) if (prop == nullptr)
{ {
return 0xFF; resultLength = 0;
return;;
} }
return prop->state(data, length, resultData, resultLength); prop->state(data, length, resultData, resultLength);
} }
uint8_t InterfaceObject::propertyDescriptionCount() uint8_t InterfaceObject::propertyDescriptionCount()

View File

@ -114,7 +114,7 @@ class InterfaceObject : public SaveRestore
* *
* @param[out] resultData The result data for the function * @param[out] resultData The result data for the function
*/ */
virtual uint8_t command(PropertyID id, uint8_t* data, uint8_t length, uint8_t* resultData, uint8_t &resultLength); virtual void command(PropertyID id, uint8_t* data, uint8_t length, uint8_t* resultData, uint8_t &resultLength);
/** /**
* Get state of a function property of the interface object. Property type must be PDT_FUNCTION * Get state of a function property of the interface object. Property type must be PDT_FUNCTION
* *
@ -128,7 +128,7 @@ class InterfaceObject : public SaveRestore
* *
* @param[out] resultData The result data for the function * @param[out] resultData The result data for the function
*/ */
virtual uint8_t state(PropertyID id, uint8_t* data, uint8_t length, uint8_t* resultData, uint8_t resultLength); virtual void state(PropertyID id, uint8_t* data, uint8_t length, uint8_t* resultData, uint8_t resultLength);
/** /**
* Read the Description of a property of the interface object. The output parameters are only valid if nuberOfElements is not zero. * Read the Description of a property of the interface object. The output parameters are only valid if nuberOfElements is not zero.
* *

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

@ -204,22 +204,18 @@ uint8_t Property::write(uint16_t position, uint16_t value)
return write(position, 1, data); return write(position, 1, data);
} }
uint8_t Property::command(uint8_t* data, uint8_t length, uint8_t* resultData, uint8_t& resultLength) void Property::command(uint8_t* data, uint8_t length, uint8_t* resultData, uint8_t& resultLength)
{ {
(void)data; (void)data;
(void)length; (void)length;
(void)resultData; (void)resultData;
resultLength = 0; resultLength = 0;
return 0xFF;
} }
uint8_t Property::state(uint8_t* data, uint8_t length, uint8_t* resultData, uint8_t &resultLength) void Property::state(uint8_t* data, uint8_t length, uint8_t* resultData, uint8_t &resultLength)
{ {
(void)data; (void)data;
(void)length; (void)length;
(void)resultData; (void)resultData;
resultLength = 0; resultLength = 0;
return 0xFF;
} }

View File

@ -251,8 +251,8 @@ class Property : public SaveRestore
uint8_t ElementSize() const; uint8_t ElementSize() const;
virtual uint8_t read(uint16_t start, uint8_t count, uint8_t* data) const = 0; virtual uint8_t read(uint16_t start, uint8_t count, uint8_t* data) const = 0;
virtual uint8_t write(uint16_t start, uint8_t count, const uint8_t* data) = 0; virtual uint8_t write(uint16_t start, uint8_t count, const uint8_t* data) = 0;
virtual uint8_t command(uint8_t* data, uint8_t length, uint8_t* resultData, uint8_t& resultLength); virtual void command(uint8_t* data, uint8_t length, uint8_t* resultData, uint8_t& resultLength);
virtual uint8_t state(uint8_t* data, uint8_t length, uint8_t* resultData, uint8_t& resultLength); virtual void state(uint8_t* data, uint8_t length, uint8_t* resultData, uint8_t& resultLength);
uint8_t read(uint8_t& value) const; uint8_t read(uint8_t& value) const;
uint8_t read(uint16_t& value) const; uint8_t read(uint16_t& value) const;
uint8_t read(uint32_t& value) const; uint8_t read(uint32_t& value) const;

View File

@ -55,7 +55,7 @@ void SecureApplicationLayer::dataGroupConfirm(AckType ack, HopCountType hopType,
} }
} }
void SecureApplicationLayer::dataBroadcastIndication(HopCountType hopType, Priority priority, uint16_t source, APDU& apdu) void SecureApplicationLayer::dataBroadcastIndication(HopCountType hopType, Priority priority, uint16_t source, APDU& apdu, SystemBroadcast broadcastType)
{ {
if (apdu.type() == SecureService) if (apdu.type() == SecureService)
{ {
@ -64,31 +64,13 @@ void SecureApplicationLayer::dataBroadcastIndication(HopCountType hopType, Prior
} }
else else
{ {
ApplicationLayer::dataBroadcastIndication(hopType, priority, source, apdu); ApplicationLayer::dataBroadcastIndication(hopType, priority, source, apdu, broadcastType);
} }
} }
void SecureApplicationLayer::dataBroadcastConfirm(AckType ack, HopCountType hopType, Priority priority, APDU& apdu, bool status) void SecureApplicationLayer::dataBroadcastConfirm(AckType ack, HopCountType hopType, Priority priority, APDU& apdu, bool status, SystemBroadcast broadcastType)
{ {
ApplicationLayer::dataBroadcastConfirm(ack, hopType, priority, apdu, status); ApplicationLayer::dataBroadcastConfirm(ack, hopType, priority, apdu, status, broadcastType);
}
void SecureApplicationLayer::dataSystemBroadcastIndication(HopCountType hopType, Priority priority, uint16_t source, APDU& apdu)
{
if (apdu.type() == SecureService)
{
// Secure APDU is not allowed in Broadcast
println("Secure APDU in SystemBroadcast not allowed!");
}
else
{
ApplicationLayer::dataSystemBroadcastIndication(hopType, priority, source, apdu);
}
}
void SecureApplicationLayer::dataSystemBroadcastConfirm(HopCountType hopType, Priority priority, APDU& apdu, bool status)
{
ApplicationLayer::dataSystemBroadcastConfirm(hopType, priority, apdu, status);
} }
void SecureApplicationLayer::dataIndividualIndication(HopCountType hopType, Priority priority, uint16_t tsap, APDU& apdu) void SecureApplicationLayer::dataIndividualIndication(HopCountType hopType, Priority priority, uint16_t tsap, APDU& apdu)
@ -198,7 +180,7 @@ void SecureApplicationLayer::dataBroadcastRequest(AckType ack, HopCountType hopT
void SecureApplicationLayer::dataSystemBroadcastRequest(AckType ack, HopCountType hopType, Priority priority, APDU& apdu) void SecureApplicationLayer::dataSystemBroadcastRequest(AckType ack, HopCountType hopType, Priority priority, APDU& apdu)
{ {
ApplicationLayer::dataSystemBroadcastRequest(AckDontCare, hopType, SystemPriority, apdu); ApplicationLayer::dataSystemBroadcastRequest(ack, hopType, SystemPriority, apdu);
} }
void SecureApplicationLayer::dataIndividualRequest(AckType ack, HopCountType hopType, Priority priority, uint16_t destination, APDU& apdu) void SecureApplicationLayer::dataIndividualRequest(AckType ack, HopCountType hopType, Priority priority, uint16_t destination, APDU& apdu)

View File

@ -28,10 +28,8 @@ class SecureApplicationLayer : public ApplicationLayer
virtual void dataGroupIndication(HopCountType hopType, Priority priority, uint16_t tsap, APDU& apdu) override; virtual void dataGroupIndication(HopCountType hopType, Priority priority, uint16_t tsap, APDU& apdu) override;
virtual void dataGroupConfirm(AckType ack, HopCountType hopType, Priority priority, uint16_t tsap, virtual void dataGroupConfirm(AckType ack, HopCountType hopType, Priority priority, uint16_t tsap,
APDU& apdu, bool status) override; APDU& apdu, bool status) override;
virtual void dataBroadcastIndication(HopCountType hopType, Priority priority, uint16_t source, APDU& apdu) override; virtual void dataBroadcastIndication(HopCountType hopType, Priority priority, uint16_t source, APDU& apdu, SystemBroadcast broadcastType) override;
virtual void dataBroadcastConfirm(AckType ack, HopCountType hopType, Priority priority, APDU& apdu, bool status) override; virtual void dataBroadcastConfirm(AckType ack, HopCountType hopType, Priority priority, APDU& apdu, bool status, SystemBroadcast broadcastType) override;
virtual void dataSystemBroadcastIndication(HopCountType hopType, Priority priority, uint16_t source, APDU& apdu) override;
virtual void dataSystemBroadcastConfirm(HopCountType hopType, Priority priority, APDU& apdu, bool status) override;
virtual void dataIndividualIndication(HopCountType hopType, Priority priority, uint16_t source, APDU& apdu) override; virtual void dataIndividualIndication(HopCountType hopType, Priority priority, uint16_t source, APDU& apdu) override;
virtual void dataIndividualConfirm(AckType ack, HopCountType hopType, Priority priority, uint16_t tsap, APDU& apdu, bool status) override; virtual void dataIndividualConfirm(AckType ack, HopCountType hopType, Priority priority, uint16_t tsap, APDU& apdu, bool status) override;
virtual void connectIndication(uint16_t tsap) override; virtual void connectIndication(uint16_t tsap) override;

View File

@ -31,28 +31,24 @@ SecurityInterfaceObject::SecurityInterfaceObject()
}), }),
new FunctionProperty<SecurityInterfaceObject>(this, PID_SECURITY_MODE, ReadLv3 | WriteLv0, new FunctionProperty<SecurityInterfaceObject>(this, PID_SECURITY_MODE, ReadLv3 | WriteLv0,
// Command Callback of PID_SECURITY_MODE // Command Callback of PID_SECURITY_MODE
[](SecurityInterfaceObject* obj, uint8_t* data, uint8_t length, uint8_t* resultData, uint8_t& resultLength) -> uint8_t { [](SecurityInterfaceObject* obj, uint8_t* data, uint8_t length, uint8_t* resultData, uint8_t& resultLength) -> void {
// TODO // TODO
return 0;
}, },
// State Callback of PID_SECURITY_MODE // State Callback of PID_SECURITY_MODE
[](SecurityInterfaceObject* obj, uint8_t* data, uint8_t length, uint8_t* resultData, uint8_t& resultLength) -> uint8_t { [](SecurityInterfaceObject* obj, uint8_t* data, uint8_t length, uint8_t* resultData, uint8_t& resultLength) -> void {
// TODO // TODO
return 0;
}), }),
new DataProperty( PID_P2P_KEY_TABLE, true, PDT_GENERIC_20, 1, ReadLv3 | WriteLv0, (uint16_t)0 ), // TODO: value new DataProperty( PID_P2P_KEY_TABLE, true, PDT_GENERIC_20, 1, ReadLv3 | WriteLv0, (uint16_t)0 ), // TODO: value
new DataProperty( PID_GRP_KEY_TABLE, true, PDT_GENERIC_18, 1, ReadLv3 | WriteLv0, (uint16_t)0 ), // TODO: value new DataProperty( PID_GRP_KEY_TABLE, true, PDT_GENERIC_18, 1, ReadLv3 | WriteLv0, (uint16_t)0 ), // TODO: value
new DataProperty( PID_SECURITY_INDIVIDUAL_ADDRESS_TABLE, true, PDT_GENERIC_08, 1, ReadLv3 | WriteLv0, (uint16_t)0 ), // TODO: value new DataProperty( PID_SECURITY_INDIVIDUAL_ADDRESS_TABLE, true, PDT_GENERIC_08, 1, ReadLv3 | WriteLv0, (uint16_t)0 ), // TODO: value
new FunctionProperty<SecurityInterfaceObject>(this, PID_SECURITY_FAILURES_LOG, ReadLv3 | WriteLv0, new FunctionProperty<SecurityInterfaceObject>(this, PID_SECURITY_FAILURES_LOG, ReadLv3 | WriteLv0,
// Command Callback of PID_SECURITY_FAILURES_LOG // Command Callback of PID_SECURITY_FAILURES_LOG
[](SecurityInterfaceObject* obj, uint8_t* data, uint8_t length, uint8_t* resultData, uint8_t& resultLength) -> uint8_t { [](SecurityInterfaceObject* obj, uint8_t* data, uint8_t length, uint8_t* resultData, uint8_t& resultLength) -> void {
// TODO // TODO
return 0;
}, },
// State Callback of PID_SECURITY_FAILURES_LOG // State Callback of PID_SECURITY_FAILURES_LOG
[](SecurityInterfaceObject* obj, uint8_t* data, uint8_t length, uint8_t* resultData, uint8_t& resultLength) -> uint8_t { [](SecurityInterfaceObject* obj, uint8_t* data, uint8_t length, uint8_t* resultData, uint8_t& resultLength) -> void {
// TODO // TODO
return 0;
}), }),
new DataProperty( PID_TOOL_KEY, true, PDT_GENERIC_16, 1, ReadLv3 | WriteLv0, (uint16_t)0 ), // TODO: value (default is FDSK) new DataProperty( PID_TOOL_KEY, true, PDT_GENERIC_16, 1, ReadLv3 | WriteLv0, (uint16_t)0 ), // TODO: value (default is FDSK)
new DataProperty( PID_SECURITY_REPORT, true, PDT_BITSET8, 1, ReadLv3 | WriteLv0, (uint16_t)0 ), // TODO: value new DataProperty( PID_SECURITY_REPORT, true, PDT_BITSET8, 1, ReadLv3 | WriteLv0, (uint16_t)0 ), // TODO: value

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);