mirror of
https://github.com/thelsing/knx.git
synced 2024-12-18 19:08:18 +01:00
refactor cemi server object
This commit is contained in:
parent
1465cb558c
commit
82f463f965
@ -4,103 +4,30 @@
|
||||
#include <cstring>
|
||||
#include "cemi_server_object.h"
|
||||
#include "bits.h"
|
||||
#include "data_property.h"
|
||||
|
||||
void CemiServerObject::readProperty(PropertyID propertyId, uint16_t start, uint8_t& count, uint8_t* data)
|
||||
CemiServerObject::CemiServerObject()
|
||||
{
|
||||
switch (propertyId)
|
||||
{
|
||||
case PID_OBJECT_TYPE:
|
||||
pushWord(OT_CEMI_SERVER, data);
|
||||
break;
|
||||
case PID_MEDIUM_TYPE: // PDT_BITSET16
|
||||
uint16_t mediumType = 0;
|
||||
#if MEDIUM_TYPE == 0
|
||||
pushWord(2, data); // TP1 supported
|
||||
mediumType = 2; // TP1 supported
|
||||
#elif MEDIUM_TYPE == 2
|
||||
pushWord(16, data); // RF supported
|
||||
mediumType = 16; // RF supported
|
||||
#elif MEDIUM_TYPE == 5
|
||||
pushWord(32, data); // IP supported
|
||||
mediumType = 32; // IP supported
|
||||
#endif
|
||||
break;
|
||||
case PID_COMM_MODE: // PDT_ENUM8
|
||||
// See KNX spec. cEMI 3/6/3 p.110
|
||||
data[0] = 0x00; // Only Data Link Layer mode supported and we do not allow switching (read-only)
|
||||
break;
|
||||
case PID_COMM_MODES_SUPPORTED:
|
||||
data[0] = 0x00;
|
||||
data[1] = 0x01;
|
||||
break;
|
||||
case PID_MEDIUM_AVAILABILITY: // PDT_BITSET16
|
||||
#if MEDIUM_TYPE==0
|
||||
pushWord(2, data); // TP1 active
|
||||
#elif MEDIUM_TYPE==2
|
||||
pushWord(16, data); // RF active
|
||||
#elif MEDIUM_TYPE==5
|
||||
pushWord(32, data); // IP active
|
||||
#endif
|
||||
break;
|
||||
case PID_ADD_INFO_TYPES: // PDT_ENUM8[]
|
||||
pushByteArray((uint8_t*)_addInfoTypesTable, sizeof(_addInfoTypesTable), data);
|
||||
break;
|
||||
// Not supported yet
|
||||
break;
|
||||
default:
|
||||
count = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void CemiServerObject::writeProperty(PropertyID id, uint16_t start, uint8_t* data, uint8_t& count)
|
||||
Property* properties[] =
|
||||
{
|
||||
switch (id)
|
||||
{
|
||||
case PID_COMM_MODE:
|
||||
//_commMode = data[0]; // TODO: only Data Link Layer supported for now
|
||||
// Property is also marked as read-only, normally it is read/write.
|
||||
break;
|
||||
|
||||
default:
|
||||
count = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t CemiServerObject::propertySize(PropertyID id)
|
||||
{
|
||||
switch (id)
|
||||
{
|
||||
case PID_COMM_MODE:
|
||||
return 1;
|
||||
case PID_OBJECT_TYPE:
|
||||
case PID_MEDIUM_TYPE:
|
||||
case PID_MEDIUM_AVAILABILITY:
|
||||
case PID_COMM_MODES_SUPPORTED:
|
||||
return 2;
|
||||
case PID_ADD_INFO_TYPES:
|
||||
return sizeof(_addInfoTypesTable);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static PropertyDescription _propertyDescriptions[] =
|
||||
{
|
||||
{ PID_OBJECT_TYPE, false, PDT_UNSIGNED_INT, 1, ReadLv3 | WriteLv0 },
|
||||
{ PID_MEDIUM_TYPE, false, PDT_BITSET16, 1, ReadLv3 | WriteLv0 },
|
||||
{ PID_COMM_MODE, false, PDT_ENUM8, 1, ReadLv3 | WriteLv0 },
|
||||
{ PID_COMM_MODES_SUPPORTED, false, PDT_BITSET16, 1, ReadLv3 | WriteLv0 },
|
||||
{ PID_MEDIUM_AVAILABILITY, false, PDT_BITSET16, 1, ReadLv3 | WriteLv0 },
|
||||
{ PID_ADD_INFO_TYPES, false, PDT_ENUM8, 1, ReadLv3 | WriteLv0 }
|
||||
new DataProperty( PID_OBJECT_TYPE, false, PDT_UNSIGNED_INT, 1, ReadLv3 | WriteLv0, (uint16_t)OT_CEMI_SERVER ),
|
||||
new DataProperty( PID_MEDIUM_TYPE, false, PDT_BITSET16, 1, ReadLv3 | WriteLv0, mediumType),
|
||||
new DataProperty( PID_COMM_MODE, false, PDT_ENUM8, 1, ReadLv3 | WriteLv0, (uint16_t)0),
|
||||
new DataProperty( PID_COMM_MODES_SUPPORTED, false, PDT_BITSET16, 1, ReadLv3 | WriteLv0, (uint16_t)0x100),
|
||||
new DataProperty( PID_MEDIUM_AVAILABILITY, false, PDT_BITSET16, 1, ReadLv3 | WriteLv0, mediumType),
|
||||
// cEMI additional info types supported by this cEMI server: only 0x02 (RF Control Octet and Serial Number or DoA)
|
||||
new DataProperty( PID_ADD_INFO_TYPES, false, PDT_ENUM8, 1, ReadLv3 | WriteLv0, (uint8_t)0x02)
|
||||
};
|
||||
static uint8_t _propertyDescriptionCount = sizeof(_propertyDescriptions) / sizeof(PropertyDescription);
|
||||
|
||||
uint8_t CemiServerObject::propertyDescriptionCount()
|
||||
{
|
||||
return _propertyDescriptionCount;
|
||||
initializeProperties(sizeof(properties), properties);
|
||||
}
|
||||
|
||||
PropertyDescription* CemiServerObject::propertyDescriptions()
|
||||
{
|
||||
return _propertyDescriptions;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -8,17 +8,6 @@
|
||||
class CemiServerObject: public InterfaceObject
|
||||
{
|
||||
public:
|
||||
void readProperty(PropertyID id, uint16_t start, uint8_t& count, uint8_t* data) override;
|
||||
void writeProperty(PropertyID id, uint16_t start, uint8_t* data, uint8_t& count) override;
|
||||
uint8_t propertySize(PropertyID id) override;
|
||||
|
||||
protected:
|
||||
uint8_t propertyDescriptionCount() override;
|
||||
PropertyDescription* propertyDescriptions() override;
|
||||
private:
|
||||
// cEMI additional info types supported by this cEMI server: only 0x02 (RF Control Octet and Serial Number or DoA)
|
||||
uint8_t _addInfoTypesTable[1] = { 0x02 };
|
||||
uint8_t _commMode = 0x00;
|
||||
|
||||
CemiServerObject();
|
||||
};
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user