save work

This commit is contained in:
Nanosonde 2020-07-19 13:19:37 +02:00
parent c7a7a2d121
commit d83c2ea46f
9 changed files with 52 additions and 38 deletions

View File

@ -10,6 +10,7 @@ using namespace std;
Bau091A::Bau091A(Platform& platform)
: BauSystemBCoupler(platform),
_rtObjSecondary(memory()),
_ipParameters(_deviceObj, platform),
_dlLayerPrimary(_deviceObj, _ipParameters, _netLayer.getEntity(0), _platform),
_dlLayerSecondary(_deviceObj, _netLayer.getEntity(1), platform, (ITpUartCallBacks&) *this)
@ -18,9 +19,11 @@ Bau091A::Bau091A(Platform& platform)
_cemiServer(*this)
#endif
{
// Before accessing anything of the two router objects they have to be initialized according to the used media combination
_rtObjPrimary.initialize(1, DptMedium::KNX_IP, true, false, 201);
_rtObjSecondary.initialize(2, DptMedium::KNX_TP1, false, true, 201);
// Before accessing anything of the router object they have to be initialized according to the used medium
_rtObjSecondary.initialize(1, DptMedium::KNX_TP1, false, true, 201);
// Mask 091A uses older coupler model 1.x which only uses one router object
_netLayer.rtObjSecondary(_rtObjSecondary);
_netLayer.getEntity(0).dataLinkLayer(_dlLayerPrimary);
_netLayer.getEntity(1).dataLinkLayer(_dlLayerSecondary);
@ -33,7 +36,6 @@ Bau091A::Bau091A(Platform& platform)
_memory.addSaveRestore(&_cemiServerObject);
#endif
_memory.addSaveRestore(&_rtObjPrimary);
_memory.addSaveRestore(&_rtObjSecondary);
_memory.addSaveRestore(&_ipParameters);
@ -47,7 +49,6 @@ Bau091A::Bau091A(Platform& platform)
Property* prop = _deviceObj.property(PID_IO_LIST);
prop->write(1, (uint16_t) OT_DEVICE);
prop->write(2, (uint16_t) OT_ROUTER);
prop->write(3, (uint16_t) OT_ROUTER);
prop->write(3, (uint16_t) OT_APPLICATION_PROG);
prop->write(4, (uint16_t) OT_IP_PARAMETER);
#if defined(USE_DATASECURE) && defined(USE_CEMI_SERVER)
@ -67,23 +68,21 @@ InterfaceObject* Bau091A::getInterfaceObject(uint8_t idx)
case 0:
return &_deviceObj;
case 1:
return &_rtObjPrimary;
case 2:
return &_rtObjSecondary;
case 3:
case 2:
return &_appProgram;
case 4:
case 3:
return &_ipParameters;
#if defined(USE_DATASECURE) && defined(USE_CEMI_SERVER)
case 5:
case 4:
return &_secIfObj;
case 6:
case 5:
return &_cemiServerObject;
#elif defined(USE_CEMI_SERVER)
case 5:
case 4:
return &_cemiServerObject;
#elif defined(USE_DATASECURE)
case 5:
case 4:
return &_secIfObj;
#endif
default:
@ -102,7 +101,7 @@ InterfaceObject* Bau091A::getInterfaceObject(ObjectType objectType, uint8_t obje
case OT_DEVICE:
return &_deviceObj;
case OT_ROUTER:
return objectInstance == 0 ? &_rtObjPrimary : &_rtObjSecondary;
return &_rtObjSecondary;
case OT_APPLICATION_PROG:
return &_appProgram;
case OT_IP_PARAMETER:
@ -126,6 +125,7 @@ void Bau091A::doMasterReset(EraseCode eraseCode, uint8_t channel)
BauSystemBCoupler::doMasterReset(eraseCode, channel);
_ipParameters.masterReset(eraseCode, channel);
_rtObjSecondary.masterReset(eraseCode, channel);
}
bool Bau091A::enabled()

View File

@ -25,6 +25,7 @@ class Bau091A : public BauSystemBCoupler, public ITpUartCallBacks
virtual void doMasterReset(EraseCode eraseCode, uint8_t channel) override;
private:
RouterObject _rtObjSecondary;
IpParameterObject _ipParameters;
IpDataLinkLayer _dlLayerPrimary;
TpUartDataLinkLayer _dlLayerSecondary;

View File

@ -8,8 +8,11 @@
using namespace std;
// Mask 0x2920 uses coupler model 2.0
Bau2920::Bau2920(Platform& platform)
: BauSystemBCoupler(platform),
_rtObjPrimary(memory()),
_rtObjSecondary(memory()),
_rfMediumObject(),
_dlLayerPrimary(_deviceObj, _netLayer.getEntity(0), _platform, (ITpUartCallBacks&) *this),
_dlLayerSecondary(_deviceObj, _rfMediumObject, _netLayer.getEntity(1), platform)
@ -22,6 +25,8 @@ Bau2920::Bau2920(Platform& platform)
_rtObjPrimary.initialize(1, DptMedium::KNX_TP1, true, false, 201);
_rtObjSecondary.initialize(2, DptMedium::KNX_RF, false, true, 201);
_netLayer.rtObjPrimary(_rtObjPrimary);
_netLayer.rtObjSecondary(_rtObjSecondary);
_netLayer.getEntity(0).dataLinkLayer(_dlLayerPrimary);
_netLayer.getEntity(1).dataLinkLayer(_dlLayerSecondary);
@ -48,15 +53,15 @@ Bau2920::Bau2920(Platform& platform)
prop->write(1, (uint16_t) OT_DEVICE);
prop->write(2, (uint16_t) OT_ROUTER);
prop->write(3, (uint16_t) OT_ROUTER);
prop->write(3, (uint16_t) OT_APPLICATION_PROG);
prop->write(4, (uint16_t) OT_RF_MEDIUM);
prop->write(4, (uint16_t) OT_APPLICATION_PROG);
prop->write(5, (uint16_t) OT_RF_MEDIUM);
#if defined(USE_DATASECURE) && defined(USE_CEMI_SERVER)
prop->write(5, (uint16_t) OT_SECURITY);
prop->write(6, (uint16_t) OT_CEMI_SERVER);
prop->write(6, (uint16_t) OT_SECURITY);
prop->write(7, (uint16_t) OT_CEMI_SERVER);
#elif defined(USE_DATASECURE)
prop->write(5, (uint16_t) OT_SECURITY);
prop->write(6, (uint16_t) OT_SECURITY);
#elif defined(USE_CEMI_SERVER)
prop->write(5, (uint16_t) OT_CEMI_SERVER);
prop->write(6, (uint16_t) OT_CEMI_SERVER);
#endif
}
@ -126,6 +131,8 @@ void Bau2920::doMasterReset(EraseCode eraseCode, uint8_t channel)
BauSystemBCoupler::doMasterReset(eraseCode, channel);
_rfMediumObject.masterReset(eraseCode, channel);
_rtObjPrimary.masterReset(eraseCode, channel);
_rtObjSecondary.masterReset(eraseCode, channel);
}
bool Bau2920::enabled()

