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

#ifndef AQH_AQHOME_H
#define AQH_AQHOME_H


#include <aqhome/api.h>

#include <gwenhywfar/stringlist.h>
#include <gwenhywfar/db.h>
#include <gwenhywfar/buffer.h>


enum {
  AQH_ValueType_Unknown=0,
  AQH_ValueType_Sensor,
  AQH_ValueType_Actor
};


enum {
  AQH_ValueDataType_Unknown=0,
  AQH_ValueDataType_Int,
  AQH_ValueDataType_Rational,
  AQH_ValueDataType_Uint8,
  AQH_ValueDataType_Uint16,
  AQH_ValueDataType_Uint32

};


enum {
  AQH_ValueModality_Unknown=0,
  AQH_ValueModality_Temperature,
  AQH_ValueModality_Humidity,
  AQH_ValueModality_Door,
  AQH_ValueModality_RGB,
  AQH_ValueModality_RGBW,
  AQH_ValueModality_Motion,
  AQH_ValueModality_Co2,
  AQH_ValueModality_TVOC,
  AQH_ValueModality_Stats,
  AQH_ValueModality_Light,
  AQH_ValueModality_OnOff,
  AQH_ValueModality_OnOffAuto,
  AQH_ValueModality_RPM
};



AQHOME_API int AQH_Init(void);
AQHOME_API void AQH_Fini(void);

AQHOME_API GWEN_DB_NODE *AQH_LoadConfigFile(void);
AQHOME_API void AQH_MergeConfigFileIntoConfig(GWEN_DB_NODE *dbArgs, const char *destDbGroupName);

AQHOME_API GWEN_STRINGLIST *AQH_GetListOfMatchingDataFiles(const char *subFolder, const char *mask);
AQHOME_API GWEN_STRINGLIST *AQH_GetListOfMatchingRuntimeDataFiles(const char *subFolder, const char *mask);
AQHOME_API GWEN_STRINGLIST *AQH_GetListOfMatchingSysconfFiles(const char *subFolder, const char *mask);

AQHOME_API GWEN_BUFFER *AQH_GetRuntimeFilePath(const char *sFilename);

AQHOME_API GWEN_BUFFER *AQH_FindPathOfRuntimeFile(const char *sFilename);
AQHOME_API GWEN_BUFFER *AQH_FindPathOfSysconfFile(const char *sFilename);
AQHOME_API GWEN_BUFFER *AQH_FindPathOfDataFile(const char *sFilename);


AQHOME_API GWEN_STRINGLIST *AQH_GetGlobalDataDirs(void);
AQHOME_API GWEN_STRINGLIST *AQH_GetGlobalSysconfDirs(void);


AQHOME_API int AQH_ValueType_fromString(const char *s);
AQHOME_API const char *AQH_ValueType_toString(int i);

AQHOME_API int AQH_ValueDataType_fromString(const char *s);
AQHOME_API const char *AQH_ValueDataType_toString(int i);

AQHOME_API int AQH_ValueModality_fromString(const char *s);
AQHOME_API const char *AQH_ValueModality_toString(int i);

AQHOME_API int AQH_ReadDataFromString(int dataType, const char *s, uint16_t *pDataVal, uint16_t *pDataDenom);
AQHOME_API int AQH_ReadDataFromDouble(int dataType, double d, uint16_t *pDataVal, uint16_t *pDataDenom);


#endif

