/**************************************************************************** * 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_getvalues.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 /* ------------------------------------------------------------------------------------------------ * defines * ------------------------------------------------------------------------------------------------ */ #define AQHOMEDATA_VALUESPERMSG 10 /* ------------------------------------------------------------------------------------------------ * forward declarations * ------------------------------------------------------------------------------------------------ */ static void _sendValueList(AQHOME_DATA *aqh, GWEN_MSG_ENDPOINT *ep, const AQH_VALUE_LIST *vl, uint32_t flags, uint32_t refMsgId); /* ------------------------------------------------------------------------------------------------ * implementations * ------------------------------------------------------------------------------------------------ */ void AqHomeData_HandleGetValues(AQHOME_DATA *aqh, GWEN_MSG_ENDPOINT *ep, const GWEN_MSG *msg) { const AQH_VALUE_LIST *origValueList; DBG_INFO(NULL, "HandleGetValues"); origValueList=AQH_Storage_GetValueList(aqh->storage); if (origValueList) { DBG_INFO(NULL, "Have a list of %d values", AQH_Value_List_GetCount(origValueList)); if (AQH_Value_List_GetCount(origValueList)=AQHOMEDATA_VALUESPERMSG) { DBG_INFO(NULL, "Sending %d values", AQH_Value_List_GetCount(tmpValueList)); _sendValueList(aqh, ep, tmpValueList, next?0:AQH_MSGDATA_VALUES_FLAGS_LASTMSG, GWEN_IpcMsg_GetMsgId(msg)); AQH_Value_List_Clear(tmpValueList); } v=next; } if (AQH_Value_List_GetCount(tmpValueList)) { DBG_INFO(NULL, "Sending %d values", AQH_Value_List_GetCount(tmpValueList)); _sendValueList(aqh, ep, tmpValueList, AQH_MSGDATA_VALUES_FLAGS_LASTMSG, GWEN_IpcMsg_GetMsgId(msg)); /* send remaining */ } AQH_Value_List_free(tmpValueList); } } else { /* empty list */ _sendValueList(aqh, ep, NULL, AQH_MSGDATA_VALUES_FLAGS_LASTMSG, GWEN_IpcMsg_GetMsgId(msg)); } } void _sendValueList(AQHOME_DATA *aqh, GWEN_MSG_ENDPOINT *ep, const AQH_VALUE_LIST *vl, uint32_t flags, uint32_t refMsgId) { GWEN_MSG *msg; msg=AQH_ValuesDataIpcMsg_new(AQH_MSGTYPE_IPC_DATA_GETVALUES_RSP, GWEN_MsgEndpoint_GetNextMessageId(ep), refMsgId, flags, vl); GWEN_MsgEndpoint_AddSendMessage(ep, msg); }