View File

@ -23,6 +23,8 @@ class Bau2920 : public BauSystemBCoupler
virtual void doMasterReset(EraseCode eraseCode, uint8_t channel) override;
private:
RouterObject _rtObjPrimary;
RouterObject _rtObjSecondary;
RfMediumObject _rfMediumObject;
TpUartDataLinkLayer _dlLayerPrimary;
RfDataLinkLayer _dlLayerSecondary;

View File

@ -6,15 +6,13 @@
BauSystemBCoupler::BauSystemBCoupler(Platform& platform) :
BauSystemB(platform),
_platform(platform),
_rtObjPrimary(memory()),
_rtObjSecondary(memory()),
#ifdef USE_DATASECURE
_appLayer(_deviceObj, _secIfObj, *this),
#else
_appLayer(*this),
#endif
_transLayer(_appLayer),
_netLayer(_deviceObj, _rtObjPrimary, _rtObjSecondary, _transLayer)
_netLayer(_deviceObj, _transLayer)
{
_appLayer.transportLayer(_transLayer);
_transLayer.networkLayer(_netLayer);
@ -57,4 +55,8 @@ bool BauSystemBCoupler::configured()
void BauSystemBCoupler::doMasterReset(EraseCode eraseCode, uint8_t channel)
{
BauSystemB::doMasterReset(eraseCode, channel);
#ifdef USE_DATASECURE
_secIfObj.masterReset(eraseCode, channel);
#endif
}

View File

@ -30,8 +30,6 @@ class BauSystemBCoupler : public BauSystemB
virtual void doMasterReset(EraseCode eraseCode, uint8_t channel) override;
Platform& _platform;
RouterObject _rtObjPrimary;
RouterObject _rtObjSecondary;
#ifdef USE_DATASECURE
SecureApplicationLayer _appLayer;

View File

@ -146,10 +146,6 @@ void BauSystemBDevice::doMasterReset(EraseCode eraseCode, uint8_t channel)
_assocTable.masterReset(eraseCode, channel);
_groupObjTable.masterReset(eraseCode, channel);
#ifdef USE_DATASECURE
// If erase code is FactoryReset or FactoryResetWithoutIA, set FDSK as toolkey again
// and disable security mode.
// FIXME: the A_RestartResponse PDU has still to be sent with the current toolkey.
// Idea: use local confirmation of sent A_RestartResponse PDU to trigger writing the FDSK afterwards
_secIfObj.masterReset(eraseCode, channel);
#endif
}

