added specific IPC messages and use them instead of more generic messages.
This commit is contained in:
@@ -31,8 +31,11 @@
|
||||
<enums>
|
||||
|
||||
<enum id="AQH_VALUE_TYPE" prefix="AQH_ValueType_">
|
||||
<item name="num">
|
||||
<descr>numeric type</descr>
|
||||
<item name="sensor" value="0">
|
||||
<descr>sensor</descr>
|
||||
</item>
|
||||
<item name="actor" >
|
||||
<descr>actor</descr>
|
||||
</item>
|
||||
|
||||
</enum>
|
||||
|
||||
@@ -49,6 +49,10 @@
|
||||
msg_data_values.h
|
||||
msg_data_datapoints.h
|
||||
msg_data_connect.h
|
||||
msg_data_addvalue.h
|
||||
msg_data_singledata.h
|
||||
msg_data_multidata.h
|
||||
msg_data_getdata.h
|
||||
</headers>
|
||||
|
||||
|
||||
@@ -63,6 +67,10 @@
|
||||
msg_data_values.c
|
||||
msg_data_datapoints.c
|
||||
msg_data_connect.c
|
||||
msg_data_addvalue.c
|
||||
msg_data_singledata.c
|
||||
msg_data_multidata.c
|
||||
msg_data_getdata.c
|
||||
</sources>
|
||||
|
||||
|
||||
|
||||
@@ -23,19 +23,21 @@
|
||||
|
||||
#define AQH_MSGTYPE_IPC_DATA_CONNECT_REQ 0x010 /* serviceName, userName, password */
|
||||
|
||||
#define AQH_MSGTYPE_IPC_DATA_UPDATEDATA 0x100 /* AQH_DataPointsDataIpcMsg */
|
||||
#define AQH_MSGTYPE_IPC_DATA_DATACHANGED 0x200 /* AQH_DataPointsDataIpcMsg */
|
||||
#define AQH_MSGTYPE_IPC_DATA_UPDATEDATA 0x100 /* AQH_DataPointsDataIpcMsg */ /* TODO Multi */
|
||||
#define AQH_MSGTYPE_IPC_DATA_DATACHANGED 0x200 /* AQH_DataPointsDataIpcMsg */ /* TODO */
|
||||
|
||||
#define AQH_MSGTYPE_IPC_DATA_SETDATA 0x300 /* AQH_DataPointsDataIpcMsg */
|
||||
#define AQH_MSGTYPE_IPC_DATA_SETDATA 0x300 /* AQH_SingleDataDataIpcMsg */ /* Single */
|
||||
|
||||
#define AQH_MSGTYPE_IPC_DATA_GETDATA_REQ 0x500 /* AQH_DataPointsDataIpcMsg (1 pair: fromTime, toTime) */
|
||||
#define AQH_MSGTYPE_IPC_DATA_GETDATA_RSP 0x600 /* AQH_DataPointsDataIpcMsg */
|
||||
#define AQH_MSGTYPE_IPC_DATA_ADDVALUE 0x400 /* AQH_AddValueDataIpcMsg */
|
||||
|
||||
#define AQH_MSGTYPE_IPC_DATA_GETDATA_REQ 0x500 /* AQH_GetDataDataIpcMsg */
|
||||
#define AQH_MSGTYPE_IPC_DATA_GETDATA_RSP 0x600 /* AQH_DataPointsDataIpcMsg */ /* TODO */
|
||||
|
||||
#define AQH_MSGTYPE_IPC_DATA_GETLASTDATA_REQ 0x700 /* AQH_DataPointsDataIpcMsg (0 datapoints) */
|
||||
#define AQH_MSGTYPE_IPC_DATA_GETLASTDATA_RSP 0x800 /* AQH_DataPointsDataIpcMsg */
|
||||
|
||||
#define AQH_MSGTYPE_IPC_DATA_GETVALUES_REQ 0x900 /* GWEN_IpcMsg */
|
||||
#define AQH_MSGTYPE_IPC_DATA_GETVALUES_RSP 0xa00 /* AQH_ValuesDataIpcMsg */
|
||||
#define AQH_MSGTYPE_IPC_DATA_GETVALUES_RSP 0xa00 /* AQH_ValuesDataIpcMsg */ /* TODO */
|
||||
|
||||
|
||||
|
||||
|
||||
95
aqhome/ipc/data/msg_data_addvalue.c
Normal file
95
aqhome/ipc/data/msg_data_addvalue.c
Normal file
@@ -0,0 +1,95 @@
|
||||
/****************************************************************************
|
||||
* This file is part of the project AqHome.
|
||||
* AqHome (c) by 2023 Martin Preuss, all rights reserved.
|
||||
*
|
||||
* The license for this file can be found in the file COPYING which you
|
||||
* should have received along with this file.
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <aqhome/ipc/data/msg_data_addvalue.h>
|
||||
#include <aqhome/ipc/data/ipc_data.h>
|
||||
#include <aqhome/ipc/msg_ipc_tag16.h>
|
||||
|
||||
#include <gwenhywfar/msg.h>
|
||||
#include <gwenhywfar/buffer.h>
|
||||
|
||||
#include <gwenhywfar/debug.h>
|
||||
#include <gwenhywfar/msg_ipc.h>
|
||||
|
||||
|
||||
|
||||
#define AQH_MSGDATA_ADDVALUE_MINSIZE GWEN_MSGIPC_OFFS_PAYLOAD
|
||||
|
||||
|
||||
|
||||
|
||||
GWEN_MSG *AQH_AddValueDataIpcMsg_new(uint16_t code,
|
||||
const char *valueName,
|
||||
const char *valueUnits,
|
||||
int valueType)
|
||||
{
|
||||
GWEN_MSG *msg;
|
||||
GWEN_BUFFER *buf;
|
||||
|
||||
buf=GWEN_Buffer_new(0, 256, 0, 1);
|
||||
if (valueName && *valueName)
|
||||
GWEN_Tag16_WriteStringTagToBuffer(AQH_MSGDATA_ADDVALUE_TAGS_NAME, valueName, buf);
|
||||
if (valueUnits && *valueUnits)
|
||||
GWEN_Tag16_WriteStringTagToBuffer(AQH_MSGDATA_ADDVALUE_TAGS_UNITS, valueUnits, buf);
|
||||
GWEN_Tag16_WriteUint32TagToBuffer(AQH_MSGDATA_ADDVALUE_TAGS_TYPE, valueType, buf);
|
||||
|
||||
msg=AQH_Tag16IpcMsg_new(AQH_IPC_PROTOCOL_DATA_ID, AQH_IPC_PROTOCOL_DATA_VERSION, code,
|
||||
GWEN_Buffer_GetUsedBytes(buf), (const uint8_t*) GWEN_Buffer_GetStart(buf));
|
||||
GWEN_Buffer_free(buf);
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void AQH_AddValueDataIpcMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText)
|
||||
{
|
||||
if (GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSGDATA_ADDVALUE_MINSIZE) {
|
||||
GWEN_TAG16_LIST *tagList;
|
||||
char *valueName=NULL;
|
||||
char *valueUnits=NULL;
|
||||
int valueType;
|
||||
|
||||
tagList=AQH_Tag16IpcMsg_ParseTags(msg, 0);
|
||||
if (tagList) {
|
||||
const GWEN_TAG16 *tag;
|
||||
|
||||
tag=GWEN_Tag16_List_FindFirstByTagType(tagList, AQH_MSGDATA_ADDVALUE_TAGS_NAME);
|
||||
valueName=tag?GWEN_Tag16_GetTagDataAsNewString(tag, NULL):NULL;
|
||||
|
||||
tag=GWEN_Tag16_List_FindFirstByTagType(tagList, AQH_MSGDATA_ADDVALUE_TAGS_UNITS);
|
||||
valueUnits=tag?GWEN_Tag16_GetTagDataAsNewString(tag, NULL):NULL;
|
||||
|
||||
tag=GWEN_Tag16_List_FindFirstByTagType(tagList, AQH_MSGDATA_ADDVALUE_TAGS_TYPE);
|
||||
valueType=tag?GWEN_Tag16_GetTagDataAsUint32(tag, 0):0;
|
||||
}
|
||||
|
||||
GWEN_Buffer_AppendArgs(dbuf,
|
||||
"ADDVALUE (code=%d, proto=%d, proto version=%d, name=%s, units=%s, type=%d)\n",
|
||||
GWEN_IpcMsg_GetCode(msg),
|
||||
GWEN_IpcMsg_GetProtoId(msg),
|
||||
GWEN_IpcMsg_GetProtoVersion(msg),
|
||||
valueName?valueName:"<empty>",
|
||||
valueUnits?valueUnits:"<empty>",
|
||||
valueType);
|
||||
free(valueUnits);
|
||||
free(valueName);
|
||||
GWEN_Tag16_List_free(tagList);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
46
aqhome/ipc/data/msg_data_addvalue.h
Normal file
46
aqhome/ipc/data/msg_data_addvalue.h
Normal file
@@ -0,0 +1,46 @@
|
||||
/****************************************************************************
|
||||
* This file is part of the project AqHome.
|
||||
* AqHome (c) by 2023 Martin Preuss, all rights reserved.
|
||||
*
|
||||
* The license for this file can be found in the file COPYING which you
|
||||
* should have received along with this file.
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef AQH_MSG_IPC_DATA_ADDVALUE_H
|
||||
#define AQH_MSG_IPC_DATA_ADDVALUE_H
|
||||
|
||||
|
||||
#include <aqhome/api.h>
|
||||
|
||||
#include <aqhome/data/value.h>
|
||||
|
||||
#include <gwenhywfar/msg_ipc.h>
|
||||
|
||||
|
||||
/**
|
||||
* This message is used in request AQH_MSGTYPE_IPC_DATA_ADDVALUE_REQ.
|
||||
*/
|
||||
|
||||
#define AQH_MSGDATA_ADDVALUE_TAGS_NAME 0x0001
|
||||
#define AQH_MSGDATA_ADDVALUE_TAGS_UNITS 0x0002
|
||||
#define AQH_MSGDATA_ADDVALUE_TAGS_TYPE 0x0003
|
||||
|
||||
|
||||
|
||||
AQHOME_API GWEN_MSG *AQH_AddValueDataIpcMsg_new(uint16_t code,
|
||||
const char *valueName,
|
||||
const char *valueUnits,
|
||||
int valueType);
|
||||
|
||||
AQHOME_API void AQH_AddValueDataIpcMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
90
aqhome/ipc/data/msg_data_getdata.c
Normal file
90
aqhome/ipc/data/msg_data_getdata.c
Normal file
@@ -0,0 +1,90 @@
|
||||
/****************************************************************************
|
||||
* This file is part of the project AqHome.
|
||||
* AqHome (c) by 2023 Martin Preuss, all rights reserved.
|
||||
*
|
||||
* The license for this file can be found in the file COPYING which you
|
||||
* should have received along with this file.
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <aqhome/ipc/data/msg_data_getdata.h>
|
||||
#include <aqhome/ipc/data/ipc_data.h>
|
||||
#include <aqhome/ipc/msg_ipc_tag16.h>
|
||||
|
||||
#include <gwenhywfar/msg.h>
|
||||
#include <gwenhywfar/buffer.h>
|
||||
|
||||
#include <gwenhywfar/debug.h>
|
||||
#include <gwenhywfar/msg_ipc.h>
|
||||
|
||||
|
||||
|
||||
#define AQH_MSGDATA_GETDATA_MINSIZE GWEN_MSGIPC_OFFS_PAYLOAD
|
||||
|
||||
|
||||
|
||||
|
||||
GWEN_MSG *AQH_GetDataDataIpcMsg_new(uint16_t code, const char *valueName, uint64_t tsBegin, uint64_t tsEnd)
|
||||
{
|
||||
GWEN_MSG *msg;
|
||||
GWEN_BUFFER *buf;
|
||||
|
||||
buf=GWEN_Buffer_new(0, 256, 0, 1);
|
||||
if (valueName && *valueName)
|
||||
GWEN_Tag16_WriteStringTagToBuffer(AQH_MSGDATA_GETDATA_TAGS_NAME, valueName, buf);
|
||||
GWEN_Tag16_WriteUint64TagToBuffer(AQH_MSGDATA_GETDATA_TAGS_BEGIN, tsBegin, buf);
|
||||
GWEN_Tag16_WriteUint64TagToBuffer(AQH_MSGDATA_GETDATA_TAGS_END, tsEnd, buf);
|
||||
|
||||
msg=AQH_Tag16IpcMsg_new(AQH_IPC_PROTOCOL_DATA_ID, AQH_IPC_PROTOCOL_DATA_VERSION, code,
|
||||
GWEN_Buffer_GetUsedBytes(buf), (const uint8_t*) GWEN_Buffer_GetStart(buf));
|
||||
GWEN_Buffer_free(buf);
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void AQH_GetDataDataIpcMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText)
|
||||
{
|
||||
if (GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSGDATA_GETDATA_MINSIZE) {
|
||||
GWEN_TAG16_LIST *tagList;
|
||||
char *valueName=NULL;
|
||||
uint64_t tsBegin=0;
|
||||
uint64_t tsEnd=0;
|
||||
|
||||
tagList=AQH_Tag16IpcMsg_ParseTags(msg, 0);
|
||||
if (tagList) {
|
||||
const GWEN_TAG16 *tag;
|
||||
|
||||
tag=GWEN_Tag16_List_FindFirstByTagType(tagList, AQH_MSGDATA_GETDATA_TAGS_NAME);
|
||||
valueName=tag?GWEN_Tag16_GetTagDataAsNewString(tag, NULL):NULL;
|
||||
|
||||
tag=GWEN_Tag16_List_FindFirstByTagType(tagList, AQH_MSGDATA_GETDATA_TAGS_BEGIN);
|
||||
tsBegin=tag?GWEN_Tag16_GetTagDataAsUint64(tag, 0):0;
|
||||
|
||||
tag=GWEN_Tag16_List_FindFirstByTagType(tagList, AQH_MSGDATA_GETDATA_TAGS_END);
|
||||
tsEnd=tag?GWEN_Tag16_GetTagDataAsUint64(tag, 0):0;
|
||||
}
|
||||
|
||||
GWEN_Buffer_AppendArgs(dbuf,
|
||||
"GETDATA (code=%d, proto=%d, proto version=%d, name=%s, tsBegin=%lu, tsEnd=%lu)\n",
|
||||
GWEN_IpcMsg_GetCode(msg),
|
||||
GWEN_IpcMsg_GetProtoId(msg),
|
||||
GWEN_IpcMsg_GetProtoVersion(msg),
|
||||
valueName?valueName:"<empty>",
|
||||
(unsigned long int) tsBegin,
|
||||
(unsigned long int) tsEnd);
|
||||
free(valueName);
|
||||
GWEN_Tag16_List_free(tagList);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
43
aqhome/ipc/data/msg_data_getdata.h
Normal file
43
aqhome/ipc/data/msg_data_getdata.h
Normal file
@@ -0,0 +1,43 @@
|
||||
/****************************************************************************
|
||||
* This file is part of the project AqHome.
|
||||
* AqHome (c) by 2023 Martin Preuss, all rights reserved.
|
||||
*
|
||||
* The license for this file can be found in the file COPYING which you
|
||||
* should have received along with this file.
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef AQH_MSG_IPC_DATA_GETDATA_H
|
||||
#define AQH_MSG_IPC_DATA_GETDATA_H
|
||||
|
||||
|
||||
#include <aqhome/api.h>
|
||||
|
||||
#include <aqhome/data/value.h>
|
||||
|
||||
#include <gwenhywfar/msg_ipc.h>
|
||||
|
||||
|
||||
/**
|
||||
* This message is used in request AQH_MSGTYPE_IPC_DATA_ADDVALUE_REQ.
|
||||
*/
|
||||
|
||||
#define AQH_MSGDATA_GETDATA_TAGS_NAME 0x0001
|
||||
#define AQH_MSGDATA_GETDATA_TAGS_BEGIN 0x0020
|
||||
#define AQH_MSGDATA_GETDATA_TAGS_END 0x0021
|
||||
|
||||
|
||||
|
||||
AQHOME_API GWEN_MSG *AQH_GetDataDataIpcMsg_new(uint16_t code, const char *valueName, uint64_t tsBegin, uint64_t tsEnd);
|
||||
|
||||
AQHOME_API void AQH_GetDataDataIpcMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
101
aqhome/ipc/data/msg_data_multidata.c
Normal file
101
aqhome/ipc/data/msg_data_multidata.c
Normal file
@@ -0,0 +1,101 @@
|
||||
/****************************************************************************
|
||||
* This file is part of the project AqHome.
|
||||
* AqHome (c) by 2023 Martin Preuss, all rights reserved.
|
||||
*
|
||||
* The license for this file can be found in the file COPYING which you
|
||||
* should have received along with this file.
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <aqhome/ipc/data/msg_data_multidata.h>
|
||||
#include <aqhome/ipc/data/ipc_data.h>
|
||||
#include <aqhome/ipc/msg_ipc_tag16.h>
|
||||
|
||||
#include <gwenhywfar/msg.h>
|
||||
#include <gwenhywfar/buffer.h>
|
||||
|
||||
#include <gwenhywfar/debug.h>
|
||||
#include <gwenhywfar/msg_ipc.h>
|
||||
|
||||
|
||||
|
||||
#define AQH_MSGDATA_MULTIDATA_MINSIZE GWEN_MSGIPC_OFFS_PAYLOAD
|
||||
|
||||
|
||||
|
||||
|
||||
GWEN_MSG *AQH_MultiDataDataIpcMsg_new(uint16_t code,
|
||||
const char *valueName, const char *valueUnits, int valueType,
|
||||
const uint64_t *i64Ptr, int numOfDataPoints)
|
||||
{
|
||||
GWEN_MSG *msg;
|
||||
GWEN_BUFFER *buf;
|
||||
|
||||
buf=GWEN_Buffer_new(0, 256, 0, 1);
|
||||
if (valueName && *valueName)
|
||||
GWEN_Tag16_WriteStringTagToBuffer(AQH_MSGDATA_MULTIDATA_TAGS_NAME, valueName, buf);
|
||||
if (valueUnits && *valueUnits)
|
||||
GWEN_Tag16_WriteStringTagToBuffer(AQH_MSGDATA_MULTIDATA_TAGS_UNITS, valueUnits, buf);
|
||||
GWEN_Tag16_WriteUint32TagToBuffer(AQH_MSGDATA_MULTIDATA_TAGS_TYPE, valueType, buf);
|
||||
if (i64Ptr && numOfDataPoints)
|
||||
GWEN_Tag16_WriteTagToBuffer(AQH_MSGDATA_MULTIDATA_TAGS_DATA, (const uint8_t*)i64Ptr, numOfDataPoints*2*sizeof(uint64_t), buf);
|
||||
|
||||
msg=AQH_Tag16IpcMsg_new(AQH_IPC_PROTOCOL_DATA_ID, AQH_IPC_PROTOCOL_DATA_VERSION, code,
|
||||
GWEN_Buffer_GetUsedBytes(buf), (const uint8_t*) GWEN_Buffer_GetStart(buf));
|
||||
GWEN_Buffer_free(buf);
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void AQH_MultiDataDataIpcMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText)
|
||||
{
|
||||
if (GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSGDATA_MULTIDATA_MINSIZE) {
|
||||
GWEN_TAG16_LIST *tagList;
|
||||
char *valueName=NULL;
|
||||
char *valueUnits=NULL;
|
||||
int valueType;
|
||||
unsigned int numberOfPoints=0;
|
||||
|
||||
tagList=AQH_Tag16IpcMsg_ParseTags(msg, 0);
|
||||
if (tagList) {
|
||||
const GWEN_TAG16 *tag;
|
||||
|
||||
tag=GWEN_Tag16_List_FindFirstByTagType(tagList, AQH_MSGDATA_MULTIDATA_TAGS_NAME);
|
||||
valueName=tag?GWEN_Tag16_GetTagDataAsNewString(tag, NULL):NULL;
|
||||
|
||||
tag=GWEN_Tag16_List_FindFirstByTagType(tagList, AQH_MSGDATA_MULTIDATA_TAGS_UNITS);
|
||||
valueUnits=tag?GWEN_Tag16_GetTagDataAsNewString(tag, NULL):NULL;
|
||||
|
||||
tag=GWEN_Tag16_List_FindFirstByTagType(tagList, AQH_MSGDATA_MULTIDATA_TAGS_TYPE);
|
||||
valueType=tag?GWEN_Tag16_GetTagDataAsUint32(tag, 0):0;
|
||||
|
||||
tag=GWEN_Tag16_List_FindFirstByTagType(tagList, AQH_MSGDATA_MULTIDATA_TAGS_DATA);
|
||||
numberOfPoints=(tag?GWEN_Tag16_GetTagLength(tag):0)/(2*sizeof(uint64_t));
|
||||
}
|
||||
|
||||
GWEN_Buffer_AppendArgs(dbuf,
|
||||
"MULTIDATA (code=%d, proto=%d, proto version=%d, name=%s, units=%s, type=%d, datapoints=%u)\n",
|
||||
GWEN_IpcMsg_GetCode(msg),
|
||||
GWEN_IpcMsg_GetProtoId(msg),
|
||||
GWEN_IpcMsg_GetProtoVersion(msg),
|
||||
valueName?valueName:"<empty>",
|
||||
valueUnits?valueUnits:"<empty>",
|
||||
valueType,
|
||||
numberOfPoints);
|
||||
free(valueUnits);
|
||||
free(valueName);
|
||||
GWEN_Tag16_List_free(tagList);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
42
aqhome/ipc/data/msg_data_multidata.h
Normal file
42
aqhome/ipc/data/msg_data_multidata.h
Normal file
@@ -0,0 +1,42 @@
|
||||
/****************************************************************************
|
||||
* This file is part of the project AqHome.
|
||||
* AqHome (c) by 2023 Martin Preuss, all rights reserved.
|
||||
*
|
||||
* The license for this file can be found in the file COPYING which you
|
||||
* should have received along with this file.
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef AQH_MSG_IPC_DATA_MULTIDATA_H
|
||||
#define AQH_MSG_IPC_DATA_MULTIDATA_H
|
||||
|
||||
|
||||
#include <aqhome/api.h>
|
||||
|
||||
#include <aqhome/data/value.h>
|
||||
|
||||
#include <gwenhywfar/msg_ipc.h>
|
||||
|
||||
|
||||
#define AQH_MSGDATA_MULTIDATA_TAGS_NAME 0x0001
|
||||
#define AQH_MSGDATA_MULTIDATA_TAGS_UNITS 0x0002
|
||||
#define AQH_MSGDATA_MULTIDATA_TAGS_TYPE 0x0003
|
||||
#define AQH_MSGDATA_MULTIDATA_TAGS_DATA 0x0010
|
||||
|
||||
|
||||
|
||||
AQHOME_API GWEN_MSG *AQH_MultiDataDataIpcMsg_new(uint16_t code,
|
||||
const char *valueName, const char *valueUnits, int valueType,
|
||||
const uint64_t *i64Ptr, int numOfDataPoints);
|
||||
|
||||
AQHOME_API void AQH_MultiDataDataIpcMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
111
aqhome/ipc/data/msg_data_singledata.c
Normal file
111
aqhome/ipc/data/msg_data_singledata.c
Normal file
@@ -0,0 +1,111 @@
|
||||
/****************************************************************************
|
||||
* This file is part of the project AqHome.
|
||||
* AqHome (c) by 2023 Martin Preuss, all rights reserved.
|
||||
*
|
||||
* The license for this file can be found in the file COPYING which you
|
||||
* should have received along with this file.
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <aqhome/ipc/data/msg_data_singledata.h>
|
||||
#include <aqhome/ipc/data/ipc_data.h>
|
||||
#include <aqhome/ipc/msg_ipc_tag16.h>
|
||||
|
||||
#include <gwenhywfar/msg.h>
|
||||
#include <gwenhywfar/buffer.h>
|
||||
|
||||
#include <gwenhywfar/debug.h>
|
||||
#include <gwenhywfar/msg_ipc.h>
|
||||
|
||||
|
||||
|
||||
#define AQH_MSGDATA_SINGLEDATA_MINSIZE GWEN_MSGIPC_OFFS_PAYLOAD
|
||||
|
||||
|
||||
|
||||
|
||||
GWEN_MSG *AQH_SingleDataDataIpcMsg_new(uint16_t code,
|
||||
const char *valueName,
|
||||
const char *valueUnits,
|
||||
int valueType,
|
||||
uint64_t timestamp,
|
||||
double datapoint)
|
||||
{
|
||||
GWEN_MSG *msg;
|
||||
GWEN_BUFFER *buf;
|
||||
union {double f; uint64_t i;} u;
|
||||
|
||||
u.f=datapoint;
|
||||
buf=GWEN_Buffer_new(0, 256, 0, 1);
|
||||
if (valueName && *valueName)
|
||||
GWEN_Tag16_WriteStringTagToBuffer(AQH_MSGDATA_SINGLEDATA_TAGS_NAME, valueName, buf);
|
||||
if (valueUnits && *valueUnits)
|
||||
GWEN_Tag16_WriteStringTagToBuffer(AQH_MSGDATA_SINGLEDATA_TAGS_UNITS, valueUnits, buf);
|
||||
GWEN_Tag16_WriteUint32TagToBuffer(AQH_MSGDATA_SINGLEDATA_TAGS_TYPE, valueType, buf);
|
||||
GWEN_Tag16_WriteUint64TagToBuffer(AQH_MSGDATA_SINGLEDATA_TAGS_TIME, timestamp, buf);
|
||||
GWEN_Tag16_WriteUint64TagToBuffer(AQH_MSGDATA_SINGLEDATA_TAGS_DATA, u.i, buf);
|
||||
|
||||
msg=AQH_Tag16IpcMsg_new(AQH_IPC_PROTOCOL_DATA_ID, AQH_IPC_PROTOCOL_DATA_VERSION, code,
|
||||
GWEN_Buffer_GetUsedBytes(buf), (const uint8_t*) GWEN_Buffer_GetStart(buf));
|
||||
GWEN_Buffer_free(buf);
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void AQH_SingleDataDataIpcMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText)
|
||||
{
|
||||
if (GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSGDATA_SINGLEDATA_MINSIZE) {
|
||||
GWEN_TAG16_LIST *tagList;
|
||||
char *valueName=NULL;
|
||||
char *valueUnits=NULL;
|
||||
int valueType;
|
||||
uint64_t timestamp;
|
||||
union {double f; uint64_t i;} u;
|
||||
|
||||
tagList=AQH_Tag16IpcMsg_ParseTags(msg, 0);
|
||||
if (tagList) {
|
||||
const GWEN_TAG16 *tag;
|
||||
|
||||
tag=GWEN_Tag16_List_FindFirstByTagType(tagList, AQH_MSGDATA_SINGLEDATA_TAGS_NAME);
|
||||
valueName=tag?GWEN_Tag16_GetTagDataAsNewString(tag, NULL):NULL;
|
||||
|
||||
tag=GWEN_Tag16_List_FindFirstByTagType(tagList, AQH_MSGDATA_SINGLEDATA_TAGS_UNITS);
|
||||
valueUnits=tag?GWEN_Tag16_GetTagDataAsNewString(tag, NULL):NULL;
|
||||
|
||||
tag=GWEN_Tag16_List_FindFirstByTagType(tagList, AQH_MSGDATA_SINGLEDATA_TAGS_TYPE);
|
||||
valueType=tag?GWEN_Tag16_GetTagDataAsUint32(tag, 0):0;
|
||||
|
||||
tag=GWEN_Tag16_List_FindFirstByTagType(tagList, AQH_MSGDATA_SINGLEDATA_TAGS_TIME);
|
||||
timestamp=tag?GWEN_Tag16_GetTagDataAsUint64(tag, 0):0;
|
||||
|
||||
tag=GWEN_Tag16_List_FindFirstByTagType(tagList, AQH_MSGDATA_SINGLEDATA_TAGS_DATA);
|
||||
u.i=tag?GWEN_Tag16_GetTagDataAsUint64(tag, 0):0;
|
||||
}
|
||||
|
||||
GWEN_Buffer_AppendArgs(dbuf,
|
||||
"SINGLEDATA (code=%d, proto=%d, proto version=%d, name=%s, units=%s, type=%d, time=%lu, data=%f)\n",
|
||||
GWEN_IpcMsg_GetCode(msg),
|
||||
GWEN_IpcMsg_GetProtoId(msg),
|
||||
GWEN_IpcMsg_GetProtoVersion(msg),
|
||||
valueName?valueName:"<empty>",
|
||||
valueUnits?valueUnits:"<empty>",
|
||||
valueType,
|
||||
(unsigned long int) timestamp,
|
||||
u.f);
|
||||
free(valueUnits);
|
||||
free(valueName);
|
||||
GWEN_Tag16_List_free(tagList);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
50
aqhome/ipc/data/msg_data_singledata.h
Normal file
50
aqhome/ipc/data/msg_data_singledata.h
Normal file
@@ -0,0 +1,50 @@
|
||||
/****************************************************************************
|
||||
* This file is part of the project AqHome.
|
||||
* AqHome (c) by 2023 Martin Preuss, all rights reserved.
|
||||
*
|
||||
* The license for this file can be found in the file COPYING which you
|
||||
* should have received along with this file.
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef AQH_MSG_IPC_DATA_SINGLEDATA_H
|
||||
#define AQH_MSG_IPC_DATA_SINGLEDATA_H
|
||||
|
||||
|
||||
#include <aqhome/api.h>
|
||||
|
||||
#include <aqhome/data/value.h>
|
||||
|
||||
#include <gwenhywfar/msg_ipc.h>
|
||||
|
||||
|
||||
/**
|
||||
* This message is used in request AQH_MSGTYPE_IPC_DATA_ADDVALUE_REQ.
|
||||
*/
|
||||
|
||||
#define AQH_MSGDATA_SINGLEDATA_TAGS_NAME 0x0001
|
||||
#define AQH_MSGDATA_SINGLEDATA_TAGS_UNITS 0x0002
|
||||
#define AQH_MSGDATA_SINGLEDATA_TAGS_TYPE 0x0003
|
||||
#define AQH_MSGDATA_SINGLEDATA_TAGS_TIME 0x0010
|
||||
#define AQH_MSGDATA_SINGLEDATA_TAGS_DATA 0x0011
|
||||
|
||||
|
||||
|
||||
AQHOME_API GWEN_MSG *AQH_SingleDataDataIpcMsg_new(uint16_t code,
|
||||
const char *valueName,
|
||||
const char *valueUnits,
|
||||
int valueType,
|
||||
uint64_t timestamp,
|
||||
double datapoint);
|
||||
|
||||
AQHOME_API void AQH_SingleDataDataIpcMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user