more work on IPC data protocol.

This commit is contained in:
Martin Preuss
2023-08-14 21:38:21 +02:00
parent 5fdb33c192
commit f9ae85b9ad
21 changed files with 505 additions and 32 deletions

View File

@@ -14,6 +14,8 @@
#include "./loop.h" #include "./loop.h"
#include "./aqhome_data_p.h" #include "./aqhome_data_p.h"
#include "aqhome/ipc/data/ipc_data.h" #include "aqhome/ipc/data/ipc_data.h"
#include "aqhome/ipc/data/msg_data_values.h"
#include "aqhome/ipc/msg_ipc_result.h"
#include <gwenhywfar/gwenhywfar.h> #include <gwenhywfar/gwenhywfar.h>
#include <gwenhywfar/args.h> #include <gwenhywfar/args.h>
@@ -28,6 +30,8 @@
* ------------------------------------------------------------------------------------------------ * ------------------------------------------------------------------------------------------------
*/ */
#define AQHOMEDATA_VALUESPERMSG 10
/* ------------------------------------------------------------------------------------------------ /* ------------------------------------------------------------------------------------------------
@@ -38,8 +42,10 @@
static void _readAndHandleIpcMessages(AQHOME_DATA *aqh); static void _readAndHandleIpcMessages(AQHOME_DATA *aqh);
static void _handleIpcEndpoint(AQHOME_DATA *aqh, GWEN_MSG_ENDPOINT *ep); 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 _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 _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 _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 _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); 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 */ /* exec IPC message */
code=GWEN_IpcMsg_GetCode(msg); code=GWEN_IpcMsg_GetCode(msg);
DBG_ERROR(AQH_LOGDOMAIN, "Received IPC packet"); DBG_ERROR(AQH_LOGDOMAIN, "Received IPC packet %d", (int) code);
switch(code) { switch(code) {
case AQH_MSGTYPE_IPC_DATA_GETVALUES_REQ: _handleGetValues(aqh, ep, msg); break; 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_EDITVALUE_REQ: _handleEditValues(aqh, ep, msg); break;
case AQH_MSGTYPE_IPC_DATA_ADDDATAPOINTS_REQ: _handleAddDataPoints(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; 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) 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, origValueList, AQH_MSGDATA_VALUES_FLAGS_LASTMSG);
else {
AQH_VALUE_LIST *tmpValueList;
const AQH_VALUE *v;
tmpValueList=AQH_Value_List_new();
v=AQH_Value_List_First(origValueList);
while(v) {
const AQH_VALUE *next;
AQH_VALUE *copyOfValue;
next=AQH_Value_List_Next(v);
copyOfValue=AQH_Value_dup(v);
AQH_Value_List_Add(copyOfValue, tmpValueList);
if (AQH_Value_List_GetCount(tmpValueList)>=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);
} }

View File

@@ -33,23 +33,20 @@
</setVar> </setVar>
<headers dist="true" > <headers dist="true" >
ping.h
flash.h
getdevices.h
utils.h utils.h
</headers> </headers>
<sources> <sources>
$(local/typefiles) $(local/typefiles)
main.c main.c
ping.c
flash.c
getdevices.c
utils.c utils.c
</sources> </sources>
<useTargets> <useTargets>
aqhome aqhome
aqhtool_nodes
aqhtool_data
</useTargets> </useTargets>
<libraries> <libraries>
@@ -57,6 +54,8 @@
</libraries> </libraries>
<subdirs> <subdirs>
nodes
data
</subdirs> </subdirs>

View File

@@ -0,0 +1,62 @@
<?xml?>
<gwbuild>
<target type="ConvenienceLibrary" name="aqhtool_data" >
<includes type="c" >
$(gwenhywfar_cflags)
-I$(topsrcdir)
-I$(topbuilddir)
</includes>
<includes type="tm2" >
--include=$(builddir)
--include=$(srcdir)
</includes>
<setVar name="local/cflags">$(visibility_cflags)</setVar>
<setVar name="tm2flags" >
</setVar>
<setVar name="local/typefiles" >
</setVar>
<setVar name="local/built_sources" >
</setVar>
<setVar name="local/built_headers_pub">
</setVar>
<setVar name="local/built_headers_priv" >
</setVar>
<headers dist="true" >
getvalues.h
</headers>
<sources>
$(local/typefiles)
getvalues.c
</sources>
<useTargets>
</useTargets>
<libraries>
</libraries>
<subdirs>
</subdirs>
<extradist>
</extradist>
</target>
</gwbuild>

View File

@@ -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 <config.h>
#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 <gwenhywfar/args.h>
#include <gwenhywfar/i18n.h>
#include <gwenhywfar/debug.h>
#include <gwenhywfar/text.h>
#include <time.h>
#include <unistd.h>
#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<numValues; i++) {
uint64_t valueId;
const char *valueName;
const char *valueUnits;
valueId=AQH_ValuesDataIpcMsg_GetValueId(msg, i);
valueName=AQH_ValuesDataIpcMsg_GetValueName(msg, i);
valueUnits=AQH_ValuesDataIpcMsg_GetValueUnits(msg, i);
fprintf(stdout, "%lu\t%s\t%s\n",
(unsigned long int) valueId,
valueName?valueName:"",
valueUnits?valueUnits:"");
}
if (AQH_ValuesDataIpcMsg_GetFlags(msg) & AQH_MSGDATA_VALUES_FLAGS_LASTMSG) {
DBG_INFO(NULL, "Last message received");
break;
}
}
else {
DBG_ERROR(NULL, "Invalid message received");
GWEN_MsgEndpoint_free(epTcp);
return 3;
}
}
else if (code==AQH_MSGTYPE_IPC_DATA_RESULT) {
uint32_t resultCode;
resultCode=AQH_ResultIpcMsg_GetResultCode(msg);
fprintf(stderr, "ERROR: %d\n", resultCode);
GWEN_MsgEndpoint_free(epTcp);
return 3;
}
else {
DBG_INFO(NULL, "Unexpected message \"%d\"", code);
GWEN_MsgEndpoint_free(epTcp);
return 3;
}
} /* for */
GWEN_MsgEndpoint_free(epTcp);
return 0;
}
void _sendCommand(GWEN_MSG_ENDPOINT *epTcp)
{
GWEN_MSG *msgOut;
msgOut=GWEN_IpcMsg_new(AQH_IPC_PROTOCOL_DATA_ID, AQH_IPC_PROTOCOL_DATA_VERSION, AQH_MSGTYPE_IPC_DATA_GETVALUES_REQ, 0, NULL);
GWEN_MsgEndpoint_AddSendMessage(epTcp, msgOut);
}

