mirror of
https://github.com/thelsing/knx.git
synced 2025-06-27 01:15:13 +02:00
Merge pull request #1 from nanosonde/for_upstream
Improve property description handling
This commit is contained in:
commit
d710ec327b
@ -84,7 +84,10 @@ void AddressTableObject::beforeStateChange(LoadState& newState)
|
|||||||
_groupAddresses = (uint16_t*)_data;
|
_groupAddresses = (uint16_t*)_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PropertyDescription _propertyDescriptions[] = { };
|
static PropertyDescription _propertyDescriptions[] =
|
||||||
|
{
|
||||||
|
{ PID_OBJECT_TYPE, false, PDT_UNSIGNED_INT, 1, ReadLv3 | WriteLv0 }
|
||||||
|
};
|
||||||
static uint8_t _propertyCount = sizeof(_propertyDescriptions) / sizeof(PropertyDescription);
|
static uint8_t _propertyCount = sizeof(_propertyDescriptions) / sizeof(PropertyDescription);
|
||||||
|
|
||||||
uint8_t AddressTableObject::propertyCount()
|
uint8_t AddressTableObject::propertyCount()
|
||||||
|
@ -43,9 +43,10 @@ uint8_t ApplicationProgramObject::propertySize(PropertyID id)
|
|||||||
{
|
{
|
||||||
switch (id)
|
switch (id)
|
||||||
{
|
{
|
||||||
case PID_OBJECT_TYPE:
|
|
||||||
case PID_PEI_TYPE:
|
case PID_PEI_TYPE:
|
||||||
return 1;
|
return 1;
|
||||||
|
case PID_OBJECT_TYPE:
|
||||||
|
return 2;
|
||||||
case PID_PROG_VERSION:
|
case PID_PROG_VERSION:
|
||||||
return 5;
|
return 5;
|
||||||
}
|
}
|
||||||
@ -86,7 +87,10 @@ uint8_t* ApplicationProgramObject::restore(uint8_t* buffer)
|
|||||||
return TableObject::restore(buffer);
|
return TableObject::restore(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
static PropertyDescription _propertyDescriptions[] = {};
|
static PropertyDescription _propertyDescriptions[] =
|
||||||
|
{
|
||||||
|
{ PID_OBJECT_TYPE, false, PDT_UNSIGNED_INT, 1, ReadLv3 | WriteLv0 }
|
||||||
|
};
|
||||||
static uint8_t _propertyCount = sizeof(_propertyDescriptions) / sizeof(PropertyDescription);
|
static uint8_t _propertyCount = sizeof(_propertyDescriptions) / sizeof(PropertyDescription);
|
||||||
|
|
||||||
uint8_t ApplicationProgramObject::propertyCount()
|
uint8_t ApplicationProgramObject::propertyCount()
|
||||||
|
@ -70,7 +70,8 @@ void AssociationTableObject::beforeStateChange(LoadState& newState)
|
|||||||
|
|
||||||
static PropertyDescription _propertyDescriptions[] =
|
static PropertyDescription _propertyDescriptions[] =
|
||||||
{
|
{
|
||||||
{ PID_TABLE, false, PDT_GENERIC_02, 254, ReadLv3 | WriteLv0 },
|
{ PID_OBJECT_TYPE, false, PDT_UNSIGNED_INT, 1, ReadLv3 | WriteLv0 },
|
||||||
|
{ PID_TABLE, false, PDT_GENERIC_02, 254, ReadLv3 | WriteLv0 }
|
||||||
};
|
};
|
||||||
static uint8_t _propertyCount = sizeof(_propertyDescriptions) / sizeof(PropertyDescription);
|
static uint8_t _propertyCount = sizeof(_propertyDescriptions) / sizeof(PropertyDescription);
|
||||||
|
|
||||||
|
@ -181,15 +181,16 @@ void Bau57B0::userMemoryWriteIndication(Priority priority, HopCountType hopType,
|
|||||||
void Bau57B0::propertyDescriptionReadIndication(Priority priority, HopCountType hopType, uint16_t asap, uint8_t objectIndex,
|
void Bau57B0::propertyDescriptionReadIndication(Priority priority, HopCountType hopType, uint16_t asap, uint8_t objectIndex,
|
||||||
uint8_t propertyId, uint8_t propertyIndex)
|
uint8_t propertyId, uint8_t propertyIndex)
|
||||||
{
|
{
|
||||||
|
uint8_t pid = propertyId;
|
||||||
bool writeEnable = false;
|
bool writeEnable = false;
|
||||||
uint8_t type = 0;
|
uint8_t type = 0;
|
||||||
uint16_t numberOfElements = 0;
|
uint16_t numberOfElements = 0;
|
||||||
uint8_t access = 0;
|
uint8_t access = 0;
|
||||||
InterfaceObject* obj = getInterfaceObject(objectIndex);
|
InterfaceObject* obj = getInterfaceObject(objectIndex);
|
||||||
if (obj)
|
if (obj)
|
||||||
obj->readPropertyDescription(propertyId, propertyIndex, writeEnable, type, numberOfElements, access);
|
obj->readPropertyDescription(pid, propertyIndex, writeEnable, type, numberOfElements, access);
|
||||||
|
|
||||||
_appLayer.propertyDescriptionReadResponse(AckRequested, priority, hopType, asap, objectIndex, propertyId, propertyIndex,
|
_appLayer.propertyDescriptionReadResponse(AckRequested, priority, hopType, asap, objectIndex, pid, propertyIndex,
|
||||||
writeEnable, type, numberOfElements, access);
|
writeEnable, type, numberOfElements, access);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,13 +83,13 @@ uint8_t DeviceObject::propertySize(PropertyID id)
|
|||||||
{
|
{
|
||||||
switch (id)
|
switch (id)
|
||||||
{
|
{
|
||||||
case PID_OBJECT_TYPE:
|
|
||||||
case PID_DEVICE_CONTROL:
|
case PID_DEVICE_CONTROL:
|
||||||
case PID_ROUTING_COUNT:
|
case PID_ROUTING_COUNT:
|
||||||
case PID_PROG_MODE:
|
case PID_PROG_MODE:
|
||||||
case PID_SUBNET_ADDR:
|
case PID_SUBNET_ADDR:
|
||||||
case PID_DEVICE_ADDR:
|
case PID_DEVICE_ADDR:
|
||||||
return 1;
|
return 1;
|
||||||
|
case PID_OBJECT_TYPE:
|
||||||
case PID_MANUFACTURER_ID:
|
case PID_MANUFACTURER_ID:
|
||||||
case PID_VERSION:
|
case PID_VERSION:
|
||||||
case PID_DEVICE_DESCRIPTOR:
|
case PID_DEVICE_DESCRIPTOR:
|
||||||
@ -254,7 +254,11 @@ void DeviceObject::version(uint16_t value)
|
|||||||
_version = value;
|
_version = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PropertyDescription _propertyDescriptions[] = {};
|
static PropertyDescription _propertyDescriptions[] =
|
||||||
|
{
|
||||||
|
{ PID_OBJECT_TYPE, false, PDT_UNSIGNED_INT, 1, ReadLv3 | WriteLv0 },
|
||||||
|
{ PID_SERIAL_NUMBER, false, PDT_GENERIC_06, 1, ReadLv3 | WriteLv0 }
|
||||||
|
};
|
||||||
static uint8_t _propertyCount = sizeof(_propertyDescriptions) / sizeof(PropertyDescription);
|
static uint8_t _propertyCount = sizeof(_propertyDescriptions) / sizeof(PropertyDescription);
|
||||||
|
|
||||||
uint8_t DeviceObject::propertyCount()
|
uint8_t DeviceObject::propertyCount()
|
||||||
|
@ -120,7 +120,10 @@ bool GroupObjectTableObject::initGroupObjects()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PropertyDescription _propertyDescriptions[] = { };
|
static PropertyDescription _propertyDescriptions[] =
|
||||||
|
{
|
||||||
|
{ PID_OBJECT_TYPE, false, PDT_UNSIGNED_INT, 1, ReadLv3 | WriteLv0 }
|
||||||
|
};
|
||||||
static uint8_t _propertyCount = sizeof(_propertyDescriptions) / sizeof(PropertyDescription);
|
static uint8_t _propertyCount = sizeof(_propertyDescriptions) / sizeof(PropertyDescription);
|
||||||
|
|
||||||
uint8_t GroupObjectTableObject::propertyCount()
|
uint8_t GroupObjectTableObject::propertyCount()
|
||||||
|
@ -1,17 +1,19 @@
|
|||||||
#include "interface_object.h"
|
#include "interface_object.h"
|
||||||
|
|
||||||
void InterfaceObject::readPropertyDescription(uint8_t propertyId, uint8_t& propertyIndex, bool& writeEnable, uint8_t& type, uint16_t& numberOfElements, uint8_t& access)
|
void InterfaceObject::readPropertyDescription(uint8_t& propertyId, uint8_t& propertyIndex, bool& writeEnable, uint8_t& type, uint16_t& numberOfElements, uint8_t& access)
|
||||||
{
|
{
|
||||||
PropertyDescription* descriptions = propertyDescriptions();
|
PropertyDescription* descriptions = propertyDescriptions();
|
||||||
uint8_t count = propertyCount();
|
uint8_t count = propertyCount();
|
||||||
|
|
||||||
PropertyDescription* desc = nullptr;
|
PropertyDescription* desc = nullptr;
|
||||||
|
|
||||||
|
// from KNX spec. 03.03.07 Application Layer (page 56) - 3.4.3.3 A_PropertyDescription_Read-service
|
||||||
|
// Summary: either propertyId OR propertyIndex, but not both at the same time
|
||||||
if (propertyId != 0)
|
if (propertyId != 0)
|
||||||
{
|
{
|
||||||
|
|
||||||
for (uint8_t i = 0; i < count; i++)
|
for (uint8_t i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
PropertyDescription d = descriptions[propertyIndex];
|
PropertyDescription d = descriptions[i];
|
||||||
if (d.Id != propertyId)
|
if (d.Id != propertyId)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -22,7 +24,9 @@ void InterfaceObject::readPropertyDescription(uint8_t propertyId, uint8_t& prope
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (propertyIndex > 0 && propertyIndex < count)
|
// If propertyId is zero, propertyIndex shall be used.
|
||||||
|
// Response: propertyIndex of received A_PropertyDescription_Read
|
||||||
|
if (propertyIndex < count)
|
||||||
{
|
{
|
||||||
desc = &descriptions[propertyIndex];
|
desc = &descriptions[propertyIndex];
|
||||||
}
|
}
|
||||||
@ -30,6 +34,7 @@ void InterfaceObject::readPropertyDescription(uint8_t propertyId, uint8_t& prope
|
|||||||
|
|
||||||
if (desc != nullptr)
|
if (desc != nullptr)
|
||||||
{
|
{
|
||||||
|
propertyId = desc->Id;
|
||||||
writeEnable = desc->WriteEnable;
|
writeEnable = desc->WriteEnable;
|
||||||
type = desc->Type;
|
type = desc->Type;
|
||||||
numberOfElements = desc->MaxElements;
|
numberOfElements = desc->MaxElements;
|
||||||
|
@ -57,7 +57,7 @@ public:
|
|||||||
virtual void readProperty(PropertyID id, uint32_t start, uint32_t& count, uint8_t* data) = 0;
|
virtual void readProperty(PropertyID id, uint32_t start, uint32_t& count, uint8_t* data) = 0;
|
||||||
virtual void writeProperty(PropertyID id, uint8_t start, uint8_t* data, uint8_t count) = 0;
|
virtual void writeProperty(PropertyID id, uint8_t start, uint8_t* data, uint8_t count) = 0;
|
||||||
virtual uint8_t propertySize(PropertyID id) = 0;
|
virtual uint8_t propertySize(PropertyID id) = 0;
|
||||||
void readPropertyDescription(uint8_t propertyId, uint8_t& propertyIndex, bool& writeEnable, uint8_t& type, uint16_t& numberOfElements, uint8_t& access);
|
void readPropertyDescription(uint8_t& propertyId, uint8_t& propertyIndex, bool& writeEnable, uint8_t& type, uint16_t& numberOfElements, uint8_t& access);
|
||||||
protected:
|
protected:
|
||||||
virtual uint8_t propertyCount() = 0;
|
virtual uint8_t propertyCount() = 0;
|
||||||
virtual PropertyDescription* propertyDescriptions() = 0;
|
virtual PropertyDescription* propertyDescriptions() = 0;
|
||||||
|
@ -304,7 +304,10 @@ void IpParameterObject::additionalLoadControls(uint8_t* data)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PropertyDescription _propertyDescriptions[] = { };
|
static PropertyDescription _propertyDescriptions[] =
|
||||||
|
{
|
||||||
|
{ PID_OBJECT_TYPE, false, PDT_UNSIGNED_INT, 1, ReadLv3 | WriteLv0 }
|
||||||
|
};
|
||||||
static uint8_t _propertyCount = sizeof(_propertyDescriptions) / sizeof(PropertyDescription);
|
static uint8_t _propertyCount = sizeof(_propertyDescriptions) / sizeof(PropertyDescription);
|
||||||
|
|
||||||
uint8_t IpParameterObject::propertyCount()
|
uint8_t IpParameterObject::propertyCount()
|
||||||
|
@ -52,6 +52,8 @@ uint8_t TableObject::propertySize(PropertyID id)
|
|||||||
return 4;
|
return 4;
|
||||||
case PID_ERROR_CODE:
|
case PID_ERROR_CODE:
|
||||||
return 1;
|
return 1;
|
||||||
|
case PID_OBJECT_TYPE:
|
||||||
|
return 2;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user