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
1d3648d372
commit
d25b9cec65
@ -9,13 +9,11 @@ using namespace std;
|
||||
|
||||
Bau07B0::Bau07B0(Platform& platform)
|
||||
: BauSystemBDevice(platform),
|
||||
_dlLayer(_deviceObj, _netLayer.getEntity(0), _platform)
|
||||
_dlLayer(_deviceObj, _netLayer.getEntity(0), _platform, (ITpUartCallBacks&) *this)
|
||||
#ifdef USE_CEMI_SERVER
|
||||
, _cemiServer(*this)
|
||||
#endif
|
||||
{
|
||||
_dlLayer.groupAddressTable(_addrTable);
|
||||
|
||||
_netLayer.getEntity(0).dataLinkLayer(_dlLayer);
|
||||
#ifdef USE_CEMI_SERVER
|
||||
_cemiServerObject.setMediumTypeAsSupported(DptMedium::KNX_TP1);
|
||||
@ -128,4 +126,22 @@ void Bau07B0::loop()
|
||||
#endif
|
||||
}
|
||||
|
||||
bool Bau07B0::isAckRequired(uint16_t address, bool isGrpAddr)
|
||||
{
|
||||
if (isGrpAddr)
|
||||
{
|
||||
// ACK for broadcasts
|
||||
if (address == 0)
|
||||
return true;
|
||||
// is group address in group address table? ACK if yes.
|
||||
return _addrTable.contains(address);
|
||||
}
|
||||
|
||||
// Also ACK for our own individual address
|
||||
if (address == _deviceObj.induvidualAddress())
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
#ifdef USE_TP
|
||||
|
||||
class Bau07B0 : public BauSystemBDevice
|
||||
class Bau07B0 : public BauSystemBDevice, public ITpUartCallBacks
|
||||
{
|
||||
public:
|
||||
Bau07B0(Platform& platform);
|
||||
@ -20,6 +20,9 @@ class Bau07B0 : public BauSystemBDevice
|
||||
InterfaceObject* getInterfaceObject(uint8_t idx);
|
||||
InterfaceObject* getInterfaceObject(ObjectType objectType, uint8_t objectInstance);
|
||||
|
||||
// For TP1 only
|
||||
virtual bool isAckRequired(uint16_t address, bool isGrpAddr) override;
|
||||
|
||||
private:
|
||||
TpUartDataLinkLayer _dlLayer;
|
||||
#ifdef USE_CEMI_SERVER
|
||||
|
@ -12,12 +12,15 @@ Bau091A::Bau091A(Platform& platform)
|
||||
: BauSystemBCoupler(platform),
|
||||
_ipParameters(_deviceObj, platform),
|
||||
_dlLayerPrimary(_deviceObj, _ipParameters, _netLayer.getEntity(0), _platform),
|
||||
_dlLayerSecondary(_deviceObj, _netLayer.getEntity(1), platform)
|
||||
_dlLayerSecondary(_deviceObj, _netLayer.getEntity(1), platform, (ITpUartCallBacks&) *this)
|
||||
#ifdef USE_CEMI_SERVER
|
||||
,
|
||||
_cemiServer(*this)
|
||||
#endif
|
||||
{
|
||||
// TODO: setup callback for address check on TP1 medium which supports ACK
|
||||
//_dlLayerSecondary.setAckRequiredCallback();
|
||||
|
||||
// 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);
|
||||
@ -146,4 +149,25 @@ void Bau091A::loop()
|
||||
BauSystemBCoupler::loop();
|
||||
}
|
||||
|
||||
bool Bau091A::isAckRequired(uint16_t address, bool isGrpAddr)
|
||||
{
|
||||
if (isGrpAddr)
|
||||
{
|
||||
// ACK for broadcasts
|
||||
if (address == 0)
|
||||
return true;
|
||||
// is group address in filter table? ACK if yes.
|
||||
return _rtObjSecondary.isGroupAddressInFilterTable(address);
|
||||
}
|
||||
|
||||
// Also ACK for our own individual address
|
||||
if (address == _deviceObj.induvidualAddress())
|
||||
return true;
|
||||
|
||||
// TODO: ACKs for frames with individual addresses of the sub line (secondary I/F)
|
||||
// Check spec. about his
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include "tpuart_data_link_layer.h"
|
||||
#include "cemi_server_object.h"
|
||||
|
||||
class Bau091A : public BauSystemBCoupler
|
||||
class Bau091A : public BauSystemBCoupler, public ITpUartCallBacks
|
||||
{
|
||||
public:
|
||||
Bau091A(Platform& platform);
|
||||
@ -20,6 +20,9 @@ class Bau091A : public BauSystemBCoupler
|
||||
InterfaceObject* getInterfaceObject(uint8_t idx);
|
||||
InterfaceObject* getInterfaceObject(ObjectType objectType, uint8_t objectInstance);
|
||||
|
||||
// For TP1 only
|
||||
virtual bool isAckRequired(uint16_t address, bool isGrpAddr) override;
|
||||
|
||||
virtual void doMasterReset(EraseCode eraseCode, uint8_t channel) override;
|
||||
private:
|
||||
IpParameterObject _ipParameters;
|
||||
|
@ -266,53 +266,16 @@ void TpUartDataLinkLayer::loop()
|
||||
{
|
||||
uint8_t c = 0x10;
|
||||
|
||||
// TODO: Improve for coupler mode. Use callback from bau to check if we are addressed
|
||||
// The bau knows everything and could either check the address table object (normal device)
|
||||
// or any filter tables (coupler) to see if we are addressed.
|
||||
if (_groupAddressTable)
|
||||
{
|
||||
//check if individual or group address
|
||||
if ((buffer[6] & 0x80) == 0)
|
||||
{
|
||||
//individual
|
||||
if (_deviceObject.induvidualAddress() == getWord(buffer + 4))
|
||||
{
|
||||
c |= 0x01;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//group
|
||||
if (_groupAddressTable->contains(getWord(buffer + 4)) || getWord(buffer + 4) == 0)
|
||||
{
|
||||
c |= 0x01;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO: test for only our coupler
|
||||
|
||||
//individual
|
||||
//check if individual or group address
|
||||
if ((buffer[6] & 0x80) == 0)
|
||||
{
|
||||
//individual
|
||||
if (_deviceObject.induvidualAddress() == getWord(buffer + 4))
|
||||
{
|
||||
c |= 0x01;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO: test for only our coupler
|
||||
//check if individual or group address
|
||||
bool isGroupAddress = (buffer[6] & 0x80) != 0;
|
||||
uint16_t addr = getWord(buffer + 4);
|
||||
|
||||
//group
|
||||
if (getWord(buffer + 4) == 0)
|
||||
{
|
||||
c |= 0x01;
|
||||
}
|
||||
}
|
||||
if (_cb.isAckRequired(addr, isGroupAddress))
|
||||
{
|
||||
c |= 0x01;
|
||||
}
|
||||
|
||||
_platform.writeUart(c);
|
||||
@ -446,16 +409,14 @@ void TpUartDataLinkLayer::stopChip()
|
||||
}
|
||||
|
||||
TpUartDataLinkLayer::TpUartDataLinkLayer(DeviceObject& devObj,
|
||||
NetworkLayerEntity &netLayerEntity, Platform& platform)
|
||||
: DataLinkLayer(devObj, netLayerEntity, platform)
|
||||
NetworkLayerEntity &netLayerEntity,
|
||||
Platform& platform,
|
||||
ITpUartCallBacks& cb)
|
||||
: DataLinkLayer(devObj, netLayerEntity, platform),
|
||||
_cb(cb)
|
||||
{
|
||||
}
|
||||
|
||||
void TpUartDataLinkLayer::groupAddressTable(AddressTableObject &addrTable)
|
||||
{
|
||||
_groupAddressTable = &addrTable;
|
||||
}
|
||||
|
||||
void TpUartDataLinkLayer::frameBytesReceived(uint8_t* buffer, uint16_t length)
|
||||
{
|
||||
//printHex("=>", buffer, length);
|
||||
|
@ -8,7 +8,12 @@
|
||||
|
||||
#define MAX_KNX_TELEGRAM_SIZE 263
|
||||
|
||||
class AddressTableObject;
|
||||
class ITpUartCallBacks
|
||||
{
|
||||
public:
|
||||
virtual ~ITpUartCallBacks() = default;
|
||||
virtual bool isAckRequired(uint16_t address, bool isGrpAddr) = 0;
|
||||
};
|
||||
|
||||
class TpUartDataLinkLayer : public DataLinkLayer
|
||||
{
|
||||
@ -17,9 +22,7 @@ class TpUartDataLinkLayer : public DataLinkLayer
|
||||
|
||||
public:
|
||||
TpUartDataLinkLayer(DeviceObject& devObj, NetworkLayerEntity& netLayerEntity,
|
||||
Platform& platform);
|
||||
|
||||
void groupAddressTable(AddressTableObject& addrTable);
|
||||
Platform& platform, ITpUartCallBacks& cb);
|
||||
|
||||
void loop();
|
||||
void enabled(bool value);
|
||||
@ -67,6 +70,6 @@ class TpUartDataLinkLayer : public DataLinkLayer
|
||||
bool resetChip();
|
||||
void stopChip();
|
||||
|
||||
AddressTableObject* _groupAddressTable = nullptr;
|
||||
ITpUartCallBacks& _cb;
|
||||
};
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user