Implemented GETLASTDATA in server and aqhome-tool.

This commit is contained in:
Martin Preuss
2023-09-11 22:55:38 +02:00
parent 518a3a53f9
commit 71f5ce8c7e
14 changed files with 408 additions and 51 deletions

View File

@@ -471,6 +471,35 @@ uint64_t *AQH_Storage_GetDataPoints(AQH_STORAGE *sto, uint64_t valueId, uint64_t
int AQH_Storage_GetLastDataPoint(AQH_STORAGE *sto, uint64_t valueId, uint64_t *pTimestamp, double *pValue)
{
AQH_DATAFILE *df;
uint64_t numEntries;
int rv;
df=_getDataFileByValueId(sto, valueId);
if (df==NULL) {
DBG_ERROR(AQH_LOGDOMAIN, "No file for value id %lu", (unsigned long int) valueId);
return GWEN_ERROR_INVALID;
}
numEntries=AQH_DataFile_GetNumberOfEntries(df);
if (numEntries<2) {
DBG_INFO(AQH_LOGDOMAIN, "No data entries in file");
return GWEN_ERROR_NO_DATA;
}
rv=AQH_DataFile_ReadRecord(df, numEntries-1, pTimestamp, pValue);
if (rv<0) {
DBG_INFO(AQH_LOGDOMAIN, "here (%d)", rv);
return rv;
}
return 0;
}
void AQH_Storage_HandleMqttPublish(AQH_STORAGE *sto, const char *sTopic, const char *sValue)
{
if (sto) {