knx
ETS configurable knx-stack
bau57B0.cpp
Go to the documentation of this file.
1 #include "config.h"
2 #if MASK_VERSION == 0x57B0
3 
4 #include "bau57B0.h"
5 #include "bits.h"
6 #include <string.h>
7 #include <stdio.h>
8 
9 using namespace std;
10 
13  _ipParameters(_deviceObj, platform),
14  _dlLayer(_deviceObj, _ipParameters, _netLayer.getInterface(), _platform, (DataLinkLayerCallbacks*) this)
15 #ifdef USE_CEMI_SERVER
16  , _cemiServer(*this)
17 #endif
18 {
20 #ifdef USE_CEMI_SERVER
22  _cemiServer.dataLinkLayer(_dlLayer);
23  _dlLayer.cemiServer(_cemiServer);
24  _memory.addSaveRestore(&_cemiServerObject);
25 #endif
26  _memory.addSaveRestore(&_ipParameters);
27 
28  // Set Mask Version in Device Object depending on the BAU
29  _deviceObj.maskVersion(0x57B0);
30 
31  // Set which interface objects are available in the device object
32  // This differs from BAU to BAU with different medium types.
33  // See PID_IO_LIST
35  prop->write(1, (uint16_t) OT_DEVICE);
36  prop->write(2, (uint16_t) OT_ADDR_TABLE);
37  prop->write(3, (uint16_t) OT_ASSOC_TABLE);
38  prop->write(4, (uint16_t) OT_GRP_OBJ_TABLE);
39  prop->write(5, (uint16_t) OT_APPLICATION_PROG);
40  prop->write(6, (uint16_t) OT_IP_PARAMETER);
41 #if defined(USE_DATASECURE) && defined(USE_CEMI_SERVER)
42  prop->write(7, (uint16_t) OT_SECURITY);
43  prop->write(8, (uint16_t) OT_CEMI_SERVER);
44 #elif defined(USE_DATASECURE)
45  prop->write(7, (uint16_t) OT_SECURITY);
46 #elif defined(USE_CEMI_SERVER)
47  prop->write(7, (uint16_t) OT_CEMI_SERVER);
48 #endif
49 }
50 
52 {
53  switch (idx)
54  {
55  case 0:
56  return &_deviceObj;
57 
58  case 1:
59  return &_addrTable;
60 
61  case 2:
62  return &_assocTable;
63 
64  case 3:
65  return &_groupObjTable;
66 
67  case 4:
68  return &_appProgram;
69 
70  case 5: // would be app_program 2
71  return nullptr;
72 
73  case 6:
74  return &_ipParameters;
75 #if defined(USE_DATASECURE) && defined(USE_CEMI_SERVER)
76 
77  case 7:
78  return &_secIfObj;
79 
80  case 8:
81  return &_cemiServerObject;
82 #elif defined(USE_CEMI_SERVER)
83 
84  case 7:
85  return &_cemiServerObject;
86 #elif defined(USE_DATASECURE)
87 
88  case 7:
89  return &_secIfObj;
90 #endif
91 
92  default:
93  return nullptr;
94  }
95 }
96 
97 InterfaceObject* Bau57B0::getInterfaceObject(ObjectType objectType, uint16_t objectInstance)
98 {
99  // We do not use it right now.
100  // Required for coupler mode as there are multiple router objects for example
101  (void) objectInstance;
102 
103  switch (objectType)
104  {
105  case OT_DEVICE:
106  return &_deviceObj;
107 
108  case OT_ADDR_TABLE:
109  return &_addrTable;
110 
111  case OT_ASSOC_TABLE:
112  return &_assocTable;
113 
114  case OT_GRP_OBJ_TABLE:
115  return &_groupObjTable;
116 
117  case OT_APPLICATION_PROG:
118  return &_appProgram;
119 
120  case OT_IP_PARAMETER:
121  return &_ipParameters;
122 #ifdef USE_DATASECURE
123 
124  case OT_SECURITY:
125  return &_secIfObj;
126 #endif
127 #ifdef USE_CEMI_SERVER
128 
129  case OT_CEMI_SERVER:
130  return &_cemiServerObject;
131 #endif
132 
133  default:
134  return nullptr;
135  }
136 }
137 
138 void Bau57B0::doMasterReset(EraseCode eraseCode, uint8_t channel)
139 {
140  // Common SystemB objects
141  BauSystemB::doMasterReset(eraseCode, channel);
142 
143  _ipParameters.masterReset(eraseCode, channel);
144 }
145 
147 {
148  return _dlLayer.enabled();
149 }
150 
151 void Bau57B0::enabled(bool value)
152 {
153  _dlLayer.enabled(value);
154 }
155 
157 {
158  _dlLayer.loop();
160 #ifdef USE_CEMI_SERVER
161  _cemiServer.loop();
162 #endif
163 }
164 
166 {
167  return (IpDataLinkLayer*)&_dlLayer;
168 }
169 #endif
IpDataLinkLayer * getDataLinkLayer()
Definition: bau57B0.cpp:165
Bau57B0(Platform &platform)
Definition: bau57B0.cpp:11
bool enabled() override
Definition: bau57B0.cpp:146
InterfaceObject * getInterfaceObject(uint8_t idx)
void loop() override
Definition: bau57B0.cpp:156
void doMasterReset(EraseCode eraseCode, uint8_t channel) override
Definition: bau57B0.cpp:138
void loop() override
AssociationTableObject _assocTable
NetworkLayerDevice _netLayer
AddressTableObject _addrTable
GroupObjectTableObject _groupObjTable
SecurityInterfaceObject _secIfObj
virtual void doMasterReset(EraseCode eraseCode, uint8_t channel)
Memory _memory
Definition: bau_systemB.h:123
ApplicationProgramObject _appProgram
Definition: bau_systemB.h:125
DeviceObject _deviceObj
Definition: bau_systemB.h:124
void dataLinkLayer(DataLinkLayer &layer)
void setMediumTypeAsSupported(DptMedium dptMedium)
uint16_t maskVersion()
This class represents and interface object.
virtual void masterReset(EraseCode eraseCode, uint8_t channel)
Property * property(PropertyID id)
Gets property with PropertyID id if it exists and nullptr otherwise.
void addSaveRestore(SaveRestore *obj)
Definition: memory.cpp:209
NetworkLayerEntity & getInterface()
void dataLinkLayer(DataLinkLayer &layer)
virtual uint8_t write(uint16_t start, uint8_t count, const uint8_t *data)=0
ObjectType
Enum for the type of an interface object.
@ OT_CEMI_SERVER
cEMI Server Object
@ OT_APPLICATION_PROG
Application program object.
@ OT_GRP_OBJ_TABLE
Group Object Table Object.
@ OT_IP_PARAMETER
KNXnet/IP Parameter Object.
@ OT_ADDR_TABLE
Address table object.
@ OT_DEVICE
Device object.
@ OT_SECURITY
Security Interface Object.
@ OT_ASSOC_TABLE
Association table object.
EraseCode
Definition: knx_types.h:242
@ KNX_IP
Definition: knx_types.h:260
@ PID_IO_LIST
Definition: property.h:98