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