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
2d0b0d05e5
commit
d17fe1003b
@ -83,8 +83,12 @@ add_executable(knx-linux
|
||||
../../src/knx/knx_value.h
|
||||
../../src/knx/memory.cpp
|
||||
../../src/knx/memory.h
|
||||
../../src/knx/network_layer.cpp
|
||||
../../src/knx/network_layer.h
|
||||
../../src/knx/network_layer.cpp
|
||||
../../src/knx/network_layer.h
|
||||
../../src/knx/network_layer_coupler.cpp
|
||||
../../src/knx/network_layer_coupler.h
|
||||
../../src/knx/network_layer_device.cpp
|
||||
../../src/knx/network_layer_device.h
|
||||
../../src/knx/network_layer_entity.cpp
|
||||
../../src/knx/network_layer_entity.h
|
||||
../../src/knx/npdu.cpp
|
||||
|
@ -11,7 +11,7 @@
|
||||
#include "application_layer.h"
|
||||
#include "secure_application_layer.h"
|
||||
#include "transport_layer.h"
|
||||
#include "network_layer.h"
|
||||
#include "network_layer_coupler.h"
|
||||
#include "data_link_layer.h"
|
||||
#include "platform.h"
|
||||
#include "memory.h"
|
||||
@ -36,6 +36,6 @@ class BauSystemBCoupler : public BauSystemB
|
||||
ApplicationLayer _appLayer;
|
||||
#endif
|
||||
TransportLayer _transLayer;
|
||||
NetworkLayer _netLayer;
|
||||
NetworkLayerCoupler _netLayer;
|
||||
bool _configured = true;
|
||||
};
|
||||
|
@ -11,7 +11,7 @@
|
||||
#include "application_layer.h"
|
||||
#include "secure_application_layer.h"
|
||||
#include "transport_layer.h"
|
||||
#include "network_layer.h"
|
||||
#include "network_layer_device.h"
|
||||
#include "data_link_layer.h"
|
||||
#include "platform.h"
|
||||
#include "memory.h"
|
||||
@ -50,7 +50,7 @@ class BauSystemBDevice : public BauSystemB
|
||||
ApplicationLayer _appLayer;
|
||||
#endif
|
||||
TransportLayer _transLayer;
|
||||
NetworkLayer _netLayer;
|
||||
NetworkLayerDevice _netLayer;
|
||||
|
||||
bool _configured = true;
|
||||
};
|
||||
|
@ -1,46 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include "knx_types.h"
|
||||
#include "npdu.h"
|
||||
#include "transport_layer.h"
|
||||
#include "network_layer_entity.h"
|
||||
|
||||
class DeviceObject;
|
||||
|
||||
class NetworkLayer
|
||||
{
|
||||
public:
|
||||
NetworkLayer(DeviceObject& deviceObj, TransportLayer& layer);
|
||||
|
||||
NetworkLayerEntity& getEntity(uint8_t num);
|
||||
uint8_t hopCount() const;
|
||||
void hopCount(uint8_t value);
|
||||
|
||||
// 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,
|
||||
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:
|
||||
uint8_t _hopCount = 6;
|
||||
|
||||
// Support a maximum of two physical interfaces
|
||||
NetworkLayerEntity _netLayerEntities[2];
|
||||
|
||||
TransportLayer& _transportLayer;
|
||||
DeviceObject& _deviceObj;
|
||||
};
|
@ -1,32 +1,21 @@
|
||||
#include "network_layer.h"
|
||||
#include "network_layer_device.h"
|
||||
#include "device_object.h"
|
||||
#include "tpdu.h"
|
||||
#include "cemi_frame.h"
|
||||
#include "bits.h"
|
||||
|
||||
NetworkLayer::NetworkLayer(DeviceObject &deviceObj, TransportLayer& layer) :
|
||||
_netLayerEntities { {*this, 0}, {*this, 1} },
|
||||
_transportLayer(layer),
|
||||
_deviceObj(deviceObj)
|
||||
NetworkLayerDevice::NetworkLayerDevice(DeviceObject &deviceObj, TransportLayer& layer) :
|
||||
NetworkLayer(deviceObj, layer),
|
||||
_netLayerEntities { {*this, 0} }
|
||||
{
|
||||
}
|
||||
|
||||
NetworkLayerEntity& NetworkLayer::getEntity(uint8_t num)
|
||||
NetworkLayerEntity& NetworkLayerDevice::getEntity(uint8_t interfaceIndex)
|
||||
{
|
||||
return _netLayerEntities[num];
|
||||
return _netLayerEntities[interfaceIndex];
|
||||
}
|
||||
|
||||
uint8_t NetworkLayer::hopCount() const
|
||||
{
|
||||
return _hopCount;
|
||||
}
|
||||
|
||||
void NetworkLayer::hopCount(uint8_t value)
|
||||
{
|
||||
_hopCount = value & 0x7;
|
||||
}
|
||||
|
||||
void NetworkLayer::dataIndication(AckType ack, AddressType addrType, uint16_t destination, FrameFormat format, NPDU& npdu, Priority priority, uint16_t source)
|
||||
void NetworkLayerDevice::dataIndication(AckType ack, AddressType addrType, uint16_t destination, FrameFormat format, NPDU& npdu, Priority priority, uint16_t source)
|
||||
{
|
||||
HopCountType hopType = npdu.hopCount() == 7 ? UnlimitedRouting : NetworkLayerParameter;
|
||||
|
||||
@ -64,7 +53,7 @@ void NetworkLayer::dataIndication(AckType ack, AddressType addrType, uint16_t de
|
||||
_transportLayer.dataBroadcastIndication(hopType, priority, source, npdu.tpdu());
|
||||
}
|
||||
|
||||
void NetworkLayer::dataConfirm(AckType ack, AddressType addressType, uint16_t destination, FrameFormat format, Priority priority, uint16_t source, NPDU& npdu, bool status)
|
||||
void NetworkLayerDevice::dataConfirm(AckType ack, AddressType addressType, uint16_t destination, FrameFormat format, Priority priority, uint16_t source, NPDU& npdu, bool status)
|
||||
{
|
||||
HopCountType hopType = npdu.hopCount() == 7 ? UnlimitedRouting : NetworkLayerParameter;
|
||||
if (addressType == InduvidualAddress)
|
||||
@ -82,38 +71,38 @@ void NetworkLayer::dataConfirm(AckType ack, AddressType addressType, uint16_t de
|
||||
_transportLayer.dataBroadcastConfirm(ack, hopType, priority, npdu.tpdu(), status);
|
||||
}
|
||||
|
||||
void NetworkLayer::broadcastIndication(AckType ack, FrameFormat format, NPDU& npdu, Priority priority, uint16_t source)
|
||||
void NetworkLayerDevice::broadcastIndication(AckType ack, FrameFormat format, NPDU& npdu, Priority priority, uint16_t source)
|
||||
{
|
||||
HopCountType hopType = npdu.hopCount() == 7 ? UnlimitedRouting : NetworkLayerParameter;
|
||||
_transportLayer.dataBroadcastIndication(hopType, priority, source, npdu.tpdu());
|
||||
}
|
||||
|
||||
void NetworkLayer::broadcastConfirm(AckType ack, FrameFormat format, Priority priority, uint16_t source, NPDU& npdu, bool status)
|
||||
void NetworkLayerDevice::broadcastConfirm(AckType ack, FrameFormat format, Priority priority, uint16_t source, NPDU& npdu, bool status)
|
||||
{
|
||||
HopCountType hopType = npdu.hopCount() == 7 ? UnlimitedRouting : NetworkLayerParameter;
|
||||
_transportLayer.dataBroadcastConfirm(ack, hopType, priority, npdu.tpdu(), status);
|
||||
}
|
||||
|
||||
void NetworkLayer::systemBroadcastIndication(AckType ack, FrameFormat format, NPDU& npdu, Priority priority, uint16_t source)
|
||||
void NetworkLayerDevice::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)
|
||||
void NetworkLayerDevice::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 NetworkLayerDevice::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);
|
||||
npdu.hopCount(hopCount());
|
||||
|
||||
//if (tpdu.apdu().length() > 0)
|
||||
//{
|
||||
@ -123,38 +112,38 @@ void NetworkLayer::dataIndividualRequest(AckType ack, uint16_t destination, HopC
|
||||
_netLayerEntities[0].sendDataRequest(npdu, ack, destination, priority, InduvidualAddress, Broadcast);
|
||||
}
|
||||
|
||||
void NetworkLayer::dataGroupRequest(AckType ack, uint16_t destination, HopCountType hopType, Priority priority, TPDU& tpdu)
|
||||
void NetworkLayerDevice::dataGroupRequest(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);
|
||||
npdu.hopCount(hopCount());
|
||||
|
||||
_netLayerEntities[0].sendDataRequest(npdu, ack, destination, priority, GroupAddress, Broadcast);
|
||||
}
|
||||
|
||||
void NetworkLayer::dataBroadcastRequest(AckType ack, HopCountType hopType, Priority priority, TPDU& tpdu)
|
||||
void NetworkLayerDevice::dataBroadcastRequest(AckType ack, HopCountType hopType, Priority priority, TPDU& tpdu)
|
||||
{
|
||||
NPDU& npdu = tpdu.frame().npdu();
|
||||
|
||||
if (hopType == UnlimitedRouting)
|
||||
npdu.hopCount(7);
|
||||
else
|
||||
npdu.hopCount(_hopCount);
|
||||
npdu.hopCount(hopCount());
|
||||
|
||||
_netLayerEntities[0].sendDataRequest(npdu, ack, 0, priority, GroupAddress, Broadcast);
|
||||
}
|
||||
|
||||
void NetworkLayer::dataSystemBroadcastRequest(AckType ack, HopCountType hopType, Priority priority, TPDU& tpdu)
|
||||
void NetworkLayerDevice::dataSystemBroadcastRequest(AckType ack, HopCountType hopType, Priority priority, TPDU& tpdu)
|
||||
{
|
||||
NPDU& npdu = tpdu.frame().npdu();
|
||||
|
||||
if (hopType == UnlimitedRouting)
|
||||
npdu.hopCount(7);
|
||||
else
|
||||
npdu.hopCount(_hopCount);
|
||||
npdu.hopCount(hopCount());
|
||||
|
||||
_netLayerEntities[0].sendDataRequest(npdu, ack, 0, priority, GroupAddress, SysBroadcast);
|
||||
}
|
42
src/knx/network_layer_device.h
Normal file
42
src/knx/network_layer_device.h
Normal file
@ -0,0 +1,42 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include "knx_types.h"
|
||||
#include "npdu.h"
|
||||
#include "transport_layer.h"
|
||||
#include "network_layer_entity.h"
|
||||
#include "network_layer.h"
|
||||
|
||||
class DeviceObject;
|
||||
|
||||
class NetworkLayerDevice : public NetworkLayer
|
||||
{
|
||||
friend class NetworkLayerEntity;
|
||||
|
||||
public:
|
||||
NetworkLayerDevice(DeviceObject& deviceObj, TransportLayer& layer);
|
||||
|
||||
virtual NetworkLayerEntity& getEntity(uint8_t interfaceIndex) override;
|
||||
|
||||
// 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;
|
||||
virtual void dataBroadcastRequest(AckType ack, HopCountType hopType, Priority priority, TPDU& tpdu) override;
|
||||
virtual void dataSystemBroadcastRequest(AckType ack, HopCountType hopType, Priority priority, TPDU& tpdu) override;
|
||||
|
||||
private:
|
||||
// from entities
|
||||
virtual void dataIndication(AckType ack, AddressType addType, uint16_t destination, FrameFormat format, NPDU& npdu,
|
||||
Priority priority, uint16_t source) override;
|
||||
virtual void dataConfirm(AckType ack, AddressType addressType, uint16_t destination, FrameFormat format, Priority priority,
|
||||
uint16_t source, NPDU& npdu, bool status) override;
|
||||
virtual void broadcastIndication(AckType ack, FrameFormat format, NPDU& npdu,
|
||||
Priority priority, uint16_t source) override;
|
||||
virtual void broadcastConfirm(AckType ack, FrameFormat format, Priority priority, uint16_t source, NPDU& npdu, bool status) override;
|
||||
virtual void systemBroadcastIndication(AckType ack, FrameFormat format, NPDU& npdu,
|
||||
Priority priority, uint16_t source) override;
|
||||
virtual void systemBroadcastConfirm(AckType ack, FrameFormat format, Priority priority, uint16_t source, NPDU& npdu, bool status) override;
|
||||
|
||||
// Support only physical interface for normal devices
|
||||
NetworkLayerEntity _netLayerEntities[1];
|
||||
};
|
@ -9,17 +9,14 @@ class NetworkLayer;
|
||||
|
||||
class NetworkLayerEntity
|
||||
{
|
||||
friend class NetworkLayerCoupler;
|
||||
friend class NetworkLayerDevice;
|
||||
|
||||
public:
|
||||
NetworkLayerEntity(NetworkLayer &netLayer, uint8_t entityIndex);
|
||||
|
||||
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);
|
||||
@ -33,6 +30,9 @@ class NetworkLayerEntity
|
||||
void systemBroadcastConfirm(AckType ack, FrameFormat format, Priority priority, uint16_t source, NPDU& npdu, bool status);
|
||||
|
||||
private:
|
||||
// From network layer
|
||||
void sendDataRequest(NPDU& npdu, AckType ack, uint16_t destination, Priority priority, AddressType addrType, SystemBroadcast systemBroadcast);
|
||||
|
||||
DataLinkLayer* _dataLinkLayer = 0;
|
||||
NetworkLayer& _netLayer;
|
||||
uint8_t _entityIndex;
|
||||
|
Loading…
Reference in New Issue
Block a user