/****************************************************************************
 * 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.
 ****************************************************************************/

#ifdef HAVE_CONFIG_H
# include <config.h>
#endif


#include "./r_setaccmsggrps.h"
#include "./server_p.h"
#include "aqhome/ipc2/endpoint.h"
#include "aqhome/msg/ipc/m_ipc.h"
#include "aqhome/msg/ipc/nodes/m_ipcn.h"
#include "aqhome/msg/ipc/nodes/m_ipcn_setaccmsggrps.h"
#include "aqhome/msg/ipc/m_ipc_connect.h"
#include "aqhome/msg/ipc/m_ipc_result.h"
#include "aqhome/msg/ipc/m_ipc_tag16.h"

#include <gwenhywfar/debug.h>



/* ------------------------------------------------------------------------------------------------
 * code
 * ------------------------------------------------------------------------------------------------
 */

void AQH_NodeServer_HandleSetAccMsgGrps(AQH_OBJECT *o, AQH_OBJECT *ep, const AQH_MESSAGE *msg, const GWEN_TAG16_LIST *tagList)
{
  AQH_NODE_SERVER *xo;

  xo=AQH_NodeServer_GetServerData(o);
  if (xo) {
    AQH_MESSAGE *outMsg;
    int resultCode=AQH_MSGDATA_RESULT_SUCCESS;
    uint32_t msgGrps=0;

    msgGrps=AQH_IpcnMessageSetAcceptedMsgGroups_GetGroups(tagList);
    AQH_Endpoint_SetAcceptedMsgGroups(ep, msgGrps);
    outMsg=AQH_IpcMessageResult_new(AQH_IPC_PROTOCOL_NODES_ID,
                                    AQH_IPC_PROTOCOL_NODES_VERSION,
                                    AQH_MSGTYPE_IPC_NODES_RESULT,
                                    AQH_Endpoint_GetNextMessageId(ep),
                                    AQH_IpcMessage_GetMsgId(msg),
                                    resultCode, NULL);
    AQH_Endpoint_AddMsgOut(ep, outMsg);
  }
}



