From f9ae85b9add08fb359ffc246f1d5f05aca447b6d Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Mon, 14 Aug 2023 21:38:21 +0200 Subject: [PATCH] more work on IPC data protocol. --- apps/aqhome-data/loop.c | 105 ++++++++++- apps/aqhome-tool/0BUILD | 11 +- apps/aqhome-tool/data/0BUILD | 62 +++++++ apps/aqhome-tool/data/getvalues.c | 209 ++++++++++++++++++++++ apps/aqhome-tool/data/getvalues.h | 21 +++ apps/aqhome-tool/main.c | 8 +- apps/aqhome-tool/nodes/0BUILD | 66 +++++++ apps/aqhome-tool/{ => nodes}/flash.c | 2 +- apps/aqhome-tool/{ => nodes}/flash.h | 0 apps/aqhome-tool/{ => nodes}/getdevices.c | 4 +- apps/aqhome-tool/{ => nodes}/getdevices.h | 0 apps/aqhome-tool/{ => nodes}/ping.c | 2 +- apps/aqhome-tool/{ => nodes}/ping.h | 0 apps/aqhome-tool/utils.c | 5 +- apps/aqhome-tool/utils.h | 9 +- apps/aqhomed/loop_ipc.c | 2 +- aqhome/ipc/data/ipc_data.h | 2 +- aqhome/ipc/data/msg_data_values.c | 18 +- aqhome/ipc/data/msg_data_values.h | 1 + aqhome/ipc/msg_ipc_result.h | 7 +- aqhome/ipc/nodes/ipc_nodes.h | 3 +- 21 files changed, 505 insertions(+), 32 deletions(-) create mode 100644 apps/aqhome-tool/data/0BUILD create mode 100644 apps/aqhome-tool/data/getvalues.c create mode 100644 apps/aqhome-tool/data/getvalues.h create mode 100644 apps/aqhome-tool/nodes/0BUILD rename apps/aqhome-tool/{ => nodes}/flash.c (99%) rename apps/aqhome-tool/{ => nodes}/flash.h (100%) rename apps/aqhome-tool/{ => nodes}/getdevices.c (98%) rename apps/aqhome-tool/{ => nodes}/getdevices.h (100%) rename apps/aqhome-tool/{ => nodes}/ping.c (99%) rename apps/aqhome-tool/{ => nodes}/ping.h (100%) diff --git a/apps/aqhome-data/loop.c b/apps/aqhome-data/loop.c index d4cf192..18de2c3 100644 --- a/apps/aqhome-data/loop.c +++ b/apps/aqhome-data/loop.c @@ -14,6 +14,8 @@ #include "./loop.h" #include "./aqhome_data_p.h" #include "aqhome/ipc/data/ipc_data.h" +#include "aqhome/ipc/data/msg_data_values.h" +#include "aqhome/ipc/msg_ipc_result.h" #include #include @@ -28,6 +30,8 @@ * ------------------------------------------------------------------------------------------------ */ +#define AQHOMEDATA_VALUESPERMSG 10 + /* ------------------------------------------------------------------------------------------------ @@ -38,8 +42,10 @@ static void _readAndHandleIpcMessages(AQHOME_DATA *aqh); static void _handleIpcEndpoint(AQHOME_DATA *aqh, GWEN_MSG_ENDPOINT *ep); static void _handleIpcMsg(AQHOME_DATA *aqh, GWEN_MSG_ENDPOINT *ep, const GWEN_MSG *msg); + static void _handleGetValues(AQHOME_DATA *aqh, GWEN_MSG_ENDPOINT *ep, const GWEN_MSG *msg); -static void _handleAddValues(AQHOME_DATA *aqh, GWEN_MSG_ENDPOINT *ep, const GWEN_MSG *msg); +static void _sendValueList(AQHOME_DATA *aqh, GWEN_MSG_ENDPOINT *ep, const AQH_VALUE_LIST *vl, uint32_t flags); +static void _handleAddValue(AQHOME_DATA *aqh, GWEN_MSG_ENDPOINT *ep, const GWEN_MSG *msg); static void _handleEditValues(AQHOME_DATA *aqh, GWEN_MSG_ENDPOINT *ep, const GWEN_MSG *msg); static void _handleAddDataPoints(AQHOME_DATA *aqh, GWEN_MSG_ENDPOINT *ep, const GWEN_MSG *msg); static void _handleGetDataPoints(AQHOME_DATA *aqh, GWEN_MSG_ENDPOINT *ep, const GWEN_MSG *msg); @@ -125,10 +131,10 @@ void _handleIpcMsg(AQHOME_DATA *aqh, GWEN_MSG_ENDPOINT *ep, const GWEN_MSG *msg) /* exec IPC message */ code=GWEN_IpcMsg_GetCode(msg); - DBG_ERROR(AQH_LOGDOMAIN, "Received IPC packet"); + DBG_ERROR(AQH_LOGDOMAIN, "Received IPC packet %d", (int) code); switch(code) { case AQH_MSGTYPE_IPC_DATA_GETVALUES_REQ: _handleGetValues(aqh, ep, msg); break; - case AQH_MSGTYPE_IPC_DATA_ADDVALUES_REQ: _handleAddValues(aqh, ep, msg); break; + case AQH_MSGTYPE_IPC_DATA_ADDVALUES_REQ: _handleAddValue(aqh, ep, msg); break; case AQH_MSGTYPE_IPC_DATA_EDITVALUE_REQ: _handleEditValues(aqh, ep, msg); break; case AQH_MSGTYPE_IPC_DATA_ADDDATAPOINTS_REQ: _handleAddDataPoints(aqh, ep, msg); break; case AQH_MSGTYPE_IPC_DATA_GETDATAPOINTS_REQ: _handleGetDataPoints(aqh, ep, msg); break; @@ -141,12 +147,103 @@ void _handleIpcMsg(AQHOME_DATA *aqh, GWEN_MSG_ENDPOINT *ep, const GWEN_MSG *msg) void _handleGetValues(AQHOME_DATA *aqh, GWEN_MSG_ENDPOINT *ep, const GWEN_MSG *msg) { + const AQH_VALUE_LIST *origValueList; + + origValueList=AQH_Storage_GetValueList(aqh->storage); + if (origValueList) { + if (AQH_Value_List_GetCount(origValueList)=AQHOMEDATA_VALUESPERMSG) { + _sendValueList(aqh, ep, tmpValueList, next?0:AQH_MSGDATA_VALUES_FLAGS_LASTMSG); + AQH_Value_List_Clear(tmpValueList); + } + v=next; + } + if (AQH_Value_List_GetCount(tmpValueList)) + _sendValueList(aqh, ep, tmpValueList, AQH_MSGDATA_VALUES_FLAGS_LASTMSG); /* send remaining */ + AQH_Value_List_free(tmpValueList); + } + } + else { + /* empty list */ + _sendValueList(aqh, ep, NULL, AQH_MSGDATA_VALUES_FLAGS_LASTMSG); + } } -void _handleAddValues(AQHOME_DATA *aqh, GWEN_MSG_ENDPOINT *ep, const GWEN_MSG *msg) +void _sendValueList(AQHOME_DATA *aqh, GWEN_MSG_ENDPOINT *ep, const AQH_VALUE_LIST *vl, uint32_t flags) { + GWEN_MSG *msg; + + msg=AQH_ValuesDataIpcMsg_new(AQH_MSGTYPE_IPC_DATA_GETVALUES_RSP, flags, vl); + GWEN_MsgEndpoint_AddSendMessage(ep, msg); +} + + + +void _handleAddValue(AQHOME_DATA *aqh, GWEN_MSG_ENDPOINT *ep, const GWEN_MSG *recvdMsg) +{ + GWEN_MSG *outMsg; + int resultCode=0; + + if (AQH_ValuesDataIpcMsg_IsValid(recvdMsg)) { + uint32_t numValues; + + numValues=AQH_ValuesDataIpcMsg_GetNumValues(recvdMsg); + if (numValues==1) { + const char *s; + + s=AQH_ValuesDataIpcMsg_GetValueName(recvdMsg, 0); + if (s && *s) { + if (AQH_Storage_GetValueByName(aqh->storage, s)==NULL) { + AQH_VALUE *v; + + v=AQH_Value_new(); + AQH_Value_SetName(v, s); + + s=AQH_ValuesDataIpcMsg_GetValueUnits(recvdMsg, 0); + if (s && *s) + AQH_Value_SetValueUnits(v, s); + DBG_INFO(NULL, "Adding value \"%s\"", s); + AQH_Storage_AddValue(aqh->storage, v); + resultCode=AQH_MSG_IPC_SUCCESS; + } + else { + DBG_INFO(NULL, "Value \"%s\" already exists", s); + resultCode=AQH_MSG_IPC_ERROR_EXISTS; + } + } + else { + DBG_INFO(NULL, "Value without name "); + resultCode=AQH_MSG_IPC_ERROR_INVALID; + } + } + else { + DBG_INFO(NULL, "Invalid number of values in message (%d)", numValues); + resultCode=AQH_MSG_IPC_ERROR_INVALID; + } + } + else { + DBG_INFO(NULL, "Invalid message received"); + resultCode=AQH_MSG_IPC_ERROR_BADDATA; + } + + outMsg=AQH_ResultIpcMsg_new(AQH_MSGTYPE_IPC_DATA_RESULT, resultCode); + GWEN_MsgEndpoint_AddSendMessage(ep, outMsg); } diff --git a/apps/aqhome-tool/0BUILD b/apps/aqhome-tool/0BUILD index bb9a4c6..63659d7 100644 --- a/apps/aqhome-tool/0BUILD +++ b/apps/aqhome-tool/0BUILD @@ -33,23 +33,20 @@ - ping.h - flash.h - getdevices.h utils.h $(local/typefiles) + main.c - ping.c - flash.c - getdevices.c utils.c aqhome + aqhtool_nodes + aqhtool_data @@ -57,6 +54,8 @@ + nodes + data diff --git a/apps/aqhome-tool/data/0BUILD b/apps/aqhome-tool/data/0BUILD new file mode 100644 index 0000000..3aeb0d0 --- /dev/null +++ b/apps/aqhome-tool/data/0BUILD @@ -0,0 +1,62 @@ + + + + + + + + $(gwenhywfar_cflags) + -I$(topsrcdir) + -I$(topbuilddir) + + + + --include=$(builddir) + --include=$(srcdir) + + + $(visibility_cflags) + + + + + + + + + + + + + + + + + + getvalues.h + + + + $(local/typefiles) + + getvalues.c + + + + + + + + + + + + + + + + + + + + diff --git a/apps/aqhome-tool/data/getvalues.c b/apps/aqhome-tool/data/getvalues.c new file mode 100644 index 0000000..a333a31 --- /dev/null +++ b/apps/aqhome-tool/data/getvalues.c @@ -0,0 +1,209 @@ +/**************************************************************************** + * 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 +#endif + +#include "./getvalues.h" +#include "../utils.h" + +#include "aqhome/msg/msg_node.h" +#include "aqhome/ipc/msg_ipc_result.h" +#include "aqhome/ipc/data/msg_data_values.h" +#include "aqhome/ipc/data/ipc_data.h" + +#include +#include +#include +#include + +#include +#include + + +#define I18S(msg) msg +#define I18N(msg) GWEN_I18N_Translate(PACKAGE, msg) + + +static int _doGetValues(GWEN_DB_NODE *dbArgs); +static void _sendCommand(GWEN_MSG_ENDPOINT *epTcp); + + + + +int AQH_Tool_GetValues(GWEN_DB_NODE *dbGlobalArgs, int argc, char **argv) +{ + GWEN_DB_NODE *dbLocalArgs; + int rv; + const GWEN_ARGS args[]= { + { + GWEN_ARGS_FLAGS_HAS_ARGUMENT, /* flags */ + GWEN_ArgsType_Char, /* type */ + "tcpAddress", /* name */ + 0, /* minnum */ + 1, /* maxnum */ + "t", /* short option */ + "tcpaddress", /* long option */ + I18S("Specify TCP address to connect to (defaults to 127.0.0.1)"), + I18S("Specify TCP address to connect to (defaults to 127.0.0.1)") + }, + { + GWEN_ARGS_FLAGS_HAS_ARGUMENT, /* flags */ + GWEN_ArgsType_Int, /* type */ + "tcpPort", /* name */ + 0, /* minnum */ + 1, /* maxnum */ + "P", /* short option */ + "tcpport", /* long option */ + I18S("Specify the TCP port to listen on"), + I18S("Specify the TCP port to listen on") + }, + { + GWEN_ARGS_FLAGS_HAS_ARGUMENT, /* flags */ + GWEN_ArgsType_Int, /* type */ + "timeout", /* name */ + 0, /* minnum */ + 1, /* maxnum */ + "T", /* short option */ + NULL, /* long option */ + I18S("Specify timeout in seconds for response"), + I18S("Specify timeout in seconds for response") + }, + { + GWEN_ARGS_FLAGS_HELP | GWEN_ARGS_FLAGS_LAST, /* flags */ + GWEN_ArgsType_Int, /* type */ + "help", /* name */ + 0, /* minnum */ + 0, /* maxnum */ + "h", /* short option */ + "help", /* long option */ + "Show this help screen", /* short description */ + "Show this help screen" /* long description */ + } + }; + + dbLocalArgs=GWEN_DB_GetGroup(dbGlobalArgs, GWEN_DB_FLAGS_DEFAULT, "local"); + rv=GWEN_Args_Check(argc, argv, 1, + GWEN_ARGS_MODE_ALLOW_FREEPARAM, + args, + dbLocalArgs); + if (rv==GWEN_ARGS_RESULT_ERROR) { + fprintf(stderr, "ERROR: Could not parse arguments\n"); + return 1; + } + else if (rv==GWEN_ARGS_RESULT_HELP) { + GWEN_BUFFER *ubuf; + + ubuf=GWEN_Buffer_new(0, 1024, 0, 1); + if (GWEN_Args_Usage(args, ubuf, GWEN_ArgsOutType_Txt)) { + fprintf(stderr, "ERROR: Could not create help string\n"); + return 1; + } + fprintf(stderr, "%s\n", GWEN_Buffer_GetStart(ubuf)); + GWEN_Buffer_free(ubuf); + return 0; + } + + return _doGetValues(dbLocalArgs); +} + + + +int _doGetValues(GWEN_DB_NODE *dbArgs) +{ + GWEN_MSG_ENDPOINT *epTcp; + int timeoutInSeconds; + GWEN_MSG *msg; + + epTcp=Utils_SetupIpcEndpoint(dbArgs); + if (epTcp==NULL) { + DBG_ERROR(NULL, "ERROR creating TCP connection"); + return 2; + } + + timeoutInSeconds=GWEN_DB_GetIntValue(dbArgs, "timeout", 0, 5); + + fprintf(stdout, "Sending PING request\n"); + + _sendCommand(epTcp); + + for (;;) { + uint16_t code; + + msg=Utils_WaitForSpecificIpcMessage(epTcp, AQH_MSGTYPE_IPC_DATA_GETVALUES_RSP, timeoutInSeconds); + if (msg==NULL) { + DBG_ERROR(NULL, "No response received"); + return 2; + } + code=GWEN_IpcMsg_GetCode(msg); + if (code==AQH_MSGTYPE_IPC_DATA_GETVALUES_RSP) { + if (AQH_ValuesDataIpcMsg_IsValid(msg)) { + uint32_t numValues; + uint32_t i; + + numValues=AQH_ValuesDataIpcMsg_GetNumValues(msg); + for(i=0; i + + + +int AQH_Tool_GetValues(GWEN_DB_NODE *dbGlobalArgs, int argc, char **argv); + + +#endif + diff --git a/apps/aqhome-tool/main.c b/apps/aqhome-tool/main.c index 2e06669..07b283e 100644 --- a/apps/aqhome-tool/main.c +++ b/apps/aqhome-tool/main.c @@ -10,9 +10,10 @@ # include #endif -#include "./ping.h" -#include "./flash.h" -#include "./getdevices.h" +#include "./nodes/ping.h" +#include "./nodes/flash.h" +#include "./nodes/getdevices.h" +#include "./data/getvalues.h" #include #include @@ -69,6 +70,7 @@ int main(int argc, char **argv) GWEN_FE_DAH("ping", AQH_Tool_Ping, I18N("Ping a given node on the network")), GWEN_FE_DAH("flash", AQH_Tool_Flash, I18N("Flash a given node on the network")), GWEN_FE_DAH("getdevices", AQH_Tool_GetDevices, I18N("Request list of known devices on the network")), + GWEN_FE_DAH("getvalues", AQH_Tool_GetValues, I18N("Request list of known values on the data server")), GWEN_FE_END(), }; const GWEN_FUNCS *func; diff --git a/apps/aqhome-tool/nodes/0BUILD b/apps/aqhome-tool/nodes/0BUILD new file mode 100644 index 0000000..3f8c236 --- /dev/null +++ b/apps/aqhome-tool/nodes/0BUILD @@ -0,0 +1,66 @@ + + + + + + + + $(gwenhywfar_cflags) + -I$(topsrcdir) + -I$(topbuilddir) + + + + --include=$(builddir) + --include=$(srcdir) + + + $(visibility_cflags) + + + + + + + + + + + + + + + + + + ping.h + flash.h + getdevices.h + + + + $(local/typefiles) + + ping.c + flash.c + getdevices.c + + + + + + + + + + + + + + + + + + + + diff --git a/apps/aqhome-tool/flash.c b/apps/aqhome-tool/nodes/flash.c similarity index 99% rename from apps/aqhome-tool/flash.c rename to apps/aqhome-tool/nodes/flash.c index f578ecc..d1169cd 100644 --- a/apps/aqhome-tool/flash.c +++ b/apps/aqhome-tool/nodes/flash.c @@ -11,7 +11,7 @@ #endif #include "./flash.h" -#include "./utils.h" +#include "../utils.h" #include "aqhome/ipc/endpoint_ipc.h" #include "aqhome/ipc/nodes/msg_ipc_setaccmsggrps.h" diff --git a/apps/aqhome-tool/flash.h b/apps/aqhome-tool/nodes/flash.h similarity index 100% rename from apps/aqhome-tool/flash.h rename to apps/aqhome-tool/nodes/flash.h diff --git a/apps/aqhome-tool/getdevices.c b/apps/aqhome-tool/nodes/getdevices.c similarity index 98% rename from apps/aqhome-tool/getdevices.c rename to apps/aqhome-tool/nodes/getdevices.c index 8893c5f..8a378fe 100644 --- a/apps/aqhome-tool/getdevices.c +++ b/apps/aqhome-tool/nodes/getdevices.c @@ -11,7 +11,7 @@ #endif #include "./getdevices.h" -#include "./utils.h" +#include "../utils.h" #include "aqhome/ipc/endpoint_ipc.h" #include "aqhome/ipc/nodes/msg_ipc_getdevices_req.h" @@ -153,7 +153,7 @@ int _doGetDevices(GWEN_DB_NODE *dbArgs) return 2; } code=GWEN_IpcMsg_GetCode(msg); - if (code==AQH_MSGTYPE_IPC_NODES_ERROR) { + if (code==AQH_MSGTYPE_IPC_NODES_RESULT) { fprintf(stdout, "No device list (%d)\n", AQH_ResultIpcMsg_GetResultCode(msg)); GWEN_Msg_free(msg); break; diff --git a/apps/aqhome-tool/getdevices.h b/apps/aqhome-tool/nodes/getdevices.h similarity index 100% rename from apps/aqhome-tool/getdevices.h rename to apps/aqhome-tool/nodes/getdevices.h diff --git a/apps/aqhome-tool/ping.c b/apps/aqhome-tool/nodes/ping.c similarity index 99% rename from apps/aqhome-tool/ping.c rename to apps/aqhome-tool/nodes/ping.c index ae139b5..4e23b3b 100644 --- a/apps/aqhome-tool/ping.c +++ b/apps/aqhome-tool/nodes/ping.c @@ -11,7 +11,7 @@ #endif #include "./ping.h" -#include "./utils.h" +#include "../utils.h" #include "aqhome/ipc/nodes/msg_ipc_setaccmsggrps.h" #include "aqhome/ipc/nodes/msg_ipc_ping.h" diff --git a/apps/aqhome-tool/ping.h b/apps/aqhome-tool/nodes/ping.h similarity index 100% rename from apps/aqhome-tool/ping.h rename to apps/aqhome-tool/nodes/ping.h diff --git a/apps/aqhome-tool/utils.c b/apps/aqhome-tool/utils.c index dae69dc..6072dcc 100644 --- a/apps/aqhome-tool/utils.c +++ b/apps/aqhome-tool/utils.c @@ -16,6 +16,7 @@ #include "aqhome/ipc/endpoint_ipc.h" #include "aqhome/ipc/nodes/msg_ipc_setaccmsggrps.h" #include "aqhome/ipc/nodes/msg_ipc_forward.h" +#include "aqhome/ipc/data/ipc_data.h" #include #include @@ -125,8 +126,8 @@ GWEN_MSG *Utils_WaitForSpecificIpcMessage(GWEN_MSG_ENDPOINT *epTcp, DBG_INFO(NULL, "Received expected IPC message"); return msg; } - else if (code==AQH_MSGTYPE_IPC_NODES_ERROR) { - DBG_INFO(NULL, "Received IPC error message"); + else if (code==AQH_MSGTYPE_IPC_DATA_RESULT) { + DBG_INFO(NULL, "Received IPC result message"); return msg; } GWEN_Msg_free(msg); diff --git a/apps/aqhome-tool/utils.h b/apps/aqhome-tool/utils.h index ca7b1a6..e06f032 100644 --- a/apps/aqhome-tool/utils.h +++ b/apps/aqhome-tool/utils.h @@ -17,14 +17,9 @@ GWEN_MSG_ENDPOINT *Utils_SetupIpcEndpoint(GWEN_DB_NODE *dbArgs); -GWEN_MSG *Utils_WaitForSpecificNodeMessage(GWEN_MSG_ENDPOINT *epTcp, - int msgCode, - int nodeAddr, - int timeoutInSeconds); +GWEN_MSG *Utils_WaitForSpecificNodeMessage(GWEN_MSG_ENDPOINT *epTcp, int msgCode, int nodeAddr, int timeoutInSeconds); -GWEN_MSG *Utils_WaitForSpecificIpcMessage(GWEN_MSG_ENDPOINT *epTcp, - int msgCode, - int timeoutInSeconds); +GWEN_MSG *Utils_WaitForSpecificIpcMessage(GWEN_MSG_ENDPOINT *epTcp, int msgCode, int timeoutInSeconds); int Utils_FlushOutMessageQueue(GWEN_MSG_ENDPOINT *epTcp, int timeoutInSeconds); diff --git a/apps/aqhomed/loop_ipc.c b/apps/aqhomed/loop_ipc.c index 87da781..2e049d3 100644 --- a/apps/aqhomed/loop_ipc.c +++ b/apps/aqhomed/loop_ipc.c @@ -176,7 +176,7 @@ void _handleIpcMsgGetDevicesReq(AQHOMED *aqh, GWEN_MSG_ENDPOINT *ep, const GWEN_ GWEN_MSG *msgOut; DBG_INFO(AQH_LOGDOMAIN, "No nodes"); - msgOut=AQH_ResultIpcMsg_new(AQH_MSGTYPE_IPC_NODES_ERROR, AQH_MSG_IPC_ERROR_NODATA); + msgOut=AQH_ResultIpcMsg_new(AQH_MSGTYPE_IPC_NODES_RESULT, AQH_MSG_IPC_ERROR_NODATA); GWEN_MsgEndpoint_AddSendMessage(ep, msgOut); } } diff --git a/aqhome/ipc/data/ipc_data.h b/aqhome/ipc/data/ipc_data.h index 4616ef5..c789fbc 100644 --- a/aqhome/ipc/data/ipc_data.h +++ b/aqhome/ipc/data/ipc_data.h @@ -15,7 +15,7 @@ #include -#define AQH_IPC_PROTOCOL_DATA_ID 1 +#define AQH_IPC_PROTOCOL_DATA_ID 2 #define AQH_IPC_PROTOCOL_DATA_VERSION 1 diff --git a/aqhome/ipc/data/msg_data_values.c b/aqhome/ipc/data/msg_data_values.c index 7b16986..7172ae2 100644 --- a/aqhome/ipc/data/msg_data_values.c +++ b/aqhome/ipc/data/msg_data_values.c @@ -53,7 +53,7 @@ GWEN_MSG *AQH_ValuesDataIpcMsg_new(uint16_t code, uint32_t flags, const AQH_VALU int count; int payloadSize; - count=AQH_Value_List_GetCount(valueList); + count=valueList?AQH_Value_List_GetCount(valueList):0; payloadSize=AQH_MSGDATA_VALUES_OFFS_VALUES+(count*AQH_MSGDATA_VALUES_VALUES_SIZE); msg=GWEN_IpcMsg_new(AQH_IPC_PROTOCOL_DATA_ID, AQH_IPC_PROTOCOL_DATA_VERSION, code, payloadSize, NULL); @@ -192,6 +192,22 @@ const char *AQH_ValuesDataIpcMsg_GetValueName(const GWEN_MSG *msg, int idx) +const char *AQH_ValuesDataIpcMsg_GetValueUnits(const GWEN_MSG *msg, int idx) +{ + uint32_t pos; + + pos= + AQH_MSGDATA_VALUES_OFFS_VALUES+ + (idx*AQH_MSGDATA_VALUES_VALUES_SIZE)+ + AQH_MSGDATA_VALUES_VALUES_OFFS_UNITS; + + if (GWEN_Msg_GetBytesInBuffer(msg)>=pos+GWEN_MSGIPC_OFFS_PAYLOAD) + return (const char*) (GWEN_Msg_GetConstBuffer(msg)+GWEN_MSGIPC_OFFS_PAYLOAD+pos); + return NULL; +} + + + int AQH_ValuesDataIpcMsg_IsValid(const GWEN_MSG *msg) { int msgLen; diff --git a/aqhome/ipc/data/msg_data_values.h b/aqhome/ipc/data/msg_data_values.h index 2817f8b..cba0c5a 100644 --- a/aqhome/ipc/data/msg_data_values.h +++ b/aqhome/ipc/data/msg_data_values.h @@ -33,6 +33,7 @@ AQHOME_API uint32_t AQH_ValuesDataIpcMsg_GetNumValues(const GWEN_MSG *msg); AQHOME_API uint64_t AQH_ValuesDataIpcMsg_GetValueId(const GWEN_MSG *msg, int idx); AQHOME_API const char *AQH_ValuesDataIpcMsg_GetValueName(const GWEN_MSG *msg, int idx); +AQHOME_API const char *AQH_ValuesDataIpcMsg_GetValueUnits(const GWEN_MSG *msg, int idx); AQHOME_API int AQH_ValuesDataIpcMsg_IsValid(const GWEN_MSG *msg); AQHOME_API void AQH_ValuesDataIpcMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText); diff --git a/aqhome/ipc/msg_ipc_result.h b/aqhome/ipc/msg_ipc_result.h index ee3434c..71ceaaa 100644 --- a/aqhome/ipc/msg_ipc_result.h +++ b/aqhome/ipc/msg_ipc_result.h @@ -22,8 +22,11 @@ #define AQH_IPC_PROTOCOL_RESULT_VERSION 1 -#define AQH_MSG_IPC_SUCCESS 0 -#define AQH_MSG_IPC_ERROR_NODATA 1 +#define AQH_MSG_IPC_SUCCESS 0 +#define AQH_MSG_IPC_ERROR_INVALID 1 +#define AQH_MSG_IPC_ERROR_EXISTS 2 +#define AQH_MSG_IPC_ERROR_NODATA 3 +#define AQH_MSG_IPC_ERROR_BADDATA 4 AQHOME_API GWEN_MSG *AQH_ResultIpcMsg_new(uint16_t code, uint32_t resultCode); diff --git a/aqhome/ipc/nodes/ipc_nodes.h b/aqhome/ipc/nodes/ipc_nodes.h index 4d8d27b..2e6e08b 100644 --- a/aqhome/ipc/nodes/ipc_nodes.h +++ b/aqhome/ipc/nodes/ipc_nodes.h @@ -20,13 +20,14 @@ #define AQH_IPC_PROTOCOL_NODES_VERSION 1 +#define AQH_MSGTYPE_IPC_NODES_RESULT 0x001 + #define AQH_MSGTYPE_IPC_NODES_FORWARD 0x100 #define AQH_MSGTYPE_IPC_NODES_VALUE 0x200 #define AQH_MSGTYPE_IPC_NODES_PING 0x300 #define AQH_MSGTYPE_IPC_NODES_SETACCMSGGRPS 0x400 #define AQH_MSGTYPE_IPC_NODES_GETDEVICES_REQ 0x500 #define AQH_MSGTYPE_IPC_NODES_GETDEVICES_RSP 0x600 -#define AQH_MSGTYPE_IPC_NODES_ERROR 0x700