aqhome-data: adding datapoints basically works now.

This commit is contained in:
Martin Preuss
2023-08-17 00:24:38 +02:00
parent f9ae85b9ad
commit 3bfb39966f
19 changed files with 727 additions and 45 deletions

View File

@@ -359,6 +359,23 @@ void AQH_Storage_SetDataFileFolder(AQH_STORAGE *sto, const char *s)
int AQH_Storage_AddDatapoint(AQH_STORAGE *sto, uint64_t valueId, uint64_t timestamp, double dataPoint)
{
AQH_DATAFILE *df;
df=_getDataFileByValueId(sto, valueId);
if (df) {
DBG_INFO(AQH_LOGDOMAIN, "Appending record to datafile");
AQH_DataFile_AppendRecord(df, timestamp, dataPoint);
return 0;
}
else {
DBG_ERROR(AQH_LOGDOMAIN, "Error getting data file for value %lu", (unsigned long int) valueId);
return GWEN_ERROR_GENERIC;
}
}
void AQH_Storage_HandleMqttPublish(AQH_STORAGE *sto, const char *sTopic, const char *sValue)
{

View File

@@ -86,6 +86,8 @@ AQHOME_API int AQH_Storage_Fini(AQH_STORAGE *sto);
AQHOME_API int AQH_Storage_WriteState(AQH_STORAGE *sto);
AQHOME_API int AQH_Storage_AddDatapoint(AQH_STORAGE *sto, uint64_t valueId, uint64_t timestamp, double dataPoint);
AQHOME_API void AQH_Storage_HandleMqttPublish(AQH_STORAGE *sto, const char *topic, const char *value);

View File

@@ -18,6 +18,7 @@
#include <gwenhywfar/debug.h>
#include <gwenhywfar/msg_ipc.h>
#include <gwenhywfar/text.h>
#include <string.h>

View File

@@ -23,10 +23,11 @@
#define AQH_MSG_IPC_SUCCESS 0
#define AQH_MSG_IPC_ERROR_INVALID 1
#define AQH_MSG_IPC_ERROR_EXISTS 2
#define AQH_MSG_IPC_ERROR_NODATA 3
#define AQH_MSG_IPC_ERROR_BADDATA 4
#define AQH_MSG_IPC_ERROR_GENERIC 1
#define AQH_MSG_IPC_ERROR_INVALID 2
#define AQH_MSG_IPC_ERROR_EXISTS 3
#define AQH_MSG_IPC_ERROR_NODATA 4
#define AQH_MSG_IPC_ERROR_BADDATA 5
AQHOME_API GWEN_MSG *AQH_ResultIpcMsg_new(uint16_t code, uint32_t resultCode);