View File

@ -6,13 +6,9 @@
#include "bits.h"
NetworkLayerCoupler::NetworkLayerCoupler(DeviceObject &deviceObj,
RouterObject& rtObjPrimary,
RouterObject& rtObjSecondary,
TransportLayer& layer) :
NetworkLayer(deviceObj, layer),
_netLayerEntities { {*this, 0}, {*this, 1} },
_rtObjPrimary(rtObjPrimary),
_rtObjSecondary(rtObjSecondary)
_netLayerEntities { {*this, 0}, {*this, 1} }
{
if ((_deviceObj.induvidualAddress() & 0x00FF) == 0x00)
{
@ -32,6 +28,16 @@ NetworkLayerEntity& NetworkLayerCoupler::getEntity(uint8_t interfaceIndex)
return _netLayerEntities[interfaceIndex];
}
void NetworkLayerCoupler::rtObjPrimary(RouterObject& rtObjPrimary)
{
_rtObjPrimary = &rtObjPrimary;
}
void NetworkLayerCoupler::rtObjSecondary(RouterObject& rtObjSecondary)
{
_rtObjSecondary = &rtObjSecondary;
}
void NetworkLayerCoupler::dataIndication(AckType ack, AddressType addrType, uint16_t destination, FrameFormat format, NPDU& npdu, Priority priority, uint16_t source)
{
HopCountType hopType = npdu.hopCount() == 7 ? UnlimitedRouting : NetworkLayerParameter;

View File

@ -15,11 +15,13 @@ class NetworkLayerCoupler : public NetworkLayer
friend class NetworkLayerEntity;
public:
NetworkLayerCoupler(DeviceObject& deviceObj, RouterObject& rtObjPrimary,
RouterObject& rtObjSecondary, TransportLayer& layer);
NetworkLayerCoupler(DeviceObject& deviceObj, TransportLayer& layer);
virtual NetworkLayerEntity& getEntity(uint8_t interfaceIndex) override;
void rtObjPrimary(RouterObject& rtObjPrimary);
void rtObjSecondary(RouterObject& rtObjSecondary);
// from transport layer
virtual void dataIndividualRequest(AckType ack, uint16_t destination, HopCountType hopType, Priority priority, TPDU& tpdu) override;
virtual void dataGroupRequest(AckType ack, uint16_t destination, HopCountType hopType, Priority priority, TPDU& tpdu) override;
@ -42,6 +44,6 @@ class NetworkLayerCoupler : public NetworkLayer
// Support a maximum of two physical interfaces for couplers
NetworkLayerEntity _netLayerEntities[2];
RouterObject& _rtObjPrimary;
RouterObject& _rtObjSecondary;
RouterObject* _rtObjPrimary {nullptr};
RouterObject* _rtObjSecondary {nullptr};
};