/****************************************************************************
 * 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 "./s_annvalue.h"
#include "./server_p.h"
#include "aqhome/ipc2/endpoint.h"
#include "aqhome/msg/ipc/m_ipc.h"
#include "aqhome/msg/ipc/data/m_ipcd.h"
#include "aqhome/msg/ipc/data/m_ipcd_values.h"
#include "aqhome/msg/ipc/m_ipc_result.h"
#include "aqhome/msg/ipc/m_ipc_tag16.h"

#include <gwenhywfar/debug.h>



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

void AqHomeDataServer_HandleAnnounceValue(AQH_OBJECT *o, AQH_OBJECT *ep, const AQH_MESSAGE *msg, const GWEN_TAG16_LIST *tagList)
{
  if (tagList) {
    AQHOME_SERVER *xo;

    xo=AqHomeDataServer_GetServerData(o);
    if (xo) {
      AQH_VALUE *recvdValue;

      recvdValue=AQH_IpcdMessageValues_ReadFirstValue(tagList);
      if (recvdValue) {
        AqHomeDataServer_GetOrCreateValueForDriverWithTemplate(o, ep, recvdValue);
        AQH_Value_free(recvdValue);
      }
    }
  }
}