View File

@@ -0,0 +1,21 @@
/****************************************************************************
* 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 AQHOME_TOOL_GETVALUES_H
#define AQHOME_TOOL_GETVALUES_H
#include <gwenhywfar/db.h>
int AQH_Tool_GetValues(GWEN_DB_NODE *dbGlobalArgs, int argc, char **argv);
#endif

View File

@@ -10,9 +10,10 @@
# include <config.h> # include <config.h>
#endif #endif
#include "./ping.h" #include "./nodes/ping.h"
#include "./flash.h" #include "./nodes/flash.h"
#include "./getdevices.h" #include "./nodes/getdevices.h"
#include "./data/getvalues.h"
#include <aqhome/api.h> #include <aqhome/api.h>
#include <aqhome/aqhome.h> #include <aqhome/aqhome.h>
@@ -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("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("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("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(), GWEN_FE_END(),
}; };
const GWEN_FUNCS *func; const GWEN_FUNCS *func;

View File

@@ -0,0 +1,66 @@
<?xml?>
<gwbuild>
<target type="ConvenienceLibrary" name="aqhtool_nodes" >
<includes type="c" >
$(gwenhywfar_cflags)
-I$(topsrcdir)
-I$(topbuilddir)
</includes>
<includes type="tm2" >
--include=$(builddir)
--include=$(srcdir)
</includes>
<setVar name="local/cflags">$(visibility_cflags)</setVar>
<setVar name="tm2flags" >
</setVar>
<setVar name="local/typefiles" >
</setVar>
<setVar name="local/built_sources" >
</setVar>
<setVar name="local/built_headers_pub">
</setVar>
<setVar name="local/built_headers_priv" >
</setVar>
<headers dist="true" >
ping.h
flash.h
getdevices.h
</headers>
<sources>
$(local/typefiles)
ping.c
flash.c
getdevices.c
</sources>
<useTargets>
</useTargets>
<libraries>
</libraries>
<subdirs>
</subdirs>
<extradist>
</extradist>
</target>
</gwbuild>

View File

@@ -11,7 +11,7 @@
#endif #endif
#include "./flash.h" #include "./flash.h"
#include "./utils.h" #include "../utils.h"
#include "aqhome/ipc/endpoint_ipc.h" #include "aqhome/ipc/endpoint_ipc.h"
#include "aqhome/ipc/nodes/msg_ipc_setaccmsggrps.h" #include "aqhome/ipc/nodes/msg_ipc_setaccmsggrps.h"

View File

@@ -11,7 +11,7 @@
#endif #endif
#include "./getdevices.h" #include "./getdevices.h"
#include "./utils.h" #include "../utils.h"
#include "aqhome/ipc/endpoint_ipc.h" #include "aqhome/ipc/endpoint_ipc.h"
#include "aqhome/ipc/nodes/msg_ipc_getdevices_req.h" #include "aqhome/ipc/nodes/msg_ipc_getdevices_req.h"
@@ -153,7 +153,7 @@ int _doGetDevices(GWEN_DB_NODE *dbArgs)
return 2; return 2;
} }
code=GWEN_IpcMsg_GetCode(msg); 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)); fprintf(stdout, "No device list (%d)\n", AQH_ResultIpcMsg_GetResultCode(msg));
GWEN_Msg_free(msg); GWEN_Msg_free(msg);
break; break;

View File

@@ -11,7 +11,7 @@
#endif #endif
#include "./ping.h" #include "./ping.h"
#include "./utils.h" #include "../utils.h"
#include "aqhome/ipc/nodes/msg_ipc_setaccmsggrps.h" #include "aqhome/ipc/nodes/msg_ipc_setaccmsggrps.h"
#include "aqhome/ipc/nodes/msg_ipc_ping.h" #include "aqhome/ipc/nodes/msg_ipc_ping.h"

View File

@@ -16,6 +16,7 @@
#include "aqhome/ipc/endpoint_ipc.h" #include "aqhome/ipc/endpoint_ipc.h"
#include "aqhome/ipc/nodes/msg_ipc_setaccmsggrps.h" #include "aqhome/ipc/nodes/msg_ipc_setaccmsggrps.h"
#include "aqhome/ipc/nodes/msg_ipc_forward.h" #include "aqhome/ipc/nodes/msg_ipc_forward.h"
#include "aqhome/ipc/data/ipc_data.h"
#include <gwenhywfar/endpoint_tcpc.h> #include <gwenhywfar/endpoint_tcpc.h>
#include <gwenhywfar/debug.h> #include <gwenhywfar/debug.h>
@@ -125,8 +126,8 @@ GWEN_MSG *Utils_WaitForSpecificIpcMessage(GWEN_MSG_ENDPOINT *epTcp,
DBG_INFO(NULL, "Received expected IPC message"); DBG_INFO(NULL, "Received expected IPC message");
return msg; return msg;
} }
else if (code==AQH_MSGTYPE_IPC_NODES_ERROR) { else if (code==AQH_MSGTYPE_IPC_DATA_RESULT) {
DBG_INFO(NULL, "Received IPC error message"); DBG_INFO(NULL, "Received IPC result message");
return msg; return msg;
} }
GWEN_Msg_free(msg); GWEN_Msg_free(msg);

View File

@@ -17,14 +17,9 @@
GWEN_MSG_ENDPOINT *Utils_SetupIpcEndpoint(GWEN_DB_NODE *dbArgs); GWEN_MSG_ENDPOINT *Utils_SetupIpcEndpoint(GWEN_DB_NODE *dbArgs);
GWEN_MSG *Utils_WaitForSpecificNodeMessage(GWEN_MSG_ENDPOINT *epTcp, GWEN_MSG *Utils_WaitForSpecificNodeMessage(GWEN_MSG_ENDPOINT *epTcp, int msgCode, int nodeAddr, int timeoutInSeconds);
int msgCode,
int nodeAddr,
int timeoutInSeconds);
GWEN_MSG *Utils_WaitForSpecificIpcMessage(GWEN_MSG_ENDPOINT *epTcp, GWEN_MSG *Utils_WaitForSpecificIpcMessage(GWEN_MSG_ENDPOINT *epTcp, int msgCode, int timeoutInSeconds);
int msgCode,
int timeoutInSeconds);
int Utils_FlushOutMessageQueue(GWEN_MSG_ENDPOINT *epTcp, int timeoutInSeconds); int Utils_FlushOutMessageQueue(GWEN_MSG_ENDPOINT *epTcp, int timeoutInSeconds);

View File

@@ -176,7 +176,7 @@ void _handleIpcMsgGetDevicesReq(AQHOMED *aqh, GWEN_MSG_ENDPOINT *ep, const GWEN_
GWEN_MSG *msgOut; GWEN_MSG *msgOut;
DBG_INFO(AQH_LOGDOMAIN, "No nodes"); 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); GWEN_MsgEndpoint_AddSendMessage(ep, msgOut);
} }
} }

View File

@@ -15,7 +15,7 @@
#include <gwenhywfar/msg_ipc.h> #include <gwenhywfar/msg_ipc.h>
#define AQH_IPC_PROTOCOL_DATA_ID 1 #define AQH_IPC_PROTOCOL_DATA_ID 2
#define AQH_IPC_PROTOCOL_DATA_VERSION 1 #define AQH_IPC_PROTOCOL_DATA_VERSION 1

View File

@@ -53,7 +53,7 @@ GWEN_MSG *AQH_ValuesDataIpcMsg_new(uint16_t code, uint32_t flags, const AQH_VALU
int count; int count;
int payloadSize; 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); 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); 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 AQH_ValuesDataIpcMsg_IsValid(const GWEN_MSG *msg)
{ {
int msgLen; int msgLen;

View File

@@ -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 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_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 int AQH_ValuesDataIpcMsg_IsValid(const GWEN_MSG *msg);
AQHOME_API void AQH_ValuesDataIpcMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText); AQHOME_API void AQH_ValuesDataIpcMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText);

View File

@@ -22,8 +22,11 @@
#define AQH_IPC_PROTOCOL_RESULT_VERSION 1 #define AQH_IPC_PROTOCOL_RESULT_VERSION 1
#define AQH_MSG_IPC_SUCCESS 0 #define AQH_MSG_IPC_SUCCESS 0
#define AQH_MSG_IPC_ERROR_NODATA 1 #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); AQHOME_API GWEN_MSG *AQH_ResultIpcMsg_new(uint16_t code, uint32_t resultCode);

View File

@@ -20,13 +20,14 @@
#define AQH_IPC_PROTOCOL_NODES_VERSION 1 #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_FORWARD 0x100
#define AQH_MSGTYPE_IPC_NODES_VALUE 0x200 #define AQH_MSGTYPE_IPC_NODES_VALUE 0x200
#define AQH_MSGTYPE_IPC_NODES_PING 0x300 #define AQH_MSGTYPE_IPC_NODES_PING 0x300
#define AQH_MSGTYPE_IPC_NODES_SETACCMSGGRPS 0x400 #define AQH_MSGTYPE_IPC_NODES_SETACCMSGGRPS 0x400
#define AQH_MSGTYPE_IPC_NODES_GETDEVICES_REQ 0x500 #define AQH_MSGTYPE_IPC_NODES_GETDEVICES_REQ 0x500
#define AQH_MSGTYPE_IPC_NODES_GETDEVICES_RSP 0x600 #define AQH_MSGTYPE_IPC_NODES_GETDEVICES_RSP 0x600
#define AQH_MSGTYPE_IPC_NODES_ERROR 0x700