save work

This commit is contained in:
Nanosonde 2020-07-09 21:45:41 +02:00
parent 27433fe5e1
commit 62f18e725b
18 changed files with 96 additions and 86 deletions

View File

@ -108,14 +108,20 @@ InterfaceObject* Bau07B0::getInterfaceObject(ObjectType objectType, uint8_t obje
}
}
DataLinkLayer& Bau07B0::dataLinkLayer()
bool Bau07B0::enabled()
{
return _dlLayer;
return _dlLayer.enabled();
}
void Bau07B0::enabled(bool value)
{
_dlLayer.enabled(value);
}
void Bau07B0::loop()
{
::BauSystemB::loop();
_dlLayer.loop();
BauSystemBDevice::loop();
#ifdef USE_CEMI_SERVER
_cemiServer.loop();
#endif

View File

@ -12,12 +12,13 @@ class Bau07B0 : public BauSystemBDevice
{
public:
Bau07B0(Platform& platform);
void loop();
virtual void loop() override;
virtual bool enabled() override;
virtual void enabled(bool value) override;
protected:
InterfaceObject* getInterfaceObject(uint8_t idx);
InterfaceObject* getInterfaceObject(ObjectType objectType, uint8_t objectInstance);
DataLinkLayer& dataLinkLayer();
private:
TpUartDataLinkLayer _dlLayer;

View File

@ -108,14 +108,27 @@ InterfaceObject* Bau091A::getInterfaceObject(ObjectType objectType, uint8_t obje
void Bau091A::doMasterReset(EraseCode eraseCode, uint8_t channel)
{
// Common SystemB objects
BauSystemB::doMasterReset(eraseCode, channel);
BauSystemBCoupler::doMasterReset(eraseCode, channel);
_ipParameters.masterReset(eraseCode, channel);
}
DataLinkLayer& Bau091A::dataLinkLayer()
bool Bau091A::enabled()
{
return _dlLayerSecondary;
return _dlLayerPrimary.enabled() && _dlLayerSecondary.enabled();
}
void Bau091A::enabled(bool value)
{
_dlLayerPrimary.enabled(value);
_dlLayerSecondary.enabled(value);
}
void Bau091A::loop()
{
_dlLayerPrimary.loop();
_dlLayerSecondary.loop();
BauSystemBCoupler::loop();
}
#endif

View File

@ -12,11 +12,13 @@ class Bau091A : public BauSystemBCoupler
{
public:
Bau091A(Platform& platform);
virtual void loop() override;
virtual bool enabled() override;
virtual void enabled(bool value) override;
protected:
InterfaceObject* getInterfaceObject(uint8_t idx);
InterfaceObject* getInterfaceObject(ObjectType objectType, uint8_t objectInstance);
DataLinkLayer& dataLinkLayer();
virtual void doMasterReset(EraseCode eraseCode, uint8_t channel) override;
private:

View File

@ -128,14 +128,20 @@ void Bau27B0::doMasterReset(EraseCode eraseCode, uint8_t channel)
_rfMediumObj.masterReset(eraseCode, channel);
}
DataLinkLayer& Bau27B0::dataLinkLayer()
bool Bau27B0::enabled()
{
return _dlLayer;
return _dlLayer.enabled();
}
void Bau27B0::enabled(bool value)
{
_dlLayer.enabled(value);
}
void Bau27B0::loop()
{
::BauSystemB::loop();
_dlLayer.loop();
BauSystemBDevice::loop();
#ifdef USE_CEMI_SERVER
_cemiServer.loop();
#endif

View File

@ -13,12 +13,13 @@ class Bau27B0 : public BauSystemBDevice
{
public:
Bau27B0(Platform& platform);
void loop();
virtual void loop() override;
virtual bool enabled() override;
virtual void enabled(bool value) override;
protected:
InterfaceObject* getInterfaceObject(uint8_t idx);
InterfaceObject* getInterfaceObject(ObjectType objectType, uint8_t objectInstance);
DataLinkLayer& dataLinkLayer();
virtual void doMasterReset(EraseCode eraseCode, uint8_t channel) override;
private:

View File

@ -124,9 +124,23 @@ void Bau57B0::doMasterReset(EraseCode eraseCode, uint8_t channel)
_ipParameters.masterReset(eraseCode, channel);
}
DataLinkLayer& Bau57B0::dataLinkLayer()
bool Bau57B0::enabled()
{
return _dlLayer;
return _dlLayer.enabled();
}
void Bau57B0::enabled(bool value)
{
_dlLayer.enabled(value);
}
void Bau57B0::loop()
{
_dlLayer.loop();
BauSystemBDevice::loop();
#ifdef USE_CEMI_SERVER
_cemiServer.loop();
#endif
}
#endif

View File

@ -11,11 +11,13 @@ class Bau57B0 : public BauSystemBDevice
{
public:
Bau57B0(Platform& platform);
virtual void loop() override;
virtual bool enabled() override;
virtual void enabled(bool value) override;
protected:
InterfaceObject* getInterfaceObject(uint8_t idx);
InterfaceObject* getInterfaceObject(ObjectType objectType, uint8_t objectInstance);
DataLinkLayer& dataLinkLayer();
virtual void doMasterReset(EraseCode eraseCode, uint8_t channel) override;
private:

View File

@ -21,22 +21,6 @@ BauSystemB::BauSystemB(Platform& platform): _memory(platform, _deviceObj),
_memory.addSaveRestore(&_appProgram);
}
void BauSystemB::loop()
{
dataLinkLayer().loop();
nextRestartState();
}
bool BauSystemB::enabled()
{
return dataLinkLayer().enabled();
}
void BauSystemB::enabled(bool value)
{
dataLinkLayer().enabled(value);
}
void BauSystemB::readMemory()
{
_memory.readMemory();
@ -166,6 +150,7 @@ void BauSystemB::memoryExtReadIndication(Priority priority, HopCountType hopType
void BauSystemB::doMasterReset(EraseCode eraseCode, uint8_t channel)
{
_deviceObj.masterReset(eraseCode, channel);
_appProgram.masterReset(eraseCode, channel);
}

View File

@ -16,13 +16,13 @@ class BauSystemB : protected BusAccessUnit
{
public:
BauSystemB(Platform& platform);
virtual void loop();
virtual void loop() = 0;
ApplicationProgramObject& parameters();
DeviceObject& deviceObject();
Memory& memory();
bool configured();
bool enabled();
void enabled(bool value);
virtual bool enabled() = 0;
virtual void enabled(bool value) = 0;
void readMemory();
void writeMemory();
void addSaveRestore(SaveRestore* obj);
@ -37,7 +37,6 @@ class BauSystemB : protected BusAccessUnit
uint8_t* data, uint32_t length) override;
protected:
virtual DataLinkLayer& dataLinkLayer() = 0;
virtual ApplicationLayer& applicationLayer() = 0;
void memoryWriteIndication(Priority priority, HopCountType hopType, uint16_t asap, const SecurityControl &secCtrl, uint8_t number,

View File

@ -13,9 +13,6 @@ BauSystemBCoupler::BauSystemBCoupler(Platform& platform) :
#endif
_transLayer(_appLayer), _netLayer(_deviceObj, _transLayer)
{
#ifdef USE_DATASECURE
_secIfObj.secureApplicationLayer(_appLayer);
#endif
_appLayer.transportLayer(_transLayer);
_transLayer.networkLayer(_netLayer);
_memory.addSaveRestore(&_deviceObj);
@ -33,7 +30,6 @@ ApplicationLayer& BauSystemBCoupler::applicationLayer()
void BauSystemBCoupler::loop()
{
dataLinkLayer().loop();
_transLayer.loop();
#ifdef USE_DATASECURE
_appLayer.loop();
@ -54,4 +50,5 @@ bool BauSystemBCoupler::configured()
void BauSystemBCoupler::doMasterReset(EraseCode eraseCode, uint8_t channel)
{
BauSystemB::doMasterReset(eraseCode, channel);
}

View File

@ -24,10 +24,9 @@ class BauSystemBCoupler : public BauSystemB
bool configured();
protected:
virtual DataLinkLayer& dataLinkLayer() = 0;
virtual ApplicationLayer& applicationLayer() override;
virtual void doMasterReset(EraseCode eraseCode, uint8_t channel);
virtual void doMasterReset(EraseCode eraseCode, uint8_t channel) override;
enum RestartState
{

View File

@ -14,9 +14,6 @@ BauSystemBDevice::BauSystemBDevice(Platform& platform) :
#endif
_transLayer(_appLayer), _netLayer(_deviceObj, _transLayer)
{
#ifdef USE_DATASECURE
_secIfObj.secureApplicationLayer(_appLayer);
#endif
_appLayer.transportLayer(_transLayer);
_appLayer.associationTableObject(_assocTable);
_appLayer.groupAddressTable(_addrTable);
@ -39,7 +36,6 @@ ApplicationLayer& BauSystemBDevice::applicationLayer()
void BauSystemBDevice::loop()
{
dataLinkLayer().loop();
_transLayer.loop();
sendNextGroupTelegram();
nextRestartState();
@ -138,10 +134,11 @@ bool BauSystemBDevice::configured()
void BauSystemBDevice::doMasterReset(EraseCode eraseCode, uint8_t channel)
{
BauSystemB::doMasterReset(eraseCode, channel);
_addrTable.masterReset(eraseCode, channel);
_assocTable.masterReset(eraseCode, channel);
_groupObjTable.masterReset(eraseCode, channel);
_appProgram.masterReset(eraseCode, channel);
#ifdef USE_DATASECURE
// If erase code is FactoryReset or FactoryResetWithoutIA, set FDSK as toolkey again
// and disable security mode.

View File

@ -22,7 +22,6 @@ class BauSystemBDevice : public BauSystemB
BauSystemBDevice(Platform& platform);
virtual void loop();
GroupObjectTableObject& groupObjectTable();
Memory& memory();
bool configured();
protected:
@ -40,7 +39,7 @@ class BauSystemBDevice : public BauSystemB
void sendNextGroupTelegram();
void updateGroupObject(GroupObject& go, uint8_t* data, uint8_t length);
virtual void doMasterReset(EraseCode eraseCode, uint8_t channel);
virtual void doMasterReset(EraseCode eraseCode, uint8_t channel) override;
AddressTableObject _addrTable;
AssociationTableObject _assocTable;

View File

@ -1251,24 +1251,6 @@ bool SecureApplicationLayer::createSecureApdu(APDU& plainApdu, APDU& secureApdu,
return false;
}
void SecureApplicationLayer::clearFailureLog()
{
println("clearFailureLog()");
}
void SecureApplicationLayer::getFailureCounters(uint8_t* data)
{
memset(data, 0, 8);
println("getFailureCounters()");
}
uint8_t SecureApplicationLayer::getFromFailureLogByIndex(uint8_t index, uint8_t* data, uint8_t maxDataLen)
{
print("getFromFailureLogByIndex(): Index: ");
println(index);
return 0;
}
uint64_t SecureApplicationLayer::getRandomNumber()
{
return 0x000102030405; // TODO: generate random number

View File

@ -32,10 +32,6 @@ class SecureApplicationLayer : public ApplicationLayer
void groupAddressTable(AddressTableObject& addrTable);
void clearFailureLog();
void getFailureCounters(uint8_t* data);
uint8_t getFromFailureLogByIndex(uint8_t index, uint8_t* data, uint8_t maxDataLen);
// from transport layer
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,

View File

@ -97,7 +97,7 @@ SecurityInterfaceObject::SecurityInterfaceObject()
uint8_t info = data[2];
if (id == 0 && info == 0)
{
obj->_secAppLayer->clearFailureLog();
obj->clearFailureLog();
resultData[0] = ReturnCodes::Success;
resultData[1] = id;
resultLength = 2;
@ -123,7 +123,7 @@ SecurityInterfaceObject::SecurityInterfaceObject()
resultData[0] = ReturnCodes::Success;
resultData[1] = id;
resultData[2] = info;
obj->_secAppLayer->getFailureCounters(&resultData[3]); // Put 8 bytes in the buffer
obj->getFailureCounters(&resultData[3]); // Put 8 bytes in the buffer
resultLength = 3 + 8;
return;
}
@ -132,7 +132,7 @@ SecurityInterfaceObject::SecurityInterfaceObject()
{
uint8_t maxBufferSize = resultLength; // Remember the maximum buffer size of the buffer that is provided to us
uint8_t index = info;
uint8_t numBytes = obj->_secAppLayer->getFromFailureLogByIndex(index, &resultData[2], maxBufferSize);
uint8_t numBytes = obj->getFromFailureLogByIndex(index, &resultData[2], maxBufferSize);
if ( numBytes > 0)
{
resultData[0] = ReturnCodes::Success;
@ -163,11 +163,6 @@ SecurityInterfaceObject::SecurityInterfaceObject()
initializeProperties(sizeof(properties), properties);
}
void SecurityInterfaceObject::secureApplicationLayer(SecureApplicationLayer& secAppLayer)
{
_secAppLayer = &secAppLayer;
}
uint8_t* SecurityInterfaceObject::save(uint8_t* buffer)
{
buffer = pushByte(_state, buffer);
@ -206,6 +201,24 @@ bool SecurityInterfaceObject::isSecurityModeEnabled()
return _securityModeEnabled;
}
void SecurityInterfaceObject::clearFailureLog()
{
println("clearFailureLog()");
}
void SecurityInterfaceObject::getFailureCounters(uint8_t* data)
{
memset(data, 0, 8);
println("getFailureCounters()");
}
uint8_t SecurityInterfaceObject::getFromFailureLogByIndex(uint8_t index, uint8_t* data, uint8_t maxDataLen)
{
print("getFromFailureLogByIndex(): Index: ");
println(index);
return 0;
}
bool SecurityInterfaceObject::isLoaded()
{
return _state == LS_LOADED;

View File

@ -6,15 +6,11 @@
#include "interface_object.h"
#include "knx_types.h"
class SecureApplicationLayer;
class SecurityInterfaceObject: public InterfaceObject
{
public:
SecurityInterfaceObject();
void secureApplicationLayer(SecureApplicationLayer& secAppLayer);
virtual void masterReset(EraseCode eraseCode, uint8_t channel) override;
bool isSecurityModeEnabled();
@ -39,10 +35,12 @@ public:
uint16_t saveSize() override;
private:
SecureApplicationLayer* _secAppLayer = nullptr;
void setSecurityMode(bool enabled);
void clearFailureLog();
void getFailureCounters(uint8_t* data);
uint8_t getFromFailureLogByIndex(uint8_t index, uint8_t* data, uint8_t maxDataLen);
void errorCode(ErrorCode errorCode);
void loadEvent(const uint8_t* data);