diff --git a/src/knx/address_table_object.h b/src/knx/address_table_object.h index c589843..28ce2bc 100644 --- a/src/knx/address_table_object.h +++ b/src/knx/address_table_object.h @@ -9,18 +9,18 @@ * See section 4.10 of @cite knx:3/5/1 for further details. * It implements realisation type 7 (see section 4.10.7 of @cite knx:3/5/1). */ -class AddressTableObject: public TableObject +class AddressTableObject : public TableObject { -public: + public: /** * The contructor. * * @param platform This parameter is only passed to the custructor of TableObject an not used by this class. */ AddressTableObject(Platform& platform); - void readProperty(PropertyID id, uint32_t start, uint32_t& count, uint8_t *data); - uint8_t *save(uint8_t *buffer); - uint8_t *restore(uint8_t *buffer); + void readProperty(PropertyID id, uint32_t start, uint32_t& count, uint8_t* data); + uint8_t* save(uint8_t* buffer); + uint8_t* restore(uint8_t* buffer); /** * returns the number of group addresses of the object. */ @@ -49,10 +49,12 @@ public: * @return true if the address table contains the group address, false otherwise */ bool contains(uint16_t groupAddress); -protected: + + protected: virtual void beforeStateChange(LoadState& newState); uint8_t propertyCount(); PropertyDescription* propertyDescriptions(); -private: - uint16_t* _groupAddresses; + + private: + uint16_t* _groupAddresses = 0; }; diff --git a/src/knx/apdu.h b/src/knx/apdu.h index 6322579..4b9fcf2 100644 --- a/src/knx/apdu.h +++ b/src/knx/apdu.h @@ -48,6 +48,6 @@ class APDU APDU(uint8_t* data, CemiFrame& frame); private: - uint8_t* _data; + uint8_t* _data = 0; CemiFrame& _frame; }; \ No newline at end of file diff --git a/src/knx/application_layer.h b/src/knx/application_layer.h index 46311a4..7af7262 100644 --- a/src/knx/application_layer.h +++ b/src/knx/application_layer.h @@ -146,6 +146,6 @@ class ApplicationLayer uint16_t _savedAsapResponse; AssociationTableObject& _assocTable; BusAccessUnit& _bau; - TransportLayer* _transportLayer; + TransportLayer* _transportLayer = 0; int32_t _connectedTsap; }; diff --git a/src/knx/application_program_object.h b/src/knx/application_program_object.h index 22d8b3a..e7ac83f 100644 --- a/src/knx/application_program_object.h +++ b/src/knx/application_program_object.h @@ -2,9 +2,9 @@ #include "table_object.h" -class ApplicationProgramObject: public TableObject +class ApplicationProgramObject : public TableObject { -public: + public: ApplicationProgramObject(Platform& platform); void readProperty(PropertyID id, uint32_t start, uint32_t& count, uint8_t* data); void writeProperty(PropertyID id, uint8_t start, uint8_t* data, uint8_t count); @@ -15,9 +15,11 @@ public: uint32_t getInt(uint32_t addr); uint8_t* save(uint8_t* buffer); uint8_t* restore(uint8_t* buffer); -protected: + + protected: uint8_t propertyCount(); PropertyDescription* propertyDescriptions(); -private: - uint8_t _programVersion[5]; + + private: + uint8_t _programVersion[5] = {0, 0, 0, 0, 0}; }; \ No newline at end of file diff --git a/src/knx/association_table_object.h b/src/knx/association_table_object.h index 80a133d..0021046 100644 --- a/src/knx/association_table_object.h +++ b/src/knx/association_table_object.h @@ -2,9 +2,9 @@ #include "table_object.h" -class AssociationTableObject: public TableObject +class AssociationTableObject : public TableObject { -public: + public: AssociationTableObject(Platform& platform); void readProperty(PropertyID id, uint32_t start, uint32_t& count, uint8_t* data); uint16_t entryCount(); @@ -13,10 +13,12 @@ public: uint8_t* restore(uint8_t* buffer); int32_t translateAsap(uint16_t asap); -protected: + + protected: void beforeStateChange(LoadState& newState); uint8_t propertyCount(); PropertyDescription* propertyDescriptions(); -private: - uint16_t* _tableData; + + private: + uint16_t* _tableData = 0; }; \ No newline at end of file diff --git a/src/knx/bau.h b/src/knx/bau.h index 6753064..a6cbd8d 100644 --- a/src/knx/bau.h +++ b/src/knx/bau.h @@ -4,107 +4,107 @@ class BusAccessUnit { -public: + public: virtual void groupValueReadLocalConfirm(AckType ack, uint16_t asap, Priority priority, HopCountType hopType, bool status); virtual void groupValueReadIndication(uint16_t asap, Priority priority, HopCountType hopType); virtual void groupValueReadResponseConfirm(AckType ack, uint16_t asap, Priority priority, HopCountType hopTtype, - uint8_t* data, uint8_t dataLength, bool status); + uint8_t* data, uint8_t dataLength, bool status); virtual void groupValueReadAppLayerConfirm(uint16_t asap, Priority priority, HopCountType hopType, - uint8_t* data, uint8_t dataLength); + uint8_t* data, uint8_t dataLength); virtual void groupValueWriteLocalConfirm(AckType ack, uint16_t asap, Priority priority, HopCountType hopType, - uint8_t* data, uint8_t dataLength, bool status); + uint8_t* data, uint8_t dataLength, bool status); virtual void groupValueWriteIndication(uint16_t asap, Priority priority, HopCountType hopType, - uint8_t* data, uint8_t dataLength); + uint8_t* data, uint8_t dataLength); virtual void individualAddressWriteLocalConfirm(AckType ack, HopCountType hopType, - uint16_t newaddress, bool status); + uint16_t newaddress, bool status); virtual void individualAddressWriteIndication(HopCountType hopType, uint16_t newaddress); virtual void individualAddressReadLocalConfirm(AckType ack, HopCountType hopType, bool status); virtual void individualAddressReadIndication(HopCountType hopType); virtual void individualAddressReadResponseConfirm(AckType ack, HopCountType hopType, bool status); virtual void individualAddressReadAppLayerConfirm(HopCountType hopType, uint16_t individualAddress); virtual void individualAddressSerialNumberReadLocalConfirm(AckType ack, HopCountType hopType, - uint8_t* serialNumber, bool status); + uint8_t* serialNumber, bool status); virtual void individualAddressSerialNumberReadIndication(HopCountType hopType, uint8_t* serialNumber); virtual void individualAddressSerialNumberReadResponseConfirm(AckType ack, HopCountType hopType, - uint8_t* serialNumber, uint16_t domainAddress, bool status); + uint8_t* serialNumber, uint16_t domainAddress, bool status); virtual void individualAddressSerialNumberReadAppLayerConfirm(HopCountType hopType, uint8_t* serialNumber, - uint16_t individualAddress, uint16_t domainAddress); + uint16_t individualAddress, uint16_t domainAddress); virtual void individualAddressSerialNumberWriteLocalConfirm(AckType ack, HopCountType hopType, uint8_t* serialNumber, - uint16_t newaddress, bool status); + uint16_t newaddress, bool status); virtual void individualAddressSerialNumberWriteIndication(HopCountType hopType, uint8_t* serialNumber, uint16_t newaddress); virtual void deviceDescriptorReadLocalConfirm(AckType ack, Priority priority, HopCountType hopType, uint16_t asap, - uint8_t descriptorType, bool status); + uint8_t descriptorType, bool status); virtual void deviceDescriptorReadIndication(Priority priority, HopCountType hopType, uint16_t asap, uint8_t descriptorType); virtual void deviceDescriptorReadResponseConfirm(AckType ack, Priority priority, HopCountType hopType, uint16_t asap, - uint8_t descriptor_type, uint8_t* device_descriptor, bool status); + uint8_t descriptor_type, uint8_t* device_descriptor, bool status); virtual void deviceDescriptorReadAppLayerConfirm(Priority priority, HopCountType hopType, uint16_t asap, - uint8_t descriptortype, uint8_t* deviceDescriptor); + uint8_t descriptortype, uint8_t* deviceDescriptor); virtual void restartRequestLocalConfirm(AckType ack, Priority priority, HopCountType hopType, uint16_t asap, bool status); virtual void restartRequestIndication(Priority priority, HopCountType hopType, uint16_t asap); virtual void propertyValueReadLocalConfirm(AckType ack, Priority priority, HopCountType hopType, uint16_t asap, - uint8_t objectIndex, uint8_t propertyId, uint8_t numberOfElements, uint16_t startIndex, bool status); + uint8_t objectIndex, uint8_t propertyId, uint8_t numberOfElements, uint16_t startIndex, bool status); virtual void propertyValueReadIndication(Priority priority, HopCountType hopType, uint16_t asap, uint8_t objectIndex, - uint8_t propertyId, uint8_t numberOfElements, uint16_t startIndex); + uint8_t propertyId, uint8_t numberOfElements, uint16_t startIndex); virtual void propertyValueReadResponseConfirm(AckType ack, Priority priority, HopCountType hopType, uint16_t asap, uint8_t objectIndex, - uint8_t propertyId, uint8_t numberOfElements, uint16_t startIndex, uint8_t* data, uint8_t length, bool status); + uint8_t propertyId, uint8_t numberOfElements, uint16_t startIndex, uint8_t* data, uint8_t length, bool status); virtual void propertyValueReadAppLayerConfirm(Priority priority, HopCountType hopType, uint16_t asap, uint8_t objectIndex, - uint8_t propertyId, uint8_t numberOfElements, uint16_t startIndex, uint8_t* data, uint8_t length); + uint8_t propertyId, uint8_t numberOfElements, uint16_t startIndex, uint8_t* data, uint8_t length); virtual void propertyValueWriteLocalConfirm(AckType ack, Priority priority, HopCountType hopType, uint16_t asap, uint8_t objectIndex, - uint8_t propertyId, uint8_t numberOfElements, uint16_t startIndex, uint8_t* data, uint8_t length, bool status); + uint8_t propertyId, uint8_t numberOfElements, uint16_t startIndex, uint8_t* data, uint8_t length, bool status); virtual void propertyValueWriteIndication(Priority priority, HopCountType hopType, uint16_t asap, uint8_t objectIndex, - uint8_t propertyId, uint8_t numberOfElements, uint16_t startIndex, uint8_t* data, uint8_t length); + uint8_t propertyId, uint8_t numberOfElements, uint16_t startIndex, uint8_t* data, uint8_t length); virtual void propertyDescriptionReadLocalConfirm(AckType ack, Priority priority, HopCountType hopType, uint16_t asap, - uint8_t objectIndex, uint8_t propertyId, uint8_t propertyIndex, bool status); + uint8_t objectIndex, uint8_t propertyId, uint8_t propertyIndex, bool status); virtual void propertyDescriptionReadIndication(Priority priority, HopCountType hopType, uint16_t asap, - uint8_t objectIndex, uint8_t propertyId, uint8_t propertyIndex); + uint8_t objectIndex, uint8_t propertyId, uint8_t propertyIndex); virtual void propertyDescriptionReadResponse(AckType ack, Priority priority, HopCountType hopType, uint16_t asap, - uint8_t objectIndex, uint8_t propertyId, uint8_t propertyIndex, bool writeEnable, uint8_t type, - uint16_t maxNumberOfElements, uint8_t access); + uint8_t objectIndex, uint8_t propertyId, uint8_t propertyIndex, bool writeEnable, uint8_t type, + uint16_t maxNumberOfElements, uint8_t access); virtual void propertyDescriptionReadResponseConfirm(AckType ack, Priority priority, HopCountType hopType, uint16_t asap, - uint8_t objectIndex, uint8_t propertyId, uint8_t propertyIndex, bool writeEnable, uint8_t type, - uint16_t maxNumberOfElements, uint8_t access, bool status); + uint8_t objectIndex, uint8_t propertyId, uint8_t propertyIndex, bool writeEnable, uint8_t type, + uint16_t maxNumberOfElements, uint8_t access, bool status); virtual void propertyDescriptionReadAppLayerConfirm(Priority priority, HopCountType hopType, uint16_t asap, - uint8_t objectIndex, uint8_t propertyId, uint8_t propertyIndex, bool writeEnable, uint8_t type, - uint16_t maxNumberOfElements, uint8_t access); + uint8_t objectIndex, uint8_t propertyId, uint8_t propertyIndex, bool writeEnable, uint8_t type, + uint16_t maxNumberOfElements, uint8_t access); virtual void memoryReadLocalConfirm(AckType ack, Priority priority, HopCountType hopType, uint16_t asap, uint8_t number, - uint16_t memoryAddress, bool status); + uint16_t memoryAddress, bool status); virtual void memoryReadIndication(Priority priority, HopCountType hopType, uint16_t asap, uint8_t number, uint16_t memoryAddress); virtual void memoryReadResponseConfirm(AckType ack, Priority priority, HopCountType hopType, uint16_t asap, uint8_t number, - uint16_t memoryAddress, uint8_t* data, bool status); + uint16_t memoryAddress, uint8_t* data, bool status); virtual void memoryReadAppLayerConfirm(Priority priority, HopCountType hopType, uint16_t asap, uint8_t number, - uint16_t memoryAddress, uint8_t* data); + uint16_t memoryAddress, uint8_t* data); virtual void memoryWriteLocalConfirm(AckType ack, Priority priority, HopCountType hopType, uint16_t asap, uint8_t number, - uint16_t memoryAddress, uint8_t* data, bool status); + uint16_t memoryAddress, uint8_t* data, bool status); virtual void memoryWriteIndication(Priority priority, HopCountType hopType, uint16_t asap, uint8_t number, - uint16_t memoryAddress, uint8_t* data); + uint16_t memoryAddress, uint8_t* data); virtual void userMemoryReadLocalConfirm(AckType ack, Priority priority, HopCountType hopType, uint16_t asap, uint8_t number, - uint32_t memoryAddress, bool status); + uint32_t memoryAddress, bool status); virtual void userMemoryReadIndication(Priority priority, HopCountType hopType, uint16_t asap, uint8_t number, - uint32_t memoryAddress); + uint32_t memoryAddress); virtual void userMemoryReadResponseConfirm(AckType ack, Priority priority, HopCountType hopType, uint16_t asap, uint8_t number, - uint32_t memoryAddress, uint8_t* memoryData, bool status); + uint32_t memoryAddress, uint8_t* memoryData, bool status); virtual void userMemoryReadAppLayerConfirm(Priority priority, HopCountType hopType, uint16_t asap, uint8_t number, - uint32_t memoryAddress, uint8_t* memoryData); + uint32_t memoryAddress, uint8_t* memoryData); virtual void userMemoryWriteLocalConfirm(AckType ack, Priority priority, HopCountType hopType, uint16_t asap, uint8_t number, - uint32_t memoryAddress, uint8_t* memoryData, bool status); + uint32_t memoryAddress, uint8_t* memoryData, bool status); virtual void userMemoryWriteIndication(Priority priority, HopCountType hopType, uint16_t asap, uint8_t number, - uint32_t memoryAddress, uint8_t* memoryData); + uint32_t memoryAddress, uint8_t* memoryData); virtual void userManufacturerInfoLocalConfirm(AckType ack, Priority priority, HopCountType hopType, uint16_t asap, bool status); virtual void userManufacturerInfoIndication(Priority priority, HopCountType hopType, uint16_t asap); virtual void userManufacturerInfoResponseConfirm(AckType ack, Priority priority, HopCountType hopType, uint16_t asap, - uint8_t* info, bool status); + uint8_t* info, bool status); virtual void userManufacturerInfoAppLayerConfirm(Priority priority, HopCountType hopType, uint16_t asap, - uint8_t* info); + uint8_t* info); virtual void authorizeLocalConfirm(AckType ack, Priority priority, HopCountType hopType, uint16_t asap, uint32_t key, bool status); virtual void authorizeIndication(Priority priority, HopCountType hopType, uint16_t asap, uint32_t key); virtual void authorizeResponseConfirm(AckType ack, Priority priority, HopCountType hopType, uint16_t asap, uint8_t level, - bool status); + bool status); virtual void authorizeAppLayerConfirm(Priority priority, HopCountType hopType, uint16_t asap, uint8_t level); virtual void keyWriteLocalConfirm(AckType ack, Priority priority, HopCountType hopType, uint16_t asap, uint8_t level, - uint32_t key, bool status); + uint32_t key, bool status); virtual void keyWriteIndication(Priority priority, HopCountType hopType, uint16_t asap, uint8_t level, - uint32_t key); + uint32_t key); virtual void keyWriteResponseConfirm(AckType ack, Priority priority, HopCountType hopType, uint16_t asap, uint8_t level, - bool status); + bool status); virtual void keyWriteAppLayerConfirm(Priority priority, HopCountType hopType, uint16_t asap, uint8_t level); }; diff --git a/src/knx/bau07B0.cpp b/src/knx/bau07B0.cpp index 6381b8e..435ba5e 100644 --- a/src/knx/bau07B0.cpp +++ b/src/knx/bau07B0.cpp @@ -2,37 +2,33 @@ #include #include - using namespace std; -Bau07B0::Bau07B0(Platform& platform): BauSystemB(platform), - _dlLayer(_deviceObj, _addrTable, _netLayer, _platform) +Bau07B0::Bau07B0(Platform& platform) + : BauSystemB(platform), + _dlLayer(_deviceObj, _addrTable, _netLayer, _platform) { _netLayer.dataLinkLayer(_dlLayer); - - uint8_t descriptor[] = { 0x07, 0xb0 }; - _descriptor[0] = descriptor[0]; - _descriptor[1] = descriptor[1]; } InterfaceObject* Bau07B0::getInterfaceObject(uint8_t idx) { switch (idx) { - case 0: - return &_deviceObj; - case 1: - return &_addrTable; - case 2: - return &_assocTable; - case 3: - return &_groupObjTable; - case 4: - return &_appProgram; - case 5: // would be app_program 2 - return nullptr; - default: - return nullptr; + case 0: + return &_deviceObj; + case 1: + return &_addrTable; + case 2: + return &_assocTable; + case 3: + return &_groupObjTable; + case 4: + return &_appProgram; + case 5: // would be app_program 2 + return nullptr; + default: + return nullptr; } } diff --git a/src/knx/bau07B0.h b/src/knx/bau07B0.h index 27588cd..84d8aba 100644 --- a/src/knx/bau07B0.h +++ b/src/knx/bau07B0.h @@ -3,15 +3,17 @@ #include "bau_systemB.h" #include "tpuart_data_link_layer.h" -class Bau07B0: public BauSystemB +class Bau07B0 : public BauSystemB { -public: + public: Bau07B0(Platform& platform); -protected: + + protected: InterfaceObject* getInterfaceObject(uint8_t idx); uint8_t* descriptor(); DataLinkLayer& dataLinkLayer(); -private: + + private: TpUartDataLinkLayer _dlLayer; - uint8_t _descriptor[2]; + uint8_t _descriptor[2] = {0x07, 0xb0}; }; \ No newline at end of file diff --git a/src/knx/bau57B0.cpp b/src/knx/bau57B0.cpp index c915959..c255934 100644 --- a/src/knx/bau57B0.cpp +++ b/src/knx/bau57B0.cpp @@ -4,38 +4,35 @@ using namespace std; -Bau57B0::Bau57B0(Platform& platform): BauSystemB(platform), - _ipParameters(_deviceObj, platform), - _dlLayer(_deviceObj, _addrTable, _ipParameters, _netLayer, _platform) +Bau57B0::Bau57B0(Platform& platform) + : BauSystemB(platform), + _ipParameters(_deviceObj, platform), + _dlLayer(_deviceObj, _addrTable, _ipParameters, _netLayer, _platform) { _netLayer.dataLinkLayer(_dlLayer); _memory.addSaveRestore(&_ipParameters); - - uint8_t descriptor[] = { 0x57, 0xb0 }; - _descriptor[0] = descriptor[0]; - _descriptor[1] = descriptor[1]; } InterfaceObject* Bau57B0::getInterfaceObject(uint8_t idx) { switch (idx) { - case 0: - return &_deviceObj; - case 1: - return &_addrTable; - case 2: - return &_assocTable; - case 3: - return &_groupObjTable; - case 4: - return &_appProgram; - case 5: // would be app_program 2 - return nullptr; - case 6: - return &_ipParameters; - default: - return nullptr; + case 0: + return &_deviceObj; + case 1: + return &_addrTable; + case 2: + return &_assocTable; + case 3: + return &_groupObjTable; + case 4: + return &_appProgram; + case 5: // would be app_program 2 + return nullptr; + case 6: + return &_ipParameters; + default: + return nullptr; } } diff --git a/src/knx/bau57B0.h b/src/knx/bau57B0.h index 59bfb15..297f4aa 100644 --- a/src/knx/bau57B0.h +++ b/src/knx/bau57B0.h @@ -4,16 +4,18 @@ #include "ip_parameter_object.h" #include "ip_data_link_layer.h" -class Bau57B0: public BauSystemB +class Bau57B0 : public BauSystemB { -public: + public: Bau57B0(Platform& platform); -protected: + + protected: InterfaceObject* getInterfaceObject(uint8_t idx); uint8_t* descriptor(); DataLinkLayer& dataLinkLayer(); -private: + + private: IpParameterObject _ipParameters; IpDataLinkLayer _dlLayer; - uint8_t _descriptor[2]; + uint8_t _descriptor[2] = {0x57, 0xb0}; }; \ No newline at end of file diff --git a/src/knx/bau_systemB.h b/src/knx/bau_systemB.h index d701b74..91a0741 100644 --- a/src/knx/bau_systemB.h +++ b/src/knx/bau_systemB.h @@ -13,9 +13,9 @@ #include "platform.h" #include "memory.h" -class BauSystemB: protected BusAccessUnit +class BauSystemB : protected BusAccessUnit { -public: + public: BauSystemB(Platform& platform); virtual void loop(); DeviceObject& deviceObject(); @@ -28,13 +28,14 @@ public: void writeMemory(); void addSaveRestore(SaveRestore* obj); void restartRequest(uint16_t asap); -protected: + + protected: virtual DataLinkLayer& dataLinkLayer() = 0; virtual uint8_t* descriptor() = 0; void memoryWriteIndication(Priority priority, HopCountType hopType, uint16_t asap, uint8_t number, - uint16_t memoryAddress, uint8_t* data) override; + uint16_t memoryAddress, uint8_t* data) override; void memoryReadIndication(Priority priority, HopCountType hopType, uint16_t asap, uint8_t number, - uint16_t memoryAddress) override; + uint16_t memoryAddress) override; void deviceDescriptorReadIndication(Priority priority, HopCountType hopType, uint16_t asap, uint8_t descriptorType) override; void restartRequestIndication(Priority priority, HopCountType hopType, uint16_t asap) override; void authorizeIndication(Priority priority, HopCountType hopType, uint16_t asap, uint32_t key) override; @@ -58,7 +59,6 @@ protected: void groupValueWriteIndication(uint16_t asap, Priority priority, HopCountType hopType, uint8_t* data, uint8_t dataLength) override; - virtual InterfaceObject* getInterfaceObject(uint8_t idx) = 0; void sendNextGroupTelegram(); void updateGroupObject(GroupObject& go, uint8_t* data, uint8_t length); diff --git a/src/knx/cemi_frame.h b/src/knx/cemi_frame.h index 8a2ed60..f8f69e6 100644 --- a/src/knx/cemi_frame.h +++ b/src/knx/cemi_frame.h @@ -15,18 +15,19 @@ class CemiFrame { friend class DataLinkLayer; -public: + + public: CemiFrame(uint8_t* data, uint16_t length); CemiFrame(uint8_t apduLength); CemiFrame(const CemiFrame& other); - CemiFrame& operator= (CemiFrame other); + CemiFrame& operator=(CemiFrame other); MessageCode messageCode() const; void messageCode(MessageCode value); uint16_t totalLenght() const; uint16_t telegramLengthtTP() const; void fillTelegramTP(uint8_t* data); - + FrameFormat frameType() const; void frameType(FrameFormat value); Repetition repetition() const; @@ -49,15 +50,16 @@ public: NPDU& npdu(); TPDU& tpdu(); APDU& apdu(); - + uint8_t calcCRC(uint8_t* buffer, uint16_t len); bool valid() const; -private: - uint8_t buffer[0xff + NPDU_LPDU_DIFF]; //only valid of add info is zero - uint8_t* _data; - uint8_t* _ctrl1; + + private: + uint8_t buffer[0xff + NPDU_LPDU_DIFF] = {0}; //only valid of add info is zero + uint8_t* _data = 0; + uint8_t* _ctrl1 = 0; NPDU _npdu; TPDU _tpdu; APDU _apdu; - uint16_t _length; // only set if created from byte array + uint16_t _length = 0; // only set if created from byte array }; \ No newline at end of file diff --git a/src/knx/data_link_layer.h b/src/knx/data_link_layer.h index 74a3b50..c1bd908 100644 --- a/src/knx/data_link_layer.h +++ b/src/knx/data_link_layer.h @@ -8,21 +8,22 @@ class DataLinkLayer { -public: - DataLinkLayer(DeviceObject& devObj, AddressTableObject& addrTab, NetworkLayer& layer, - Platform& platform); + public: + DataLinkLayer(DeviceObject& devObj, AddressTableObject& addrTab, NetworkLayer& layer, + Platform& platform); // from network layer - void dataRequest(AckType ack, AddressType addrType, uint16_t destinationAddr, FrameFormat format, - Priority priority, NPDU& npdu); + void dataRequest(AckType ack, AddressType addrType, uint16_t destinationAddr, FrameFormat format, + Priority priority, NPDU& npdu); void systemBroadcastRequest(AckType ack, FrameFormat format, Priority priority, NPDU& npdu); virtual void loop() = 0; virtual void enabled(bool value) = 0; virtual bool enabled() const = 0; -protected: + + protected: void frameRecieved(CemiFrame& frame); void dataConReceived(CemiFrame& frame, bool success); - bool sendTelegram(NPDU &npdu, AckType ack, uint16_t destinationAddr, AddressType addrType, FrameFormat format, Priority priority); + bool sendTelegram(NPDU& npdu, AckType ack, uint16_t destinationAddr, AddressType addrType, FrameFormat format, Priority priority); virtual bool sendFrame(CemiFrame& frame) = 0; uint8_t* frameData(CemiFrame& frame); DeviceObject& _deviceObject; diff --git a/src/knx/device_object.h b/src/knx/device_object.h index dcc594c..6d66133 100644 --- a/src/knx/device_object.h +++ b/src/knx/device_object.h @@ -39,13 +39,13 @@ protected: uint8_t propertyCount(); PropertyDescription* propertyDescriptions(); private: - uint8_t _deviceControl; - uint8_t _routingCount; - uint8_t _prgMode; - uint16_t _ownAddress; + uint8_t _deviceControl = 0; + uint8_t _routingCount = 0; + uint8_t _prgMode = 0; + uint16_t _ownAddress = 0; uint16_t _manufacturerId = 0xfa; //Default to KNXA - uint32_t _bauNumber; - char _orderNumber[10]; - uint8_t _hardwareType[6]; - uint16_t _version; + uint32_t _bauNumber = 0; + char _orderNumber[10] = ""; + uint8_t _hardwareType[6] = { 0, 0, 0, 0, 0, 0}; + uint16_t _version = 0; }; \ No newline at end of file diff --git a/src/knx/dptconvert.h b/src/knx/dptconvert.h index 98d7192..37df062 100644 --- a/src/knx/dptconvert.h +++ b/src/knx/dptconvert.h @@ -36,110 +36,110 @@ /** * Converts the KNX Payload given by the specific DPT and puts the value in the KNXValue struc */ -int KNX_Decode_Value(uint8_t *payload, int payload_length, const Dpt& datatype, KNXValue& value); +int KNX_Decode_Value(uint8_t* payload, int payload_length, const Dpt& datatype, KNXValue& value); /** * Converts the KNXValue struct to the KNX Payload as the specific DPT */ -int KNX_Encode_Value(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype); +int KNX_Encode_Value(const KNXValue& value, uint8_t* payload, int payload_length, const Dpt& datatype); //KNX to internal -int busValueToBinary(const uint8_t *payload, int payload_length, const Dpt& datatype, KNXValue& value); -int busValueToBinaryControl(const uint8_t *payload, int payload_length, const Dpt& datatype, KNXValue& value); -int busValueToStepControl(const uint8_t *payload, int payload_length, const Dpt& datatype, KNXValue& value); -int busValueToCharacter(const uint8_t *payload, int payload_length, const Dpt& datatype, KNXValue& value); -int busValueToUnsigned8(const uint8_t *payload, int payload_length, const Dpt& datatype, KNXValue& value); -int busValueToSigned8(const uint8_t *payload, int payload_length, const Dpt& datatype, KNXValue& value); -int busValueToStatusAndMode(const uint8_t *payload, int payload_length, const Dpt& datatype, KNXValue& value); -int busValueToUnsigned16(const uint8_t *payload, int payload_length, const Dpt& datatype, KNXValue& value); -int busValueToTimePeriod(const uint8_t *payload, int payload_length, const Dpt& datatype, KNXValue& value); -int busValueToSigned16(const uint8_t *payload, int payload_length, const Dpt& datatype, KNXValue& value); -int busValueToTimeDelta(const uint8_t *payload, int payload_length, const Dpt& datatype, KNXValue& value); -int busValueToFloat16(const uint8_t *payload, int payload_length, const Dpt& datatype, KNXValue& value); -int busValueToTime(const uint8_t *payload, int payload_length, const Dpt& datatype, KNXValue& value); -int busValueToDate(const uint8_t *payload, int payload_length, const Dpt& datatype, KNXValue& value); -int busValueToUnsigned32(const uint8_t *payload, int payload_length, const Dpt& datatype, KNXValue& value); -int busValueToSigned32(const uint8_t *payload, int payload_length, const Dpt& datatype, KNXValue& value); -int busValueToLongTimePeriod(const uint8_t *payload, int payload_length, const Dpt& datatype, KNXValue& value); -int busValueToFloat32(const uint8_t *payload, int payload_length, const Dpt& datatype, KNXValue& value); -int busValueToAccess(const uint8_t *payload, int payload_length, const Dpt& datatype, KNXValue& value); -int busValueToString(const uint8_t *payload, int payload_length, const Dpt& datatype, KNXValue& value); -int busValueToScene(const uint8_t *payload, int payload_length, const Dpt& datatype, KNXValue& value); -int busValueToSceneControl(const uint8_t *payload, int payload_length, const Dpt& datatype, KNXValue& value); -int busValueToSceneInfo(const uint8_t *payload, int payload_length, const Dpt& datatype, KNXValue& value); -int busValueToSceneConfig(const uint8_t *payload, int payload_length, const Dpt& datatype, KNXValue& value); -int busValueToDateTime(const uint8_t *payload, int payload_length, const Dpt& datatype, KNXValue& value); -int busValueToUnicode(const uint8_t *payload, int payload_length, const Dpt& datatype, KNXValue& value); -int busValueToSigned64(const uint8_t *payload, int payload_length, const Dpt& datatype, KNXValue& value); -int busValueToAlarmInfo(const uint8_t *payload, int payload_length, const Dpt& datatype, KNXValue& value); -int busValueToSerialNumber(const uint8_t *payload, int payload_length, const Dpt& datatype, KNXValue& value); -int busValueToVersion(const uint8_t *payload, int payload_length, const Dpt& datatype, KNXValue& value); -int busValueToScaling(const uint8_t *payload, int payload_length, const Dpt& datatype, KNXValue& value); -int busValueToTariff(const uint8_t *payload, int payload_length, const Dpt& datatype, KNXValue& value); -int busValueToLocale(const uint8_t *payload, int payload_length, const Dpt& datatype, KNXValue& value); -int busValueToRGB(const uint8_t *payload, int payload_length, const Dpt& datatype, KNXValue& value); -int busValueToFlaggedScaling(const uint8_t *payload, int payload_length, const Dpt& datatype, KNXValue& value); -int busValueToActiveEnergy(const uint8_t *payload, int payload_length, const Dpt& datatype, KNXValue& value); +int busValueToBinary(const uint8_t* payload, int payload_length, const Dpt& datatype, KNXValue& value); +int busValueToBinaryControl(const uint8_t* payload, int payload_length, const Dpt& datatype, KNXValue& value); +int busValueToStepControl(const uint8_t* payload, int payload_length, const Dpt& datatype, KNXValue& value); +int busValueToCharacter(const uint8_t* payload, int payload_length, const Dpt& datatype, KNXValue& value); +int busValueToUnsigned8(const uint8_t* payload, int payload_length, const Dpt& datatype, KNXValue& value); +int busValueToSigned8(const uint8_t* payload, int payload_length, const Dpt& datatype, KNXValue& value); +int busValueToStatusAndMode(const uint8_t* payload, int payload_length, const Dpt& datatype, KNXValue& value); +int busValueToUnsigned16(const uint8_t* payload, int payload_length, const Dpt& datatype, KNXValue& value); +int busValueToTimePeriod(const uint8_t* payload, int payload_length, const Dpt& datatype, KNXValue& value); +int busValueToSigned16(const uint8_t* payload, int payload_length, const Dpt& datatype, KNXValue& value); +int busValueToTimeDelta(const uint8_t* payload, int payload_length, const Dpt& datatype, KNXValue& value); +int busValueToFloat16(const uint8_t* payload, int payload_length, const Dpt& datatype, KNXValue& value); +int busValueToTime(const uint8_t* payload, int payload_length, const Dpt& datatype, KNXValue& value); +int busValueToDate(const uint8_t* payload, int payload_length, const Dpt& datatype, KNXValue& value); +int busValueToUnsigned32(const uint8_t* payload, int payload_length, const Dpt& datatype, KNXValue& value); +int busValueToSigned32(const uint8_t* payload, int payload_length, const Dpt& datatype, KNXValue& value); +int busValueToLongTimePeriod(const uint8_t* payload, int payload_length, const Dpt& datatype, KNXValue& value); +int busValueToFloat32(const uint8_t* payload, int payload_length, const Dpt& datatype, KNXValue& value); +int busValueToAccess(const uint8_t* payload, int payload_length, const Dpt& datatype, KNXValue& value); +int busValueToString(const uint8_t* payload, int payload_length, const Dpt& datatype, KNXValue& value); +int busValueToScene(const uint8_t* payload, int payload_length, const Dpt& datatype, KNXValue& value); +int busValueToSceneControl(const uint8_t* payload, int payload_length, const Dpt& datatype, KNXValue& value); +int busValueToSceneInfo(const uint8_t* payload, int payload_length, const Dpt& datatype, KNXValue& value); +int busValueToSceneConfig(const uint8_t* payload, int payload_length, const Dpt& datatype, KNXValue& value); +int busValueToDateTime(const uint8_t* payload, int payload_length, const Dpt& datatype, KNXValue& value); +int busValueToUnicode(const uint8_t* payload, int payload_length, const Dpt& datatype, KNXValue& value); +int busValueToSigned64(const uint8_t* payload, int payload_length, const Dpt& datatype, KNXValue& value); +int busValueToAlarmInfo(const uint8_t* payload, int payload_length, const Dpt& datatype, KNXValue& value); +int busValueToSerialNumber(const uint8_t* payload, int payload_length, const Dpt& datatype, KNXValue& value); +int busValueToVersion(const uint8_t* payload, int payload_length, const Dpt& datatype, KNXValue& value); +int busValueToScaling(const uint8_t* payload, int payload_length, const Dpt& datatype, KNXValue& value); +int busValueToTariff(const uint8_t* payload, int payload_length, const Dpt& datatype, KNXValue& value); +int busValueToLocale(const uint8_t* payload, int payload_length, const Dpt& datatype, KNXValue& value); +int busValueToRGB(const uint8_t* payload, int payload_length, const Dpt& datatype, KNXValue& value); +int busValueToFlaggedScaling(const uint8_t* payload, int payload_length, const Dpt& datatype, KNXValue& value); +int busValueToActiveEnergy(const uint8_t* payload, int payload_length, const Dpt& datatype, KNXValue& value); //Internal to KNX -int valueToBusValueBinary(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype); -int valueToBusValueBinaryControl(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype); -int valueToBusValueStepControl(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype); -int valueToBusValueCharacter(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype); -int valueToBusValueUnsigned8(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype); -int valueToBusValueSigned8(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype); -int valueToBusValueStatusAndMode(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype); -int valueToBusValueUnsigned16(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype); -int valueToBusValueTimePeriod(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype); -int valueToBusValueSigned16(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype); -int valueToBusValueTimeDelta(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype); -int valueToBusValueFloat16(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype); -int valueToBusValueTime(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype); -int valueToBusValueDate(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype); -int valueToBusValueUnsigned32(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype); -int valueToBusValueSigned32(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype); -int valueToBusValueLongTimePeriod(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype); -int valueToBusValueFloat32(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype); -int valueToBusValueAccess(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype); -int valueToBusValueString(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype); -int valueToBusValueScene(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype); -int valueToBusValueSceneControl(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype); -int valueToBusValueSceneInfo(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype); -int valueToBusValueSceneConfig(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype); -int valueToBusValueDateTime(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype); -int valueToBusValueUnicode(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype); -int valueToBusValueSigned64(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype); -int valueToBusValueAlarmInfo(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype); -int valueToBusValueSerialNumber(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype); -int valueToBusValueVersion(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype); -int valueToBusValueScaling(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype); -int valueToBusValueTariff(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype); -int valueToBusValueLocale(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype); -int valueToBusValueRGB(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype); -int valueToBusValueFlaggedScaling(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype); -int valueToBusValueActiveEnergy(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype); +int valueToBusValueBinary(const KNXValue& value, uint8_t* payload, int payload_length, const Dpt& datatype); +int valueToBusValueBinaryControl(const KNXValue& value, uint8_t* payload, int payload_length, const Dpt& datatype); +int valueToBusValueStepControl(const KNXValue& value, uint8_t* payload, int payload_length, const Dpt& datatype); +int valueToBusValueCharacter(const KNXValue& value, uint8_t* payload, int payload_length, const Dpt& datatype); +int valueToBusValueUnsigned8(const KNXValue& value, uint8_t* payload, int payload_length, const Dpt& datatype); +int valueToBusValueSigned8(const KNXValue& value, uint8_t* payload, int payload_length, const Dpt& datatype); +int valueToBusValueStatusAndMode(const KNXValue& value, uint8_t* payload, int payload_length, const Dpt& datatype); +int valueToBusValueUnsigned16(const KNXValue& value, uint8_t* payload, int payload_length, const Dpt& datatype); +int valueToBusValueTimePeriod(const KNXValue& value, uint8_t* payload, int payload_length, const Dpt& datatype); +int valueToBusValueSigned16(const KNXValue& value, uint8_t* payload, int payload_length, const Dpt& datatype); +int valueToBusValueTimeDelta(const KNXValue& value, uint8_t* payload, int payload_length, const Dpt& datatype); +int valueToBusValueFloat16(const KNXValue& value, uint8_t* payload, int payload_length, const Dpt& datatype); +int valueToBusValueTime(const KNXValue& value, uint8_t* payload, int payload_length, const Dpt& datatype); +int valueToBusValueDate(const KNXValue& value, uint8_t* payload, int payload_length, const Dpt& datatype); +int valueToBusValueUnsigned32(const KNXValue& value, uint8_t* payload, int payload_length, const Dpt& datatype); +int valueToBusValueSigned32(const KNXValue& value, uint8_t* payload, int payload_length, const Dpt& datatype); +int valueToBusValueLongTimePeriod(const KNXValue& value, uint8_t* payload, int payload_length, const Dpt& datatype); +int valueToBusValueFloat32(const KNXValue& value, uint8_t* payload, int payload_length, const Dpt& datatype); +int valueToBusValueAccess(const KNXValue& value, uint8_t* payload, int payload_length, const Dpt& datatype); +int valueToBusValueString(const KNXValue& value, uint8_t* payload, int payload_length, const Dpt& datatype); +int valueToBusValueScene(const KNXValue& value, uint8_t* payload, int payload_length, const Dpt& datatype); +int valueToBusValueSceneControl(const KNXValue& value, uint8_t* payload, int payload_length, const Dpt& datatype); +int valueToBusValueSceneInfo(const KNXValue& value, uint8_t* payload, int payload_length, const Dpt& datatype); +int valueToBusValueSceneConfig(const KNXValue& value, uint8_t* payload, int payload_length, const Dpt& datatype); +int valueToBusValueDateTime(const KNXValue& value, uint8_t* payload, int payload_length, const Dpt& datatype); +int valueToBusValueUnicode(const KNXValue& value, uint8_t* payload, int payload_length, const Dpt& datatype); +int valueToBusValueSigned64(const KNXValue& value, uint8_t* payload, int payload_length, const Dpt& datatype); +int valueToBusValueAlarmInfo(const KNXValue& value, uint8_t* payload, int payload_length, const Dpt& datatype); +int valueToBusValueSerialNumber(const KNXValue& value, uint8_t* payload, int payload_length, const Dpt& datatype); +int valueToBusValueVersion(const KNXValue& value, uint8_t* payload, int payload_length, const Dpt& datatype); +int valueToBusValueScaling(const KNXValue& value, uint8_t* payload, int payload_length, const Dpt& datatype); +int valueToBusValueTariff(const KNXValue& value, uint8_t* payload, int payload_length, const Dpt& datatype); +int valueToBusValueLocale(const KNXValue& value, uint8_t* payload, int payload_length, const Dpt& datatype); +int valueToBusValueRGB(const KNXValue& value, uint8_t* payload, int payload_length, const Dpt& datatype); +int valueToBusValueFlaggedScaling(const KNXValue& value, uint8_t* payload, int payload_length, const Dpt& datatype); +int valueToBusValueActiveEnergy(const KNXValue& value, uint8_t* payload, int payload_length, const Dpt& datatype); //Payload manipulation -bool bitFromPayload(const uint8_t *payload, int index); -uint8_t unsigned8FromPayload(const uint8_t *payload, int index); -int8_t signed8FromPayload(const uint8_t *payload, int index); -uint16_t unsigned16FromPayload(const uint8_t *payload, int index); -int16_t signed16FromPayload(const uint8_t *payload, int index); -uint32_t unsigned32FromPayload(const uint8_t *payload, int index); -int32_t signed32FromPayload(const uint8_t *payload, int index); -double float16FromPayload(const uint8_t *payload, int index); -float float32FromPayload(const uint8_t *payload, int index); -int64_t signed64FromPayload(const uint8_t *payload, int index); -uint8_t bcdFromPayload(const uint8_t *payload, int index); +bool bitFromPayload(const uint8_t* payload, int index); +uint8_t unsigned8FromPayload(const uint8_t* payload, int index); +int8_t signed8FromPayload(const uint8_t* payload, int index); +uint16_t unsigned16FromPayload(const uint8_t* payload, int index); +int16_t signed16FromPayload(const uint8_t* payload, int index); +uint32_t unsigned32FromPayload(const uint8_t* payload, int index); +int32_t signed32FromPayload(const uint8_t* payload, int index); +double float16FromPayload(const uint8_t* payload, int index); +float float32FromPayload(const uint8_t* payload, int index); +int64_t signed64FromPayload(const uint8_t* payload, int index); +uint8_t bcdFromPayload(const uint8_t* payload, int index); -void bitToPayload(uint8_t *payload, int payload_length, int index, bool value); -void unsigned8ToPayload(uint8_t *payload, int payload_length, int index, uint8_t value, uint8_t mask); //mask 0xFF -void signed8ToPayload(uint8_t *payload, int payload_length, int index, int8_t value, uint8_t mask); //mask 0xFF -void unsigned16ToPayload(uint8_t *payload, int payload_length, int index, uint16_t value, uint16_t mask); //mask 0xFFFF -void signed16ToPayload(uint8_t *payload, int payload_length, int index, int16_t value, uint16_t mask); //mask 0xFFFF -void unsigned32ToPayload(uint8_t *payload, int payload_length, int index, uint32_t value, uint32_t mask); //mask = 0xFFFFFFFF -void signed32ToPayload(uint8_t *payload, int payload_length, int index, int32_t value, uint32_t mask); //mask = 0xFFFFFFFF -void float16ToPayload(uint8_t *payload, int payload_length, int index, double value, uint16_t mask); //mask = 0xFFFF -void float32ToPayload(uint8_t *payload, int payload_length, int index, double value, uint32_t mask); //mask = 0xFFFFFFFF -void signed64ToPayload(uint8_t *payload, int payload_length, int index, int64_t value, uint64_t mask); //mask = UINT64_C(0xFFFFFFFFFFFFFFFF) -void bcdToPayload(uint8_t *payload, int payload_length, int index, uint8_t value); \ No newline at end of file +void bitToPayload(uint8_t* payload, int payload_length, int index, bool value); +void unsigned8ToPayload(uint8_t* payload, int payload_length, int index, uint8_t value, uint8_t mask); //mask 0xFF +void signed8ToPayload(uint8_t* payload, int payload_length, int index, int8_t value, uint8_t mask); //mask 0xFF +void unsigned16ToPayload(uint8_t* payload, int payload_length, int index, uint16_t value, uint16_t mask); //mask 0xFFFF +void signed16ToPayload(uint8_t* payload, int payload_length, int index, int16_t value, uint16_t mask); //mask 0xFFFF +void unsigned32ToPayload(uint8_t* payload, int payload_length, int index, uint32_t value, uint32_t mask); //mask = 0xFFFFFFFF +void signed32ToPayload(uint8_t* payload, int payload_length, int index, int32_t value, uint32_t mask); //mask = 0xFFFFFFFF +void float16ToPayload(uint8_t* payload, int payload_length, int index, double value, uint16_t mask); //mask = 0xFFFF +void float32ToPayload(uint8_t* payload, int payload_length, int index, double value, uint32_t mask); //mask = 0xFFFFFFFF +void signed64ToPayload(uint8_t* payload, int payload_length, int index, int64_t value, uint64_t mask); //mask = UINT64_C(0xFFFFFFFFFFFFFFFF) +void bcdToPayload(uint8_t* payload, int payload_length, int index, uint8_t value); \ No newline at end of file diff --git a/src/knx/group_object.h b/src/knx/group_object.h index 372d69e..0e71b96 100644 --- a/src/knx/group_object.h +++ b/src/knx/group_object.h @@ -9,7 +9,7 @@ class GroupObjectTableObject; enum ComFlag { - Updated = 0, //!< Group object was updated + Updated = 0, //!< Group object was updated ReadRequest = 1, //!< Read was requested but was not processed WriteRequest = 2, //!< Write was requested but was not processed Transmitting = 3, //!< Group Object is processed a the moment (read or write) @@ -19,12 +19,11 @@ enum ComFlag class GroupObject; - #ifdef __linux__ #include typedef std::function GroupObjectUpdatedHandler; #else -typedef void(*GroupObjectUpdatedHandler)(GroupObject& go); +typedef void (*GroupObjectUpdatedHandler)(GroupObject& go); #endif /** @@ -33,7 +32,8 @@ typedef void(*GroupObjectUpdatedHandler)(GroupObject& go); class GroupObject { friend class GroupObjectTableObject; -public: + + public: /** * The constructor. */ @@ -41,7 +41,7 @@ public: /** * The copy constructor. */ - GroupObject(const GroupObject& other); + GroupObject(const GroupObject& other); /** * The destructor. */ @@ -71,12 +71,12 @@ public: * Check if the communication flag (C) was set. (K-flag in german) */ bool communicationEnable(); - + /** * Get the priority of the group object. */ Priority priority(); - + /** * Return the current state of the group object. See ::ComFlag */ @@ -206,10 +206,10 @@ public: size_t asapValueSize(uint8_t code); GroupObjectUpdatedHandler _updateHandler; size_t goSize(); - uint16_t _asap; - ComFlag _commFlag; - uint8_t* _data; - uint8_t _dataLength; - GroupObjectTableObject* _table; + uint16_t _asap = 0; + ComFlag _commFlag = Ok; + uint8_t* _data = 0; + uint8_t _dataLength = 0; + GroupObjectTableObject* _table = 0; Dpt _datapointType; }; diff --git a/src/knx/group_object_table_object.h b/src/knx/group_object_table_object.h index 44d1057..bd9bdd3 100644 --- a/src/knx/group_object_table_object.h +++ b/src/knx/group_object_table_object.h @@ -3,11 +3,11 @@ #include "table_object.h" #include "group_object.h" -class GroupObjectTableObject: public TableObject +class GroupObjectTableObject : public TableObject { friend class GroupObject; -public: + public: GroupObjectTableObject(Platform& platform); virtual ~GroupObjectTableObject(); void readProperty(PropertyID id, uint32_t start, uint32_t& count, uint8_t* data); @@ -18,11 +18,13 @@ public: virtual uint8_t* save(uint8_t* buffer); virtual uint8_t* restore(uint8_t* buffer); -protected: + + protected: virtual void beforeStateChange(LoadState& newState); uint8_t propertyCount(); PropertyDescription* propertyDescriptions(); -private: + + private: void freeGroupObjects(); bool initGroupObjects(); uint16_t* _tableData = 0; diff --git a/src/knx/interface_object.h b/src/knx/interface_object.h index e1fcb72..1452eca 100644 --- a/src/knx/interface_object.h +++ b/src/knx/interface_object.h @@ -53,9 +53,9 @@ enum ObjectType /** * This class represents and interface object. See section 4 of @cite knx:3/4/1. */ -class InterfaceObject: public SaveRestore +class InterfaceObject : public SaveRestore { -public: + public: /** * Destructor */ @@ -112,9 +112,10 @@ public: * * @param[out] access the ::AccessLevel necessary to read/write the property. */ - + void readPropertyDescription(uint8_t& propertyId, uint8_t& propertyIndex, bool& writeEnable, uint8_t& type, uint16_t& numberOfElements, uint8_t& access); -protected: + + protected: /** * Returns the number of properties the interface object has. */ diff --git a/src/knx/ip_data_link_layer.h b/src/knx/ip_data_link_layer.h index 4ad86af..ddb1baa 100644 --- a/src/knx/ip_data_link_layer.h +++ b/src/knx/ip_data_link_layer.h @@ -4,17 +4,19 @@ #include "data_link_layer.h" #include "ip_parameter_object.h" -class IpDataLinkLayer: public DataLinkLayer +class IpDataLinkLayer : public DataLinkLayer { using DataLinkLayer::_deviceObject; -public: - IpDataLinkLayer(DeviceObject& devObj, AddressTableObject& addrTab, IpParameterObject& ipParam, NetworkLayer& layer, - Platform& platform); + + public: + IpDataLinkLayer(DeviceObject& devObj, AddressTableObject& addrTab, IpParameterObject& ipParam, NetworkLayer& layer, + Platform& platform); void loop(); void enabled(bool value); bool enabled() const; -private: + + private: bool _enabled = false; bool sendFrame(CemiFrame& frame); bool sendBytes(uint8_t* buffer, uint16_t length); diff --git a/src/knx/ip_parameter_object.h b/src/knx/ip_parameter_object.h index efd272b..4b23e34 100644 --- a/src/knx/ip_parameter_object.h +++ b/src/knx/ip_parameter_object.h @@ -4,9 +4,9 @@ #include "device_object.h" #include "platform.h" -class IpParameterObject: public InterfaceObject +class IpParameterObject : public InterfaceObject { -public: + public: IpParameterObject(DeviceObject& deviceObject, Platform& platform); void readProperty(PropertyID id, uint32_t start, uint32_t& count, uint8_t* data); void writeProperty(PropertyID id, uint8_t start, uint8_t* data, uint8_t count); @@ -17,10 +17,12 @@ public: uint32_t multicastAddress() const; uint8_t ttl() const { return _ttl; } -protected: + + protected: uint8_t propertyCount(); PropertyDescription* propertyDescriptions(); -private: + + private: uint16_t _projectInstallationId = 0; uint8_t _ipAssignmentMethod = 0; uint8_t _ipCapabilities = 0; @@ -29,7 +31,7 @@ private: uint32_t _defaultGateway = 0; uint32_t _multicastAddress = 0; uint8_t _ttl = 60; - char _friendlyName[30] = { 0 }; + char _friendlyName[30] = {0}; DeviceObject& _deviceObject; Platform& _platform; diff --git a/src/knx/memory.h b/src/knx/memory.h index f13ccae..b9831ec 100644 --- a/src/knx/memory.h +++ b/src/knx/memory.h @@ -18,7 +18,7 @@ public: private: Platform& _platform; bool _modified = false; - SaveRestore* _saveRestores[MAXSAVE]; + SaveRestore* _saveRestores[MAXSAVE] = {0}; int _saveCount = 0; uint8_t* _data = 0; }; diff --git a/src/knx/network_layer.h b/src/knx/network_layer.h index cc94b31..2386469 100644 --- a/src/knx/network_layer.h +++ b/src/knx/network_layer.h @@ -8,20 +8,20 @@ class DataLinkLayer; class NetworkLayer { -public: + public: NetworkLayer(TransportLayer& layer); - + void dataLinkLayer(DataLinkLayer& layer); uint8_t hopCount() const; void hopCount(uint8_t value); // from data link layer void dataIndication(AckType ack, AddressType addType, uint16_t destination, FrameFormat format, NPDU& npdu, - Priority priority, uint16_t source); + Priority priority, uint16_t source); void dataConfirm(AckType ack, AddressType addressType, uint16_t destination, FrameFormat format, Priority priority, - uint16_t source, NPDU& npdu, bool status); + uint16_t source, NPDU& npdu, bool status); void systemBroadcastIndication(AckType ack, FrameFormat format, NPDU& npdu, - Priority priority, uint16_t source); + Priority priority, uint16_t source); void systemBroadcastConfirm(AckType ack, FrameFormat format, Priority priority, uint16_t source, NPDU& npdu, bool status); // from transport layer @@ -30,9 +30,9 @@ public: void dataBroadcastRequest(AckType ack, HopCountType hopType, Priority priority, TPDU& tpdu); void dataSystemBroadcastRequest(AckType ack, HopCountType hopType, Priority priority, TPDU& tpdu); -private: - void sendDataRequest(TPDU &tpdu, HopCountType hopType, AckType ack, uint16_t destination, Priority priority, AddressType addrType); + private: + void sendDataRequest(TPDU& tpdu, HopCountType hopType, AckType ack, uint16_t destination, Priority priority, AddressType addrType); uint8_t _hopCount = 6; - DataLinkLayer* _dataLinkLayer; + DataLinkLayer* _dataLinkLayer = 0; TransportLayer& _transportLayer; }; diff --git a/src/knx/npdu.h b/src/knx/npdu.h index b069809..72f6164 100644 --- a/src/knx/npdu.h +++ b/src/knx/npdu.h @@ -22,6 +22,6 @@ class NPDU NPDU(uint8_t* data, CemiFrame& frame); private: - uint8_t* _data; + uint8_t* _data = 0; CemiFrame& _frame; }; \ No newline at end of file diff --git a/src/knx/save_restore.h b/src/knx/save_restore.h index 31bba83..f87091d 100644 --- a/src/knx/save_restore.h +++ b/src/knx/save_restore.h @@ -6,7 +6,7 @@ */ class SaveRestore { -public: + public: /** * This method is called when the object should save its state to the buffer. * diff --git a/src/knx/tpdu.h b/src/knx/tpdu.h index 0760d53..b3fe767 100644 --- a/src/knx/tpdu.h +++ b/src/knx/tpdu.h @@ -31,6 +31,6 @@ class TPDU TPDU(uint8_t* data, CemiFrame& frame); private: - uint8_t* _data; + uint8_t* _data = 0; CemiFrame& _frame; }; diff --git a/src/linux_platform.h b/src/linux_platform.h index 404325b..4881d8a 100644 --- a/src/linux_platform.h +++ b/src/linux_platform.h @@ -51,15 +51,15 @@ public: void cmdlineArgs(int argc, char** argv); private: - uint32_t _multicastAddr; - uint16_t _port; + uint32_t _multicastAddr = -1; + uint16_t _port = -1; int _socketFd = -1; void doMemoryMapping(); - uint8_t* _mappedFile; + uint8_t* _mappedFile = 0; int _fd = -1; uint8_t* _currentMaxMem = 0; std::string _flashFilePath = "flash.bin"; - char** _args; + char** _args = 0; }; #endif \ No newline at end of file