added specific IPC messages and use them instead of more generic messages.
This commit is contained in:
@@ -18,10 +18,12 @@
|
||||
#include "./c_getlastdatapoint.h"
|
||||
#include "./c_getvalues.h"
|
||||
#include "./c_setdata.h"
|
||||
#include "./c_addvalue.h"
|
||||
#include "./aqhome_data_p.h"
|
||||
#include "aqhome/ipc/data/ipc_data.h"
|
||||
#include "aqhome/ipc/data/msg_data_values.h"
|
||||
#include "aqhome/ipc/data/msg_data_datapoints.h"
|
||||
#include "aqhome/ipc/endpoint_ipc.h"
|
||||
#include "aqhome/ipc/msg_ipc_result.h"
|
||||
|
||||
#include <gwenhywfar/gwenhywfar.h>
|
||||
@@ -95,6 +97,52 @@ int AqHomeData_WriteStorageIfChanged(AQHOME_DATA *aqh)
|
||||
|
||||
|
||||
|
||||
AQH_VALUE *AqHomeData_GetOrCreateValueForDriver(AQHOME_DATA *aqh,
|
||||
GWEN_MSG_ENDPOINT *epDriver,
|
||||
const char *nameForDriver,
|
||||
const char *units,
|
||||
int valueType)
|
||||
{
|
||||
const char *serviceName;
|
||||
AQH_VALUE *v;
|
||||
GWEN_BUFFER *buf;
|
||||
|
||||
serviceName=AQH_IpcEndpoint_GetServiceName(epDriver);
|
||||
|
||||
buf=GWEN_Buffer_new(0, 256, 0, 1);
|
||||
if (serviceName && *serviceName) {
|
||||
GWEN_Buffer_AppendString(buf, serviceName);
|
||||
GWEN_Buffer_AppendString(buf, "/");
|
||||
}
|
||||
else {
|
||||
GWEN_Buffer_AppendString(buf, "unknown/");
|
||||
}
|
||||
GWEN_Buffer_AppendString(buf, nameForDriver);
|
||||
|
||||
v=AQH_Storage_GetValueByNameForSystem(aqh->storage, GWEN_Buffer_GetStart(buf));
|
||||
if (v==NULL) {
|
||||
if (AQH_IpcEndpoint_GetPermissions(epDriver) & AQH_IPCENDPOINT_PERMS_ADDVALUE) {
|
||||
DBG_INFO(AQH_LOGDOMAIN, "Creating value \"%s\"", GWEN_Buffer_GetStart(buf));
|
||||
v=AQH_Value_new();
|
||||
AQH_Value_SetDriver(v, serviceName);
|
||||
AQH_Value_SetNameForDriver(v, nameForDriver);
|
||||
AQH_Value_SetNameForSystem(v, GWEN_Buffer_GetStart(buf));
|
||||
AQH_Value_SetValueUnits(v, units);
|
||||
AQH_Value_SetValueType(v, valueType);
|
||||
AQH_Storage_AddValue(aqh->storage, v);
|
||||
}
|
||||
else {
|
||||
DBG_ERROR(AQH_LOGDOMAIN, "No permissions to create value \"%s\"", GWEN_Buffer_GetStart(buf));
|
||||
GWEN_Buffer_free(buf);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
GWEN_Buffer_free(buf);
|
||||
return v;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void _readAndHandleIpcMessages(AQHOME_DATA *aqh)
|
||||
{
|
||||
if (aqh->ipcdEndpoint) {
|
||||
@@ -136,6 +184,7 @@ void _handleIpcMsg(AQHOME_DATA *aqh, GWEN_MSG_ENDPOINT *ep, const GWEN_MSG *msg)
|
||||
case AQH_MSGTYPE_IPC_DATA_GETDATA_REQ: AqHomeData_HandleGetDataPoints(aqh, ep, msg); break;
|
||||
case AQH_MSGTYPE_IPC_DATA_GETLASTDATA_REQ: AqHomeData_HandleGetLastDataPoint(aqh, ep, msg); break;
|
||||
case AQH_MSGTYPE_IPC_DATA_SETDATA: AqHomeData_HandleSetData(aqh, ep, msg); break;
|
||||
case AQH_MSGTYPE_IPC_DATA_ADDVALUE: AqHomeData_HandleAddValue(aqh, ep, msg); break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user