/**************************************************************************** * 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 "./c_addvalue.h" #include "./aqhome_data_p.h" #include "./loop.h" #include "aqhome/ipc/data/ipc_data.h" #include "aqhome/ipc/endpoint_ipc.h" #include "aqhome/ipc/msg_ipc_result.h" #include "aqhome/ipc/data/msg_data_values.h" #include "aqhome/ipc/msg_ipc_tag16.h" #include /* ------------------------------------------------------------------------------------------------ * defines * ------------------------------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------------------------------ * forward declarations * ------------------------------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------------------------------ * implementations * ------------------------------------------------------------------------------------------------ */ void AqHomeData_HandleAddValue(AQHOME_DATA *aqh, GWEN_MSG_ENDPOINT *ep, GWEN_MSG *msg) { GWEN_MSG *outMsg; int resultCode=AQH_MSG_IPC_SUCCESS; AQH_VALUE *recvdValue; AQH_ValuesDataIpcMsg_Parse(msg, 0); recvdValue=AQH_ValuesDataIpcMsg_ReadFirstValue(msg); if (recvdValue) { AQH_VALUE *value; value=AqHomeData_GetOrCreateValueForDriverWithTemplate(aqh, ep, recvdValue); if (value==NULL) resultCode=AQH_MSG_IPC_ERROR_PERMS; AQH_Value_free(recvdValue); } outMsg=AQH_ResultIpcMsg_new(AQH_MSGTYPE_IPC_DATA_RESULT, resultCode); GWEN_MsgEndpoint_AddSendMessage(ep, outMsg); }