/****************************************************************************
 * 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_VALUE_H
#define AQH_M_VALUE_H


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

#include <gwenhywfar/debug.h>



#define AQH_MSG_VALUE_TYPE_TEMP     1
#define AQH_MSG_VALUE_TYPE_HUMIDITY 2
#define AQH_MSG_VALUE_TYPE_DOOR     3
#define AQH_MSG_VALUE_TYPE_MOTION   6
#define AQH_MSG_VALUE_TYPE_CO2      7
#define AQH_MSG_VALUE_TYPE_TVOC     8



AQHOME_API AQH_MESSAGE *AQH_ValueMessage_new(uint8_t destAddr, uint8_t srcAddr, uint8_t code,
                                             uint16_t msgId, uint8_t valueId, uint16_t value, uint16_t denom);
AQHOME_API uint32_t AQH_ValueMessage_GetUid(const AQH_MESSAGE *msg);
AQHOME_API uint16_t AQH_ValueMessage_GetMsgId(const AQH_MESSAGE *msg);
AQHOME_API uint8_t AQH_ValueMessage_GetValueId(const AQH_MESSAGE *msg);
AQHOME_API uint8_t AQH_ValueMessage_GetValueType(const AQH_MESSAGE *msg);
AQHOME_API uint16_t AQH_ValueMessage_GetValueNom(const AQH_MESSAGE *msg);
AQHOME_API uint16_t AQH_ValueMessage_GetValueDenom(const AQH_MESSAGE *msg);
AQHOME_API const char *AQH_ValueMessage_GetValueTypeName(const AQH_MESSAGE *msg);
AQHOME_API const char *AQH_ValueMessage_GetValueAsWindowStateString(const AQH_MESSAGE *msg);
AQHOME_API const char *AQH_ValueMessage_GetValueTypeUnits(const AQH_MESSAGE *msg);
AQHOME_API double AQH_ValueMessage_GetValue(const AQH_MESSAGE *msg);

AQHOME_API void AQH_ValueMessage_DumpToBuffer(const AQH_MESSAGE *msg, GWEN_BUFFER *dbuf, const char *sText);



#endif
