knx
ETS configurable knx-stack
interface_object.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <stddef.h>
4 #include "property.h"
5 #include "save_restore.h"
6 #include "knx_types.h"
7 #include "bits.h"
8 
11 {
13  OT_DEVICE = 0,
14 
17 
20 
23 
26 
29 
31  OT_ROUTER = 6,
32 
35 
38 
41 
44 
47 
50 
53 
56 
59 
61  OT_DUMMY = 0xFFFF
62 };
63 
68 {
69  public:
73  virtual ~InterfaceObject();
81  virtual void readPropertyLength(PropertyID id, uint16_t& length);
94  virtual void readProperty(PropertyID id, uint16_t start, uint8_t& count, uint8_t* data);
108  virtual void writeProperty(PropertyID id, uint16_t start, uint8_t* data, uint8_t& count);
116  virtual uint8_t propertySize(PropertyID id);
130  virtual void command(PropertyID id, uint8_t* data, uint8_t length, uint8_t* resultData, uint8_t& resultLength);
144  virtual void state(PropertyID id, uint8_t* data, uint8_t length, uint8_t* resultData, uint8_t& resultLength);
163  void readPropertyDescription(uint8_t& propertyId, uint8_t& propertyIndex, bool& writeEnable, uint8_t& type, uint16_t& numberOfElements, uint8_t& access);
164 
165  // every interface object shall implement this
166  // However, for the time being we provide an empty default implementation
167  virtual void masterReset(EraseCode eraseCode, uint8_t channel);
168 
173 
174  template <typename T>
176  {
177  const Property* prop = property(id);
178 
179  T value = 0;
180  prop->read(value);
181  return value;
182  }
183 
184  template <typename T>
185  void propertyValue(PropertyID id, T value)
186  {
187  Property* prop = property(id);
188  prop->write(value);
189  }
190 
191  const uint8_t* propertyData(PropertyID id);
192  const uint8_t* propertyData(PropertyID id, uint16_t elementIndex);
196  const Property* property(PropertyID id) const;
197 
198  uint8_t* save(uint8_t* buffer) override;
199  const uint8_t* restore(const uint8_t* buffer) override;
200  uint16_t saveSize() override;
201 
202  protected:
206  virtual void initializeProperties(size_t propertiesSize, Property** properties);
207 
208  Property** _properties = nullptr;
209  uint8_t _propertyCount = 0;
210 };
This class represents and interface object.
uint8_t * save(uint8_t *buffer) override
This method is called when the object should save its state to the buffer.
const uint8_t * propertyData(PropertyID id)
Property ** _properties
const uint8_t * restore(const uint8_t *buffer) override
This method is called when the object should restore its state from the buffer.
void readPropertyDescription(uint8_t &propertyId, uint8_t &propertyIndex, bool &writeEnable, uint8_t &type, uint16_t &numberOfElements, uint8_t &access)
Read the Description of a property of the interface object.
virtual void masterReset(EraseCode eraseCode, uint8_t channel)
virtual void command(PropertyID id, uint8_t *data, uint8_t length, uint8_t *resultData, uint8_t &resultLength)
Call command of a function property of the interface object.
virtual ~InterfaceObject()
Destructor.
virtual void writeProperty(PropertyID id, uint16_t start, uint8_t *data, uint8_t &count)
Write property of the interface object.
void propertyValue(PropertyID id, T value)
virtual uint8_t propertySize(PropertyID id)
Gets the size of of property in bytes.
virtual void readProperty(PropertyID id, uint16_t start, uint8_t &count, uint8_t *data)
Read a property of the interface object.
virtual void state(PropertyID id, uint8_t *data, uint8_t length, uint8_t *resultData, uint8_t &resultLength)
Get state of a function property of the interface object.
virtual void readPropertyLength(PropertyID id, uint16_t &length)
Read length of a property of the interface object.
virtual void initializeProperties(size_t propertiesSize, Property **properties)
Intializes the Property-array the the supplied values.
uint16_t saveSize() override
T propertyValue(PropertyID id)
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
Interface for classes that can save and restore data from a buffer.
Definition: save_restore.h:8
ObjectType
Enum for the type of an interface object.
@ OT_FILE_SERVER
File Server Object.
@ OT_INTERFACE_PROG
Interface program object.
@ OT_RESERVED
Reserved.
@ OT_RF_MEDIUM
RF Medium Object.
@ OT_CEMI_SERVER
cEMI Server Object
@ OT_APPLICATION_PROG
Application program object.
@ OT_LTE_ADDR_ROUTING_TABLE
LTE Address Routing Table Object.
@ OT_GRP_OBJ_TABLE
Group Object Table Object.
@ OT_POLLING_MASTER
Polling Master.
@ OT_OJB_ASSOC_TABLE
KNX - Object Associationtable.
@ OT_IP_PARAMETER
KNXnet/IP Parameter Object.
@ OT_ADDR_TABLE
Address table object.
@ OT_DEVICE
Device object.
@ OT_DUMMY
Dummy so this enum is 16bit.
@ OT_SECURITY
Security Interface Object.
@ OT_ROUTER
Router Object.
@ OT_ASSOC_TABLE
Association table object.
EraseCode
Definition: knx_types.h:242
PropertyID
Definition: property.h:70