Implemented GETLASTDATA in server and aqhome-tool.
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user