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
d83c2ea46f
commit
3634f9476d
@ -20,7 +20,7 @@ Bau091A::Bau091A(Platform& platform)
|
||||
#endif
|
||||
{
|
||||
// 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);
|
||||
_rtObjSecondary.initialize(CouplerModel::Model_1x, 1, DptMedium::KNX_TP1, false, true, 201);
|
||||
|
||||
// Mask 091A uses older coupler model 1.x which only uses one router object
|
||||
_netLayer.rtObjSecondary(_rtObjSecondary);
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include "config.h"
|
||||
#if defined(USE_IP) && defined (USE_TP)
|
||||
#include "bau_systemB_coupler.h"
|
||||
#include "router_object.h"
|
||||
#include "ip_parameter_object.h"
|
||||
#include "ip_data_link_layer.h"
|
||||
#include "tpuart_data_link_layer.h"
|
||||
|
@ -22,8 +22,8 @@ Bau2920::Bau2920(Platform& platform)
|
||||
#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_TP1, true, false, 201);
|
||||
_rtObjSecondary.initialize(2, DptMedium::KNX_RF, false, true, 201);
|
||||
_rtObjPrimary.initialize(CouplerModel::Model_20, 1, DptMedium::KNX_TP1, true, false, 201);
|
||||
_rtObjSecondary.initialize(CouplerModel::Model_20, 2, DptMedium::KNX_RF, false, true, 201);
|
||||
|
||||
_netLayer.rtObjPrimary(_rtObjPrimary);
|
||||
_netLayer.rtObjSecondary(_rtObjSecondary);
|
||||
|
@ -177,9 +177,14 @@ enum PropertyID
|
||||
|
||||
/** Router Object */
|
||||
PID_MEDIUM_STATUS = 51,
|
||||
PID_MAIN_LCCONFIG = 52,
|
||||
PID_SUB_LCCONFIG = 53,
|
||||
PID_MAIN_LCGRPCONFIG = 54,
|
||||
PID_SUB_LCGRPCONFIG = 55,
|
||||
PID_ROUTETABLE_CONTROL = 56,
|
||||
PID_COUPLER_SERVICES_CONTROL = 57,
|
||||
PID_MAX_APDU_LENGTH_ROUTER = 58,
|
||||
PID_L2_COUPLER_TYPE = 59,
|
||||
PID_HOP_COUNT = 61,
|
||||
PID_MEDIUM = 63,
|
||||
PID_FILTER_TABLE_USE = 67,
|
||||
|
@ -30,8 +30,9 @@ RouterObject::RouterObject(Memory& memory)
|
||||
{
|
||||
}
|
||||
|
||||
void RouterObject::initialize(uint8_t objIndex, DptMedium mediumType, bool useHopCount, bool useTable, uint16_t maxApduSize)
|
||||
void RouterObject::initialize(CouplerModel model, uint8_t objIndex, DptMedium mediumType, bool useHopCount, bool useTable, uint16_t maxApduSize)
|
||||
{
|
||||
// These properties are always present
|
||||
Property* fixedProperties[] =
|
||||
{
|
||||
new DataProperty( PID_OBJECT_TYPE, false, PDT_UNSIGNED_INT, 1, ReadLv3 | WriteLv0, (uint16_t) OT_ROUTER ),
|
||||
@ -39,19 +40,53 @@ void RouterObject::initialize(uint8_t objIndex, DptMedium mediumType, bool useHo
|
||||
new DataProperty( PID_MEDIUM_STATUS, false, PDT_GENERIC_01, 1, ReadLv3 | WriteLv0, (uint16_t) 0 ), // 0 means communication is possible, could be set by datalink layer or bau to 1 (comm impossible)
|
||||
new DataProperty( PID_MAX_APDU_LENGTH_ROUTER, false, PDT_UNSIGNED_INT, 1, ReadLv3 | WriteLv0, maxApduSize ),
|
||||
new DataProperty( PID_MEDIUM, false, PDT_ENUM8, 1, ReadLv3 | WriteLv0, (uint8_t) mediumType ),
|
||||
|
||||
};
|
||||
uint8_t fixesPropertiesCount = sizeof(fixedProperties) / sizeof(Property*);
|
||||
uint8_t fixedPropertiesCount = sizeof(fixedProperties) / sizeof(Property*);
|
||||
|
||||
size_t allPropertiesCount = fixesPropertiesCount;
|
||||
// Only present if coupler model is 1.x
|
||||
Property* model1xProperties[] =
|
||||
{
|
||||
new DataProperty( PID_MAIN_LCCONFIG, true, PDT_BITSET8, 1, ReadLv3 | WriteLv0, (uint16_t) 0 ), // Primary: data individual (connless and connorient) + broadcast
|
||||
new DataProperty( PID_SUB_LCCONFIG, true, PDT_BITSET8, 1, ReadLv3 | WriteLv0, (uint16_t) 0 ), // Secondary: data individual (connless and connorient) + broadcast
|
||||
new DataProperty( PID_MAIN_LCGRPCONFIG, true, PDT_BITSET8, 1, ReadLv3 | WriteLv0, (uint16_t) 0 ), // Primary: data group
|
||||
new DataProperty( PID_SUB_LCGRPCONFIG, true, PDT_BITSET8, 1, ReadLv3 | WriteLv0, (uint16_t) 0 ), // Secondary: data group
|
||||
};
|
||||
uint8_t model1xPropertiesCount = sizeof(model1xProperties) / sizeof(Property*);
|
||||
|
||||
Property* tableProperties[] =
|
||||
{
|
||||
new DataProperty( PID_COUPLER_SERVICES_CONTROL, true, PDT_GENERIC_01, 1, ReadLv3 | WriteLv0, (uint8_t) 0), // written by ETS TODO: implement
|
||||
new DataProperty( PID_MCB_TABLE, false, PDT_GENERIC_08, 1, ReadLv3 | WriteLv0), // TODO: improve: move to TableObject once segment size handling is clear
|
||||
new DataProperty( PID_FILTER_TABLE_USE, true, PDT_BINARY_INFORMATION, 1, ReadLv3 | WriteLv0, (uint16_t) 0 ), // default: invalid filter table, do not use, written by ETS
|
||||
new FunctionProperty<RouterObject>(this, PID_ROUTETABLE_CONTROL,
|
||||
// Command Callback of PID_ROUTETABLE_CONTROL
|
||||
[](RouterObject* obj, uint8_t* data, uint8_t length, uint8_t* resultData, uint8_t& resultLength) -> void {
|
||||
obj->functionRouteTableControl(true, data, length, resultData, resultLength);
|
||||
},
|
||||
// State Callback of PID_ROUTETABLE_CONTROL
|
||||
[](RouterObject* obj, uint8_t* data, uint8_t length, uint8_t* resultData, uint8_t& resultLength) -> void {
|
||||
obj->functionRouteTableControl(false, data, length, resultData, resultLength);
|
||||
})
|
||||
};
|
||||
uint8_t tablePropertiesCount = sizeof(tableProperties) / sizeof(Property*);
|
||||
|
||||
size_t allPropertiesCount = fixedPropertiesCount;
|
||||
allPropertiesCount += (model == CouplerModel::Model_1x) ? model1xPropertiesCount : 0;
|
||||
allPropertiesCount += useHopCount ? 1 : 0;
|
||||
allPropertiesCount += useTable ? 1 : 0;
|
||||
allPropertiesCount += useTable ? tablePropertiesCount : 0;
|
||||
allPropertiesCount += (mediumType == DptMedium::KNX_RF) ? 1 : 0;
|
||||
|
||||
Property* allProperties[allPropertiesCount];
|
||||
|
||||
memcpy(&allProperties[0], &fixedProperties[0], sizeof(fixedProperties));
|
||||
|
||||
uint8_t i = fixesPropertiesCount;
|
||||
uint8_t i = fixedPropertiesCount;
|
||||
|
||||
if (model == CouplerModel::Model_1x)
|
||||
{
|
||||
memcpy(&allProperties[i], model1xProperties, sizeof(model1xProperties));
|
||||
i += sizeof(model1xProperties) / sizeof(Property*);
|
||||
}
|
||||
|
||||
if (useHopCount)
|
||||
{
|
||||
@ -62,20 +97,6 @@ void RouterObject::initialize(uint8_t objIndex, DptMedium mediumType, bool useHo
|
||||
|
||||
if (useTable)
|
||||
{
|
||||
Property* tableProperties[] =
|
||||
{
|
||||
new DataProperty( PID_MCB_TABLE, false, PDT_GENERIC_08, 1, ReadLv3 | WriteLv0), // TODO: improve: move to TableObject once segment size handling is clear
|
||||
new DataProperty( PID_FILTER_TABLE_USE, true, PDT_BINARY_INFORMATION, 1, ReadLv3 | WriteLv0, (uint16_t) 0 ), // default: invalid filter table, do not use, written by ETS
|
||||
new FunctionProperty<RouterObject>(this, PID_ROUTETABLE_CONTROL,
|
||||
// Command Callback of PID_ROUTETABLE_CONTROL
|
||||
[](RouterObject* obj, uint8_t* data, uint8_t length, uint8_t* resultData, uint8_t& resultLength) -> void {
|
||||
obj->functionRouteTableControl(true, data, length, resultData, resultLength);
|
||||
},
|
||||
// State Callback of PID_ROUTETABLE_CONTROL
|
||||
[](RouterObject* obj, uint8_t* data, uint8_t length, uint8_t* resultData, uint8_t& resultLength) -> void {
|
||||
obj->functionRouteTableControl(false, data, length, resultData, resultLength);
|
||||
})
|
||||
};
|
||||
memcpy(&allProperties[i], tableProperties, sizeof(tableProperties));
|
||||
i += sizeof(tableProperties) / sizeof(Property*);
|
||||
}
|
||||
|
@ -7,12 +7,18 @@
|
||||
|
||||
class Memory;
|
||||
|
||||
enum CouplerModel
|
||||
{
|
||||
Model_1x,
|
||||
Model_20
|
||||
};
|
||||
|
||||
class RouterObject : public TableObject
|
||||
{
|
||||
public:
|
||||
RouterObject(Memory& memory);
|
||||
|
||||
void initialize(uint8_t objIndex, DptMedium mediumType, bool useHopCount, bool useTable, uint16_t maxApduSize);
|
||||
void initialize(CouplerModel model, uint8_t objIndex, DptMedium mediumType, bool useHopCount, bool useTable, uint16_t maxApduSize);
|
||||
|
||||
bool isGroupAddressInFilterTable(uint16_t groupAddress);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user