mirror of
https://github.com/thelsing/knx.git
synced 2025-01-02 00:06:43 +01:00
refactor cemi server object
This commit is contained in:
parent
1465cb558c
commit
82f463f965
@ -4,103 +4,30 @@
|
|||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include "cemi_server_object.h"
|
#include "cemi_server_object.h"
|
||||||
#include "bits.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)
|
uint16_t mediumType = 0;
|
||||||
{
|
#if MEDIUM_TYPE == 0
|
||||||
case PID_OBJECT_TYPE:
|
mediumType = 2; // TP1 supported
|
||||||
pushWord(OT_CEMI_SERVER, data);
|
#elif MEDIUM_TYPE == 2
|
||||||
break;
|
mediumType = 16; // RF supported
|
||||||
case PID_MEDIUM_TYPE: // PDT_BITSET16
|
#elif MEDIUM_TYPE == 5
|
||||||
#if MEDIUM_TYPE==0
|
mediumType = 32; // IP supported
|
||||||
pushWord(2, data); // TP1 supported
|
|
||||||
#elif MEDIUM_TYPE==2
|
|
||||||
pushWord(16, data); // RF supported
|
|
||||||
#elif MEDIUM_TYPE==5
|
|
||||||
pushWord(32, data); // IP supported
|
|
||||||
#endif
|
#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:
|
new DataProperty( PID_OBJECT_TYPE, false, PDT_UNSIGNED_INT, 1, ReadLv3 | WriteLv0, (uint16_t)OT_CEMI_SERVER ),
|
||||||
//_commMode = data[0]; // TODO: only Data Link Layer supported for now
|
new DataProperty( PID_MEDIUM_TYPE, false, PDT_BITSET16, 1, ReadLv3 | WriteLv0, mediumType),
|
||||||
// Property is also marked as read-only, normally it is read/write.
|
new DataProperty( PID_COMM_MODE, false, PDT_ENUM8, 1, ReadLv3 | WriteLv0, (uint16_t)0),
|
||||||
break;
|
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),
|
||||||
default:
|
// cEMI additional info types supported by this cEMI server: only 0x02 (RF Control Octet and Serial Number or DoA)
|
||||||
count = 0;
|
new DataProperty( PID_ADD_INFO_TYPES, false, PDT_ENUM8, 1, ReadLv3 | WriteLv0, (uint8_t)0x02)
|
||||||
break;
|
};
|
||||||
}
|
initializeProperties(sizeof(properties), properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
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 }
|
|
||||||
};
|
|
||||||
static uint8_t _propertyDescriptionCount = sizeof(_propertyDescriptions) / sizeof(PropertyDescription);
|
|
||||||
|
|
||||||
uint8_t CemiServerObject::propertyDescriptionCount()
|
|
||||||
{
|
|
||||||
return _propertyDescriptionCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
PropertyDescription* CemiServerObject::propertyDescriptions()
|
|
||||||
{
|
|
||||||
return _propertyDescriptions;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -8,17 +8,6 @@
|
|||||||
class CemiServerObject: public InterfaceObject
|
class CemiServerObject: public InterfaceObject
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void readProperty(PropertyID id, uint16_t start, uint8_t& count, uint8_t* data) override;
|
CemiServerObject();
|
||||||
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;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
Loading…
Reference in New Issue
Block a user