/****************************************************************************
 * This file is part of the project AqHome.
 * AqHome (c) by 2025 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_M_IPC_RESULT_H
#define AQH_M_IPC_RESULT_H



#include <aqhome/api.h>
#include <aqhome/ipc2/message.h>

#include <gwenhywfar/tag16.h>


#define AQH_MSGDATA_RESULT_SUCCESS         0
#define AQH_MSGDATA_RESULT_ERROR_GENERIC   1
#define AQH_MSGDATA_RESULT_ERROR_INVALID   2
#define AQH_MSGDATA_RESULT_ERROR_EXISTS    3
#define AQH_MSGDATA_RESULT_ERROR_NODATA    4
#define AQH_MSGDATA_RESULT_ERROR_BADDATA   5
#define AQH_MSGDATA_RESULT_ERROR_PERMS     6
#define AQH_MSGDATA_RESULT_ERROR_NOTFOUND  7
#define AQH_MSGDATA_RESULT_ERROR_IO        8
#define AQH_MSGDATA_RESULT_ERROR_TRYAGAIN  9



#define AQH_MSGDATA_RESULT_TAGS_RESULT     0x0001
#define AQH_MSGDATA_RESULT_TAGS_TEXT       0x0002



AQHOME_API AQH_MESSAGE *AQH_IpcMessageResult_new(uint8_t protoId, uint8_t protoVer, uint16_t code,
                                                 uint32_t msgId, uint32_t refMsgId,
                                                 int result, const char *text);

AQHOME_API uint32_t AQH_IpcMessageResult_GetResult(const GWEN_TAG16_LIST *tagList);
AQHOME_API char *AQH_IpcMessageResult_GetText(const GWEN_TAG16_LIST *tagList);

AQHOME_API void AQH_IpcMessageResult_DumpToBuffer(const AQH_MESSAGE *msg, const GWEN_TAG16_LIST *tagList,
                                                  GWEN_BUFFER *dbuf, const char *sText);


#endif
