mirror of
https://github.com/thelsing/knx.git
synced 2025-10-08 11:14:29 +02:00
save work
This commit is contained in:
parent
f3d9af5576
commit
a4599f4f9d
@ -85,6 +85,8 @@ add_executable(knx-linux
|
|||||||
../../src/knx/memory.h
|
../../src/knx/memory.h
|
||||||
../../src/knx/network_layer.cpp
|
../../src/knx/network_layer.cpp
|
||||||
../../src/knx/network_layer.h
|
../../src/knx/network_layer.h
|
||||||
|
../../src/knx/network_layer_entity.cpp
|
||||||
|
../../src/knx/network_layer_entity.h
|
||||||
../../src/knx/npdu.cpp
|
../../src/knx/npdu.cpp
|
||||||
../../src/knx/npdu.h
|
../../src/knx/npdu.h
|
||||||
../../src/knx/platform.cpp
|
../../src/knx/platform.cpp
|
||||||
|
@ -9,14 +9,14 @@ using namespace std;
|
|||||||
|
|
||||||
Bau07B0::Bau07B0(Platform& platform)
|
Bau07B0::Bau07B0(Platform& platform)
|
||||||
: BauSystemBDevice(platform),
|
: BauSystemBDevice(platform),
|
||||||
_dlLayer(_deviceObj, _netLayer, _platform)
|
_dlLayer(_deviceObj, _netLayer.getEntity(0), _platform)
|
||||||
#ifdef USE_CEMI_SERVER
|
#ifdef USE_CEMI_SERVER
|
||||||
, _cemiServer(*this)
|
, _cemiServer(*this)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
_dlLayer.groupAddressTable(_addrTable);
|
_dlLayer.groupAddressTable(_addrTable);
|
||||||
|
|
||||||
_netLayer.dataLinkLayer(_dlLayer);
|
_netLayer.getEntity(0).dataLinkLayer(_dlLayer);
|
||||||
#ifdef USE_CEMI_SERVER
|
#ifdef USE_CEMI_SERVER
|
||||||
_cemiServer.dataLinkLayer(_dlLayer);
|
_cemiServer.dataLinkLayer(_dlLayer);
|
||||||
_dlLayer.cemiServer(_cemiServer);
|
_dlLayer.cemiServer(_cemiServer);
|
||||||
|
@ -11,14 +11,15 @@ using namespace std;
|
|||||||
Bau091A::Bau091A(Platform& platform)
|
Bau091A::Bau091A(Platform& platform)
|
||||||
: BauSystemBCoupler(platform),
|
: BauSystemBCoupler(platform),
|
||||||
_ipParameters(_deviceObj, platform),
|
_ipParameters(_deviceObj, platform),
|
||||||
_dlLayerPrimary(_deviceObj, _ipParameters, _netLayer, _platform),
|
_dlLayerPrimary(_deviceObj, _ipParameters, _netLayer.getEntity(0), _platform),
|
||||||
_dlLayerSecondary(_deviceObj, _netLayer, platform)
|
_dlLayerSecondary(_deviceObj, _netLayer.getEntity(1), platform)
|
||||||
#ifdef USE_CEMI_SERVER
|
#ifdef USE_CEMI_SERVER
|
||||||
,
|
,
|
||||||
_cemiServer(*this)
|
_cemiServer(*this)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
_netLayer.dataLinkLayer(_dlLayerSecondary);
|
_netLayer.getEntity(0).dataLinkLayer(_dlLayerPrimary);
|
||||||
|
_netLayer.getEntity(1).dataLinkLayer(_dlLayerSecondary);
|
||||||
#ifdef USE_CEMI_SERVER
|
#ifdef USE_CEMI_SERVER
|
||||||
_cemiServer.dataLinkLayer(_dlLayerSecondary); // Secondary I/F is the important one!
|
_cemiServer.dataLinkLayer(_dlLayerSecondary); // Secondary I/F is the important one!
|
||||||
_dlLayer.cemiServer(_cemiServer);
|
_dlLayer.cemiServer(_cemiServer);
|
||||||
|
@ -8,12 +8,12 @@ using namespace std;
|
|||||||
|
|
||||||
Bau27B0::Bau27B0(Platform& platform)
|
Bau27B0::Bau27B0(Platform& platform)
|
||||||
: BauSystemBDevice(platform),
|
: BauSystemBDevice(platform),
|
||||||
_dlLayer(_deviceObj, _rfMediumObj, _netLayer, _platform)
|
_dlLayer(_deviceObj, _rfMediumObj, _netLayer.getEntity(0), _platform)
|
||||||
#ifdef USE_CEMI_SERVER
|
#ifdef USE_CEMI_SERVER
|
||||||
, _cemiServer(*this)
|
, _cemiServer(*this)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
_netLayer.dataLinkLayer(_dlLayer);
|
_netLayer.getEntity(0).dataLinkLayer(_dlLayer);
|
||||||
_memory.addSaveRestore(&_rfMediumObj);
|
_memory.addSaveRestore(&_rfMediumObj);
|
||||||
#ifdef USE_CEMI_SERVER
|
#ifdef USE_CEMI_SERVER
|
||||||
_cemiServer.dataLinkLayer(_dlLayer);
|
_cemiServer.dataLinkLayer(_dlLayer);
|
||||||
|
@ -11,13 +11,13 @@ using namespace std;
|
|||||||
Bau57B0::Bau57B0(Platform& platform)
|
Bau57B0::Bau57B0(Platform& platform)
|
||||||
: BauSystemBDevice(platform),
|
: BauSystemBDevice(platform),
|
||||||
_ipParameters(_deviceObj, platform),
|
_ipParameters(_deviceObj, platform),
|
||||||
_dlLayer(_deviceObj, _ipParameters, _netLayer, _platform)
|
_dlLayer(_deviceObj, _ipParameters, _netLayer.getEntity(0), _platform)
|
||||||
#ifdef USE_CEMI_SERVER
|
#ifdef USE_CEMI_SERVER
|
||||||
,
|
,
|
||||||
_cemiServer(*this)
|
_cemiServer(*this)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
_netLayer.dataLinkLayer(_dlLayer);
|
_netLayer.getEntity(0).dataLinkLayer(_dlLayer);
|
||||||
#ifdef USE_CEMI_SERVER
|
#ifdef USE_CEMI_SERVER
|
||||||
_cemiServer.dataLinkLayer(_dlLayer);
|
_cemiServer.dataLinkLayer(_dlLayer);
|
||||||
_dlLayer.cemiServer(_cemiServer);
|
_dlLayer.cemiServer(_cemiServer);
|
||||||
|
@ -41,18 +41,6 @@ DeviceObject& BauSystemB::deviceObject()
|
|||||||
return _deviceObj;
|
return _deviceObj;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BauSystemB::configured()
|
|
||||||
{
|
|
||||||
// _configured is set to true initially, if the device was configured with ETS it will be set to true after restart
|
|
||||||
|
|
||||||
if (!_configured)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
_configured = _appProgram.loadState() == LS_LOADED;
|
|
||||||
|
|
||||||
return _configured;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t BauSystemB::checkmasterResetValidity(EraseCode eraseCode, uint8_t channel)
|
uint8_t BauSystemB::checkmasterResetValidity(EraseCode eraseCode, uint8_t channel)
|
||||||
{
|
{
|
||||||
static constexpr uint8_t successCode = 0x00; // Where does this come from? It is the code for "success".
|
static constexpr uint8_t successCode = 0x00; // Where does this come from? It is the code for "success".
|
||||||
|
@ -17,15 +17,18 @@ class BauSystemB : protected BusAccessUnit
|
|||||||
public:
|
public:
|
||||||
BauSystemB(Platform& platform);
|
BauSystemB(Platform& platform);
|
||||||
virtual void loop() = 0;
|
virtual void loop() = 0;
|
||||||
ApplicationProgramObject& parameters();
|
virtual bool configured() = 0;
|
||||||
DeviceObject& deviceObject();
|
|
||||||
Memory& memory();
|
|
||||||
bool configured();
|
|
||||||
virtual bool enabled() = 0;
|
virtual bool enabled() = 0;
|
||||||
virtual void enabled(bool value) = 0;
|
virtual void enabled(bool value) = 0;
|
||||||
|
|
||||||
|
ApplicationProgramObject& parameters();
|
||||||
|
DeviceObject& deviceObject();
|
||||||
|
|
||||||
|
Memory& memory();
|
||||||
void readMemory();
|
void readMemory();
|
||||||
void writeMemory();
|
void writeMemory();
|
||||||
void addSaveRestore(SaveRestore* obj);
|
void addSaveRestore(SaveRestore* obj);
|
||||||
|
|
||||||
bool restartRequest(uint16_t asap, const SecurityControl secCtrl);
|
bool restartRequest(uint16_t asap, const SecurityControl secCtrl);
|
||||||
uint8_t checkmasterResetValidity(EraseCode eraseCode, uint8_t channel);
|
uint8_t checkmasterResetValidity(EraseCode eraseCode, uint8_t channel);
|
||||||
|
|
||||||
@ -38,6 +41,8 @@ class BauSystemB : protected BusAccessUnit
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual ApplicationLayer& applicationLayer() = 0;
|
virtual ApplicationLayer& applicationLayer() = 0;
|
||||||
|
virtual InterfaceObject* getInterfaceObject(uint8_t idx) = 0;
|
||||||
|
virtual InterfaceObject* getInterfaceObject(ObjectType objectType, uint8_t objectInstance) = 0;
|
||||||
|
|
||||||
void memoryWriteIndication(Priority priority, HopCountType hopType, uint16_t asap, const SecurityControl &secCtrl, uint8_t number,
|
void memoryWriteIndication(Priority priority, HopCountType hopType, uint16_t asap, const SecurityControl &secCtrl, uint8_t number,
|
||||||
uint16_t memoryAddress, uint8_t* data) override;
|
uint16_t memoryAddress, uint8_t* data) override;
|
||||||
@ -82,10 +87,7 @@ class BauSystemB : protected BusAccessUnit
|
|||||||
uint16_t propertyId, uint8_t* testInfo, uint16_t testInfoLength, bool status) override;
|
uint16_t propertyId, uint8_t* testInfo, uint16_t testInfoLength, bool status) override;
|
||||||
void connectConfirm(uint16_t tsap) override;
|
void connectConfirm(uint16_t tsap) override;
|
||||||
|
|
||||||
virtual InterfaceObject* getInterfaceObject(uint8_t idx) = 0;
|
|
||||||
virtual InterfaceObject* getInterfaceObject(ObjectType objectType, uint8_t objectInstance) = 0;
|
|
||||||
void nextRestartState();
|
void nextRestartState();
|
||||||
|
|
||||||
virtual void doMasterReset(EraseCode eraseCode, uint8_t channel);
|
virtual void doMasterReset(EraseCode eraseCode, uint8_t channel);
|
||||||
|
|
||||||
enum RestartState
|
enum RestartState
|
||||||
@ -100,7 +102,6 @@ class BauSystemB : protected BusAccessUnit
|
|||||||
DeviceObject _deviceObj;
|
DeviceObject _deviceObj;
|
||||||
ApplicationProgramObject _appProgram;
|
ApplicationProgramObject _appProgram;
|
||||||
Platform& _platform;
|
Platform& _platform;
|
||||||
bool _configured = true;
|
|
||||||
RestartState _restartState = Idle;
|
RestartState _restartState = Idle;
|
||||||
SecurityControl _restartSecurity;
|
SecurityControl _restartSecurity;
|
||||||
uint32_t _restartDelay = 0;
|
uint32_t _restartDelay = 0;
|
||||||
|
@ -44,6 +44,9 @@ bool BauSystemBCoupler::configured()
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
_configured = _appProgram.loadState() == LS_LOADED;
|
_configured = _appProgram.loadState() == LS_LOADED;
|
||||||
|
#ifdef USE_DATASECURE
|
||||||
|
_configured &= _secIfObj.loadState() == LS_LOADED;
|
||||||
|
#endif
|
||||||
|
|
||||||
return _configured;
|
return _configured;
|
||||||
}
|
}
|
||||||
|
@ -20,22 +20,14 @@ class BauSystemBCoupler : public BauSystemB
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
BauSystemBCoupler(Platform& platform);
|
BauSystemBCoupler(Platform& platform);
|
||||||
virtual void loop();
|
virtual void loop() override;
|
||||||
bool configured();
|
virtual bool configured() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual ApplicationLayer& applicationLayer() override;
|
virtual ApplicationLayer& applicationLayer() override;
|
||||||
|
|
||||||
virtual void doMasterReset(EraseCode eraseCode, uint8_t channel) override;
|
virtual void doMasterReset(EraseCode eraseCode, uint8_t channel) override;
|
||||||
|
|
||||||
enum RestartState
|
|
||||||
{
|
|
||||||
Idle,
|
|
||||||
Connecting,
|
|
||||||
Connected,
|
|
||||||
Restarted
|
|
||||||
};
|
|
||||||
|
|
||||||
Platform& _platform;
|
Platform& _platform;
|
||||||
#ifdef USE_DATASECURE
|
#ifdef USE_DATASECURE
|
||||||
SecureApplicationLayer _appLayer;
|
SecureApplicationLayer _appLayer;
|
||||||
@ -46,7 +38,4 @@ class BauSystemBCoupler : public BauSystemB
|
|||||||
TransportLayer _transLayer;
|
TransportLayer _transLayer;
|
||||||
NetworkLayer _netLayer;
|
NetworkLayer _netLayer;
|
||||||
bool _configured = true;
|
bool _configured = true;
|
||||||
RestartState _restartState = Idle;
|
|
||||||
SecurityControl _restartSecurity;
|
|
||||||
uint32_t _restartDelay = 0;
|
|
||||||
};
|
};
|
||||||
|
@ -112,11 +112,6 @@ void BauSystemBDevice::updateGroupObject(GroupObject & go, uint8_t * data, uint8
|
|||||||
handler(go);
|
handler(go);
|
||||||
}
|
}
|
||||||
|
|
||||||
GroupObjectTableObject& BauSystemBDevice::groupObjectTable()
|
|
||||||
{
|
|
||||||
return _groupObjTable;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool BauSystemBDevice::configured()
|
bool BauSystemBDevice::configured()
|
||||||
{
|
{
|
||||||
// _configured is set to true initially, if the device was configured with ETS it will be set to true after restart
|
// _configured is set to true initially, if the device was configured with ETS it will be set to true after restart
|
||||||
@ -129,6 +124,10 @@ bool BauSystemBDevice::configured()
|
|||||||
&& _assocTable.loadState() == LS_LOADED
|
&& _assocTable.loadState() == LS_LOADED
|
||||||
&& _appProgram.loadState() == LS_LOADED;
|
&& _appProgram.loadState() == LS_LOADED;
|
||||||
|
|
||||||
|
#ifdef USE_DATASECURE
|
||||||
|
_configured &= _secIfObj.loadState() == LS_LOADED;
|
||||||
|
#endif
|
||||||
|
|
||||||
return _configured;
|
return _configured;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,9 +20,8 @@ class BauSystemBDevice : public BauSystemB
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
BauSystemBDevice(Platform& platform);
|
BauSystemBDevice(Platform& platform);
|
||||||
virtual void loop();
|
virtual void loop() override;
|
||||||
GroupObjectTableObject& groupObjectTable();
|
virtual bool configured() override;
|
||||||
bool configured();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual ApplicationLayer& applicationLayer() override;
|
virtual ApplicationLayer& applicationLayer() override;
|
||||||
@ -52,4 +51,6 @@ class BauSystemBDevice : public BauSystemB
|
|||||||
#endif
|
#endif
|
||||||
TransportLayer _transLayer;
|
TransportLayer _transLayer;
|
||||||
NetworkLayer _netLayer;
|
NetworkLayer _netLayer;
|
||||||
|
|
||||||
|
bool _configured = true;
|
||||||
};
|
};
|
||||||
|
@ -5,9 +5,10 @@
|
|||||||
#include "device_object.h"
|
#include "device_object.h"
|
||||||
#include "address_table_object.h"
|
#include "address_table_object.h"
|
||||||
#include "cemi_server.h"
|
#include "cemi_server.h"
|
||||||
|
#include "cemi_frame.h"
|
||||||
|
|
||||||
DataLinkLayer::DataLinkLayer(DeviceObject& devObj, NetworkLayer& layer, Platform& platform) :
|
DataLinkLayer::DataLinkLayer(DeviceObject& devObj, NetworkLayerEntity& netLayerEntity, Platform& platform) :
|
||||||
_deviceObject(devObj), _networkLayer(layer), _platform(platform)
|
_deviceObject(devObj), _networkLayerEntity(netLayerEntity), _platform(platform)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,11 +74,11 @@ void DataLinkLayer::dataConReceived(CemiFrame& frame, bool success)
|
|||||||
|
|
||||||
if (addrType == GroupAddress && destination == 0)
|
if (addrType == GroupAddress && destination == 0)
|
||||||
if (systemBroadcast == SysBroadcast)
|
if (systemBroadcast == SysBroadcast)
|
||||||
_networkLayer.systemBroadcastConfirm(ack, type, priority, source, npdu, success);
|
_networkLayerEntity.systemBroadcastConfirm(ack, type, priority, source, npdu, success);
|
||||||
else
|
else
|
||||||
_networkLayer.broadcastConfirm(ack, type, priority, source, npdu, success);
|
_networkLayerEntity.broadcastConfirm(ack, type, priority, source, npdu, success);
|
||||||
else
|
else
|
||||||
_networkLayer.dataConfirm(ack, addrType, destination, type, priority, source, npdu, success);
|
_networkLayerEntity.dataConfirm(ack, addrType, destination, type, priority, source, npdu, success);
|
||||||
|
|
||||||
frame.messageCode(backupMsgCode);
|
frame.messageCode(backupMsgCode);
|
||||||
}
|
}
|
||||||
@ -108,13 +109,13 @@ void DataLinkLayer::frameRecieved(CemiFrame& frame)
|
|||||||
if (addrType == GroupAddress && destination == 0)
|
if (addrType == GroupAddress && destination == 0)
|
||||||
{
|
{
|
||||||
if (systemBroadcast == SysBroadcast)
|
if (systemBroadcast == SysBroadcast)
|
||||||
_networkLayer.systemBroadcastIndication(ack, type, npdu, priority, source);
|
_networkLayerEntity.systemBroadcastIndication(ack, type, npdu, priority, source);
|
||||||
else
|
else
|
||||||
_networkLayer.broadcastIndication(ack, type, npdu, priority, source);
|
_networkLayerEntity.broadcastIndication(ack, type, npdu, priority, source);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_networkLayer.dataIndication(ack, addrType, destination, type, npdu, priority, source);
|
_networkLayerEntity.dataIndication(ack, addrType, destination, type, npdu, priority, source);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,13 +5,15 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include "device_object.h"
|
#include "device_object.h"
|
||||||
#include "knx_types.h"
|
#include "knx_types.h"
|
||||||
#include "network_layer.h"
|
#include "network_layer_entity.h"
|
||||||
#include "cemi_server.h"
|
#include "cemi_server.h"
|
||||||
|
|
||||||
|
class Platform;
|
||||||
|
|
||||||
class DataLinkLayer
|
class DataLinkLayer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DataLinkLayer(DeviceObject& devObj, NetworkLayer& layer,
|
DataLinkLayer(DeviceObject& devObj, NetworkLayerEntity& netLayerEntity,
|
||||||
Platform& platform);
|
Platform& platform);
|
||||||
|
|
||||||
#ifdef USE_CEMI_SERVER
|
#ifdef USE_CEMI_SERVER
|
||||||
@ -35,7 +37,7 @@ class DataLinkLayer
|
|||||||
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;
|
||||||
NetworkLayer& _networkLayer;
|
NetworkLayerEntity& _networkLayerEntity;
|
||||||
Platform& _platform;
|
Platform& _platform;
|
||||||
#ifdef USE_CEMI_SERVER
|
#ifdef USE_CEMI_SERVER
|
||||||
CemiServer* _cemiServer;
|
CemiServer* _cemiServer;
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
#define MIN_LEN_CEMI 10
|
#define MIN_LEN_CEMI 10
|
||||||
|
|
||||||
IpDataLinkLayer::IpDataLinkLayer(DeviceObject& devObj, IpParameterObject& ipParam,
|
IpDataLinkLayer::IpDataLinkLayer(DeviceObject& devObj, IpParameterObject& ipParam,
|
||||||
NetworkLayer& layer, Platform& platform) : DataLinkLayer(devObj, layer, platform), _ipParameters(ipParam)
|
NetworkLayerEntity &netLayerEntity, Platform& platform) : DataLinkLayer(devObj, netLayerEntity, platform), _ipParameters(ipParam)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ class IpDataLinkLayer : public DataLinkLayer
|
|||||||
using DataLinkLayer::_deviceObject;
|
using DataLinkLayer::_deviceObject;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IpDataLinkLayer(DeviceObject& devObj, IpParameterObject& ipParam, NetworkLayer& layer,
|
IpDataLinkLayer(DeviceObject& devObj, IpParameterObject& ipParam, NetworkLayerEntity& netLayerEntity,
|
||||||
Platform& platform);
|
Platform& platform);
|
||||||
|
|
||||||
void loop();
|
void loop();
|
||||||
|
@ -1,17 +1,19 @@
|
|||||||
#include "network_layer.h"
|
#include "network_layer.h"
|
||||||
|
#include "device_object.h"
|
||||||
#include "tpdu.h"
|
#include "tpdu.h"
|
||||||
#include "cemi_frame.h"
|
#include "cemi_frame.h"
|
||||||
#include "data_link_layer.h"
|
|
||||||
#include "bits.h"
|
#include "bits.h"
|
||||||
|
|
||||||
NetworkLayer::NetworkLayer(DeviceObject &deviceObj, TransportLayer& layer): _transportLayer(layer), _deviceObj(deviceObj)
|
NetworkLayer::NetworkLayer(DeviceObject &deviceObj, TransportLayer& layer) :
|
||||||
|
_netLayerEntities {*this, *this},
|
||||||
|
_transportLayer(layer),
|
||||||
|
_deviceObj(deviceObj)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetworkLayer::dataLinkLayer(DataLinkLayer& layer)
|
NetworkLayerEntity& NetworkLayer::getEntity(uint8_t num)
|
||||||
{
|
{
|
||||||
_dataLinkLayer = &layer;
|
return _netLayerEntities[num];
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t NetworkLayer::hopCount() const
|
uint8_t NetworkLayer::hopCount() const
|
||||||
@ -106,15 +108,22 @@ void NetworkLayer::systemBroadcastConfirm(AckType ack, FrameFormat format, Prior
|
|||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
|
NPDU& npdu = tpdu.frame().npdu();
|
||||||
|
|
||||||
|
if (hopType == UnlimitedRouting)
|
||||||
|
npdu.hopCount(7);
|
||||||
|
else
|
||||||
|
npdu.hopCount(_hopCount);
|
||||||
|
|
||||||
//if (tpdu.apdu().length() > 0)
|
//if (tpdu.apdu().length() > 0)
|
||||||
//{
|
//{
|
||||||
// print.print("-> NL ");
|
// print.print("-> NL ");
|
||||||
// tpdu.apdu().printPDU();
|
// tpdu.apdu().printPDU();
|
||||||
//}
|
//}
|
||||||
sendDataRequest(tpdu, hopType, ack, destination, priority, InduvidualAddress);
|
_netLayerEntities[0].sendDataRequest(npdu, ack, destination, priority, InduvidualAddress, Broadcast);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetworkLayer::sendDataRequest(TPDU &tpdu, HopCountType hopType, AckType ack, uint16_t destination, Priority priority, AddressType addrType)
|
void NetworkLayer::dataGroupRequest(AckType ack, uint16_t destination, HopCountType hopType, Priority priority, TPDU& tpdu)
|
||||||
{
|
{
|
||||||
NPDU& npdu = tpdu.frame().npdu();
|
NPDU& npdu = tpdu.frame().npdu();
|
||||||
|
|
||||||
@ -123,19 +132,19 @@ void NetworkLayer::sendDataRequest(TPDU &tpdu, HopCountType hopType, AckType ack
|
|||||||
else
|
else
|
||||||
npdu.hopCount(_hopCount);
|
npdu.hopCount(_hopCount);
|
||||||
|
|
||||||
FrameFormat frameFormat = npdu.octetCount() > 15 ? ExtendedFrame : StandardFrame;
|
_netLayerEntities[0].sendDataRequest(npdu, ack, destination, priority, GroupAddress, Broadcast);
|
||||||
|
|
||||||
_dataLinkLayer->dataRequest(ack, addrType, destination, frameFormat, priority, npdu);
|
|
||||||
}
|
|
||||||
|
|
||||||
void NetworkLayer::dataGroupRequest(AckType ack, uint16_t destination, HopCountType hopType, Priority priority, TPDU& tpdu)
|
|
||||||
{
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
sendDataRequest(tpdu, hopType, ack, 0, priority, GroupAddress);
|
NPDU& npdu = tpdu.frame().npdu();
|
||||||
|
|
||||||
|
if (hopType == UnlimitedRouting)
|
||||||
|
npdu.hopCount(7);
|
||||||
|
else
|
||||||
|
npdu.hopCount(_hopCount);
|
||||||
|
|
||||||
|
_netLayerEntities[0].sendDataRequest(npdu, ack, 0, priority, GroupAddress, Broadcast);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetworkLayer::dataSystemBroadcastRequest(AckType ack, HopCountType hopType, Priority priority, TPDU& tpdu)
|
void NetworkLayer::dataSystemBroadcastRequest(AckType ack, HopCountType hopType, Priority priority, TPDU& tpdu)
|
||||||
@ -147,7 +156,5 @@ void NetworkLayer::dataSystemBroadcastRequest(AckType ack, HopCountType hopType,
|
|||||||
else
|
else
|
||||||
npdu.hopCount(_hopCount);
|
npdu.hopCount(_hopCount);
|
||||||
|
|
||||||
FrameFormat frameFormat = npdu.octetCount() > 15 ? ExtendedFrame : StandardFrame;
|
_netLayerEntities[0].sendDataRequest(npdu, ack, 0, priority, GroupAddress, SysBroadcast);
|
||||||
|
|
||||||
_dataLinkLayer->systemBroadcastRequest(ack, frameFormat, priority, npdu);
|
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,8 @@
|
|||||||
#include "knx_types.h"
|
#include "knx_types.h"
|
||||||
#include "npdu.h"
|
#include "npdu.h"
|
||||||
#include "transport_layer.h"
|
#include "transport_layer.h"
|
||||||
class DataLinkLayer;
|
#include "network_layer_entity.h"
|
||||||
|
|
||||||
class DeviceObject;
|
class DeviceObject;
|
||||||
|
|
||||||
class NetworkLayer
|
class NetworkLayer
|
||||||
@ -12,11 +13,17 @@ class NetworkLayer
|
|||||||
public:
|
public:
|
||||||
NetworkLayer(DeviceObject& deviceObj, TransportLayer& layer);
|
NetworkLayer(DeviceObject& deviceObj, TransportLayer& layer);
|
||||||
|
|
||||||
void dataLinkLayer(DataLinkLayer& layer);
|
NetworkLayerEntity& getEntity(uint8_t num);
|
||||||
uint8_t hopCount() const;
|
uint8_t hopCount() const;
|
||||||
void hopCount(uint8_t value);
|
void hopCount(uint8_t value);
|
||||||
|
|
||||||
// from data link layer
|
// from transport layer
|
||||||
|
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 dataBroadcastRequest(AckType ack, HopCountType hopType, Priority priority, TPDU& tpdu);
|
||||||
|
void dataSystemBroadcastRequest(AckType ack, HopCountType hopType, Priority priority, TPDU& tpdu);
|
||||||
|
|
||||||
|
// from entities
|
||||||
void dataIndication(AckType ack, AddressType addType, uint16_t destination, FrameFormat format, NPDU& npdu,
|
void dataIndication(AckType ack, AddressType addType, uint16_t destination, FrameFormat format, NPDU& npdu,
|
||||||
Priority priority, uint16_t source);
|
Priority priority, uint16_t source);
|
||||||
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,
|
||||||
@ -28,17 +35,11 @@ class NetworkLayer
|
|||||||
Priority priority, uint16_t source);
|
Priority priority, uint16_t source);
|
||||||
void systemBroadcastConfirm(AckType ack, FrameFormat format, Priority priority, uint16_t source, NPDU& npdu, bool status);
|
void systemBroadcastConfirm(AckType ack, FrameFormat format, Priority priority, uint16_t source, NPDU& npdu, bool status);
|
||||||
|
|
||||||
// from transport layer
|
|
||||||
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 dataBroadcastRequest(AckType ack, HopCountType hopType, Priority priority, TPDU& tpdu);
|
|
||||||
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);
|
|
||||||
uint8_t _hopCount = 6;
|
uint8_t _hopCount = 6;
|
||||||
DataLinkLayer* _dataLinkLayer = 0;
|
|
||||||
|
NetworkLayerEntity _netLayerEntities[2];
|
||||||
|
|
||||||
TransportLayer& _transportLayer;
|
TransportLayer& _transportLayer;
|
||||||
DeviceObject& _deviceObj;
|
DeviceObject& _deviceObj;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
55
src/knx/network_layer_entity.cpp
Normal file
55
src/knx/network_layer_entity.cpp
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
#include "network_layer.h"
|
||||||
|
#include "network_layer_entity.h"
|
||||||
|
#include "tpdu.h"
|
||||||
|
#include "cemi_frame.h"
|
||||||
|
#include "data_link_layer.h"
|
||||||
|
#include "bits.h"
|
||||||
|
|
||||||
|
NetworkLayerEntity::NetworkLayerEntity(NetworkLayer &netLayer) : _netLayer(netLayer)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void NetworkLayerEntity::dataLinkLayer(DataLinkLayer& layer)
|
||||||
|
{
|
||||||
|
_dataLinkLayer = &layer;
|
||||||
|
}
|
||||||
|
|
||||||
|
void NetworkLayerEntity::dataIndication(AckType ack, AddressType addrType, uint16_t destination, FrameFormat format, NPDU& npdu, Priority priority, uint16_t source)
|
||||||
|
{
|
||||||
|
_netLayer.dataIndication(ack, addrType, destination, format, npdu, priority, source);
|
||||||
|
}
|
||||||
|
|
||||||
|
void NetworkLayerEntity::dataConfirm(AckType ack, AddressType addressType, uint16_t destination, FrameFormat format, Priority priority, uint16_t source, NPDU& npdu, bool status)
|
||||||
|
{
|
||||||
|
_netLayer.dataConfirm(ack, addressType, destination, format, priority, source, npdu, status);
|
||||||
|
}
|
||||||
|
|
||||||
|
void NetworkLayerEntity::broadcastIndication(AckType ack, FrameFormat format, NPDU& npdu, Priority priority, uint16_t source)
|
||||||
|
{
|
||||||
|
_netLayer.broadcastIndication(ack, format, npdu, priority, source);
|
||||||
|
}
|
||||||
|
|
||||||
|
void NetworkLayerEntity::broadcastConfirm(AckType ack, FrameFormat format, Priority priority, uint16_t source, NPDU& npdu, bool status)
|
||||||
|
{
|
||||||
|
_netLayer.broadcastConfirm(ack, format, priority, source, npdu, status);
|
||||||
|
}
|
||||||
|
|
||||||
|
void NetworkLayerEntity::systemBroadcastIndication(AckType ack, FrameFormat format, NPDU& npdu, Priority priority, uint16_t source)
|
||||||
|
{
|
||||||
|
_netLayer.systemBroadcastIndication(ack, format, npdu, priority, source);
|
||||||
|
}
|
||||||
|
|
||||||
|
void NetworkLayerEntity::systemBroadcastConfirm(AckType ack, FrameFormat format, Priority priority, uint16_t source, NPDU& npdu, bool status)
|
||||||
|
{
|
||||||
|
_netLayer.systemBroadcastConfirm(ack, format, priority, source, npdu, status);
|
||||||
|
}
|
||||||
|
|
||||||
|
void NetworkLayerEntity::sendDataRequest(NPDU &npdu, AckType ack, uint16_t destination, Priority priority, AddressType addrType, SystemBroadcast systemBroadcast)
|
||||||
|
{
|
||||||
|
FrameFormat frameFormat = npdu.octetCount() > 15 ? ExtendedFrame : StandardFrame;
|
||||||
|
|
||||||
|
if (systemBroadcast == Broadcast)
|
||||||
|
_dataLinkLayer->dataRequest(ack, addrType, destination, frameFormat, priority, npdu);
|
||||||
|
else
|
||||||
|
_dataLinkLayer->systemBroadcastRequest(ack, frameFormat, priority, npdu);
|
||||||
|
}
|
38
src/knx/network_layer_entity.h
Normal file
38
src/knx/network_layer_entity.h
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include "knx_types.h"
|
||||||
|
#include "npdu.h"
|
||||||
|
|
||||||
|
class DataLinkLayer;
|
||||||
|
class NetworkLayer;
|
||||||
|
|
||||||
|
class NetworkLayerEntity
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
NetworkLayerEntity(NetworkLayer &netLayer);
|
||||||
|
|
||||||
|
void dataLinkLayer(DataLinkLayer& layer);
|
||||||
|
|
||||||
|
// From network layer
|
||||||
|
/*
|
||||||
|
void dataSystemBroadcastRequest(AckType ack, HopCountType hopType, Priority priority, TPDU& tpdu);
|
||||||
|
*/
|
||||||
|
void sendDataRequest(NPDU& npdu, AckType ack, uint16_t destination, Priority priority, AddressType addrType, SystemBroadcast systemBroadcast);
|
||||||
|
|
||||||
|
// from data link layer
|
||||||
|
void dataIndication(AckType ack, AddressType addType, uint16_t destination, FrameFormat format, NPDU& npdu,
|
||||||
|
Priority priority, uint16_t source);
|
||||||
|
void dataConfirm(AckType ack, AddressType addressType, uint16_t destination, FrameFormat format, Priority priority,
|
||||||
|
uint16_t source, NPDU& npdu, bool status);
|
||||||
|
void broadcastIndication(AckType ack, FrameFormat format, NPDU& npdu,
|
||||||
|
Priority priority, uint16_t source);
|
||||||
|
void broadcastConfirm(AckType ack, FrameFormat format, Priority priority, uint16_t source, NPDU& npdu, bool status);
|
||||||
|
void systemBroadcastIndication(AckType ack, FrameFormat format, NPDU& npdu,
|
||||||
|
Priority priority, uint16_t source);
|
||||||
|
void systemBroadcastConfirm(AckType ack, FrameFormat format, Priority priority, uint16_t source, NPDU& npdu, bool status);
|
||||||
|
|
||||||
|
private:
|
||||||
|
DataLinkLayer* _dataLinkLayer = 0;
|
||||||
|
NetworkLayer& _netLayer;
|
||||||
|
};
|
@ -74,8 +74,8 @@ bool RfDataLinkLayer::sendFrame(CemiFrame& frame)
|
|||||||
}
|
}
|
||||||
|
|
||||||
RfDataLinkLayer::RfDataLinkLayer(DeviceObject& devObj, RfMediumObject& rfMediumObj,
|
RfDataLinkLayer::RfDataLinkLayer(DeviceObject& devObj, RfMediumObject& rfMediumObj,
|
||||||
NetworkLayer& layer, Platform& platform)
|
NetworkLayerEntity &netLayerEntity, Platform& platform)
|
||||||
: DataLinkLayer(devObj, layer, platform),
|
: DataLinkLayer(devObj, netLayerEntity, platform),
|
||||||
_rfMediumObj(rfMediumObj),
|
_rfMediumObj(rfMediumObj),
|
||||||
_rfPhy(*this, platform)
|
_rfPhy(*this, platform)
|
||||||
{
|
{
|
||||||
|
@ -19,7 +19,7 @@ class RfDataLinkLayer : public DataLinkLayer
|
|||||||
using DataLinkLayer::_platform;
|
using DataLinkLayer::_platform;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
RfDataLinkLayer(DeviceObject& devObj, RfMediumObject& rfMediumObj, NetworkLayer& layer,
|
RfDataLinkLayer(DeviceObject& devObj, RfMediumObject& rfMediumObj, NetworkLayerEntity& netLayerEntity,
|
||||||
Platform& platform);
|
Platform& platform);
|
||||||
|
|
||||||
void loop();
|
void loop();
|
||||||
|
@ -224,6 +224,11 @@ bool SecurityInterfaceObject::isLoaded()
|
|||||||
return _state == LS_LOADED;
|
return _state == LS_LOADED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LoadState SecurityInterfaceObject::loadState()
|
||||||
|
{
|
||||||
|
return _state;
|
||||||
|
}
|
||||||
|
|
||||||
void SecurityInterfaceObject::loadEvent(const uint8_t* data)
|
void SecurityInterfaceObject::loadEvent(const uint8_t* data)
|
||||||
{
|
{
|
||||||
switch (_state)
|
switch (_state)
|
||||||
|
@ -429,8 +429,8 @@ void TpUartDataLinkLayer::stopChip()
|
|||||||
}
|
}
|
||||||
|
|
||||||
TpUartDataLinkLayer::TpUartDataLinkLayer(DeviceObject& devObj,
|
TpUartDataLinkLayer::TpUartDataLinkLayer(DeviceObject& devObj,
|
||||||
NetworkLayer& layer, Platform& platform)
|
NetworkLayerEntity &netLayerEntity, Platform& platform)
|
||||||
: DataLinkLayer(devObj, layer, platform)
|
: DataLinkLayer(devObj, netLayerEntity, platform)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,16 +8,17 @@
|
|||||||
|
|
||||||
#define MAX_KNX_TELEGRAM_SIZE 263
|
#define MAX_KNX_TELEGRAM_SIZE 263
|
||||||
|
|
||||||
|
class AddressTableObject;
|
||||||
|
|
||||||
class TpUartDataLinkLayer : public DataLinkLayer
|
class TpUartDataLinkLayer : public DataLinkLayer
|
||||||
{
|
{
|
||||||
using DataLinkLayer::_deviceObject;
|
using DataLinkLayer::_deviceObject;
|
||||||
using DataLinkLayer::_platform;
|
using DataLinkLayer::_platform;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TpUartDataLinkLayer(DeviceObject& devObj, NetworkLayer& layer,
|
TpUartDataLinkLayer(DeviceObject& devObj, NetworkLayerEntity& netLayerEntity,
|
||||||
Platform& platform);
|
Platform& platform);
|
||||||
|
|
||||||
;
|
|
||||||
void groupAddressTable(AddressTableObject& addrTable);
|
void groupAddressTable(AddressTableObject& addrTable);
|
||||||
|
|
||||||
void loop();
|
void loop();
|
||||||
|
Loading…
Reference in New Issue
Block a user