mirror of
https://github.com/thelsing/knx.git
synced 2025-01-21 00:05:43 +01:00
c++isfy the datapoint conversion code (untested)
This commit is contained in:
parent
d58483530d
commit
d54369434a
File diff suppressed because it is too large
Load Diff
@ -31,10 +31,11 @@
|
|||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
|
|
||||||
class KNXDatatype
|
class Dpt
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
KNXDatatype(short mainGroup, short subGroup, short index)
|
Dpt() {}
|
||||||
|
Dpt(short mainGroup, short subGroup, short index)
|
||||||
{
|
{
|
||||||
this->mainGroup = mainGroup;
|
this->mainGroup = mainGroup;
|
||||||
this->subGroup = subGroup;
|
this->subGroup = subGroup;
|
||||||
@ -43,119 +44,153 @@ class KNXDatatype
|
|||||||
unsigned short mainGroup;
|
unsigned short mainGroup;
|
||||||
unsigned short subGroup;
|
unsigned short subGroup;
|
||||||
unsigned short index;
|
unsigned short index;
|
||||||
|
bool operator==(const Dpt& other) const
|
||||||
|
{
|
||||||
|
return other.mainGroup == mainGroup && other.subGroup == subGroup && other.index == index;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator!=(const Dpt& other) const
|
||||||
|
{
|
||||||
|
return !(other == *this);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct
|
class KNXValue
|
||||||
{
|
{
|
||||||
uint8_t bValue;
|
public:
|
||||||
uint8_t cValue;
|
KNXValue() {}
|
||||||
uint16_t sValue;
|
KNXValue(bool value) { _value.boolValue = value; }
|
||||||
uint32_t iValue;
|
KNXValue(uint8_t value) { _value.ucharValue = value; }
|
||||||
uint64_t uiValue;
|
KNXValue(uint16_t value) { _value.ushortValue = value; }
|
||||||
double dValue;
|
KNXValue(uint32_t value) { _value.uintValue = value; }
|
||||||
char *strValue;
|
KNXValue(uint64_t value) { _value.ulongValue = value; }
|
||||||
struct tm tValue;
|
KNXValue(int8_t value) { _value.charValue = value; }
|
||||||
} KNXValue;
|
KNXValue(int16_t value) { _value.shortValue = value; }
|
||||||
|
KNXValue(int32_t value) { _value.intValue = value; }
|
||||||
|
KNXValue(int64_t value) { _value.longValue = value; }
|
||||||
|
KNXValue(double value) { _value.doubleValue = value; }
|
||||||
|
KNXValue(char* value) { _value.stringValue = value; }
|
||||||
|
KNXValue(struct tm value) { _value.timeValue = value; }
|
||||||
|
|
||||||
#define KNX_ASSUME_KNX_VALUE(x, y) \
|
operator bool() const { return _value.boolValue; }
|
||||||
x.bValue = (unsigned char)y; \
|
operator uint8_t() const { return _value.ucharValue; }
|
||||||
x.iValue = (uint32_t)y; \
|
operator uint16_t() const { return _value.ushortValue; }
|
||||||
x.cValue = (unsigned char)y; \
|
operator uint32_t() const { return _value.uintValue; }
|
||||||
x.sValue = (unsigned short)y; \
|
operator uint64_t() const { return _value.ulongValue; }
|
||||||
x.uiValue = (uint64_t)y; \
|
operator int8_t() const { return _value.charValue; }
|
||||||
x.dValue = (double)y;
|
operator int16_t() const { return _value.shortValue; }
|
||||||
#define KNX_ASSUME_STR_VALUE(value, y) \
|
operator int32_t() const { return _value.intValue; }
|
||||||
value.strValue = (char *)malloc(strlen(y)); \
|
operator int64_t() const { return _value.longValue; }
|
||||||
strncpy(value.strValue, y, strlen(y));
|
operator double() const { return _value.doubleValue; }
|
||||||
|
operator char*() const { return _value.stringValue; }
|
||||||
|
operator struct tm() const { return _value.timeValue; }
|
||||||
|
private:
|
||||||
|
union Value
|
||||||
|
{
|
||||||
|
struct tm timeValue;
|
||||||
|
char* stringValue;
|
||||||
|
int8_t charValue;
|
||||||
|
int16_t shortValue;
|
||||||
|
int32_t intValue;
|
||||||
|
int64_t longValue;
|
||||||
|
uint8_t ucharValue;
|
||||||
|
uint16_t ushortValue;
|
||||||
|
uint32_t uintValue;
|
||||||
|
uint64_t ulongValue;
|
||||||
|
double doubleValue;
|
||||||
|
bool boolValue;
|
||||||
|
};
|
||||||
|
Value _value;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts the KNX Payload given by the specific DPT and puts the value in the KNXValue struc
|
* 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 KNXDatatype& 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
|
* Converts the KNXValue struct to the KNX Payload as the specific DPT
|
||||||
*/
|
*/
|
||||||
int KNX_Encode_Value(KNXValue& value, uint8_t *payload, int payload_length, const KNXDatatype& datatype);
|
int KNX_Encode_Value(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype);
|
||||||
|
|
||||||
//KNX to internal
|
//KNX to internal
|
||||||
int busValueToBinary(const uint8_t *payload, int payload_length, const KNXDatatype& 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 KNXDatatype& 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 KNXDatatype& 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 KNXDatatype& 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 KNXDatatype& 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 KNXDatatype& 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 KNXDatatype& 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 KNXDatatype& 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 KNXDatatype& 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 KNXDatatype& 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 KNXDatatype& 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 KNXDatatype& 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 KNXDatatype& 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 KNXDatatype& 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 KNXDatatype& 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 KNXDatatype& 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 KNXDatatype& 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 KNXDatatype& 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 KNXDatatype& 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 KNXDatatype& 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 KNXDatatype& 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 KNXDatatype& 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 KNXDatatype& 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 KNXDatatype& 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 KNXDatatype& 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 KNXDatatype& 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 KNXDatatype& 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 KNXDatatype& 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 KNXDatatype& 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 KNXDatatype& 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 KNXDatatype& 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 KNXDatatype& 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 KNXDatatype& 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 KNXDatatype& 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 KNXDatatype& 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 KNXDatatype& datatype, KNXValue& value);
|
int busValueToActiveEnergy(const uint8_t *payload, int payload_length, const Dpt& datatype, KNXValue& value);
|
||||||
|
|
||||||
//Internal to KNX
|
//Internal to KNX
|
||||||
int valueToBusValueBinary(KNXValue& value, uint8_t *payload, int payload_length, const KNXDatatype& datatype);
|
int valueToBusValueBinary(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype);
|
||||||
int valueToBusValueBinaryControl(KNXValue& value, uint8_t *payload, int payload_length, const KNXDatatype& datatype);
|
int valueToBusValueBinaryControl(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype);
|
||||||
int valueToBusValueStepControl(KNXValue& value, uint8_t *payload, int payload_length, const KNXDatatype& datatype);
|
int valueToBusValueStepControl(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype);
|
||||||
int valueToBusValueCharacter(KNXValue& value, uint8_t *payload, int payload_length, const KNXDatatype& datatype);
|
int valueToBusValueCharacter(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype);
|
||||||
int valueToBusValueUnsigned8(KNXValue& value, uint8_t *payload, int payload_length, const KNXDatatype& datatype);
|
int valueToBusValueUnsigned8(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype);
|
||||||
int valueToBusValueSigned8(KNXValue& value, uint8_t *payload, int payload_length, const KNXDatatype& datatype);
|
int valueToBusValueSigned8(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype);
|
||||||
int valueToBusValueStatusAndMode(KNXValue& value, uint8_t *payload, int payload_length, const KNXDatatype& datatype);
|
int valueToBusValueStatusAndMode(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype);
|
||||||
int valueToBusValueUnsigned16(KNXValue& value, uint8_t *payload, int payload_length, const KNXDatatype& datatype);
|
int valueToBusValueUnsigned16(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype);
|
||||||
int valueToBusValueTimePeriod(KNXValue& value, uint8_t *payload, int payload_length, const KNXDatatype& datatype);
|
int valueToBusValueTimePeriod(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype);
|
||||||
int valueToBusValueSigned16(KNXValue& value, uint8_t *payload, int payload_length, const KNXDatatype& datatype);
|
int valueToBusValueSigned16(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype);
|
||||||
int valueToBusValueTimeDelta(KNXValue& value, uint8_t *payload, int payload_length, const KNXDatatype& datatype);
|
int valueToBusValueTimeDelta(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype);
|
||||||
int valueToBusValueFloat16(KNXValue& value, uint8_t *payload, int payload_length, const KNXDatatype& datatype);
|
int valueToBusValueFloat16(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype);
|
||||||
int valueToBusValueTime(KNXValue& value, uint8_t *payload, int payload_length, const KNXDatatype& datatype);
|
int valueToBusValueTime(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype);
|
||||||
int valueToBusValueDate(KNXValue& value, uint8_t *payload, int payload_length, const KNXDatatype& datatype);
|
int valueToBusValueDate(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype);
|
||||||
int valueToBusValueUnsigned32(KNXValue& value, uint8_t *payload, int payload_length, const KNXDatatype& datatype);
|
int valueToBusValueUnsigned32(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype);
|
||||||
int valueToBusValueSigned32(KNXValue& value, uint8_t *payload, int payload_length, const KNXDatatype& datatype);
|
int valueToBusValueSigned32(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype);
|
||||||
int valueToBusValueLongTimePeriod(KNXValue& value, uint8_t *payload, int payload_length, const KNXDatatype& datatype);
|
int valueToBusValueLongTimePeriod(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype);
|
||||||
int valueToBusValueFloat32(KNXValue& value, uint8_t *payload, int payload_length, const KNXDatatype& datatype);
|
int valueToBusValueFloat32(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype);
|
||||||
int valueToBusValueAccess(KNXValue& value, uint8_t *payload, int payload_length, const KNXDatatype& datatype);
|
int valueToBusValueAccess(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype);
|
||||||
int valueToBusValueString(KNXValue& value, uint8_t *payload, int payload_length, const KNXDatatype& datatype);
|
int valueToBusValueString(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype);
|
||||||
int valueToBusValueScene(KNXValue& value, uint8_t *payload, int payload_length, const KNXDatatype& datatype);
|
int valueToBusValueScene(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype);
|
||||||
int valueToBusValueSceneControl(KNXValue& value, uint8_t *payload, int payload_length, const KNXDatatype& datatype);
|
int valueToBusValueSceneControl(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype);
|
||||||
int valueToBusValueSceneInfo(KNXValue& value, uint8_t *payload, int payload_length, const KNXDatatype& datatype);
|
int valueToBusValueSceneInfo(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype);
|
||||||
int valueToBusValueSceneConfig(KNXValue& value, uint8_t *payload, int payload_length, const KNXDatatype& datatype);
|
int valueToBusValueSceneConfig(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype);
|
||||||
int valueToBusValueDateTime(KNXValue& value, uint8_t *payload, int payload_length, const KNXDatatype& datatype);
|
int valueToBusValueDateTime(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype);
|
||||||
int valueToBusValueUnicode(KNXValue& value, uint8_t *payload, int payload_length, const KNXDatatype& datatype);
|
int valueToBusValueUnicode(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype);
|
||||||
int valueToBusValueSigned64(KNXValue& value, uint8_t *payload, int payload_length, const KNXDatatype& datatype);
|
int valueToBusValueSigned64(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype);
|
||||||
int valueToBusValueAlarmInfo(KNXValue& value, uint8_t *payload, int payload_length, const KNXDatatype& datatype);
|
int valueToBusValueAlarmInfo(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype);
|
||||||
int valueToBusValueSerialNumber(KNXValue& value, uint8_t *payload, int payload_length, const KNXDatatype& datatype);
|
int valueToBusValueSerialNumber(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype);
|
||||||
int valueToBusValueVersion(KNXValue& value, uint8_t *payload, int payload_length, const KNXDatatype& datatype);
|
int valueToBusValueVersion(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype);
|
||||||
int valueToBusValueScaling(KNXValue& value, uint8_t *payload, int payload_length, const KNXDatatype& datatype);
|
int valueToBusValueScaling(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype);
|
||||||
int valueToBusValueTariff(KNXValue& value, uint8_t *payload, int payload_length, const KNXDatatype& datatype);
|
int valueToBusValueTariff(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype);
|
||||||
int valueToBusValueLocale(KNXValue& value, uint8_t *payload, int payload_length, const KNXDatatype& datatype);
|
int valueToBusValueLocale(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype);
|
||||||
int valueToBusValueRGB(KNXValue& value, uint8_t *payload, int payload_length, const KNXDatatype& datatype);
|
int valueToBusValueRGB(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype);
|
||||||
int valueToBusValueFlaggedScaling(KNXValue& value, uint8_t *payload, int payload_length, const KNXDatatype& datatype);
|
int valueToBusValueFlaggedScaling(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype);
|
||||||
int valueToBusValueActiveEnergy(KNXValue& value, uint8_t *payload, int payload_length, const KNXDatatype& datatype);
|
int valueToBusValueActiveEnergy(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype);
|
||||||
|
|
||||||
//Payload manipulation
|
//Payload manipulation
|
||||||
int bitFromPayload(const uint8_t *payload, int index);
|
bool bitFromPayload(const uint8_t *payload, int index);
|
||||||
uint8_t unsigned8FromPayload(const uint8_t *payload, int index);
|
uint8_t unsigned8FromPayload(const uint8_t *payload, int index);
|
||||||
int8_t signed8FromPayload(const uint8_t *payload, int index);
|
int8_t signed8FromPayload(const uint8_t *payload, int index);
|
||||||
uint16_t unsigned16FromPayload(const uint8_t *payload, int index);
|
uint16_t unsigned16FromPayload(const uint8_t *payload, int index);
|
||||||
@ -167,7 +202,7 @@ float float32FromPayload(const uint8_t *payload, int index);
|
|||||||
int64_t signed64FromPayload(const uint8_t *payload, int index);
|
int64_t signed64FromPayload(const uint8_t *payload, int index);
|
||||||
uint8_t bcdFromPayload(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, int value);
|
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 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 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 unsigned16ToPayload(uint8_t *payload, int payload_length, int index, uint16_t value, uint16_t mask); //mask 0xFFFF
|
||||||
|
@ -272,22 +272,51 @@ GroupObjectUpdatedHandler GroupObject::callback()
|
|||||||
return _updateHandler;
|
return _updateHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GroupObject::value(const KNXValue& value, const Dpt& type)
|
||||||
void GroupObject::value(const KNXDatatype& type, KNXValue& value)
|
|
||||||
{
|
{
|
||||||
KNX_Encode_Value(value, _data, _dataLength, type);
|
KNX_Encode_Value(value, _data, _dataLength, type);
|
||||||
|
objectWritten();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
KNXValue GroupObject::value(const KNXDatatype& type)
|
KNXValue GroupObject::value(const Dpt& type)
|
||||||
{
|
{
|
||||||
KNXValue value;
|
KNXValue value;
|
||||||
KNX_Decode_Value(_data, _dataLength, type, value);
|
KNX_Decode_Value(_data, _dataLength, type, value);
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool GroupObject::tryValue(KNXValue& value, const Dpt& type)
|
||||||
bool GroupObject::tryValue(const KNXDatatype& type, KNXValue& value)
|
|
||||||
{
|
{
|
||||||
return KNX_Decode_Value(_data, _dataLength, type, value);
|
return KNX_Decode_Value(_data, _dataLength, type, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GroupObject::dataPointType(Dpt value)
|
||||||
|
{
|
||||||
|
_datapointType = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Dpt GroupObject::dataPointType()
|
||||||
|
{
|
||||||
|
return _datapointType;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool GroupObject::tryValue(KNXValue& value)
|
||||||
|
{
|
||||||
|
return tryValue(value, _datapointType);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GroupObject::value(const KNXValue& value)
|
||||||
|
{
|
||||||
|
this->value(value, _datapointType);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
KNXValue GroupObject::value()
|
||||||
|
{
|
||||||
|
return value(_datapointType);
|
||||||
|
}
|
||||||
|
@ -120,9 +120,14 @@ public:
|
|||||||
void callback(GroupObjectUpdatedHandler handler);
|
void callback(GroupObjectUpdatedHandler handler);
|
||||||
GroupObjectUpdatedHandler callback();
|
GroupObjectUpdatedHandler callback();
|
||||||
|
|
||||||
KNXValue value(const KNXDatatype& type);
|
KNXValue value(const Dpt& type);
|
||||||
void value(const KNXDatatype& type, KNXValue& value);
|
void value(const KNXValue& value, const Dpt& type);
|
||||||
bool tryValue(const KNXDatatype& type, KNXValue& value);
|
bool tryValue(KNXValue& value, const Dpt& type);
|
||||||
|
KNXValue value();
|
||||||
|
void value(const KNXValue& value);
|
||||||
|
bool tryValue(KNXValue& value);
|
||||||
|
Dpt dataPointType();
|
||||||
|
void dataPointType(Dpt value);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
GroupObjectUpdatedHandler _updateHandler;
|
GroupObjectUpdatedHandler _updateHandler;
|
||||||
@ -132,4 +137,5 @@ public:
|
|||||||
uint8_t* _data;
|
uint8_t* _data;
|
||||||
uint8_t _dataLength;
|
uint8_t _dataLength;
|
||||||
GroupObjectTableObject* _table;
|
GroupObjectTableObject* _table;
|
||||||
|
Dpt _datapointType;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user