knx
ETS configurable knx-stack
cemi_server_object.cpp
Go to the documentation of this file.
1 #include "config.h"
2 #ifdef USE_CEMI_SERVER
3 
4 #include <cstring>
5 #include "cemi_server_object.h"
6 #include "bits.h"
7 #include "data_property.h"
8 
10 {
11  Property* properties[] =
12  {
14  new DataProperty( PID_MEDIUM_TYPE, false, PDT_BITSET16, 1, ReadLv3 | WriteLv0, (uint16_t)0),
15  new DataProperty( PID_COMM_MODE, false, PDT_ENUM8, 1, ReadLv3 | WriteLv0, (uint16_t)0),
16  new DataProperty( PID_COMM_MODES_SUPPORTED, false, PDT_BITSET16, 1, ReadLv3 | WriteLv0, (uint16_t)0x100),
17  new DataProperty( PID_MEDIUM_AVAILABILITY, false, PDT_BITSET16, 1, ReadLv3 | WriteLv0, (uint16_t)0),
18  // cEMI additional info types supported by this cEMI server: only 0x02 (RF Control Octet and Serial Number or DoA)
19  new DataProperty( PID_ADD_INFO_TYPES, false, PDT_ENUM8, 1, ReadLv3 | WriteLv0, (uint8_t)0x02)
20  };
21  initializeProperties(sizeof(properties), properties);
22 }
23 
25 {
26  uint16_t mediaTypesSupported;
27  property(PID_MEDIUM_TYPE)->read(mediaTypesSupported);
28 
29  switch (dptMedium)
30  {
31  case DptMedium::KNX_IP:
32  mediaTypesSupported |= 1 << 1;
33  break;
34 
35  case DptMedium::KNX_RF:
36  mediaTypesSupported |= 1 << 4;
37  break;
38 
39  case DptMedium::KNX_TP1:
40  mediaTypesSupported |= 1 << 5;
41  break;
42 
44  mediaTypesSupported |= 1 << 2;
45  break;
46  }
47 
48  property(PID_MEDIUM_TYPE)->write(mediaTypesSupported);
49  // We also set the medium as available too
50  property(PID_MEDIUM_AVAILABILITY)->write(mediaTypesSupported);
51 }
52 
54 {
55  property(PID_MEDIUM_TYPE)->write((uint16_t) 0);
56  // We also set the medium as not available too
57  property(PID_MEDIUM_AVAILABILITY)->write((uint16_t) 0);
58 }
59 
60 #endif
61 
void setMediumTypeAsSupported(DptMedium dptMedium)
virtual void initializeProperties(size_t propertiesSize, Property **properties)
Intializes the Property-array the the supplied values.
Property * property(PropertyID id)
Gets property with PropertyID id if it exists and nullptr otherwise.
virtual uint8_t read(uint16_t start, uint8_t count, uint8_t *data) const =0
virtual uint8_t write(uint16_t start, uint8_t count, const uint8_t *data)=0
@ OT_CEMI_SERVER
cEMI Server Object
DptMedium
Definition: knx_types.h:254
@ KNX_IP
Definition: knx_types.h:260
@ KNX_TP1
Definition: knx_types.h:257
@ KNX_RF
Definition: knx_types.h:259
@ KNX_PL110
Definition: knx_types.h:258
@ PID_ADD_INFO_TYPES
Definition: property.h:149
@ PID_COMM_MODES_SUPPORTED
Definition: property.h:159
@ PID_OBJECT_TYPE
Interface Object Type independent Properties.
Definition: property.h:72
@ PID_MEDIUM_TYPE
cEMI Server Object
Definition: property.h:146
@ PID_COMM_MODE
Definition: property.h:147
@ PID_MEDIUM_AVAILABILITY
Definition: property.h:148
@ PDT_BITSET16
length: 3
Definition: property.h:60
@ PDT_ENUM8
length: 3
Definition: property.h:61
@ PDT_UNSIGNED_INT
length: 2
Definition: property.h:22
@ WriteLv0
Definition: property.h:247
@ ReadLv3
Definition: property.h:246