added generic IPC result message.
This commit is contained in:
@@ -46,6 +46,7 @@
|
||||
|
||||
<headers dist="true" install="$(pkgincludedir)/ipc" >
|
||||
endpoint_ipc.h
|
||||
msg_ipc_result.h
|
||||
</headers>
|
||||
|
||||
|
||||
@@ -58,6 +59,7 @@
|
||||
$(local/typefiles)
|
||||
|
||||
endpoint_ipc.c
|
||||
msg_ipc_result.c
|
||||
</sources>
|
||||
|
||||
|
||||
@@ -67,10 +69,12 @@
|
||||
|
||||
<useTargets>
|
||||
aqhipcnodes
|
||||
aqhipcdata
|
||||
</useTargets>
|
||||
|
||||
<subdirs>
|
||||
nodes
|
||||
data
|
||||
</subdirs>
|
||||
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <aqhome/ipc/nodes/msg_ipc_error.h>
|
||||
#include <aqhome/ipc/msg_ipc_result.h>
|
||||
|
||||
#include <gwenhywfar/msg.h>
|
||||
#include <gwenhywfar/buffer.h>
|
||||
@@ -23,46 +23,47 @@
|
||||
#include <gwenhywfar/msg_ipc.h>
|
||||
|
||||
|
||||
#define AQH_MSGIPC_ERROR_OFFS_ERRORCODE 0 /* 2 bytes */
|
||||
|
||||
#define AQH_MSGIPC_ERROR_MINSIZE (GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_ERROR_OFFS_ERRORCODE+2)
|
||||
#define AQH_MSGIPC_RESULT_OFFS_RESULTCODE 0 /* 2 bytes */
|
||||
|
||||
#define AQH_MSGIPC_RESULT_MINSIZE (GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_RESULT_OFFS_RESULTCODE+2)
|
||||
|
||||
|
||||
|
||||
|
||||
GWEN_MSG *AQH_ErrorIpcMsg_new(uint16_t code, uint16_t errorCode)
|
||||
GWEN_MSG *AQH_ResultIpcMsg_new(uint16_t code, uint16_t errorCode)
|
||||
{
|
||||
GWEN_MSG *msg;
|
||||
uint8_t *ptr;
|
||||
|
||||
msg=GWEN_IpcMsg_new(AQH_IPC_PROTOCOL_NODES_ID, AQH_IPC_PROTOCOL_NODES_VERSION, code, AQH_MSGIPC_ERROR_MINSIZE, NULL);
|
||||
msg=GWEN_IpcMsg_new(AQH_IPC_PROTOCOL_RESULT_ID, AQH_IPC_PROTOCOL_RESULT_VERSION, code, AQH_MSGIPC_RESULT_MINSIZE, NULL);
|
||||
ptr=GWEN_Msg_GetBuffer(msg);
|
||||
ptr[GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_ERROR_OFFS_ERRORCODE+0]=errorCode & 0xff;
|
||||
ptr[GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_ERROR_OFFS_ERRORCODE+1]=errorCode & 0xff;
|
||||
ptr[GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_RESULT_OFFS_RESULTCODE+0]=errorCode & 0xff;
|
||||
ptr[GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_RESULT_OFFS_RESULTCODE+1]=errorCode & 0xff;
|
||||
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint16_t AQH_ErrorIpcMsg_GetErrorCode(const GWEN_MSG *msg)
|
||||
uint16_t AQH_ResultIpcMsg_GetResultCode(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint16At(msg, GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_ERROR_OFFS_ERRORCODE, 0);
|
||||
return GWEN_Msg_GetUint16At(msg, GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_RESULT_OFFS_RESULTCODE, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void AQH_ErrorIpcMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText)
|
||||
void AQH_ResultIpcMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText)
|
||||
{
|
||||
if (GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSGIPC_ERROR_MINSIZE) {
|
||||
if (GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSGIPC_RESULT_MINSIZE) {
|
||||
GWEN_Buffer_AppendArgs(dbuf,
|
||||
"ERROR (code=%d, proto=%d, proto version=%d, error=%d)\n",
|
||||
GWEN_IpcMsg_GetCode(msg),
|
||||
GWEN_IpcMsg_GetProtoId(msg),
|
||||
GWEN_IpcMsg_GetProtoVersion(msg),
|
||||
AQH_ErrorIpcMsg_GetErrorCode(msg));
|
||||
AQH_ResultIpcMsg_GetResultCode(msg));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
* should have received along with this file.
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef AQH_MSG_IPC_ERROR_H
|
||||
#define AQH_MSG_IPC_ERROR_H
|
||||
#ifndef AQH_MSG_IPC_RESULT_H
|
||||
#define AQH_MSG_IPC_RESULT_H
|
||||
|
||||
|
||||
#include <aqhome/api.h>
|
||||
@@ -18,13 +18,17 @@
|
||||
#include <gwenhywfar/buffer.h>
|
||||
|
||||
|
||||
#define AQH_MSG_IPC_ERROR_OK 0
|
||||
#define AQH_IPC_PROTOCOL_RESULT_ID 0
|
||||
#define AQH_IPC_PROTOCOL_RESULT_VERSION 1
|
||||
|
||||
|
||||
#define AQH_MSG_IPC_SUCCESS 0
|
||||
#define AQH_MSG_IPC_ERROR_NODATA 1
|
||||
|
||||
|
||||
AQHOME_API GWEN_MSG *AQH_ErrorIpcMsg_new(uint16_t code, uint16_t errorCode);
|
||||
AQHOME_API uint16_t AQH_ErrorIpcMsg_GetErrorCode(const GWEN_MSG *msg);
|
||||
AQHOME_API void AQH_ErrorIpcMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText);
|
||||
AQHOME_API GWEN_MSG *AQH_ResultIpcMsg_new(uint16_t code, uint16_t errorCode);
|
||||
AQHOME_API uint16_t AQH_ResultIpcMsg_GetResultCode(const GWEN_MSG *msg);
|
||||
AQHOME_API void AQH_ResultIpcMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText);
|
||||
|
||||
|
||||
#endif
|
||||
@@ -49,7 +49,6 @@
|
||||
msg_ipc_forward.h
|
||||
msg_ipc_value.h
|
||||
msg_ipc_ping.h
|
||||
msg_ipc_error.h
|
||||
msg_ipc_setaccmsggrps.h
|
||||
msg_ipc_getdevices_req.h
|
||||
msg_ipc_getdevices_rsp.h
|
||||
@@ -68,7 +67,6 @@
|
||||
msg_ipc_forward.c
|
||||
msg_ipc_value.c
|
||||
msg_ipc_ping.c
|
||||
msg_ipc_error.c
|
||||
msg_ipc_setaccmsggrps.c
|
||||
msg_ipc_getdevices_req.c
|
||||
msg_ipc_getdevices_rsp.c
|
||||
|
||||
Reference in New Issue
Block a user