adapted to latest changes in gwen, more work on data and nodes servers.

This commit is contained in:
Martin Preuss
2024-09-26 10:45:22 +02:00
parent be053b035f
commit b0b6efb1c3
88 changed files with 1745 additions and 445 deletions

View File

@@ -62,7 +62,9 @@ void AqHomeData_HandleAddValue(AQHOME_DATA *aqh, GWEN_MSG_ENDPOINT *ep, GWEN_MSG
AQH_Value_free(recvdValue); AQH_Value_free(recvdValue);
} }
outMsg=AQH_ResultIpcMsg_new(AQH_MSGTYPE_IPC_DATA_RESULT, resultCode); outMsg=AQH_ResultIpcMsg_new(AQH_MSGTYPE_IPC_DATA_RESULT,
GWEN_MsgEndpoint_GetNextMessageId(ep), GWEN_IpcMsg_GetMsgId(msg),
resultCode);
GWEN_MsgEndpoint_AddSendMessage(ep, outMsg); GWEN_MsgEndpoint_AddSendMessage(ep, outMsg);
} }

View File

@@ -83,7 +83,9 @@ void AqHomeData_HandleConnect(AQHOME_DATA *aqh, GWEN_MSG_ENDPOINT *ep, GWEN_MSG
free(userId); free(userId);
free(clientId); free(clientId);
outMsg=AQH_ResultIpcMsg_new(AQH_MSGTYPE_IPC_DATA_RESULT, resultCode); outMsg=AQH_ResultIpcMsg_new(AQH_MSGTYPE_IPC_DATA_RESULT,
GWEN_MsgEndpoint_GetNextMessageId(ep), GWEN_IpcMsg_GetMsgId(msg),
resultCode);
GWEN_MsgEndpoint_AddSendMessage(ep, outMsg); GWEN_MsgEndpoint_AddSendMessage(ep, outMsg);
} }

View File

@@ -40,11 +40,13 @@
static int _getAndSendDataPoints(AQHOME_DATA *aqh, GWEN_MSG_ENDPOINT *ep, static int _getAndSendDataPoints(AQHOME_DATA *aqh, GWEN_MSG_ENDPOINT *ep,
const AQH_VALUE *value, const AQH_VALUE *value,
uint64_t tsBegin, uint64_t tsEnd, uint64_t num); uint64_t tsBegin, uint64_t tsEnd, uint64_t num, uint32_t refMsgId);
static int _getAndSendDataPointsNoNum(AQHOME_DATA *aqh, GWEN_MSG_ENDPOINT *ep, const AQH_VALUE *value, uint64_t tsBegin, uint64_t tsEnd); static int _getAndSendDataPointsNoNum(AQHOME_DATA *aqh, GWEN_MSG_ENDPOINT *ep, const AQH_VALUE *value, uint64_t tsBegin, uint64_t tsEnd,
static int _getAndSendDataPointsWithNum(AQHOME_DATA *aqh, GWEN_MSG_ENDPOINT *ep, const AQH_VALUE *value, uint64_t num); uint32_t refMsgId);
static void _sendDataPointsResponse(AQHOME_DATA *aqh, GWEN_MSG_ENDPOINT *ep, const AQH_VALUE *value, const uint64_t *tablePtr); static int _getAndSendDataPointsWithNum(AQHOME_DATA *aqh, GWEN_MSG_ENDPOINT *ep, const AQH_VALUE *value, uint64_t num, uint32_t refMsgId);
static void _getAndSendLastDatapoint(AQHOME_DATA *aqh, GWEN_MSG_ENDPOINT *ep, const AQH_VALUE *value); static void _sendDataPointsResponse(AQHOME_DATA *aqh, GWEN_MSG_ENDPOINT *ep, const AQH_VALUE *value, const uint64_t *tablePtr,
uint32_t refMsgId);
static void _getAndSendLastDatapoint(AQHOME_DATA *aqh, GWEN_MSG_ENDPOINT *ep, const AQH_VALUE *value, uint32_t refMsgId);
@@ -74,7 +76,7 @@ void AqHomeData_HandleGetDataPoints(AQHOME_DATA *aqh, GWEN_MSG_ENDPOINT *ep, GWE
value=AQH_Storage_GetValueByNameForSystem(aqh->storage, valueName); value=AQH_Storage_GetValueByNameForSystem(aqh->storage, valueName);
if (value) { if (value) {
resultCode=_getAndSendDataPoints(aqh, ep, value, tsBegin, tsEnd, numRequested); resultCode=_getAndSendDataPoints(aqh, ep, value, tsBegin, tsEnd, numRequested, GWEN_IpcMsg_GetMsgId(recvdMsg));
if (resultCode==AQH_MSG_IPC_SUCCESS) if (resultCode==AQH_MSG_IPC_SUCCESS)
return; return;
} }
@@ -89,27 +91,31 @@ void AqHomeData_HandleGetDataPoints(AQHOME_DATA *aqh, GWEN_MSG_ENDPOINT *ep, GWE
resultCode=AQH_MSG_IPC_ERROR_PERMS; resultCode=AQH_MSG_IPC_ERROR_PERMS;
} }
outMsg=AQH_ResultIpcMsg_new(AQH_MSGTYPE_IPC_DATA_RESULT, resultCode); outMsg=AQH_ResultIpcMsg_new(AQH_MSGTYPE_IPC_DATA_RESULT,
GWEN_MsgEndpoint_GetNextMessageId(ep), GWEN_IpcMsg_GetMsgId(recvdMsg),
resultCode);
GWEN_MsgEndpoint_AddSendMessage(ep, outMsg); GWEN_MsgEndpoint_AddSendMessage(ep, outMsg);
} }
int _getAndSendDataPoints(AQHOME_DATA *aqh, GWEN_MSG_ENDPOINT *ep, const AQH_VALUE *value, uint64_t tsBegin, uint64_t tsEnd, uint64_t num) int _getAndSendDataPoints(AQHOME_DATA *aqh, GWEN_MSG_ENDPOINT *ep, const AQH_VALUE *value, uint64_t tsBegin, uint64_t tsEnd, uint64_t num,
uint32_t refMsgId)
{ {
if (num==0) if (num==0)
return _getAndSendDataPointsNoNum(aqh, ep, value, tsBegin, tsEnd); return _getAndSendDataPointsNoNum(aqh, ep, value, tsBegin, tsEnd, refMsgId);
else if (num==1) { else if (num==1) {
_getAndSendLastDatapoint(aqh, ep, value); _getAndSendLastDatapoint(aqh, ep, value, refMsgId);
return AQH_MSG_IPC_SUCCESS; return AQH_MSG_IPC_SUCCESS;
} }
else else
return _getAndSendDataPointsWithNum(aqh, ep, value, num); return _getAndSendDataPointsWithNum(aqh, ep, value, num, refMsgId);
} }
int _getAndSendDataPointsNoNum(AQHOME_DATA *aqh, GWEN_MSG_ENDPOINT *ep, const AQH_VALUE *value, uint64_t tsBegin, uint64_t tsEnd) int _getAndSendDataPointsNoNum(AQHOME_DATA *aqh, GWEN_MSG_ENDPOINT *ep, const AQH_VALUE *value, uint64_t tsBegin, uint64_t tsEnd,
uint32_t refMsgId)
{ {
uint64_t valueId; uint64_t valueId;
uint64_t *tablePtr; uint64_t *tablePtr;
@@ -117,7 +123,7 @@ int _getAndSendDataPointsNoNum(AQHOME_DATA *aqh, GWEN_MSG_ENDPOINT *ep, const AQ
valueId=AQH_Value_GetId(value); valueId=AQH_Value_GetId(value);
tablePtr=AQH_Storage_GetDataPoints(aqh->storage, valueId, tsBegin, tsEnd, AQHOMEDATA_HANDLEGETDATAPOINTS_MAXTABLEENTRIES); tablePtr=AQH_Storage_GetDataPoints(aqh->storage, valueId, tsBegin, tsEnd, AQHOMEDATA_HANDLEGETDATAPOINTS_MAXTABLEENTRIES);
if (tablePtr) { if (tablePtr) {
_sendDataPointsResponse(aqh, ep, value, tablePtr); _sendDataPointsResponse(aqh, ep, value, tablePtr, refMsgId);
free(tablePtr); free(tablePtr);
return AQH_MSG_IPC_SUCCESS; return AQH_MSG_IPC_SUCCESS;
} }
@@ -129,7 +135,7 @@ int _getAndSendDataPointsNoNum(AQHOME_DATA *aqh, GWEN_MSG_ENDPOINT *ep, const AQ
int _getAndSendDataPointsWithNum(AQHOME_DATA *aqh, GWEN_MSG_ENDPOINT *ep, const AQH_VALUE *value, uint64_t num) int _getAndSendDataPointsWithNum(AQHOME_DATA *aqh, GWEN_MSG_ENDPOINT *ep, const AQH_VALUE *value, uint64_t num, uint32_t refMsgId)
{ {
uint64_t valueId; uint64_t valueId;
uint64_t *tablePtr; uint64_t *tablePtr;
@@ -139,7 +145,7 @@ int _getAndSendDataPointsWithNum(AQHOME_DATA *aqh, GWEN_MSG_ENDPOINT *ep, const
valueId=AQH_Value_GetId(value); valueId=AQH_Value_GetId(value);
tablePtr=AQH_Storage_GetLastNDataPoints(aqh->storage, valueId, num); tablePtr=AQH_Storage_GetLastNDataPoints(aqh->storage, valueId, num);
if (tablePtr) { if (tablePtr) {
_sendDataPointsResponse(aqh, ep, value, tablePtr); _sendDataPointsResponse(aqh, ep, value, tablePtr, refMsgId);
free(tablePtr); free(tablePtr);
return AQH_MSG_IPC_SUCCESS; return AQH_MSG_IPC_SUCCESS;
} }
@@ -151,7 +157,8 @@ int _getAndSendDataPointsWithNum(AQHOME_DATA *aqh, GWEN_MSG_ENDPOINT *ep, const
void _sendDataPointsResponse(AQHOME_DATA *aqh, GWEN_MSG_ENDPOINT *ep, const AQH_VALUE *value, const uint64_t *tablePtr) void _sendDataPointsResponse(AQHOME_DATA *aqh, GWEN_MSG_ENDPOINT *ep, const AQH_VALUE *value, const uint64_t *tablePtr,
uint32_t refMsgId)
{ {
int numTableEntries; int numTableEntries;
int numDataPoints; int numDataPoints;
@@ -159,13 +166,15 @@ void _sendDataPointsResponse(AQHOME_DATA *aqh, GWEN_MSG_ENDPOINT *ep, const AQH_
numTableEntries=(int)(tablePtr[0]); numTableEntries=(int)(tablePtr[0]);
numDataPoints=numTableEntries/2; numDataPoints=numTableEntries/2;
outMsg=AQH_MultiDataDataIpcMsg_new(AQH_MSGTYPE_IPC_DATA_GETDATA_RSP, value, &(tablePtr[1]), numDataPoints); outMsg=AQH_MultiDataDataIpcMsg_new(AQH_MSGTYPE_IPC_DATA_GETDATA_RSP,
GWEN_MsgEndpoint_GetNextMessageId(ep), refMsgId,
value, &(tablePtr[1]), numDataPoints);
GWEN_MsgEndpoint_AddSendMessage(ep, outMsg); GWEN_MsgEndpoint_AddSendMessage(ep, outMsg);
} }
void _getAndSendLastDatapoint(AQHOME_DATA *aqh, GWEN_MSG_ENDPOINT *ep, const AQH_VALUE *value) void _getAndSendLastDatapoint(AQHOME_DATA *aqh, GWEN_MSG_ENDPOINT *ep, const AQH_VALUE *value, uint32_t refMsgId)
{ {
GWEN_MSG *outMsg; GWEN_MSG *outMsg;
int resultCode=AQH_MSG_IPC_SUCCESS; int resultCode=AQH_MSG_IPC_SUCCESS;
@@ -182,12 +191,16 @@ void _getAndSendLastDatapoint(AQHOME_DATA *aqh, GWEN_MSG_ENDPOINT *ep, const AQH
} }
} }
else { else {
outMsg=AQH_MultiDataDataIpcMsg_newForOne(AQH_MSGTYPE_IPC_DATA_GETDATA_RSP, value, timestamp, data); outMsg=AQH_MultiDataDataIpcMsg_newForOne(AQH_MSGTYPE_IPC_DATA_GETDATA_RSP,
GWEN_MsgEndpoint_GetNextMessageId(ep), refMsgId,
value, timestamp, data);
GWEN_MsgEndpoint_AddSendMessage(ep, outMsg); GWEN_MsgEndpoint_AddSendMessage(ep, outMsg);
return; return;
} }
outMsg=AQH_ResultIpcMsg_new(AQH_MSGTYPE_IPC_DATA_RESULT, resultCode); outMsg=AQH_ResultIpcMsg_new(AQH_MSGTYPE_IPC_DATA_RESULT,
GWEN_MsgEndpoint_GetNextMessageId(ep), refMsgId,
resultCode);
GWEN_MsgEndpoint_AddSendMessage(ep, outMsg); GWEN_MsgEndpoint_AddSendMessage(ep, outMsg);
} }

View File

@@ -35,7 +35,7 @@
* ------------------------------------------------------------------------------------------------ * ------------------------------------------------------------------------------------------------
*/ */
static void _sendDeviceList(AQHOME_DATA *aqh, GWEN_MSG_ENDPOINT *ep, const AQH_DEVICE_LIST *vl, uint32_t flags); static void _sendDeviceList(AQHOME_DATA *aqh, GWEN_MSG_ENDPOINT *ep, const AQH_DEVICE_LIST *vl, uint32_t flags, uint32_t refMsgId);
@@ -54,7 +54,7 @@ void AqHomeData_HandleGetDevices(AQHOME_DATA *aqh, GWEN_MSG_ENDPOINT *ep, const
DBG_INFO(NULL, "Have a list of %d devices", AQH_Device_List_GetCount(origDeviceList)); DBG_INFO(NULL, "Have a list of %d devices", AQH_Device_List_GetCount(origDeviceList));
if (AQH_Device_List_GetCount(origDeviceList)<AQHOMEDATA_DEVICESPERMSG) { if (AQH_Device_List_GetCount(origDeviceList)<AQHOMEDATA_DEVICESPERMSG) {
DBG_INFO(NULL, "Sending all entries in one message"); DBG_INFO(NULL, "Sending all entries in one message");
_sendDeviceList(aqh, ep, origDeviceList, AQH_MSGDATA_DEVICES_FLAGS_LASTMSG); _sendDeviceList(aqh, ep, origDeviceList, AQH_MSGDATA_DEVICES_FLAGS_LASTMSG, GWEN_IpcMsg_GetMsgId(msg));
} }
else { else {
AQH_DEVICE_LIST *tmpDeviceList; AQH_DEVICE_LIST *tmpDeviceList;
@@ -72,31 +72,33 @@ void AqHomeData_HandleGetDevices(AQHOME_DATA *aqh, GWEN_MSG_ENDPOINT *ep, const
AQH_Device_List_Add(copyOfDevice, tmpDeviceList); AQH_Device_List_Add(copyOfDevice, tmpDeviceList);
if (AQH_Device_List_GetCount(tmpDeviceList)>=AQHOMEDATA_DEVICESPERMSG) { if (AQH_Device_List_GetCount(tmpDeviceList)>=AQHOMEDATA_DEVICESPERMSG) {
DBG_INFO(NULL, "Sending %d devices", AQH_Device_List_GetCount(tmpDeviceList)); DBG_INFO(NULL, "Sending %d devices", AQH_Device_List_GetCount(tmpDeviceList));
_sendDeviceList(aqh, ep, tmpDeviceList, next?0:AQH_MSGDATA_DEVICES_FLAGS_LASTMSG); _sendDeviceList(aqh, ep, tmpDeviceList, next?0:AQH_MSGDATA_DEVICES_FLAGS_LASTMSG, GWEN_IpcMsg_GetMsgId(msg));
AQH_Device_List_Clear(tmpDeviceList); AQH_Device_List_Clear(tmpDeviceList);
} }
v=next; v=next;
} }
if (AQH_Device_List_GetCount(tmpDeviceList)) { if (AQH_Device_List_GetCount(tmpDeviceList)) {
DBG_INFO(NULL, "Sending %d devices", AQH_Device_List_GetCount(tmpDeviceList)); DBG_INFO(NULL, "Sending %d devices", AQH_Device_List_GetCount(tmpDeviceList));
_sendDeviceList(aqh, ep, tmpDeviceList, AQH_MSGDATA_DEVICES_FLAGS_LASTMSG); /* send remaining */ _sendDeviceList(aqh, ep, tmpDeviceList, AQH_MSGDATA_DEVICES_FLAGS_LASTMSG, GWEN_IpcMsg_GetMsgId(msg)); /* send remaining */
} }
AQH_Device_List_free(tmpDeviceList); AQH_Device_List_free(tmpDeviceList);
} }
} }
else { else {
/* empty list */ /* empty list */
_sendDeviceList(aqh, ep, NULL, AQH_MSGDATA_DEVICES_FLAGS_LASTMSG); _sendDeviceList(aqh, ep, NULL, AQH_MSGDATA_DEVICES_FLAGS_LASTMSG, GWEN_IpcMsg_GetMsgId(msg));
} }
} }
void _sendDeviceList(AQHOME_DATA *aqh, GWEN_MSG_ENDPOINT *ep, const AQH_DEVICE_LIST *vl, uint32_t flags) void _sendDeviceList(AQHOME_DATA *aqh, GWEN_MSG_ENDPOINT *ep, const AQH_DEVICE_LIST *vl, uint32_t flags, uint32_t refMsgId)
{ {
GWEN_MSG *msg; GWEN_MSG *msg;
msg=AQH_DevicesDataIpcMsg_new(AQH_MSGTYPE_IPC_DATA_GETDEVICES_RSP, flags, vl); msg=AQH_DevicesDataIpcMsg_new(AQH_MSGTYPE_IPC_DATA_GETDEVICES_RSP,
GWEN_MsgEndpoint_GetNextMessageId(ep), refMsgId,
flags, vl);
GWEN_MsgEndpoint_AddSendMessage(ep, msg); GWEN_MsgEndpoint_AddSendMessage(ep, msg);
} }

View File

@@ -73,7 +73,9 @@ void AqHomeData_HandleGetLastDataPoint(AQHOME_DATA *aqh, GWEN_MSG_ENDPOINT *ep,
} }
} }
else { else {
outMsg=AQH_MultiDataDataIpcMsg_newForOne(AQH_MSGTYPE_IPC_DATA_GETLASTDATA_RSP, storedValue, timestamp, data); outMsg=AQH_MultiDataDataIpcMsg_newForOne(AQH_MSGTYPE_IPC_DATA_GETLASTDATA_RSP,
GWEN_MsgEndpoint_GetNextMessageId(ep), GWEN_IpcMsg_GetMsgId(recvdMsg),
storedValue, timestamp, data);
GWEN_MsgEndpoint_AddSendMessage(ep, outMsg); GWEN_MsgEndpoint_AddSendMessage(ep, outMsg);
free(valueName); free(valueName);
return; return;
@@ -95,7 +97,9 @@ void AqHomeData_HandleGetLastDataPoint(AQHOME_DATA *aqh, GWEN_MSG_ENDPOINT *ep,
resultCode=AQH_MSG_IPC_ERROR_PERMS; resultCode=AQH_MSG_IPC_ERROR_PERMS;
} }
outMsg=AQH_ResultIpcMsg_new(AQH_MSGTYPE_IPC_DATA_RESULT, resultCode); outMsg=AQH_ResultIpcMsg_new(AQH_MSGTYPE_IPC_DATA_RESULT,
GWEN_MsgEndpoint_GetNextMessageId(ep), GWEN_IpcMsg_GetMsgId(recvdMsg),
resultCode);
GWEN_MsgEndpoint_AddSendMessage(ep, outMsg); GWEN_MsgEndpoint_AddSendMessage(ep, outMsg);
} }

View File

@@ -35,7 +35,7 @@
* ------------------------------------------------------------------------------------------------ * ------------------------------------------------------------------------------------------------
*/ */
static void _sendValueList(AQHOME_DATA *aqh, GWEN_MSG_ENDPOINT *ep, const AQH_VALUE_LIST *vl, uint32_t flags); static void _sendValueList(AQHOME_DATA *aqh, GWEN_MSG_ENDPOINT *ep, const AQH_VALUE_LIST *vl, uint32_t flags, uint32_t refMsgId);
@@ -54,7 +54,7 @@ void AqHomeData_HandleGetValues(AQHOME_DATA *aqh, GWEN_MSG_ENDPOINT *ep, const G
DBG_INFO(NULL, "Have a list of %d values", AQH_Value_List_GetCount(origValueList)); DBG_INFO(NULL, "Have a list of %d values", AQH_Value_List_GetCount(origValueList));
if (AQH_Value_List_GetCount(origValueList)<AQHOMEDATA_VALUESPERMSG) { if (AQH_Value_List_GetCount(origValueList)<AQHOMEDATA_VALUESPERMSG) {
DBG_INFO(NULL, "Sending all entries in one message"); DBG_INFO(NULL, "Sending all entries in one message");
_sendValueList(aqh, ep, origValueList, AQH_MSGDATA_VALUES_FLAGS_LASTMSG); _sendValueList(aqh, ep, origValueList, AQH_MSGDATA_VALUES_FLAGS_LASTMSG, GWEN_IpcMsg_GetMsgId(msg));
} }
else { else {
AQH_VALUE_LIST *tmpValueList; AQH_VALUE_LIST *tmpValueList;
@@ -72,31 +72,33 @@ void AqHomeData_HandleGetValues(AQHOME_DATA *aqh, GWEN_MSG_ENDPOINT *ep, const G
AQH_Value_List_Add(copyOfValue, tmpValueList); AQH_Value_List_Add(copyOfValue, tmpValueList);
if (AQH_Value_List_GetCount(tmpValueList)>=AQHOMEDATA_VALUESPERMSG) { if (AQH_Value_List_GetCount(tmpValueList)>=AQHOMEDATA_VALUESPERMSG) {
DBG_INFO(NULL, "Sending %d values", AQH_Value_List_GetCount(tmpValueList)); DBG_INFO(NULL, "Sending %d values", AQH_Value_List_GetCount(tmpValueList));
_sendValueList(aqh, ep, tmpValueList, next?0:AQH_MSGDATA_VALUES_FLAGS_LASTMSG); _sendValueList(aqh, ep, tmpValueList, next?0:AQH_MSGDATA_VALUES_FLAGS_LASTMSG, GWEN_IpcMsg_GetMsgId(msg));
AQH_Value_List_Clear(tmpValueList); AQH_Value_List_Clear(tmpValueList);
} }
v=next; v=next;
} }
if (AQH_Value_List_GetCount(tmpValueList)) { if (AQH_Value_List_GetCount(tmpValueList)) {
DBG_INFO(NULL, "Sending %d values", AQH_Value_List_GetCount(tmpValueList)); DBG_INFO(NULL, "Sending %d values", AQH_Value_List_GetCount(tmpValueList));
_sendValueList(aqh, ep, tmpValueList, AQH_MSGDATA_VALUES_FLAGS_LASTMSG); /* send remaining */ _sendValueList(aqh, ep, tmpValueList, AQH_MSGDATA_VALUES_FLAGS_LASTMSG, GWEN_IpcMsg_GetMsgId(msg)); /* send remaining */
} }
AQH_Value_List_free(tmpValueList); AQH_Value_List_free(tmpValueList);
} }
} }
else { else {
/* empty list */ /* empty list */
_sendValueList(aqh, ep, NULL, AQH_MSGDATA_VALUES_FLAGS_LASTMSG); _sendValueList(aqh, ep, NULL, AQH_MSGDATA_VALUES_FLAGS_LASTMSG, GWEN_IpcMsg_GetMsgId(msg));
} }
} }
void _sendValueList(AQHOME_DATA *aqh, GWEN_MSG_ENDPOINT *ep, const AQH_VALUE_LIST *vl, uint32_t flags) void _sendValueList(AQHOME_DATA *aqh, GWEN_MSG_ENDPOINT *ep, const AQH_VALUE_LIST *vl, uint32_t flags, uint32_t refMsgId)
{ {
GWEN_MSG *msg; GWEN_MSG *msg;
msg=AQH_ValuesDataIpcMsg_new(AQH_MSGTYPE_IPC_DATA_GETVALUES_RSP, flags, vl); msg=AQH_ValuesDataIpcMsg_new(AQH_MSGTYPE_IPC_DATA_GETVALUES_RSP,
GWEN_MsgEndpoint_GetNextMessageId(ep), refMsgId,
flags, vl);
GWEN_MsgEndpoint_AddSendMessage(ep, msg); GWEN_MsgEndpoint_AddSendMessage(ep, msg);
} }

View File

@@ -104,7 +104,9 @@ void AqHomeData_HandleModDevice(AQHOME_DATA *aqh, GWEN_MSG_ENDPOINT *ep, GWEN_MS
resultCode=AQH_MSG_IPC_ERROR_PERMS; resultCode=AQH_MSG_IPC_ERROR_PERMS;
} }
outMsg=AQH_ResultIpcMsg_new(AQH_MSGTYPE_IPC_DATA_RESULT, resultCode); outMsg=AQH_ResultIpcMsg_new(AQH_MSGTYPE_IPC_DATA_RESULT,
GWEN_MsgEndpoint_GetNextMessageId(ep), GWEN_IpcMsg_GetMsgId(recvdMsg),
resultCode);
GWEN_MsgEndpoint_AddSendMessage(ep, outMsg); GWEN_MsgEndpoint_AddSendMessage(ep, outMsg);
} }

View File

@@ -14,6 +14,7 @@
#include "./c_setdata.h" #include "./c_setdata.h"
#include "./aqhome_data_p.h" #include "./aqhome_data_p.h"
#include "./loop.h" #include "./loop.h"
#include "aqhome/aqhome.h"
#include "aqhome/ipc/data/ipc_data.h" #include "aqhome/ipc/data/ipc_data.h"
#include "aqhome/ipc/data/msg_data_set.h" #include "aqhome/ipc/data/msg_data_set.h"
#include "aqhome/ipc/endpoint_ipc.h" #include "aqhome/ipc/endpoint_ipc.h"
@@ -77,7 +78,9 @@ void AqHomeData_HandleSetData(AQHOME_DATA *aqh, GWEN_MSG_ENDPOINT *epSrc, GWEN_M
AQH_Value_free(recvdValue); AQH_Value_free(recvdValue);
free(valueDataFreeable); free(valueDataFreeable);
outMsg=AQH_ResultIpcMsg_new(AQH_MSGTYPE_IPC_DATA_RESULT, resultCode); outMsg=AQH_ResultIpcMsg_new(AQH_MSGTYPE_IPC_DATA_RESULT,
GWEN_MsgEndpoint_GetNextMessageId(epSrc), GWEN_IpcMsg_GetMsgId(recvdMsg),
resultCode);
GWEN_MsgEndpoint_AddSendMessage(epSrc, outMsg); GWEN_MsgEndpoint_AddSendMessage(epSrc, outMsg);
} }
@@ -96,7 +99,9 @@ int _forwardDataToDriver(AQHOME_DATA *aqh, const AQH_VALUE *v, const char *data)
GWEN_MSG *driverMsg; GWEN_MSG *driverMsg;
DBG_INFO(AQH_LOGDOMAIN, "Sending SETDATA msg to driver endpoint (%s)", GWEN_MsgEndpoint_GetName(ep)); DBG_INFO(AQH_LOGDOMAIN, "Sending SETDATA msg to driver endpoint (%s)", GWEN_MsgEndpoint_GetName(ep));
driverMsg=AQH_SetDataIpcMsg_new(AQH_MSGTYPE_IPC_DATA_SETDATA, v, data); driverMsg=AQH_SetDataIpcMsg_new(AQH_MSGTYPE_IPC_DATA_SETDATA,
GWEN_MsgEndpoint_GetNextMessageId(ep), 0,
v, data);
GWEN_MsgEndpoint_AddSendMessage(ep, driverMsg); GWEN_MsgEndpoint_AddSendMessage(ep, driverMsg);
return AQH_MSG_IPC_SUCCESS; return AQH_MSG_IPC_SUCCESS;
} }

View File

@@ -87,7 +87,9 @@ void AqHomeData_HandleUpdateData(AQHOME_DATA *aqh, GWEN_MSG_ENDPOINT *ep, GWEN_M
} }
AQH_Value_free(recvdValue); AQH_Value_free(recvdValue);
outMsg=AQH_ResultIpcMsg_new(AQH_MSGTYPE_IPC_DATA_RESULT, resultCode); outMsg=AQH_ResultIpcMsg_new(AQH_MSGTYPE_IPC_DATA_RESULT,
GWEN_MsgEndpoint_GetNextMessageId(ep), GWEN_IpcMsg_GetMsgId(recvdMsg),
resultCode);
GWEN_MsgEndpoint_AddSendMessage(ep, outMsg); GWEN_MsgEndpoint_AddSendMessage(ep, outMsg);
} }
@@ -131,7 +133,9 @@ void _sendDataChangedMsgToAllClients(AQHOME_DATA *aqh, GWEN_MSG_ENDPOINT *epSrc,
GWEN_MSG *msg; GWEN_MSG *msg;
DBG_DEBUG(AQH_LOGDOMAIN, "Sending update msg to endpoint %s", GWEN_MsgEndpoint_GetName(ep)); DBG_DEBUG(AQH_LOGDOMAIN, "Sending update msg to endpoint %s", GWEN_MsgEndpoint_GetName(ep));
msg=AQH_MultiDataDataIpcMsg_new(AQH_MSGTYPE_IPC_DATA_DATACHANGED, v, dataPoints, numValues); msg=AQH_MultiDataDataIpcMsg_new(AQH_MSGTYPE_IPC_DATA_DATACHANGED,
GWEN_MsgEndpoint_GetNextMessageId(ep), 0,
v, dataPoints, numValues);
GWEN_MsgEndpoint_AddSendMessage(ep, msg); GWEN_MsgEndpoint_AddSendMessage(ep, msg);
} }
else { else {

View File

@@ -12,6 +12,7 @@
#include "./loop_mqtt.h" #include "./loop_mqtt.h"
#include "./aqhome_mqtt_p.h" #include "./aqhome_mqtt_p.h"
#include "aqhome/aqhome.h"
#include "aqhome/mqtt/msg_mqtt_publish.h" #include "aqhome/mqtt/msg_mqtt_publish.h"
#include "aqhome/ipc/data/msg_data_multidata.h" #include "aqhome/ipc/data/msg_data_multidata.h"
#include "aqhome/ipc/data/msg_data_values.h" #include "aqhome/ipc/data/msg_data_values.h"
@@ -42,7 +43,7 @@ static void _sendMessage(AQHOME_MQTT *aqh, const AQHMQTT_DEVICE *device, const A
static void _announceDeviceToBroker(AQHOME_MQTT *aqh, const AQHMQTT_DEVICE *device); static void _announceDeviceToBroker(AQHOME_MQTT *aqh, const AQHMQTT_DEVICE *device);
static void _sendAnnounceValueMessage(AQHOME_MQTT *aqh, const AQHMQTT_DEVICE *device, const AQHMQTT_VALUE *value); static void _sendAnnounceValueMessage(AQHOME_MQTT *aqh, const AQHMQTT_DEVICE *device, const AQHMQTT_VALUE *value);
static AQH_VALUE *_mkMessageValue(const AQHMQTT_DEVICE *device, const AQHMQTT_VALUE *value); static AQH_VALUE *_mkMessageValue(const AQHMQTT_DEVICE *device, const AQHMQTT_VALUE *value);
static int _mqttValueTypeTessageValueType(int t); static int _mqttValueTypeMessageValueType(int t);
static int _registerNewDeviceForTopic(AQHOME_MQTT *aqh, GWEN_MSG_ENDPOINT *ep, const char *rcvdTopic, const char *rcvdValue); static int _registerNewDeviceForTopic(AQHOME_MQTT *aqh, GWEN_MSG_ENDPOINT *ep, const char *rcvdTopic, const char *rcvdValue);
static AQHMQTT_TOPIC *_findMaskMatchingTopic(AQHMQTT_TOPIC_LIST *topicList, const char *rcvdTopic, int dir); static AQHMQTT_TOPIC *_findMaskMatchingTopic(AQHMQTT_TOPIC_LIST *topicList, const char *rcvdTopic, int dir);
static AQHMQTT_TOPIC *_findTopicMatchingTopic(AQHMQTT_TOPIC_LIST *topicList, const char *rcvdTopic, int dir); static AQHMQTT_TOPIC *_findTopicMatchingTopic(AQHMQTT_TOPIC_LIST *topicList, const char *rcvdTopic, int dir);
@@ -277,7 +278,9 @@ void _sendMessage(AQHOME_MQTT *aqh, const AQHMQTT_DEVICE *device, const AQHMQTT_
msgValue=_mkMessageValue(device, value); msgValue=_mkMessageValue(device, value);
pubMsg=AQH_MultiDataDataIpcMsg_new(AQH_MSGTYPE_IPC_DATA_UPDATEDATA, msgValue, arrayToSend, 1); pubMsg=AQH_MultiDataDataIpcMsg_new(AQH_MSGTYPE_IPC_DATA_UPDATEDATA,
GWEN_MsgEndpoint_GetNextMessageId(aqh->brokerEndpoint), 0,
msgValue, arrayToSend, 1);
if (pubMsg) { if (pubMsg) {
DBG_INFO(AQH_LOGDOMAIN, "BROKER UPDATE_DATA %s/%s: %f", DBG_INFO(AQH_LOGDOMAIN, "BROKER UPDATE_DATA %s/%s: %f",
deviceName?deviceName:"<no device name>", deviceName?deviceName:"<no device name>",
@@ -326,7 +329,9 @@ void _sendAnnounceValueMessage(AQHOME_MQTT *aqh, const AQHMQTT_DEVICE *device, c
AQH_VALUE *msgValue; AQH_VALUE *msgValue;
msgValue=_mkMessageValue(device, value); msgValue=_mkMessageValue(device, value);
pubMsg=AQH_ValuesDataIpcMsg_newForOneValue(AQH_MSGTYPE_IPC_DATA_ANNOUNCEVALUE, 0, msgValue); pubMsg=AQH_ValuesDataIpcMsg_newForOneValue(AQH_MSGTYPE_IPC_DATA_ANNOUNCEVALUE,
GWEN_MsgEndpoint_GetNextMessageId(aqh->brokerEndpoint), 0,
0, msgValue);
if (pubMsg) { if (pubMsg) {
DBG_INFO(AQH_LOGDOMAIN, "BROKER ANNOUNCE_VALUE %s", AQH_Value_GetName(msgValue)); DBG_INFO(AQH_LOGDOMAIN, "BROKER ANNOUNCE_VALUE %s", AQH_Value_GetName(msgValue));
GWEN_MsgEndpoint_AddSendMessage(aqh->brokerEndpoint, pubMsg); GWEN_MsgEndpoint_AddSendMessage(aqh->brokerEndpoint, pubMsg);
@@ -344,22 +349,22 @@ AQH_VALUE *_mkMessageValue(const AQHMQTT_DEVICE *device, const AQHMQTT_VALUE *va
AQH_Value_SetDeviceName(msgValue, AQHMQTT_Device_GetId(device)); AQH_Value_SetDeviceName(msgValue, AQHMQTT_Device_GetId(device));
AQH_Value_SetName(msgValue, AQHMQTT_Value_GetName(value)); AQH_Value_SetName(msgValue, AQHMQTT_Value_GetName(value));
AQH_Value_SetValueUnits(msgValue, AQHMQTT_Value_GetValueUnits(value)); AQH_Value_SetValueUnits(msgValue, AQHMQTT_Value_GetValueUnits(value));
AQH_Value_SetValueType(msgValue, _mqttValueTypeTessageValueType(AQHMQTT_Value_GetValueType(value))); AQH_Value_SetValueType(msgValue, _mqttValueTypeMessageValueType(AQHMQTT_Value_GetValueType(value)));
return msgValue; return msgValue;
} }
int _mqttValueTypeTessageValueType(int t) int _mqttValueTypeMessageValueType(int t)
{ {
switch(t){ switch(t){
case AQHMQTT_ValueType_Sensor: return AQH_ValueType_Sensor; case AQHMQTT_ValueType_Sensor: return AQH_ValueType_Sensor;
case AQHMQTT_ValueType_Actor: return AQH_ValueType_Actor; case AQHMQTT_ValueType_Actor: return AQH_ValueType_Actor;
default: default: break;
}
DBG_ERROR(AQH_LOGDOMAIN, "Invalid mqtt value type %d", t); DBG_ERROR(AQH_LOGDOMAIN, "Invalid mqtt value type %d", t);
return AQH_ValueType_Sensor; return AQH_ValueType_Sensor;
} }
}

View File

@@ -8,6 +8,8 @@
$(gwenhywfar_cflags) $(gwenhywfar_cflags)
-I$(topsrcdir) -I$(topsrcdir)
-I$(topbuilddir) -I$(topbuilddir)
-I$(topsrcdir)/apps
-I$(topbuilddir)/apps
</includes> </includes>
<includes type="tm2" > <includes type="tm2" >
@@ -45,6 +47,8 @@
loop_ipc.h loop_ipc.h
db.h db.h
tty_log.h tty_log.h
devicesread.h
devicesdump.h
</headers> </headers>
<sources> <sources>
@@ -61,9 +65,12 @@
loop_ipc.c loop_ipc.c
db.c db.c
tty_log.c tty_log.c
devicesread.c
devicesdump.c
</sources> </sources>
<useTargets> <useTargets>
aqhnodes_types
aqhome aqhome
</useTargets> </useTargets>
@@ -72,6 +79,7 @@
</libraries> </libraries>
<subdirs> <subdirs>
types
</subdirs> </subdirs>

View File

@@ -51,6 +51,7 @@ AQHOMED *AqHomed_new(void)
GWEN_NEW_OBJECT(AQHOMED, aqh); GWEN_NEW_OBJECT(AQHOMED, aqh);
aqh->rootEndpoint=GWEN_MsgEndpoint_new("root", 0); aqh->rootEndpoint=GWEN_MsgEndpoint_new("root", 0);
aqh->nodeDb=AQH_NodeDb_new(); aqh->nodeDb=AQH_NodeDb_new();
aqh->requestTree=GWEN_MsgRequest_new();
return aqh; return aqh;
} }
@@ -60,6 +61,7 @@ AQHOMED *AqHomed_new(void)
void AqHomed_free(AQHOMED *aqh) void AqHomed_free(AQHOMED *aqh)
{ {
if (aqh) { if (aqh) {
GWEN_MsgRequest_free(aqh->requestTree);
GWEN_MsgEndpoint_free(aqh->rootEndpoint); GWEN_MsgEndpoint_free(aqh->rootEndpoint);
aqh->rootEndpoint=NULL; aqh->rootEndpoint=NULL;
aqh->ttyEndpoint=NULL; aqh->ttyEndpoint=NULL;
@@ -164,5 +166,56 @@ int AqHomed_GetTimeout(const AQHOMED *aqh)
GWEN_MSG_REQUEST *AqHomed_GetRequestTree(const AQHOMED *aqh)
{
return aqh?aqh->requestTree:NULL;
}
void AqHomed_AddRequestToTree(AQHOMED *aqh, GWEN_MSG_REQUEST *rq)
{
if (aqh && rq)
GWEN_MsgRequest_Tree2_AddChild(aqh->requestTree, rq);
}
const AQHNODE_DEVICE_LIST *AqHomed_GetDeviceDefList(const AQHOMED *aqh)
{
return aqh?aqh->deviceDefList:NULL;
}
const AQHNODE_DEVICE *AqHomed_FindDeviceDef(const AQHOMED *aqh, uint32_t manufacturer, uint16_t deviceType, uint16_t deviceVersion)
{
if (aqh && aqh->deviceDefList) {
const AQHNODE_DEVICE *device;
device=AQHNODE_Device_List_First(aqh->deviceDefList);
while(device) {
if (AQHNODE_Device_GetManufacturer(device)==manufacturer &&
AQHNODE_Device_GetDeviceType(device)==deviceType &&
AQHNODE_Device_GetDeviceVersion(device)==(deviceVersion & 0xff00))
return device;
device=AQHNODE_Device_List_Next(device);
}
}
return NULL;
}
const AQHNODE_DEVICE *AqHomed_GetDeviceDefByName(const AQHOMED *aqh, const char *name)
{
if (aqh && aqh->deviceDefList && name)
return AQHNODE_Device_List_GetByName(aqh->deviceDefList, name);
return NULL;
}

View File

@@ -12,6 +12,7 @@
#include <gwenhywfar/endpoint.h> #include <gwenhywfar/endpoint.h>
#include <gwenhywfar/db.h> #include <gwenhywfar/db.h>
#include <gwenhywfar/request.h>
#define AQHOME_ENDPOINTGROUP_NODE 1 #define AQHOME_ENDPOINTGROUP_NODE 1
@@ -21,6 +22,10 @@
typedef struct AQHOMED AQHOMED; typedef struct AQHOMED AQHOMED;
#include "aqhome-nodes/types/device.h"
AQHOMED *AqHomed_new(void); AQHOMED *AqHomed_new(void);
void AqHomed_free(AQHOMED *aqh); void AqHomed_free(AQHOMED *aqh);
@@ -41,6 +46,14 @@ void AqHomed_SetDbFile(AQHOMED *aqh, const char *s);
int AqHomed_GetTimeout(const AQHOMED *aqh); int AqHomed_GetTimeout(const AQHOMED *aqh);
GWEN_MSG_REQUEST *AqHomed_GetRequestTree(const AQHOMED *aqh);
void AqHomed_AddRequestToTree(AQHOMED *aqh, GWEN_MSG_REQUEST *rq);
const AQHNODE_DEVICE_LIST *AqHomed_GetDeviceDefList(const AQHOMED *aqh);
const AQHNODE_DEVICE *AqHomed_FindDeviceDef(const AQHOMED *aqh, uint32_t manufacturer, uint16_t deviceType, uint16_t deviceVersion);
const AQHNODE_DEVICE *AqHomed_GetDeviceDefByName(const AQHOMED *aqh, const char *name);
#endif #endif

View File

@@ -34,6 +34,7 @@ struct AQHOMED {
GWEN_MSG_ENDPOINT *brokerEndpoint; GWEN_MSG_ENDPOINT *brokerEndpoint;
AQH_NODE_DB *nodeDb; AQH_NODE_DB *nodeDb;
AQHNODE_DEVICE_LIST *deviceDefList;
GWEN_DB_NODE *dbArgs; GWEN_DB_NODE *dbArgs;
@@ -44,6 +45,8 @@ struct AQHOMED {
int timeout; /* timeout for run e.g. inside valgrind */ int timeout; /* timeout for run e.g. inside valgrind */
int nodeAddress; int nodeAddress;
GWEN_MSG_REQUEST *requestTree;
}; };
#endif #endif

View File

@@ -18,6 +18,7 @@
#include "aqhome/msg/msg_sendstats.h" #include "aqhome/msg/msg_sendstats.h"
#include "aqhome/msg/msg_recvstats.h" #include "aqhome/msg/msg_recvstats.h"
#include "aqhome/msg/msg_value2.h" #include "aqhome/msg/msg_value2.h"
#include "aqhome/msg/msg_value3.h"
#include "aqhome/msg/msg_needaddr.h" #include "aqhome/msg/msg_needaddr.h"
#include "aqhome/msg/msg_claimaddr.h" #include "aqhome/msg/msg_claimaddr.h"
#include "aqhome/msg/msg_haveaddr.h" #include "aqhome/msg/msg_haveaddr.h"
@@ -39,6 +40,7 @@
*/ */
static void _handleMsgValue2(AQHOMED *aqh, const GWEN_MSG *msg); static void _handleMsgValue2(AQHOMED *aqh, const GWEN_MSG *msg);
static void _handleMsgValue3(AQHOMED *aqh, const GWEN_MSG *msg);
static void _handleMsgNeedAddress(AQHOMED *aqh, const GWEN_MSG *msg); static void _handleMsgNeedAddress(AQHOMED *aqh, const GWEN_MSG *msg);
static void _handleMsgClaimAddress(AQHOMED *aqh, const GWEN_MSG *msg); static void _handleMsgClaimAddress(AQHOMED *aqh, const GWEN_MSG *msg);
static void _handleMsgHaveAddress(AQHOMED *aqh, const GWEN_MSG *msg); static void _handleMsgHaveAddress(AQHOMED *aqh, const GWEN_MSG *msg);
@@ -49,6 +51,7 @@ static void _handleMsgFlashReady(AQHOMED *aqh, const GWEN_MSG *msg);
static AQH_NODE_INFO *_getOrCreateNodeAndUpdateUidAddr(AQHOMED *aqh, const GWEN_MSG *msg, uint32_t uid); static AQH_NODE_INFO *_getOrCreateNodeAndUpdateUidAddr(AQHOMED *aqh, const GWEN_MSG *msg, uint32_t uid);
static void _updateTimestampLastChange(AQH_NODE_INFO *ni); static void _updateTimestampLastChange(AQH_NODE_INFO *ni);
static void _assignDeviceId(AQHOMED *aqh, AQH_NODE_INFO *ni, uint32_t uid);
@@ -78,6 +81,7 @@ void AqHomed_NodeMsgToDb(AQHOMED *aqh, const GWEN_MSG *msg)
case AQH_MSG_TYPE_COMSENDSTATS: _handleMsgComSendStat(aqh, msg); break; case AQH_MSG_TYPE_COMSENDSTATS: _handleMsgComSendStat(aqh, msg); break;
case AQH_MSG_TYPE_COMRECVSTATS: _handleMsgComRecvStat(aqh, msg); break; case AQH_MSG_TYPE_COMRECVSTATS: _handleMsgComRecvStat(aqh, msg); break;
case AQH_MSG_TYPE_VALUE2: _handleMsgValue2(aqh, msg); break; case AQH_MSG_TYPE_VALUE2: _handleMsgValue2(aqh, msg); break;
case AQH_MSG_TYPE_VALUE_REPORT: _handleMsgValue3(aqh, msg); break;
case AQH_MSG_TYPE_NEED_ADDRESS: _handleMsgNeedAddress(aqh, msg); break; case AQH_MSG_TYPE_NEED_ADDRESS: _handleMsgNeedAddress(aqh, msg); break;
case AQH_MSG_TYPE_CLAIM_ADDRESS: _handleMsgClaimAddress(aqh, msg); break; case AQH_MSG_TYPE_CLAIM_ADDRESS: _handleMsgClaimAddress(aqh, msg); break;
case AQH_MSG_TYPE_HAVE_ADDRESS: _handleMsgHaveAddress(aqh, msg); break; case AQH_MSG_TYPE_HAVE_ADDRESS: _handleMsgHaveAddress(aqh, msg); break;
@@ -119,6 +123,20 @@ void _handleMsgValue2(AQHOMED *aqh, const GWEN_MSG *msg)
void _handleMsgValue3(AQHOMED *aqh, const GWEN_MSG *msg)
{
AQH_NODE_INFO *ni;
uint32_t uid;
uid=AQH_Value3Msg_GetUid(msg);
ni=_getOrCreateNodeAndUpdateUidAddr(aqh, msg, uid);
if (ni==NULL) {
DBG_INFO(AQH_LOGDOMAIN, "Error handling message");
}
}
void _handleMsgNeedAddress(AQHOMED *aqh, const GWEN_MSG *msg) void _handleMsgNeedAddress(AQHOMED *aqh, const GWEN_MSG *msg)
{ {
AQH_NODE_INFO *ni; AQH_NODE_INFO *ni;
@@ -207,6 +225,8 @@ void _handleMsgDevice(AQHOMED *aqh, const GWEN_MSG *msg)
uid=AQH_DeviceMsg_GetUid(msg); uid=AQH_DeviceMsg_GetUid(msg);
ni=_getOrCreateNodeAndUpdateUidAddr(aqh, msg, uid); ni=_getOrCreateNodeAndUpdateUidAddr(aqh, msg, uid);
if (ni) { if (ni) {
const char *s;
AQH_NodeInfo_SetManufacturer(ni, AQH_DeviceMsg_GetManufacturer(msg)); AQH_NodeInfo_SetManufacturer(ni, AQH_DeviceMsg_GetManufacturer(msg));
AQH_NodeInfo_SetDeviceType(ni, AQH_DeviceMsg_GetDeviceType(msg)); AQH_NodeInfo_SetDeviceType(ni, AQH_DeviceMsg_GetDeviceType(msg));
AQH_NodeInfo_SetDeviceVersion(ni, (AQH_DeviceMsg_GetDeviceVersion(msg)<<8)+AQH_DeviceMsg_GetDeviceRevision(msg)); AQH_NodeInfo_SetDeviceVersion(ni, (AQH_DeviceMsg_GetDeviceVersion(msg)<<8)+AQH_DeviceMsg_GetDeviceRevision(msg));
@@ -215,6 +235,9 @@ void _handleMsgDevice(AQHOMED *aqh, const GWEN_MSG *msg)
(AQH_DeviceMsg_GetFirmwareVersionMajor(msg)<<16) | (AQH_DeviceMsg_GetFirmwareVersionMajor(msg)<<16) |
(AQH_DeviceMsg_GetFirmwareVersionMinor(msg)<<8) | (AQH_DeviceMsg_GetFirmwareVersionMinor(msg)<<8) |
AQH_DeviceMsg_GetFirmwareVersionPatchlevel(msg)); AQH_DeviceMsg_GetFirmwareVersionPatchlevel(msg));
s=AQH_NodeInfo_GetDeviceId(ni);
if (!(s && *s))
_assignDeviceId(aqh, ni, uid);
_updateTimestampLastChange(ni); _updateTimestampLastChange(ni);
AQH_NodeDb_SetModified(aqh->nodeDb); AQH_NodeDb_SetModified(aqh->nodeDb);
} }
@@ -233,6 +256,8 @@ void _handleMsgFlashReady(AQHOMED *aqh, const GWEN_MSG *msg)
uid=AQH_FlashReadyMsg_GetUid(msg); uid=AQH_FlashReadyMsg_GetUid(msg);
ni=_getOrCreateNodeAndUpdateUidAddr(aqh, msg, uid); ni=_getOrCreateNodeAndUpdateUidAddr(aqh, msg, uid);
if (ni) { if (ni) {
const char *s;
AQH_NodeInfo_SetManufacturer(ni, AQH_FlashReadyMsg_GetManufacturer(msg)); AQH_NodeInfo_SetManufacturer(ni, AQH_FlashReadyMsg_GetManufacturer(msg));
AQH_NodeInfo_SetDeviceType(ni, AQH_FlashReadyMsg_GetDeviceType(msg)); AQH_NodeInfo_SetDeviceType(ni, AQH_FlashReadyMsg_GetDeviceType(msg));
AQH_NodeInfo_SetDeviceVersion(ni, (AQH_FlashReadyMsg_GetDeviceVersion(msg)<<8)+AQH_FlashReadyMsg_GetDeviceRevision(msg)); AQH_NodeInfo_SetDeviceVersion(ni, (AQH_FlashReadyMsg_GetDeviceVersion(msg)<<8)+AQH_FlashReadyMsg_GetDeviceRevision(msg));
@@ -241,6 +266,9 @@ void _handleMsgFlashReady(AQHOMED *aqh, const GWEN_MSG *msg)
(AQH_FlashReadyMsg_GetFirmwareVersionMajor(msg)<<16) | (AQH_FlashReadyMsg_GetFirmwareVersionMajor(msg)<<16) |
(AQH_FlashReadyMsg_GetFirmwareVersionMinor(msg)<<8) | (AQH_FlashReadyMsg_GetFirmwareVersionMinor(msg)<<8) |
AQH_FlashReadyMsg_GetFirmwareVersionPatchlevel(msg)); AQH_FlashReadyMsg_GetFirmwareVersionPatchlevel(msg));
s=AQH_NodeInfo_GetDeviceId(ni);
if (!(s && *s))
_assignDeviceId(aqh, ni, uid);
_updateTimestampLastChange(ni); _updateTimestampLastChange(ni);
AQH_NodeDb_SetModified(aqh->nodeDb); AQH_NodeDb_SetModified(aqh->nodeDb);
} }
@@ -291,6 +319,32 @@ AQH_NODE_INFO *_getOrCreateNodeAndUpdateUidAddr(AQHOMED *aqh, const GWEN_MSG *ms
void _assignDeviceId(AQHOMED *aqh, AQH_NODE_INFO *ni, uint32_t uid)
{
const AQHNODE_DEVICE *dev;
dev=AqHomed_FindDeviceDef(aqh,
AQH_NodeInfo_GetManufacturer(ni),
AQH_NodeInfo_GetDeviceType(ni),
AQH_NodeInfo_GetDeviceVersion(ni));
if (dev==NULL) {
DBG_ERROR(NULL,
"Unknown NODE device encountered (%08x, %04x, %04x)",
AQH_NodeInfo_GetManufacturer(ni),
AQH_NodeInfo_GetDeviceType(ni),
AQH_NodeInfo_GetDeviceVersion(ni));
}
else {
const char *s;
s=AQHNODE_Device_GetName(dev);
DBG_ERROR(NULL, "Found device \"%s\" (%08x)", s?s:"<no name>", uid);
AQH_NodeInfo_SetDeviceId(ni, s);
}
}
void _updateTimestampLastChange(AQH_NODE_INFO *ni) void _updateTimestampLastChange(AQH_NODE_INFO *ni)
{ {
GWEN_TIMESTAMP *t; GWEN_TIMESTAMP *t;

View File

@@ -0,0 +1,125 @@
/****************************************************************************
* This file is part of the project AqHome.
* AqHome (c) by 2024 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.
****************************************************************************/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "./devicesdump.h"
#include "./aqhomed_p.h"
#include "aqhome/aqhome.h"
#include <gwenhywfar/debug.h>
/* ------------------------------------------------------------------------------------------------
* forward declarations
* ------------------------------------------------------------------------------------------------
*/
static void _dumpDevice(const AQHNODE_DEVICE *dev, GWEN_BUFFER *dbuf, int indent);
static void _dumpValue(const AQHNODE_VALUE *value, GWEN_BUFFER *dbuf, int indent);
/* ------------------------------------------------------------------------------------------------
* implementations
* ------------------------------------------------------------------------------------------------
*/
void AqHomeNodes_DumpDevices(const AQHNODE_DEVICE_LIST *devList, GWEN_BUFFER *dbuf)
{
if (devList && AQHNODE_Device_List_GetCount(devList)) {
const AQHNODE_DEVICE *dev;
GWEN_Buffer_AppendString(dbuf, "Devices:\n");
dev=AQHNODE_Device_List_First(devList);
while(dev) {
_dumpDevice(dev, dbuf, 2);
dev=AQHNODE_Device_List_Next(dev);
}
}
}
void _dumpDevice(const AQHNODE_DEVICE *dev, GWEN_BUFFER *dbuf, int indent)
{
const char *name;
const char *driver;
uint32_t manufacturer;
uint16_t deviceType;
uint16_t deviceVersion;
const AQHNODE_VALUE_LIST *valueList;
name=AQHNODE_Device_GetName(dev);
driver=AQHNODE_Device_GetDriver(dev);
manufacturer=AQHNODE_Device_GetManufacturer(dev);
deviceType=AQHNODE_Device_GetDeviceType(dev);
deviceVersion=AQHNODE_Device_GetDeviceVersion(dev);
GWEN_Buffer_FillWithBytes(dbuf, ' ', indent);
GWEN_Buffer_AppendArgs(dbuf, "Device: %s (%s, %08x, %04x, %04x)\n",
name?name:"<empty name>",
driver?driver:"<empty driver>",
manufacturer,
deviceType,
deviceVersion);
valueList=AQHNODE_Device_GetValueList(dev);
if (valueList && AQHNODE_Value_List_GetCount(valueList)) {
const AQHNODE_VALUE *value;
value=AQHNODE_Value_List_First(valueList);
while(value) {
_dumpValue(value, dbuf, indent+2);
value=AQHNODE_Value_List_Next(value);
}
}
}
void _dumpValue(const AQHNODE_VALUE *value, GWEN_BUFFER *dbuf, int indent)
{
int id;
const char *name;
const char *descr;
int valueType;
int dataType;
int modality;
const char *units;
id=AQHNODE_Value_GetId(value);
name=AQHNODE_Value_GetName(value);
descr=AQHNODE_Value_GetDescription(value);
valueType=AQHNODE_Value_GetValueType(value);
dataType=AQHNODE_Value_GetDataType(value);
modality=AQHNODE_Value_GetModality(value);
units=AQHNODE_Value_GetValueUnits(value);
GWEN_Buffer_FillWithBytes(dbuf, ' ', indent);
GWEN_Buffer_AppendArgs(dbuf, "Value: %d[%02x] (%s, %s, %s, %s, %s, %s)\n",
id, id,
name?name:"<empty name>",
AQH_ValueType_toString(valueType),
AQH_ValueDataType_toString(dataType),
AQH_ValueModality_toString(modality),
units?units:"<empty units>",
descr?descr:"<empty descr>");
}

View File

@@ -0,0 +1,24 @@
/****************************************************************************
* This file is part of the project AqHome.
* AqHome (c) by 2024 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 AQHOME_NODES_DEVICESDUMP_H
#define AQHOME_NODES_DEVICESDUMP_H
#include "./aqhomed.h"
#include "aqhome-nodes/types/device.h"
void AqHomeNodes_DumpDevices(const AQHNODE_DEVICE_LIST *devList, GWEN_BUFFER *dbuf);
#endif

View File

@@ -0,0 +1,396 @@
/****************************************************************************
* This file is part of the project AqHome.
* AqHome (c) by 2024 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.
****************************************************************************/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "./devicesread.h"
#include "./aqhomed_p.h"
#include "aqhome/aqhome.h"
#include <gwenhywfar/directory.h>
#include <gwenhywfar/debug.h>
#include <gwenhywfar/stringlist.h>
/* ------------------------------------------------------------------------------------------------
* defines
* ------------------------------------------------------------------------------------------------
*/
/* ------------------------------------------------------------------------------------------------
* forward declarations
* ------------------------------------------------------------------------------------------------
*/
static int _readDeviceFileToList(const char *sFilename, AQHNODE_DEVICE_LIST *deviceList);
static AQHNODE_DEVICE_LIST *_readDeviceFiles(const GWEN_STRINGLIST *sl);
static int _readXmlDevices(GWEN_XMLNODE *deviceListNode, AQHNODE_DEVICE_LIST *deviceList);
static AQHNODE_DEVICE *_readXmlDevice(GWEN_XMLNODE *deviceNode);
static AQHNODE_VALUE_LIST *_readXmlValueList(GWEN_XMLNODE *valuesNode);
static AQHNODE_VALUE *_readXmlValue(GWEN_XMLNODE *valueNode);
static int _readManufacturer(AQHNODE_DEVICE *device, GWEN_XMLNODE *deviceNode);
static int _readDeviceType(AQHNODE_DEVICE *device, GWEN_XMLNODE *deviceNode);
static int _readDeviceVersion(AQHNODE_DEVICE *device, GWEN_XMLNODE *deviceNode);
/* ------------------------------------------------------------------------------------------------
* implementations
* ------------------------------------------------------------------------------------------------
*/
AQHNODE_DEVICE_LIST *AqHomeNodes_ReadDeviceFile(const char *sFilename)
{
int rv;
rv=GWEN_Directory_GetPath(sFilename, GWEN_PATH_FLAGS_CHECKROOT | GWEN_PATH_FLAGS_PATHMUSTEXIST | GWEN_PATH_FLAGS_VARIABLE);
if (rv<0) {
DBG_ERROR(NULL, "File \"%s\" does not exists, writing later", sFilename);
return NULL;
}
else {
AQHNODE_DEVICE_LIST *deviceList;
deviceList=AQHNODE_Device_List_new();
rv=_readDeviceFileToList(sFilename, deviceList);
if (rv<0) {
DBG_ERROR(NULL, "File \"%s\" not found", sFilename);
AQHNODE_Device_List_free(deviceList);
return NULL;
}
if (AQHNODE_Device_List_GetCount(deviceList)<1) {
AQHNODE_Device_List_free(deviceList);
return NULL;
}
return deviceList;
}
}
AQHNODE_DEVICE_LIST *AqHomeNodes_ReadDataDeviceFiles()
{
GWEN_STRINGLIST *sl;
sl=AQH_GetListOfMatchingDataFiles("aqhome/devices/nodes", "*.xml");
if (sl) {
AQHNODE_DEVICE_LIST *deviceList;
deviceList=_readDeviceFiles(sl);
GWEN_StringList_free(sl);
if (deviceList==NULL) {
DBG_INFO(NULL, "Error reading data device files");
return NULL;
}
return deviceList;
}
else {
DBG_ERROR(NULL, "No data device files");
return NULL;
}
}
AQHNODE_DEVICE_LIST *_readDeviceFiles(const GWEN_STRINGLIST *sl)
{
GWEN_STRINGLISTENTRY *se;
AQHNODE_DEVICE_LIST *deviceList;
deviceList=AQHNODE_Device_List_new();
se=GWEN_StringList_FirstEntry(sl);
while(se) {
const char *s;
s=GWEN_StringListEntry_Data(se);
if (s && *s) {
int rv;
DBG_INFO(NULL, "Reading device file \"%s\"", s);
rv=_readDeviceFileToList(s, deviceList);
if (rv<0 && rv!=GWEN_ERROR_NO_DATA) {
DBG_WARN(NULL, "Error reading device file \"%s\" (%d), ignoring", s, rv);
}
}
se=GWEN_StringListEntry_Next(se);
}
if (AQHNODE_Device_List_GetCount(deviceList)<1) {
AQHNODE_Device_List_free(deviceList);
return NULL;
}
return deviceList;
}
int _readDeviceFileToList(const char *sFilename, AQHNODE_DEVICE_LIST *deviceList)
{
GWEN_XMLNODE *rootNode;
GWEN_XMLNODE *deviceListNode;
int rv;
rootNode=GWEN_XMLNode_new(GWEN_XMLNodeTypeTag, NULL);
rv=GWEN_XML_ReadFile(rootNode, sFilename, GWEN_XML_FLAGS_DEFAULT);
if (rv<0) {
DBG_ERROR(NULL, "Error reading XML file \"%s\": %d", sFilename, rv);
GWEN_XMLNode_free(rootNode);
return rv;
}
deviceListNode=GWEN_XMLNode_FindFirstTag(rootNode, "devices", NULL, NULL);
if (deviceListNode==NULL)
deviceListNode=rootNode;
rv=_readXmlDevices(deviceListNode, deviceList);
if (rv<0 && rv!=GWEN_ERROR_NO_DATA) {
DBG_ERROR(AQH_LOGDOMAIN, "Error reading devices from file \"%s\" (%d)", sFilename, rv);
GWEN_XMLNode_free(rootNode);
return rv;
}
GWEN_XMLNode_free(rootNode);
return 0;
}
int _readXmlDevices(GWEN_XMLNODE *deviceListNode, AQHNODE_DEVICE_LIST *deviceList)
{
GWEN_XMLNODE *deviceNode;
deviceNode=GWEN_XMLNode_FindFirstTag(deviceListNode, "device", NULL, NULL);
if (deviceNode) {
while(deviceNode) {
const char *driverName;
driverName=GWEN_XMLNode_GetProperty(deviceNode, "driver", NULL);
if (driverName && *driverName && strcasecmp(driverName, "nodes")==0) {
AQHNODE_DEVICE *device;
device=_readXmlDevice(deviceNode);
if (device==NULL) {
DBG_INFO(NULL, "Error reading device from XML");
return GWEN_ERROR_BAD_DATA;
}
else {
const char *sDeviceName;
sDeviceName=AQHNODE_Device_GetName(device);
if (sDeviceName && *sDeviceName) {
DBG_ERROR(NULL, "Adding device type \"%s\" to list", sDeviceName?sDeviceName:"<no type name>");
AQHNODE_Device_List_Add(device, deviceList);
}
else {
DBG_ERROR(NULL, "Device with no name, not adding");
AQHNODE_Device_free(device);
}
}
}
else {
DBG_INFO(NULL, "Device is not an NODES device, ignoring");
}
deviceNode=GWEN_XMLNode_FindNextTag(deviceNode, "device", NULL, NULL);
} /* while */
return 0;
}
else {
DBG_INFO(NULL, "No <device> element found");
return GWEN_ERROR_NO_DATA;
}
}
AQHNODE_DEVICE *_readXmlDevice(GWEN_XMLNODE *deviceNode)
{
AQHNODE_DEVICE *device;
GWEN_XMLNODE *valuesNode;
int rv;
device=AQHNODE_Device_new();
AQHNODE_Device_SetName(device, GWEN_XMLNode_GetProperty(deviceNode, "name", NULL));
AQHNODE_Device_SetDriver(device, GWEN_XMLNode_GetProperty(deviceNode, "driver", NULL));
rv=_readManufacturer(device, deviceNode);
if (rv<0) {
DBG_INFO(NULL, "here (%d)", rv);
AQHNODE_Device_free(device);
return NULL;
}
rv=_readDeviceType(device, deviceNode);
if (rv<0) {
DBG_INFO(NULL, "here (%d)", rv);
AQHNODE_Device_free(device);
return NULL;
}
rv=_readDeviceVersion(device, deviceNode);
if (rv<0) {
DBG_INFO(NULL, "here (%d)", rv);
AQHNODE_Device_free(device);
return NULL;
}
/* read values */
valuesNode=GWEN_XMLNode_FindFirstTag(deviceNode, "values", NULL, NULL);
if (valuesNode) {
AQHNODE_VALUE_LIST *valueList;
valueList=_readXmlValueList(valuesNode);
if (valueList==NULL) {
DBG_INFO(NULL, "here");
AQHNODE_Device_free(device);
return NULL;
}
AQHNODE_Device_SetValueList(device, valueList);
}
else {
DBG_INFO(NULL, "No <values> element");
AQHNODE_Device_free(device);
return NULL;
}
return device;
}
AQHNODE_VALUE_LIST *_readXmlValueList(GWEN_XMLNODE *valuesNode)
{
AQHNODE_VALUE_LIST *valueList;
GWEN_XMLNODE *node;
valueList=AQHNODE_Value_List_new();
node=GWEN_XMLNode_FindFirstTag(valuesNode, "value", NULL, NULL);
while(node) {
AQHNODE_VALUE *value;
value=_readXmlValue(node);
if (value)
AQHNODE_Value_List_Add(value, valueList);
else {
DBG_INFO(NULL, "Error reading <value> element");
AQHNODE_Value_List_free(valueList);
return NULL;
}
node=GWEN_XMLNode_FindNextTag(node, "value", NULL, NULL);
}
if (AQHNODE_Value_List_GetCount(valueList)<1) {
DBG_INFO(NULL, "No <value> element in <values> element");
AQHNODE_Value_List_free(valueList);
return NULL;
}
return valueList;
}
AQHNODE_VALUE *_readXmlValue(GWEN_XMLNODE *valueNode)
{
AQHNODE_VALUE *value;
value=AQHNODE_Value_new();
AQHNODE_Value_SetName(value, GWEN_XMLNode_GetProperty(valueNode, "name", NULL));
AQHNODE_Value_SetId(value, GWEN_XMLNode_GetIntProperty(valueNode, "id", 0));
AQHNODE_Value_SetValueUnits(value, GWEN_XMLNode_GetProperty(valueNode, "units", NULL));
AQHNODE_Value_SetValueType(value, AQH_ValueType_fromString(GWEN_XMLNode_GetProperty(valueNode, "type", NULL)));
AQHNODE_Value_SetDataType(value, AQH_ValueDataType_fromString(GWEN_XMLNode_GetProperty(valueNode, "dataType", NULL)));
AQHNODE_Value_SetModality(value, AQH_ValueModality_fromString(GWEN_XMLNode_GetProperty(valueNode, "modality", NULL)));
return value;
}
int _readManufacturer(AQHNODE_DEVICE *device, GWEN_XMLNODE *deviceNode)
{
const char *s;
uint32_t v;
s=GWEN_XMLNode_GetCharValue(deviceNode, "manufacturer", NULL);
if (!(s && *s)) {
DBG_ERROR(NULL, "Missing manufacturer");
return GWEN_ERROR_BAD_DATA;
}
if (strlen(s)>4) {
DBG_ERROR(NULL, "Bad manufacturer string (too long): \"%s\"", s);
return GWEN_ERROR_BAD_DATA;
}
v=0;
while(*s) {
v<<=8;
v|=*s & 0xff;
s++;
}
v=((v>>24) & 0x000000ffL) |
((v>>8) & 0x0000ff00L) |
((v<<8) & 0x00ff0000L) |
((v<<24) & 0xff000000L);
AQHNODE_Device_SetManufacturer(device, v);
return 0;
}
int _readDeviceType(AQHNODE_DEVICE *device, GWEN_XMLNODE *deviceNode)
{
const char *s;
uint16_t v;
s=GWEN_XMLNode_GetCharValue(deviceNode, "devicetype", NULL);
if (!(s && *s)) {
DBG_ERROR(NULL, "Missing device type");
return GWEN_ERROR_BAD_DATA;
}
if (strlen(s)>2) {
DBG_ERROR(NULL, "Bad devicetype string (too long): \"%s\"", s);
return GWEN_ERROR_BAD_DATA;
}
v=0;
while(*s) {
v<<=8;
v|=*s & 0xff;
s++;
}
AQHNODE_Device_SetDeviceType(device, v);
return 0;
}
int _readDeviceVersion(AQHNODE_DEVICE *device, GWEN_XMLNODE *deviceNode)
{
int v;
v=GWEN_XMLNode_GetIntValue(deviceNode, "deviceversion", -1);
if (v<0) {
DBG_ERROR(NULL, "Missing device version");
return GWEN_ERROR_BAD_DATA;
}
AQHNODE_Device_SetDeviceVersion(device, v<<8);
return 0;
}

View File

@@ -0,0 +1,25 @@
/****************************************************************************
* This file is part of the project AqHome.
* AqHome (c) by 2024 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 AQHOME_NODES_DEVICESREAD_H
#define AQHOME_NODES_DEVICESREAD_H
#include "./aqhomed.h"
#include "aqhome-nodes/types/device.h"
AQHNODE_DEVICE_LIST *AqHomeNodes_ReadDeviceFile(const char *sFilename);
AQHNODE_DEVICE_LIST *AqHomeNodes_ReadDataDeviceFiles(void);
#endif

View File

@@ -14,6 +14,8 @@
#include "./init.h" #include "./init.h"
#include "./aqhomed_p.h" #include "./aqhomed_p.h"
#include "./tty_log.h" #include "./tty_log.h"
#include "./devicesread.h"
#include "./devicesdump.h"
#include "aqhome/aqhome.h" #include "aqhome/aqhome.h"
#include "aqhome/msg/endpoint_tty.h" #include "aqhome/msg/endpoint_tty.h"
@@ -65,6 +67,7 @@ static void _setupBroker(AQHOMED *aqh, GWEN_DB_NODE *dbArgs);
static GWEN_MSG_ENDPOINT *_acceptIpcFn(GWEN_MSG_ENDPOINT *ep, GWEN_SOCKET *sk, const GWEN_INETADDRESS *addr, void *data); static GWEN_MSG_ENDPOINT *_acceptIpcFn(GWEN_MSG_ENDPOINT *ep, GWEN_SOCKET *sk, const GWEN_INETADDRESS *addr, void *data);
static void _setupLog(AQHOMED *aqh, GWEN_DB_NODE *dbArgs); static void _setupLog(AQHOMED *aqh, GWEN_DB_NODE *dbArgs);
static void _setupDb(AQHOMED *aqh, GWEN_DB_NODE *dbArgs); static void _setupDb(AQHOMED *aqh, GWEN_DB_NODE *dbArgs);
static int _loadDeviceList(AQHOMED *aqh);
static int _readArgs(int argc, char **argv, GWEN_DB_NODE *dbArgs); static int _readArgs(int argc, char **argv, GWEN_DB_NODE *dbArgs);
static int _createPidFile(const char *pidFilename); static int _createPidFile(const char *pidFilename);
@@ -113,6 +116,20 @@ int AqHomed_Init(AQHOMED *aqh, int argc, char **argv)
aqh->nodeAddress=GWEN_DB_GetIntValue(dbArgs, "nodeAddress", 0, AQHOMED_DEFAULT_NODEADDR); aqh->nodeAddress=GWEN_DB_GetIntValue(dbArgs, "nodeAddress", 0, AQHOMED_DEFAULT_NODEADDR);
rv=_loadDeviceList(aqh);
if (rv<0) {
DBG_ERROR(NULL, "Error loading device list(%d)", rv);
return rv;
}
else {
GWEN_BUFFER *dbuf;
dbuf=GWEN_Buffer_new(0, 256, 0, 1);
AqHomeNodes_DumpDevices(aqh->deviceDefList, dbuf);
fprintf(stdout, "%s\n", GWEN_Buffer_GetStart(dbuf));
GWEN_Buffer_free(dbuf);
}
_setupDb(aqh, dbArgs); _setupDb(aqh, dbArgs);
rv=_setupTty(aqh, dbArgs); rv=_setupTty(aqh, dbArgs);
@@ -220,9 +237,9 @@ void _setupBroker(AQHOMED *aqh, GWEN_DB_NODE *dbArgs)
GWEN_MSG_ENDPOINT *_acceptIpcFn(GWEN_MSG_ENDPOINT *ep, GWEN_MSG_ENDPOINT *_acceptIpcFn(GWEN_UNUSED GWEN_MSG_ENDPOINT *ep,
GWEN_SOCKET *sk, GWEN_SOCKET *sk,
const GWEN_INETADDRESS *addr, GWEN_UNUSED const GWEN_INETADDRESS *addr,
GWEN_UNUSED void *data) GWEN_UNUSED void *data)
{ {
/* AQHOMED *aqh; /* AQHOMED *aqh;
@@ -258,7 +275,7 @@ void _setupDb(AQHOMED *aqh, GWEN_DB_NODE *dbArgs)
AqHomed_SetDbFile(aqh, s); AqHomed_SetDbFile(aqh, s);
dbNodeDb=GWEN_DB_Group_new("dbNodes"); dbNodeDb=GWEN_DB_Group_new("dbNodes");
rv=GWEN_DB_ReadFile(dbNodeDb, s, GWEN_DB_FLAGS_DEFAULT); rv=GWEN_DB_ReadFile(dbNodeDb, s, GWEN_DB_FLAGS_DEFAULT|GWEN_PATH_FLAGS_CREATE_GROUP);
if (rv==0) { if (rv==0) {
AQH_NodeDb_fromDb(aqh->nodeDb, dbNodeDb); AQH_NodeDb_fromDb(aqh->nodeDb, dbNodeDb);
} }
@@ -268,6 +285,21 @@ void _setupDb(AQHOMED *aqh, GWEN_DB_NODE *dbArgs)
int _loadDeviceList(AQHOMED *aqh)
{
AQHNODE_DEVICE_LIST *deviceList;
deviceList=AqHomeNodes_ReadDataDeviceFiles();
if (deviceList==NULL) {
DBG_ERROR(NULL, "Error reading device list");
return GWEN_ERROR_GENERIC;
}
aqh->deviceDefList=deviceList;
return 0;
}
int _createPidFile(const char *pidFilename) int _createPidFile(const char *pidFilename)
{ {
FILE *f; FILE *f;

View File

@@ -13,6 +13,7 @@
#include "./loop_broker.h" #include "./loop_broker.h"
#include "./aqhomed_p.h" #include "./aqhomed_p.h"
#include "./b_setdata.h"
#include "./tty_log.h" #include "./tty_log.h"
#include "./db.h" #include "./db.h"
@@ -22,6 +23,7 @@
#include "aqhome/msg/msg_ping.h" #include "aqhome/msg/msg_ping.h"
#include "aqhome/ipc/endpoint_ipc.h" #include "aqhome/ipc/endpoint_ipc.h"
#include "aqhome/ipc/msg_ipc_result.h" #include "aqhome/ipc/msg_ipc_result.h"
#include "aqhome/ipc/data/ipc_data.h"
#include <gwenhywfar/gwenhywfar.h> #include <gwenhywfar/gwenhywfar.h>
#include <gwenhywfar/args.h> #include <gwenhywfar/args.h>
@@ -43,6 +45,9 @@
*/ */
static void _handleIpcMsg(AQHOMED *aqh, GWEN_MSG_ENDPOINT *ep, GWEN_MSG *msg);
/* ------------------------------------------------------------------------------------------------ /* ------------------------------------------------------------------------------------------------
* implementations * implementations
@@ -62,7 +67,7 @@ void AqHomed_ReadAndHandleBrokerMessages(AQHOMED *aqh)
code=GWEN_IpcMsg_GetCode(msg); code=GWEN_IpcMsg_GetCode(msg);
DBG_DEBUG(AQH_LOGDOMAIN, "Received IPC packet %d (%x)", (int) code, code); DBG_DEBUG(AQH_LOGDOMAIN, "Received IPC packet %d (%x)", (int) code, code);
_handleIpcMsg(aqh, epTcp, msg);
GWEN_Msg_free(msg); GWEN_Msg_free(msg);
} }
} }
@@ -70,6 +75,24 @@ void AqHomed_ReadAndHandleBrokerMessages(AQHOMED *aqh)
void _handleIpcMsg(AQHOMED *aqh, GWEN_MSG_ENDPOINT *ep, GWEN_MSG *msg)
{
uint16_t code;
/* exec IPC message */
code=GWEN_IpcMsg_GetCode(msg);
DBG_DEBUG(AQH_LOGDOMAIN, "Received IPC packet");
switch(code) {
// case AQH_MSGTYPE_IPC_DATA_SETDATA: AqHomeNodes_HandleBrokerSetData(aqh, ep, msg); break;
default: break;
}
}

View File

@@ -13,7 +13,9 @@
#include "./aqhomed.h" #include "./aqhomed.h"
/**
* Handle messageexchange with the broker (aqhome-data).
*/
void AqHomed_ReadAndHandleBrokerMessages(AQHOMED *aqh); void AqHomed_ReadAndHandleBrokerMessages(AQHOMED *aqh);

View File

@@ -19,6 +19,7 @@
#include "aqhome/msg/endpoint_tty.h" #include "aqhome/msg/endpoint_tty.h"
#include "aqhome/msg/msg_node.h" #include "aqhome/msg/msg_node.h"
#include "aqhome/msg/msg_value2.h" #include "aqhome/msg/msg_value2.h"
#include "aqhome/msg/msg_value3.h"
#include "aqhome/msg/msg_ping.h" #include "aqhome/msg/msg_ping.h"
#include "aqhome/ipc/endpoint_ipc.h" #include "aqhome/ipc/endpoint_ipc.h"
#include "aqhome/ipc/nodes/ipc_nodes.h" #include "aqhome/ipc/nodes/ipc_nodes.h"
@@ -27,6 +28,8 @@
#include "aqhome/ipc/nodes/msg_ipc_ping.h" #include "aqhome/ipc/nodes/msg_ipc_ping.h"
#include "aqhome/ipc/nodes/msg_ipc_setaccmsggrps.h" #include "aqhome/ipc/nodes/msg_ipc_setaccmsggrps.h"
#include "aqhome/ipc/nodes/msg_ipc_getdevices_rsp.h" #include "aqhome/ipc/nodes/msg_ipc_getdevices_rsp.h"
#include "aqhome/ipc/data/ipc_data.h"
#include "aqhome/ipc/data/msg_data_set.h"
#include "aqhome/ipc/msg_ipc_result.h" #include "aqhome/ipc/msg_ipc_result.h"
#include <gwenhywfar/gwenhywfar.h> #include <gwenhywfar/gwenhywfar.h>
@@ -34,6 +37,8 @@
#include <gwenhywfar/debug.h> #include <gwenhywfar/debug.h>
#include <gwenhywfar/endpoint_tcpd.h> #include <gwenhywfar/endpoint_tcpd.h>
#include <stdio.h>
/* ------------------------------------------------------------------------------------------------ /* ------------------------------------------------------------------------------------------------
@@ -52,11 +57,14 @@
*/ */
static void _handleIpcEndpoint(AQHOMED *aqh, GWEN_MSG_ENDPOINT *ep); static void _handleIpcEndpoint(AQHOMED *aqh, GWEN_MSG_ENDPOINT *ep);
static void _handleIpcMsg(AQHOMED *aqh, GWEN_MSG_ENDPOINT *ep, const GWEN_MSG *msg); static void _handleIpcMsg(AQHOMED *aqh, GWEN_MSG_ENDPOINT *ep, GWEN_MSG *msg);
void _handleIpcMsgPing(AQHOMED *aqh, GWEN_MSG_ENDPOINT *ep, const GWEN_MSG *msg); void _handleIpcMsgPing(AQHOMED *aqh, GWEN_MSG_ENDPOINT *ep, const GWEN_MSG *msg);
void _handleIpcMsgSetAccMsgGrps(AQHOMED *aqh, GWEN_MSG_ENDPOINT *ep, const GWEN_MSG *msg); void _handleIpcMsgSetAccMsgGrps(AQHOMED *aqh, GWEN_MSG_ENDPOINT *ep, const GWEN_MSG *msg);
void _handleIpcMsgForward(AQHOMED *aqh, GWEN_MSG_ENDPOINT *ep, const GWEN_MSG *msg); void _handleIpcMsgForward(AQHOMED *aqh, GWEN_MSG_ENDPOINT *ep, const GWEN_MSG *msg);
void _handleIpcMsgGetDevicesReq(AQHOMED *aqh, GWEN_MSG_ENDPOINT *ep, const GWEN_MSG *msg); void _handleIpcMsgGetDevicesReq(AQHOMED *aqh, GWEN_MSG_ENDPOINT *ep, const GWEN_MSG *msg);
void _handleIpcMsgSetData(AQHOMED *aqh, GWEN_MSG_ENDPOINT *ep, GWEN_MSG *msg);
static int _readDataFromString(const char *s, uint16_t *pDataVal, uint16_t *pValDenom);
static AQH_NODE_INFO *_getNodeInfoFromValue(AQHOMED *aqh, const AQH_VALUE *value);
@@ -93,18 +101,19 @@ void _handleIpcEndpoint(AQHOMED *aqh, GWEN_MSG_ENDPOINT *ep)
void _handleIpcMsg(AQHOMED *aqh, GWEN_MSG_ENDPOINT *ep, const GWEN_MSG *msg) void _handleIpcMsg(AQHOMED *aqh, GWEN_MSG_ENDPOINT *ep, GWEN_MSG *msg)
{ {
uint16_t code; uint16_t code;
/* exec IPC message */ /* exec IPC message */
code=GWEN_IpcMsg_GetCode(msg); code=GWEN_IpcMsg_GetCode(msg);
DBG_DEBUG(AQH_LOGDOMAIN, "Received IPC packet"); DBG_INFO(AQH_LOGDOMAIN, "Received IPC packet (%d, %04x)", code, code);
switch(code) { switch(code) {
case AQH_MSGTYPE_IPC_NODES_PING: _handleIpcMsgPing(aqh, ep, msg); break; case AQH_MSGTYPE_IPC_NODES_PING: _handleIpcMsgPing(aqh, ep, msg); break;
case AQH_MSGTYPE_IPC_NODES_SETACCMSGGRPS: _handleIpcMsgSetAccMsgGrps(aqh, ep, msg); break; case AQH_MSGTYPE_IPC_NODES_SETACCMSGGRPS: _handleIpcMsgSetAccMsgGrps(aqh, ep, msg); break;
case AQH_MSGTYPE_IPC_NODES_FORWARD: _handleIpcMsgForward(aqh, ep, msg); break; case AQH_MSGTYPE_IPC_NODES_FORWARD: _handleIpcMsgForward(aqh, ep, msg); break;
case AQH_MSGTYPE_IPC_NODES_GETDEVICES_REQ: _handleIpcMsgGetDevicesReq(aqh, ep, msg); break; case AQH_MSGTYPE_IPC_NODES_GETDEVICES_REQ: _handleIpcMsgGetDevicesReq(aqh, ep, msg); break;
case AQH_MSGTYPE_IPC_DATA_SETDATA: _handleIpcMsgSetData(aqh, ep, msg); break;
default: break; default: break;
} }
} }
@@ -128,7 +137,7 @@ void _handleIpcMsgSetAccMsgGrps(AQHOMED *aqh, GWEN_MSG_ENDPOINT *ep, const GWEN_
{ {
uint32_t groups; uint32_t groups;
DBG_DEBUG(AQH_LOGDOMAIN, "Received IPC SET_ACCEPTED_MSG_GROUPS message"); DBG_INFO(AQH_LOGDOMAIN, "Received IPC SET_ACCEPTED_MSG_GROUPS message");
groups=AQH_SetAcceptedMsgGroupsIpcMsg_GetMsgGroups(msg); groups=AQH_SetAcceptedMsgGroupsIpcMsg_GetMsgGroups(msg);
AQH_IpcEndpoint_SetAcceptedMsgGroups(ep, groups); AQH_IpcEndpoint_SetAcceptedMsgGroups(ep, groups);
// TODO: send response? // TODO: send response?
@@ -154,7 +163,7 @@ void _handleIpcMsgGetDevicesReq(AQHOMED *aqh, GWEN_MSG_ENDPOINT *ep, const GWEN_
{ {
AQH_NODE_INFO_LIST *nodeInfoList; AQH_NODE_INFO_LIST *nodeInfoList;
DBG_DEBUG(AQH_LOGDOMAIN, "Received IPC GetDevicesRequest message"); DBG_INFO(AQH_LOGDOMAIN, "Received IPC GetDevicesRequest message");
nodeInfoList=AQH_NodeDb_GetAllNodeInfos(aqh->nodeDb); nodeInfoList=AQH_NodeDb_GetAllNodeInfos(aqh->nodeDb);
if (nodeInfoList && AQH_NodeInfo_List_GetCount(nodeInfoList)) { if (nodeInfoList && AQH_NodeInfo_List_GetCount(nodeInfoList)) {
const AQH_NODE_INFO *ni; const AQH_NODE_INFO *ni;
@@ -166,7 +175,9 @@ void _handleIpcMsgGetDevicesReq(AQHOMED *aqh, GWEN_MSG_ENDPOINT *ep, const GWEN_
niNext=AQH_NodeInfo_List_Next(ni); niNext=AQH_NodeInfo_List_Next(ni);
DBG_INFO(AQH_LOGDOMAIN, "Sending response for node %02x (%08x)", AQH_NodeInfo_GetBusAddress(ni), AQH_NodeInfo_GetUid(ni)); DBG_INFO(AQH_LOGDOMAIN, "Sending response for node %02x (%08x)", AQH_NodeInfo_GetBusAddress(ni), AQH_NodeInfo_GetUid(ni));
msgOut=AQH_GetDevicesResponseIpcMsg_new(AQH_MSGTYPE_IPC_NODES_GETDEVICES_RSP, niNext?0:AQH_MSGIPC_GETDEVICES_RSP_FLAGS_LAST, ni); msgOut=AQH_GetDevicesResponseIpcMsg_new(AQH_MSGTYPE_IPC_NODES_GETDEVICES_RSP,
GWEN_MsgEndpoint_GetNextMessageId(ep), GWEN_IpcMsg_GetMsgId(msg),
niNext?0:AQH_MSGIPC_GETDEVICES_RSP_FLAGS_LAST, ni);
GWEN_MsgEndpoint_AddSendMessage(ep, msgOut); GWEN_MsgEndpoint_AddSendMessage(ep, msgOut);
ni=niNext; ni=niNext;
} }
@@ -175,13 +186,112 @@ void _handleIpcMsgGetDevicesReq(AQHOMED *aqh, GWEN_MSG_ENDPOINT *ep, const GWEN_
GWEN_MSG *msgOut; GWEN_MSG *msgOut;
DBG_INFO(AQH_LOGDOMAIN, "No nodes"); DBG_INFO(AQH_LOGDOMAIN, "No nodes");
msgOut=AQH_ResultIpcMsg_new(AQH_MSGTYPE_IPC_NODES_RESULT, AQH_MSG_IPC_ERROR_NODATA); msgOut=AQH_ResultIpcMsg_new(AQH_MSGTYPE_IPC_NODES_RESULT,
GWEN_MsgEndpoint_GetNextMessageId(ep), GWEN_IpcMsg_GetMsgId(msg),
AQH_MSG_IPC_ERROR_NODATA);
GWEN_MsgEndpoint_AddSendMessage(ep, msgOut); GWEN_MsgEndpoint_AddSendMessage(ep, msgOut);
} }
} }
void _handleIpcMsgSetData(AQHOMED *aqh, GWEN_MSG_ENDPOINT *ep, GWEN_MSG *msg)
{
if (aqh->ttyEndpoint && GWEN_MsgEndpoint_GetState(aqh->ttyEndpoint)==GWEN_MSG_ENDPOINT_STATE_CONNECTED) {
AQH_VALUE *value;
DBG_DEBUG(AQH_LOGDOMAIN, "Received IPC SetDataRequest message");
AQH_SetDataIpcMsg_Parse(msg, 0);
value=AQH_SetDataIpcMsg_ReadValue(msg);
if (value) {
char *data;
data=AQH_SetDataIpcMsg_ReadData(msg);
if (data) {
uint16_t dataVal=0;
uint16_t dataDenom=0;
if (_readDataFromString(data, &dataVal, &dataDenom)==0) {
AQH_NODE_INFO *nodeInfo;
nodeInfo=_getNodeInfoFromValue(aqh, value);
if (nodeInfo) {
int valueId=0;
const char *s;
s=AQH_Value_GetName(value);
if (s && *s && 1==sscanf(s, "%d", &valueId)) {
GWEN_MSG *msgOut;
int destAddr;
destAddr=AQH_NodeInfo_GetBusAddress(nodeInfo);
msgOut=AQH_Value3Msg_new(aqh->nodeAddress, destAddr, AQH_MSG_TYPE_VALUE_SET, 0 /* msgid*/, valueId, dataVal, dataDenom);
GWEN_MsgEndpoint_AddSendMessage(aqh->ttyEndpoint, msgOut);
}
else {
DBG_ERROR(AQH_LOGDOMAIN, "Invalid value id \"%s\"", s);
}
}
else {
DBG_ERROR(AQH_LOGDOMAIN, "No matching node found");
}
}
free(data);
}
AQH_Value_free(value);
}
else {
DBG_ERROR(AQH_LOGDOMAIN, "Could not read value from message");
}
}
}
int _readDataFromString(const char *s, uint16_t *pDataVal, uint16_t *pDataDenom)
{
if (s && *s) {
if (*s=='&') {
unsigned long int v=0;
s++;
if (1==sscanf(s, "%lx", &v)) {
*pDataVal=(v>>16) & 0xffff;
*pDataDenom=v & 0xffff;
return 0;
}
else {
DBG_ERROR(AQH_LOGDOMAIN, "Bad hex value \"%s\"", s);
}
}
}
return GWEN_ERROR_GENERIC;
}
AQH_NODE_INFO *_getNodeInfoFromValue(AQHOMED *aqh, const AQH_VALUE *value)
{
const char *s;
unsigned long int uid;
s=AQH_Value_GetDeviceName(value);
if (s && *s && 1==sscanf(s, "%lx", &uid)) {
AQH_NODE_INFO *ni;
ni=AQH_NodeDb_GetNodeInfoByUid(aqh->nodeDb, uid);
if (ni==NULL) {
DBG_INFO(AQH_LOGDOMAIN, "Node \"%08lx\" not found", uid);
return NULL;
}
return ni;
}
return NULL;
}

View File

@@ -48,13 +48,11 @@
* ------------------------------------------------------------------------------------------------ * ------------------------------------------------------------------------------------------------
*/ */
static void _processValue2Message(AQHOMED *aqh, const GWEN_MSG *nodeMsg);
static void _processValue3Message(AQHOMED *aqh, const GWEN_MSG *nodeMsg); static void _processValue3Message(AQHOMED *aqh, const GWEN_MSG *nodeMsg);
static void _processSendStatsMessage(AQHOMED *aqh, const GWEN_MSG *nodeMsg); static void _processSendStatsMessage(AQHOMED *aqh, const GWEN_MSG *nodeMsg);
static void _processRecvStatsMessage(AQHOMED *aqh, const GWEN_MSG *nodeMsg); static void _processRecvStatsMessage(AQHOMED *aqh, const GWEN_MSG *nodeMsg);
static void _publishInt(AQHOMED *aqh, uint32_t uid, int valueId, const char *valueUnits, const char *valuePath, int v); static void _publishInt(AQHOMED *aqh, uint32_t uid, const char *vPath, int vModality, const char *vUnits, int v);
static void _publishDouble(AQHOMED *aqh, uint32_t uid, int valueId, const char *valueUnits, const char *valuePath, double v); static void _publishDouble(AQHOMED *aqh, uint32_t uid, const char *vPath, int vType, const char *vUnits, double v);
static void _setValueNameForDriver(AQH_VALUE *value, int valueId, const char *valuePath);
static void _setDeviceName(AQH_VALUE *value, uint32_t uid); static void _setDeviceName(AQH_VALUE *value, uint32_t uid);
@@ -69,9 +67,6 @@ void AqHomed_ForwardTtyMsgToBroker(AQHOMED *aqh, const GWEN_MSG *nodeMsg)
if (GWEN_MsgEndpoint_GetState(aqh->brokerEndpoint)==GWEN_MSG_ENDPOINT_STATE_CONNECTED) { if (GWEN_MsgEndpoint_GetState(aqh->brokerEndpoint)==GWEN_MSG_ENDPOINT_STATE_CONNECTED) {
DBG_DEBUG(AQH_LOGDOMAIN, "Processing output message"); DBG_DEBUG(AQH_LOGDOMAIN, "Processing output message");
switch(AQH_NodeMsg_GetMsgType(nodeMsg)) { switch(AQH_NodeMsg_GetMsgType(nodeMsg)) {
case AQH_MSG_TYPE_VALUE2:
_processValue2Message(aqh, nodeMsg);
break;
case AQH_MSG_TYPE_VALUE_REPORT: case AQH_MSG_TYPE_VALUE_REPORT:
_processValue3Message(aqh, nodeMsg); _processValue3Message(aqh, nodeMsg);
break; break;
@@ -89,26 +84,39 @@ void AqHomed_ForwardTtyMsgToBroker(AQHOMED *aqh, const GWEN_MSG *nodeMsg)
void _processValue2Message(AQHOMED *aqh, const GWEN_MSG *nodeMsg)
{
_publishDouble(aqh,
AQH_Value2Msg_GetUid(nodeMsg),
AQH_Value2Msg_GetValueId(nodeMsg),
AQH_Value2Msg_GetValueTypeUnits(nodeMsg),
AQH_Value2Msg_GetValueTypeName(nodeMsg),
AQH_Value2Msg_GetValue(nodeMsg));
}
void _processValue3Message(AQHOMED *aqh, const GWEN_MSG *nodeMsg) void _processValue3Message(AQHOMED *aqh, const GWEN_MSG *nodeMsg)
{ {
_publishDouble(aqh, uint32_t uid;
AQH_Value3Msg_GetUid(nodeMsg), uint8_t valueId;
AQH_Value3Msg_GetValueId(nodeMsg), AQH_NODE_INFO *ni;
AQH_Value3Msg_GetValueTypeUnits(nodeMsg), double v;
AQH_Value3Msg_GetValueTypeName(nodeMsg),
AQH_Value3Msg_GetValue(nodeMsg)); uid=AQH_Value3Msg_GetUid(nodeMsg);
valueId=AQH_Value3Msg_GetValueId(nodeMsg);
v=AQH_Value3Msg_GetValue(nodeMsg);
ni=AQH_NodeDb_GetNodeInfoByUid(aqh->nodeDb, uid);
if (ni) {
const char *devName;
devName=AQH_NodeInfo_GetDeviceId(ni);
if (devName) {
const AQHNODE_DEVICE *devInfo;
devInfo=AqHomed_GetDeviceDefByName(aqh, devName);
if (devInfo) {
const AQHNODE_VALUE *value;
value=AQHNODE_Value_List_GetById(AQHNODE_Device_GetValueList(devInfo), valueId);
if (value) {
const char *vname;
vname=AQHNODE_Value_GetName(value);
if (vname && *vname)
_publishDouble(aqh, uid, vname, AQHNODE_Value_GetModality(value), AQHNODE_Value_GetValueUnits(value), v);
}
}
}
}
} }
@@ -119,12 +127,14 @@ void _processSendStatsMessage(AQHOMED *aqh, const GWEN_MSG *nodeMsg)
packetsOutInt=AQH_SendStatsMsg_GetPacketsOut(nodeMsg); packetsOutInt=AQH_SendStatsMsg_GetPacketsOut(nodeMsg);
if (packetsOutInt) { if (packetsOutInt) {
uint32_t uid;
double packetsOut; double packetsOut;
double collisions; double collisions;
double busy; double busy;
double collisionsPercentage=0.0; double collisionsPercentage=0.0;
double busyPercentage=0.0; double busyPercentage=0.0;
uid=AQH_SendStatsMsg_GetUid(nodeMsg);
packetsOut=/*(double)*/ packetsOutInt; packetsOut=/*(double)*/ packetsOutInt;
collisions=/*(double)*/ AQH_SendStatsMsg_GetCollisions(nodeMsg); collisions=/*(double)*/ AQH_SendStatsMsg_GetCollisions(nodeMsg);
busy=/*(double)*/ AQH_SendStatsMsg_GetBusyErrors(nodeMsg); busy=/*(double)*/ AQH_SendStatsMsg_GetBusyErrors(nodeMsg);
@@ -132,10 +142,10 @@ void _processSendStatsMessage(AQHOMED *aqh, const GWEN_MSG *nodeMsg)
collisionsPercentage=collisions*100.0/packetsOut; collisionsPercentage=collisions*100.0/packetsOut;
busyPercentage=busy*100.0/packetsOut; busyPercentage=busy*100.0/packetsOut;
_publishInt(aqh, AQH_SendStatsMsg_GetUid(nodeMsg), 0, NULL, "net/packetsOut", packetsOutInt); _publishInt( aqh, uid, "net/packetsOut", 0, NULL, packetsOutInt);
_publishInt(aqh, AQH_SendStatsMsg_GetUid(nodeMsg), 0, NULL, "net/collisions", (int) AQH_SendStatsMsg_GetCollisions(nodeMsg)); _publishInt( aqh, uid, "net/collisions", 0, NULL, (int) AQH_SendStatsMsg_GetCollisions(nodeMsg));
_publishDouble(aqh, AQH_SendStatsMsg_GetUid(nodeMsg), 0, "%", "net/collisionsPercent", collisionsPercentage); _publishDouble(aqh, uid, "net/collisionsPercent", 0, "%", collisionsPercentage);
_publishDouble(aqh, AQH_SendStatsMsg_GetUid(nodeMsg), 0, "%", "net/busyPercent", busyPercentage); _publishDouble(aqh, uid, "net/busyPercent", 0, "%", busyPercentage);
} }
} }
@@ -147,12 +157,14 @@ void _processRecvStatsMessage(AQHOMED *aqh, const GWEN_MSG *nodeMsg)
packetsInInt=AQH_RecvStatsMsg_GetPacketsIn(nodeMsg); packetsInInt=AQH_RecvStatsMsg_GetPacketsIn(nodeMsg);
if (packetsInInt) { if (packetsInInt) {
uint32_t uid;
double packetsIn; double packetsIn;
double crcErrors; double crcErrors;
double ioErrors; double ioErrors;
double crcErrorsPercentage=0.0; double crcErrorsPercentage=0.0;
double ioErrorsPercentage=0.0; double ioErrorsPercentage=0.0;
uid=AQH_SendStatsMsg_GetUid(nodeMsg);
packetsIn=/*(double)*/ packetsInInt; packetsIn=/*(double)*/ packetsInInt;
crcErrors=/*(double)*/AQH_RecvStatsMsg_GetCrcErrors(nodeMsg); crcErrors=/*(double)*/AQH_RecvStatsMsg_GetCrcErrors(nodeMsg);
ioErrors=/*(double)*/AQH_RecvStatsMsg_GetIoErrors(nodeMsg); ioErrors=/*(double)*/AQH_RecvStatsMsg_GetIoErrors(nodeMsg);
@@ -160,24 +172,24 @@ void _processRecvStatsMessage(AQHOMED *aqh, const GWEN_MSG *nodeMsg)
crcErrorsPercentage=crcErrors*100.0/packetsIn; crcErrorsPercentage=crcErrors*100.0/packetsIn;
ioErrorsPercentage=ioErrors*100.0/packetsIn; ioErrorsPercentage=ioErrors*100.0/packetsIn;
_publishInt(aqh, AQH_RecvStatsMsg_GetUid(nodeMsg), 0, NULL, "net/packetsIn", packetsInInt); _publishInt( aqh, uid, "net/packetsIn", 0, NULL, packetsInInt);
_publishInt(aqh, AQH_RecvStatsMsg_GetUid(nodeMsg), 0, NULL, "net/crcerrors", (int) AQH_RecvStatsMsg_GetCrcErrors(nodeMsg)); _publishInt( aqh, uid, "net/crcerrors", 0, NULL, (int) AQH_RecvStatsMsg_GetCrcErrors(nodeMsg));
_publishInt(aqh, AQH_RecvStatsMsg_GetUid(nodeMsg), 0, NULL, "net/ioerrors", (int) AQH_RecvStatsMsg_GetIoErrors(nodeMsg)); _publishInt( aqh, uid, "net/ioerrors", 0, NULL, (int) AQH_RecvStatsMsg_GetIoErrors(nodeMsg));
_publishDouble(aqh, AQH_RecvStatsMsg_GetUid(nodeMsg), 0, "%", "net/crcerrorsPercent", crcErrorsPercentage); _publishDouble(aqh, uid, "net/crcerrorsPercent", 0, "%", crcErrorsPercentage);
_publishDouble(aqh, AQH_RecvStatsMsg_GetUid(nodeMsg), 0, "%", "net/ioerrorsPercent", ioErrorsPercentage); _publishDouble(aqh, uid, "net/ioerrorsPercent", 0, "%", ioErrorsPercentage);
} }
} }
void _publishInt(AQHOMED *aqh, uint32_t uid, int valueId, const char *valueUnits, const char *valuePath, int v) void _publishInt(AQHOMED *aqh, uint32_t uid, const char *vPath, int vModality, const char *vUnits, int v)
{ {
_publishDouble(aqh, uid, valueId, valueUnits, valuePath, /*(double)*/ v); _publishDouble(aqh, uid, vPath, vModality, vUnits, /*(double)*/ v);
} }
void _publishDouble(AQHOMED *aqh, uint32_t uid, int valueId, const char *valueUnits, const char *valuePath, double v) void _publishDouble(AQHOMED *aqh, uint32_t uid, const char *vPath, int vModality, const char *vUnits, double v)
{ {
GWEN_MSG *pubMsg; GWEN_MSG *pubMsg;
union {double f; uint64_t i;} u; union {double f; uint64_t i;} u;
@@ -189,12 +201,14 @@ void _publishDouble(AQHOMED *aqh, uint32_t uid, int valueId, const char *valueUn
arrayToSend[1]=u.i; arrayToSend[1]=u.i;
value=AQH_Value_new(); value=AQH_Value_new();
_setValueNameForDriver(value, valueId, valuePath);
AQH_Value_SetValueUnits(value, valueUnits);
AQH_Value_SetValueType(value, 0);
_setDeviceName(value, uid); _setDeviceName(value, uid);
AQH_Value_SetName(value, vPath);
AQH_Value_SetValueUnits(value, vUnits);
AQH_Value_SetValueType(value, vModality);
pubMsg=AQH_MultiDataDataIpcMsg_new(AQH_MSGTYPE_IPC_DATA_UPDATEDATA, value, arrayToSend, 1); pubMsg=AQH_MultiDataDataIpcMsg_new(AQH_MSGTYPE_IPC_DATA_UPDATEDATA,
GWEN_MsgEndpoint_GetNextMessageId(aqh->brokerEndpoint), 0,
value, arrayToSend, 1);
if (pubMsg) { if (pubMsg) {
DBG_INFO(AQH_LOGDOMAIN, "BROKER PUBLISH %s: %f", AQH_Value_GetName(value), v); DBG_INFO(AQH_LOGDOMAIN, "BROKER PUBLISH %s: %f", AQH_Value_GetName(value), v);
GWEN_MsgEndpoint_AddSendMessage(aqh->brokerEndpoint, pubMsg); GWEN_MsgEndpoint_AddSendMessage(aqh->brokerEndpoint, pubMsg);
@@ -204,21 +218,6 @@ void _publishDouble(AQHOMED *aqh, uint32_t uid, int valueId, const char *valueUn
void _setValueNameForDriver(AQH_VALUE *value, int valueId, const char *valuePath)
{
GWEN_BUFFER *buf;
buf=GWEN_Buffer_new(0, 64, 0, 1);
if (valueId>0)
GWEN_Buffer_AppendArgs(buf, "%d/%s", valueId, valuePath);
else
GWEN_Buffer_AppendArgs(buf, "%s", valuePath);
AQH_Value_SetName(value, GWEN_Buffer_GetStart(buf));
GWEN_Buffer_free(buf);
}
void _setDeviceName(AQH_VALUE *value, uint32_t uid) void _setDeviceName(AQH_VALUE *value, uint32_t uid)
{ {
GWEN_BUFFER *buf; GWEN_BUFFER *buf;

View File

@@ -93,6 +93,7 @@ void _forwardValue2MsgToIpc(GWEN_MSG_ENDPOINT *ep, const GWEN_MSG *nodeMsg)
GWEN_MSG *ipcMsg; GWEN_MSG *ipcMsg;
ipcMsg=AQH_ValueIpcMsg_new(AQH_MSGTYPE_IPC_NODES_VALUE, ipcMsg=AQH_ValueIpcMsg_new(AQH_MSGTYPE_IPC_NODES_VALUE,
GWEN_MsgEndpoint_GetNextMessageId(ep), 0,
AQH_Value2Msg_GetUid(nodeMsg), AQH_Value2Msg_GetUid(nodeMsg),
AQH_Value2Msg_GetValueId(nodeMsg), AQH_Value2Msg_GetValueId(nodeMsg),
AQH_Value2Msg_GetValueType(nodeMsg), AQH_Value2Msg_GetValueType(nodeMsg),
@@ -107,7 +108,9 @@ void _forwardAnyMsgToIpc(GWEN_MSG_ENDPOINT *ep, const GWEN_MSG *nodeMsg)
{ {
GWEN_MSG *ipcMsg; GWEN_MSG *ipcMsg;
ipcMsg=AQH_ForwardIpcMsg_new(AQH_MSGTYPE_IPC_NODES_FORWARD, GWEN_Msg_GetConstBuffer(nodeMsg), GWEN_Msg_GetBytesInBuffer(nodeMsg)); ipcMsg=AQH_ForwardIpcMsg_new(AQH_MSGTYPE_IPC_NODES_FORWARD,
GWEN_MsgEndpoint_GetNextMessageId(ep), 0,
GWEN_Msg_GetConstBuffer(nodeMsg), GWEN_Msg_GetBytesInBuffer(nodeMsg));
GWEN_MsgEndpoint_AddSendMessage(ep, ipcMsg); GWEN_MsgEndpoint_AddSendMessage(ep, ipcMsg);
} }

View File

@@ -0,0 +1,73 @@
<?xml?>
<gwbuild>
<target type="ConvenienceLibrary" name="aqhnodes_types" >
<includes type="c" >
$(gwenhywfar_cflags)
-I$(topsrcdir)
-I$(topbuilddir)
-I$(topsrcdir)/apps
-I$(topbuilddir)/apps
-I$(builddir)
-I$(srcdir)
</includes>
<includes type="tm2" >
--include=$(builddir)
--include=$(srcdir)
</includes>
<setVar name="local/cflags">$(visibility_cflags)</setVar>
<setVar name="tm2flags" >
</setVar>
<setVar name="local/typefiles" >
device.t2d
value.t2d
</setVar>
<setVar name="local/built_sources" >
device.c
value.c
</setVar>
<setVar name="local/built_headers_pub">
</setVar>
<setVar name="local/built_headers_priv" >
device.h
device_p.h
value.h
value_p.h
</setVar>
<headers dist="true" >
</headers>
<sources>
$(local/typefiles)
</sources>
<useTargets>
</useTargets>
<libraries>
</libraries>
<subdirs>
</subdirs>
<extradist>
</extradist>
</target>
</gwbuild>

View File

@@ -0,0 +1,87 @@
<?xml?>
<tm2>
<type id="AQHNODE_DEVICE" type="pointer">
<descr>
This object and its objects are used to store registered devices and definitions for possible new devices.
</descr>
<lang id="c">
<identifier>AQHNODE_DEVICE</identifier>
<prefix>AQHNODE_Device</prefix>
<baseFileName>device</baseFileName>
<flags>
with_list1
with_list2
</flags>
<headers>
<header type="sys" loc="pre">aqhome/api.h</header>
<header type="sys" loc="pre">aqhome-nodes/types/value.h</header>
</headers>
<inlines>
</inlines>
</lang>
<enums>
</enums>
<members>
<member name="name" type="char_ptr" maxlen="128">
<default>NULL</default>
<preset>NULL</preset>
<access>public</access>
<flags>own with_getbymember</flags>
</member>
<member name="driver" type="char_ptr" maxlen="64">
<default>NULL</default>
<preset>NULL</preset>
<access>public</access>
<flags>own</flags>
</member>
<member name="manufacturer" type="uint32_t" maxlen="8">
<default>0</default>
<preset>0</preset>
<access>public</access>
<flags></flags>
</member>
<member name="deviceType" type="uint16_t" maxlen="8">
<default>0</default>
<preset>0</preset>
<access>public</access>
<flags></flags>
</member>
<member name="deviceVersion" type="uint16_t" maxlen="8">
<default>0</default>
<preset>0</preset>
<access>public</access>
<flags></flags>
</member>
<member name="valueList" type="AQHNODE_VALUE_LIST" >
<default>NULL</default>
<preset>NULL</preset>
<access>public</access>
<flags>own</flags>
<getflags>none</getflags>
<setflags>none</setflags>
</member>
</members>
</type>
</tm2>

View File

@@ -0,0 +1,87 @@
<?xml?>
<tm2>
<type id="AQHNODE_VALUE" type="pointer">
<descr>
</descr>
<lang id="c">
<identifier>AQHNODE_VALUE</identifier>
<prefix>AQHNODE_Value</prefix>
<baseFileName>value</baseFileName>
<flags>
with_xml
with_db
with_list1
with_list2
</flags>
<headers>
<header type="sys" loc="pre">aqhome/api.h</header>
</headers>
<inlines>
</inlines>
</lang>
<members>
<member name="id" type="int" maxlen="8">
<default>0</default>
<preset>0</preset>
<access>public</access>
<flags>with_getbymember</flags>
</member>
<member name="name" type="char_ptr" maxlen="32">
<default>0</default>
<preset>0</preset>
<access>public</access>
<flags>own with_getbymember</flags>
</member>
<member name="description" type="char_ptr" maxlen="256">
<default>0</default>
<preset>0</preset>
<access>public</access>
<flags>own</flags>
</member>
<member name="valueType" type="int" maxlen="8">
<default>0</default>
<preset>0</preset>
<access>public</access>
<flags></flags>
</member>
<member name="dataType" type="int" maxlen="8">
<default>0</default>
<preset>0</preset>
<access>public</access>
<flags></flags>
</member>
<member name="modality" type="int" maxlen="8">
<default>0</default>
<preset>0</preset>
<access>public</access>
<flags></flags>
</member>
<member name="valueUnits" type="char_ptr" maxlen="32">
<default>0</default>
<preset>0</preset>
<access>public</access>
<flags>own</flags>
</member>
</members>
</type>
</tm2>

View File

@@ -37,8 +37,10 @@
*/ */
static void _cbInputData(AQHREACT_UNIT *unit, AQHREACT_PORT *port, const AQHREACT_DATAOBJECT *dataObject); static void _cbInputData(AQHREACT_UNIT *unit, AQHREACT_PORT *port, const AQHREACT_DATAOBJECT *dataObject);
static GWEN_MSG *_mkSetDataMsgString(const char *sValueName, const AQHREACT_DATAOBJECT *dataObject); static GWEN_MSG *_mkSetDataMsgString(GWEN_MSG_ENDPOINT *brokerEndpoint,
static GWEN_MSG *_mkSetDataMsgDouble(const char *sValueName, const AQHREACT_DATAOBJECT *dataObject); const char *sValueName, const AQHREACT_DATAOBJECT *dataObject);
static GWEN_MSG *_mkSetDataMsgDouble(GWEN_MSG_ENDPOINT *brokerEndpoint,
const char *sValueName, const AQHREACT_DATAOBJECT *dataObject);
@@ -89,10 +91,10 @@ void _cbInputData(AQHREACT_UNIT *unit, AQHREACT_PORT *port, const AQHREACT_DATAO
switch(AQHREACT_DataObject_GetDataType(dataObject)) { switch(AQHREACT_DataObject_GetDataType(dataObject)) {
case AQHREACT_DATAOBJECTTYPE_DOUBLE: case AQHREACT_DATAOBJECTTYPE_DOUBLE:
msgOut=_mkSetDataMsgDouble(sValueName, dataObject); msgOut=_mkSetDataMsgDouble(brokerEndpoint, sValueName, dataObject);
break; break;
case AQHREACT_DATAOBJECTTYPE_STRING: case AQHREACT_DATAOBJECTTYPE_STRING:
msgOut=_mkSetDataMsgString(sValueName, dataObject); msgOut=_mkSetDataMsgString(brokerEndpoint, sValueName, dataObject);
break; break;
default: default:
DBG_INFO(NULL, "Unhandled data type (%d)", AQHREACT_DataObject_GetDataType(dataObject)); DBG_INFO(NULL, "Unhandled data type (%d)", AQHREACT_DataObject_GetDataType(dataObject));
@@ -120,7 +122,7 @@ void _cbInputData(AQHREACT_UNIT *unit, AQHREACT_PORT *port, const AQHREACT_DATAO
} }
GWEN_MSG *_mkSetDataMsgString(const char *sValueName, const AQHREACT_DATAOBJECT *dataObject) GWEN_MSG *_mkSetDataMsgString(GWEN_MSG_ENDPOINT *brokerEndpoint, const char *sValueName, const AQHREACT_DATAOBJECT *dataObject)
{ {
GWEN_MSG *msgOut; GWEN_MSG *msgOut;
AQH_VALUE *v; AQH_VALUE *v;
@@ -128,14 +130,16 @@ GWEN_MSG *_mkSetDataMsgString(const char *sValueName, const AQHREACT_DATAOBJECT
v=AQH_Value_new(); v=AQH_Value_new();
AQH_Value_SetNameForSystem(v, sValueName); AQH_Value_SetNameForSystem(v, sValueName);
msgOut=AQH_SetDataIpcMsg_new(AQH_MSGTYPE_IPC_DATA_SETDATA, v, AQHREACT_DataObject_GetStringData(dataObject)); msgOut=AQH_SetDataIpcMsg_new(AQH_MSGTYPE_IPC_DATA_SETDATA,
GWEN_MsgEndpoint_GetNextMessageId(brokerEndpoint), 0,
v, AQHREACT_DataObject_GetStringData(dataObject));
AQH_Value_free(v); AQH_Value_free(v);
return msgOut; return msgOut;
} }
GWEN_MSG *_mkSetDataMsgDouble(const char *sValueName, const AQHREACT_DATAOBJECT *dataObject) GWEN_MSG *_mkSetDataMsgDouble(GWEN_MSG_ENDPOINT *brokerEndpoint, const char *sValueName, const AQHREACT_DATAOBJECT *dataObject)
{ {
GWEN_MSG *msgOut; GWEN_MSG *msgOut;
AQH_VALUE *v; AQH_VALUE *v;
@@ -155,7 +159,9 @@ GWEN_MSG *_mkSetDataMsgDouble(const char *sValueName, const AQHREACT_DATAOBJECT
return NULL; return NULL;
} }
msgOut=AQH_SetDataIpcMsg_new(AQH_MSGTYPE_IPC_DATA_SETDATA, v, GWEN_Buffer_GetStart(buf)); msgOut=AQH_SetDataIpcMsg_new(AQH_MSGTYPE_IPC_DATA_SETDATA,
GWEN_MsgEndpoint_GetNextMessageId(brokerEndpoint), 0,
v, GWEN_Buffer_GetStart(buf));
GWEN_Buffer_free(buf); GWEN_Buffer_free(buf);
AQH_Value_free(v); AQH_Value_free(v);
return msgOut; return msgOut;

View File

@@ -319,7 +319,9 @@ void _sendCommand(GWEN_MSG_ENDPOINT *epTcp, const char *valueName, const char *v
AQH_Value_SetValueUnits(value, valueUnits); AQH_Value_SetValueUnits(value, valueUnits);
AQH_Value_SetDeviceName(value, deviceName); AQH_Value_SetDeviceName(value, deviceName);
msgOut=AQH_MultiDataDataIpcMsg_new(AQH_MSGTYPE_IPC_DATA_UPDATEDATA, value, arrayToSend, 1); msgOut=AQH_MultiDataDataIpcMsg_new(AQH_MSGTYPE_IPC_DATA_UPDATEDATA,
GWEN_MsgEndpoint_GetNextMessageId(epTcp), 0,
value, arrayToSend, 1);
AQH_Value_free(value); AQH_Value_free(value);
GWEN_MsgEndpoint_AddSendMessage(epTcp, msgOut); GWEN_MsgEndpoint_AddSendMessage(epTcp, msgOut);
} }

View File

@@ -388,7 +388,9 @@ void _sendCommand(GWEN_MSG_ENDPOINT *epTcp, const char *valueName, const char *v
AQH_Value_SetValueUnits(value, valueUnits); AQH_Value_SetValueUnits(value, valueUnits);
AQH_Value_SetDeviceName(value, deviceName); AQH_Value_SetDeviceName(value, deviceName);
msgOut=AQH_MultiDataDataIpcMsg_new(AQH_MSGTYPE_IPC_DATA_UPDATEDATA, value, arrayToSend, 1); msgOut=AQH_MultiDataDataIpcMsg_new(AQH_MSGTYPE_IPC_DATA_UPDATEDATA,
GWEN_MsgEndpoint_GetNextMessageId(epTcp), 0,
value, arrayToSend, 1);
AQH_Value_free(value); AQH_Value_free(value);
GWEN_MsgEndpoint_AddSendMessage(epTcp, msgOut); GWEN_MsgEndpoint_AddSendMessage(epTcp, msgOut);
} }

View File

@@ -258,7 +258,9 @@ int _doGetDataPoints(GWEN_DB_NODE *dbArgs)
} }
/*fprintf(stdout, "Sending GetDataPoints request\n");*/ /*fprintf(stdout, "Sending GetDataPoints request\n");*/
msgOut=AQH_GetDataDataIpcMsg_new(AQH_MSGTYPE_IPC_DATA_GETDATA_REQ, valueName, tsBegin, tsEnd, num); msgOut=AQH_GetDataDataIpcMsg_new(AQH_MSGTYPE_IPC_DATA_GETDATA_REQ,
GWEN_MsgEndpoint_GetNextMessageId(epTcp), 0,
valueName, tsBegin, tsEnd, num);
GWEN_MsgEndpoint_AddSendMessage(epTcp, msgOut); GWEN_MsgEndpoint_AddSendMessage(epTcp, msgOut);
rv=_awaitAndCalcAndPrintResponse(epTcp, timeoutInSeconds, printMean?1:0, printDiff?1:0); rv=_awaitAndCalcAndPrintResponse(epTcp, timeoutInSeconds, printMean?1:0, printDiff?1:0);

View File

@@ -238,7 +238,9 @@ void _sendCommand(GWEN_MSG_ENDPOINT *epTcp)
{ {
GWEN_MSG *msgOut; GWEN_MSG *msgOut;
msgOut=GWEN_IpcMsg_new(AQH_IPC_PROTOCOL_DATA_ID, AQH_IPC_PROTOCOL_DATA_VERSION, AQH_MSGTYPE_IPC_DATA_GETDEVICES_REQ, 0, NULL); msgOut=GWEN_IpcMsg_new(AQH_IPC_PROTOCOL_DATA_ID, AQH_IPC_PROTOCOL_DATA_VERSION, AQH_MSGTYPE_IPC_DATA_GETDEVICES_REQ,
GWEN_MsgEndpoint_GetNextMessageId(epTcp), 0,
0, NULL);
GWEN_MsgEndpoint_AddSendMessage(epTcp, msgOut); GWEN_MsgEndpoint_AddSendMessage(epTcp, msgOut);
} }

View File

@@ -211,7 +211,9 @@ void _sendCommand(GWEN_MSG_ENDPOINT *epTcp, const char *valueName)
{ {
GWEN_MSG *msgOut; GWEN_MSG *msgOut;
msgOut=AQH_GetDataDataIpcMsg_new(AQH_MSGTYPE_IPC_DATA_GETLASTDATA_REQ, valueName, 0, 0, 1); msgOut=AQH_GetDataDataIpcMsg_new(AQH_MSGTYPE_IPC_DATA_GETLASTDATA_REQ,
GWEN_MsgEndpoint_GetNextMessageId(epTcp), 0,
valueName, 0, 0, 1);
GWEN_MsgEndpoint_AddSendMessage(epTcp, msgOut); GWEN_MsgEndpoint_AddSendMessage(epTcp, msgOut);
} }

View File

@@ -236,7 +236,9 @@ void _sendCommand(GWEN_MSG_ENDPOINT *epTcp)
{ {
GWEN_MSG *msgOut; GWEN_MSG *msgOut;
msgOut=GWEN_IpcMsg_new(AQH_IPC_PROTOCOL_DATA_ID, AQH_IPC_PROTOCOL_DATA_VERSION, AQH_MSGTYPE_IPC_DATA_GETVALUES_REQ, 0, NULL); msgOut=GWEN_IpcMsg_new(AQH_IPC_PROTOCOL_DATA_ID, AQH_IPC_PROTOCOL_DATA_VERSION, AQH_MSGTYPE_IPC_DATA_GETVALUES_REQ,
GWEN_MsgEndpoint_GetNextMessageId(epTcp), 0,
0, NULL);
GWEN_MsgEndpoint_AddSendMessage(epTcp, msgOut); GWEN_MsgEndpoint_AddSendMessage(epTcp, msgOut);
} }

View File

@@ -263,7 +263,9 @@ void _sendCommand(GWEN_MSG_ENDPOINT *epTcp, const AQH_DEVICE *device)
{ {
GWEN_MSG *msgOut; GWEN_MSG *msgOut;
msgOut=AQH_DevicesDataIpcMsg_newForOneDevice(AQH_MSGTYPE_IPC_DATA_MODDEVICE_REQ, AQH_MSGDATA_DEVICES_FLAGS_LASTMSG, device); msgOut=AQH_DevicesDataIpcMsg_newForOneDevice(AQH_MSGTYPE_IPC_DATA_MODDEVICE_REQ,
GWEN_MsgEndpoint_GetNextMessageId(epTcp), 0,
AQH_MSGDATA_DEVICES_FLAGS_LASTMSG, device);
GWEN_MsgEndpoint_AddSendMessage(epTcp, msgOut); GWEN_MsgEndpoint_AddSendMessage(epTcp, msgOut);
} }

View File

@@ -263,7 +263,9 @@ void _sendCommand(GWEN_MSG_ENDPOINT *epTcp, const char *valueName, const char *v
AQH_Value_SetNameForSystem(v, valueName); AQH_Value_SetNameForSystem(v, valueName);
AQH_Value_SetValueUnits(v, valueUnits); AQH_Value_SetValueUnits(v, valueUnits);
msgOut=AQH_SetDataIpcMsg_new(AQH_MSGTYPE_IPC_DATA_SETDATA, v, valueData); msgOut=AQH_SetDataIpcMsg_new(AQH_MSGTYPE_IPC_DATA_SETDATA,
GWEN_MsgEndpoint_GetNextMessageId(epTcp), 0,
v, valueData);
AQH_Value_free(v); AQH_Value_free(v);
GWEN_MsgEndpoint_AddSendMessage(epTcp, msgOut); GWEN_MsgEndpoint_AddSendMessage(epTcp, msgOut);
} }

View File

@@ -52,6 +52,17 @@ int main(int argc, char **argv)
const char *s; const char *s;
const char *cmd; const char *cmd;
const GWEN_ARGS args[]= { const GWEN_ARGS args[]= {
{
GWEN_ARGS_FLAGS_HAS_ARGUMENT, /* flags */
GWEN_ArgsType_Char, /* type */
"loglevel", /* name */
0, /* minnum */
1, /* maxnum */
"L", /* short option */
"loglevel", /* long option */
I18S("Specify loglevel"), /* short description */
I18S("Specify loglevel") /* long description */
},
{ {
GWEN_ARGS_FLAGS_HAS_ARGUMENT, /* flags */ GWEN_ARGS_FLAGS_HAS_ARGUMENT, /* flags */
GWEN_ArgsType_Char, /* type */ GWEN_ArgsType_Char, /* type */
@@ -104,8 +115,7 @@ int main(int argc, char **argv)
GWEN_Logger_Open(0, "aqhome-tool", 0, GWEN_LoggerType_Console, GWEN_LoggerFacility_User); GWEN_Logger_Open(0, "aqhome-tool", 0, GWEN_LoggerType_Console, GWEN_LoggerFacility_User);
GWEN_Logger_SetLevel(0, GWEN_LoggerLevel_Notice); GWEN_Logger_SetLevel(NULL, GWEN_LoggerLevel_Notice);
/*GWEN_Logger_SetLevel(0, GWEN_LoggerLevel_Info);*/
rv=AQH_Init(); rv=AQH_Init();
if (rv<0) { if (rv<0) {
@@ -146,6 +156,14 @@ int main(int argc, char **argv)
argv+=rv-1; argv+=rv-1;
} }
s=GWEN_DB_GetCharValue(dbArgs, "loglevel", 0, NULL);
if (s && *s) {
GWEN_LOGGER_LEVEL ll;
ll=GWEN_Logger_Name2Level(s);
GWEN_Logger_SetLevel(NULL, ll);
}
AQH_MergeConfigFileIntoConfig(dbArgs, "ConfigFile"); AQH_MergeConfigFileIntoConfig(dbArgs, "ConfigFile");
s=GWEN_DB_GetCharValue(dbArgs, "charset", 0, NULL); s=GWEN_DB_GetCharValue(dbArgs, "charset", 0, NULL);

View File

@@ -471,7 +471,9 @@ int _sendRebootRequest(GWEN_MSG_ENDPOINT *epTcp, unsigned int uid)
return GWEN_ERROR_GENERIC; return GWEN_ERROR_GENERIC;
} }
msgOut=AQH_ForwardIpcMsg_new(AQH_MSGTYPE_IPC_NODES_FORWARD, GWEN_Msg_GetConstBuffer(msgNode), GWEN_Msg_GetBytesInBuffer(msgNode)); msgOut=AQH_ForwardIpcMsg_new(AQH_MSGTYPE_IPC_NODES_FORWARD,
GWEN_MsgEndpoint_GetNextMessageId(epTcp), 0,
GWEN_Msg_GetConstBuffer(msgNode), GWEN_Msg_GetBytesInBuffer(msgNode));
GWEN_MsgEndpoint_AddSendMessage(epTcp, msgOut); GWEN_MsgEndpoint_AddSendMessage(epTcp, msgOut);
GWEN_Msg_free(msgNode); GWEN_Msg_free(msgNode);
return 0; return 0;
@@ -490,7 +492,9 @@ int _sendFlashStart(GWEN_MSG_ENDPOINT *epTcp, unsigned int uid)
return GWEN_ERROR_GENERIC; return GWEN_ERROR_GENERIC;
} }
msgOut=AQH_ForwardIpcMsg_new(AQH_MSGTYPE_IPC_NODES_FORWARD, GWEN_Msg_GetConstBuffer(msgNode), GWEN_Msg_GetBytesInBuffer(msgNode)); msgOut=AQH_ForwardIpcMsg_new(AQH_MSGTYPE_IPC_NODES_FORWARD,
GWEN_MsgEndpoint_GetNextMessageId(epTcp), 0,
GWEN_Msg_GetConstBuffer(msgNode), GWEN_Msg_GetBytesInBuffer(msgNode));
GWEN_MsgEndpoint_AddSendMessage(epTcp, msgOut); GWEN_MsgEndpoint_AddSendMessage(epTcp, msgOut);
GWEN_Msg_free(msgNode); GWEN_Msg_free(msgNode);
return 0; return 0;
@@ -509,7 +513,9 @@ int _sendFlashEnd(GWEN_MSG_ENDPOINT *epTcp, int reason)
return GWEN_ERROR_GENERIC; return GWEN_ERROR_GENERIC;
} }
msgOut=AQH_ForwardIpcMsg_new(AQH_MSGTYPE_IPC_NODES_FORWARD, GWEN_Msg_GetConstBuffer(msgNode), GWEN_Msg_GetBytesInBuffer(msgNode)); msgOut=AQH_ForwardIpcMsg_new(AQH_MSGTYPE_IPC_NODES_FORWARD,
GWEN_MsgEndpoint_GetNextMessageId(epTcp), 0,
GWEN_Msg_GetConstBuffer(msgNode), GWEN_Msg_GetBytesInBuffer(msgNode));
GWEN_MsgEndpoint_AddSendMessage(epTcp, msgOut); GWEN_MsgEndpoint_AddSendMessage(epTcp, msgOut);
GWEN_Msg_free(msgNode); GWEN_Msg_free(msgNode);
return 0; return 0;
@@ -555,7 +561,9 @@ int _sendFlashRecord(GWEN_MSG_ENDPOINT *epTcp,
return GWEN_ERROR_GENERIC; return GWEN_ERROR_GENERIC;
} }
msgOut=AQH_ForwardIpcMsg_new(AQH_MSGTYPE_IPC_NODES_FORWARD, GWEN_Msg_GetConstBuffer(msgNode), GWEN_Msg_GetBytesInBuffer(msgNode)); msgOut=AQH_ForwardIpcMsg_new(AQH_MSGTYPE_IPC_NODES_FORWARD,
GWEN_MsgEndpoint_GetNextMessageId(epTcp), 0,
GWEN_Msg_GetConstBuffer(msgNode), GWEN_Msg_GetBytesInBuffer(msgNode));
GWEN_MsgEndpoint_AddSendMessage(epTcp, msgOut); GWEN_MsgEndpoint_AddSendMessage(epTcp, msgOut);
GWEN_Msg_free(msgNode); GWEN_Msg_free(msgNode);

View File

@@ -254,7 +254,8 @@ int _sendGetDevices(GWEN_MSG_ENDPOINT *epTcp)
{ {
GWEN_MSG *msgOut; GWEN_MSG *msgOut;
msgOut=AQH_GetDevicesRequestIpcMsg_new(AQH_MSGTYPE_IPC_NODES_GETDEVICES_REQ); msgOut=AQH_GetDevicesRequestIpcMsg_new(AQH_MSGTYPE_IPC_NODES_GETDEVICES_REQ,
GWEN_MsgEndpoint_GetNextMessageId(epTcp), 0);
if (msgOut==NULL) { if (msgOut==NULL) {
DBG_ERROR(NULL, "Error creating message"); DBG_ERROR(NULL, "Error creating message");
return GWEN_ERROR_GENERIC; return GWEN_ERROR_GENERIC;

View File

@@ -175,7 +175,7 @@ int _sendPing(GWEN_MSG_ENDPOINT *epTcp, int nodeAddr)
{ {
GWEN_MSG *msgOut; GWEN_MSG *msgOut;
msgOut=AQH_PingIpcMsg_new(AQH_MSGTYPE_IPC_NODES_PING, nodeAddr); msgOut=AQH_PingIpcMsg_new(AQH_MSGTYPE_IPC_NODES_PING, GWEN_MsgEndpoint_GetNextMessageId(epTcp), 0, nodeAddr);
if (msgOut==NULL) { if (msgOut==NULL) {
DBG_ERROR(NULL, "Error creating message"); DBG_ERROR(NULL, "Error creating message");
return GWEN_ERROR_GENERIC; return GWEN_ERROR_GENERIC;

View File

@@ -212,7 +212,9 @@ int _doSetValue(GWEN_DB_NODE *dbArgs)
DBG_ERROR(NULL, "Error creating message"); DBG_ERROR(NULL, "Error creating message");
return GWEN_ERROR_GENERIC; return GWEN_ERROR_GENERIC;
} }
msgOut=AQH_ForwardIpcMsg_new(AQH_MSGTYPE_IPC_NODES_FORWARD, GWEN_Msg_GetConstBuffer(msgNode), GWEN_Msg_GetBytesInBuffer(msgNode)); msgOut=AQH_ForwardIpcMsg_new(AQH_MSGTYPE_IPC_NODES_FORWARD,
GWEN_MsgEndpoint_GetNextMessageId(epTcp), 0,
GWEN_Msg_GetConstBuffer(msgNode), GWEN_Msg_GetBytesInBuffer(msgNode));
if (msgOut==NULL) { if (msgOut==NULL) {
DBG_ERROR(NULL, "Error creating message"); DBG_ERROR(NULL, "Error creating message");
return GWEN_ERROR_GENERIC; return GWEN_ERROR_GENERIC;

View File

@@ -241,7 +241,9 @@ int Utils_SendAcceptedMsgGroups(GWEN_MSG_ENDPOINT *epTcp, uint32_t groups)
{ {
GWEN_MSG *msgOut; GWEN_MSG *msgOut;
msgOut=AQH_SetAcceptedMsgGroupsIpcMsg_new(AQH_MSGTYPE_IPC_NODES_SETACCMSGGRPS, groups); msgOut=AQH_SetAcceptedMsgGroupsIpcMsg_new(AQH_MSGTYPE_IPC_NODES_SETACCMSGGRPS,
GWEN_MsgEndpoint_GetNextMessageId(epTcp),0,
groups);
if (msgOut==NULL) { if (msgOut==NULL) {
DBG_ERROR(NULL, "Error creating message"); DBG_ERROR(NULL, "Error creating message");
return GWEN_ERROR_GENERIC; return GWEN_ERROR_GENERIC;
@@ -272,7 +274,9 @@ GWEN_MSG_ENDPOINT *Utils_OpenBrokerConnection(GWEN_DB_NODE *dbArgs, uint32_t fla
return NULL; return NULL;
} }
msgOut=AQH_ConnectDataIpcMsg_new(AQH_MSGTYPE_IPC_DATA_CONNECT_REQ, clientId, userId, password, flags); msgOut=AQH_ConnectDataIpcMsg_new(AQH_MSGTYPE_IPC_DATA_CONNECT_REQ,
GWEN_MsgEndpoint_GetNextMessageId(epTcp), 0,
clientId, userId, password, flags);
if (msgOut==NULL) { if (msgOut==NULL) {
DBG_ERROR(NULL, "Error creating message"); DBG_ERROR(NULL, "Error creating message");
GWEN_MsgEndpoint_free(epTcp); GWEN_MsgEndpoint_free(epTcp);

View File

@@ -70,6 +70,7 @@
hexfile hexfile
data data
events events
client
</subdirs> </subdirs>
@@ -81,6 +82,7 @@
aqhhexfile aqhhexfile
aqhdata aqhdata
aqhevents aqhevents
aqhclient
</useTargets> </useTargets>
<libraries> <libraries>

View File

@@ -182,6 +182,93 @@ void AQH_MergeConfigFileIntoConfig(GWEN_DB_NODE *dbArgs, const char *destDbGroup
int AQH_ValueType_fromString(const char *s)
{
if (s) {
if (strcasecmp(s, "sensor")==0)
return AQH_ValueType_Sensor;
else if (strcasecmp(s, "actor")==0)
return AQH_ValueType_Actor;
}
return AQH_ValueType_Unknown;
}
const char *AQH_ValueType_toString(int i)
{
switch (i) {
case AQH_ValueType_Sensor: return "sensor";
case AQH_ValueType_Actor: return "actor";
case AQH_ValueType_Unknown:
default: return "unknown";
}
}
int AQH_ValueDataType_fromString(const char *s)
{
if (s) {
if (strcasecmp(s, "int")==0)
return AQH_ValueDataType_Int;
else if (strcasecmp(s, "dword")==0)
return AQH_ValueDataType_Dword;
else if (strcasecmp(s, "rational")==0)
return AQH_ValueDataType_Rational;
}
return AQH_ValueDataType_Unknown;
}
const char *AQH_ValueDataType_toString(int i)
{
switch(i) {
case AQH_ValueDataType_Int: return "int";
case AQH_ValueDataType_Dword: return "dword";
case AQH_ValueDataType_Rational: return "rational";
case AQH_ValueDataType_Unknown:
default: return "unknown";
}
}
int AQH_ValueModality_fromString(const char *s)
{
if (s) {
if (strcasecmp(s, "temperature")==0)
return AQH_ValueModality_Temperature;
else if (strcasecmp(s, "humidity")==0)
return AQH_ValueModality_Humidity;
else if (strcasecmp(s, "door")==0)
return AQH_ValueModality_Door;
else if (strcasecmp(s, "rgb")==0)
return AQH_ValueModality_RGB;
else if (strcasecmp(s, "rgbw")==0)
return AQH_ValueModality_RGBW;
}
return AQH_ValueModality_Unknown;
}
const char *AQH_ValueModality_toString(int i)
{
switch(i) {
case AQH_ValueModality_Temperature: return "temperature";
case AQH_ValueModality_Humidity: return "humidity";
case AQH_ValueModality_Door: return "door";
case AQH_ValueModality_RGB: return "rgb";
case AQH_ValueModality_RGBW: return "rgbw";
case AQH_ValueModality_Unknown:
default: return "unknown";
}
}

View File

@@ -17,6 +17,31 @@
#include <gwenhywfar/buffer.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_Dword,
AQH_ValueDataType_Rational
};
enum {
AQH_ValueModality_Unknown=0,
AQH_ValueModality_Temperature,
AQH_ValueModality_Humidity,
AQH_ValueModality_Door,
AQH_ValueModality_RGB,
AQH_ValueModality_RGBW
};
AQHOME_API int AQH_Init(void); AQHOME_API int AQH_Init(void);
AQHOME_API void AQH_Fini(void); AQHOME_API void AQH_Fini(void);
@@ -39,6 +64,15 @@ AQHOME_API GWEN_STRINGLIST *AQH_GetGlobalDataDirs(void);
AQHOME_API GWEN_STRINGLIST *AQH_GetGlobalSysconfDirs(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);
#endif #endif

View File

@@ -30,16 +30,6 @@
<enums> <enums>
<enum id="AQH_VALUE_TYPE" prefix="AQH_ValueType_">
<item name="sensor" value="0">
<descr>sensor</descr>
</item>
<item name="actor" >
<descr>actor</descr>
</item>
</enum>
</enums> </enums>

View File

@@ -24,32 +24,32 @@
#define AQH_IPC_PROTOCOL_DATA_VERSION 1 #define AQH_IPC_PROTOCOL_DATA_VERSION 1
#define AQH_MSGTYPE_IPC_DATA_RESULT 0x001 /* AQH_ResultIpcMsg */ #define AQH_MSGTYPE_IPC_DATA_RESULT 0x0001 /* AQH_ResultIpcMsg */
#define AQH_MSGTYPE_IPC_DATA_CONNECT_REQ 0x010 /* serviceName, userName, password */ #define AQH_MSGTYPE_IPC_DATA_CONNECT_REQ 0x0010 /* serviceName, userName, password */
#define AQH_MSGTYPE_IPC_DATA_UPDATEDATA 0x100 /* AQH_MultiDataDataIpcMsg */ #define AQH_MSGTYPE_IPC_DATA_UPDATEDATA 0x0100 /* AQH_MultiDataDataIpcMsg */
#define AQH_MSGTYPE_IPC_DATA_DATACHANGED 0x200 /* AQH_MultiDataDataIpcMsg */ #define AQH_MSGTYPE_IPC_DATA_DATACHANGED 0x0200 /* AQH_MultiDataDataIpcMsg */
#define AQH_MSGTYPE_IPC_DATA_SETDATA 0x300 /* AQH_SetDataIpcMsg */ #define AQH_MSGTYPE_IPC_DATA_SETDATA 0x0300 /* AQH_SetDataIpcMsg */
#define AQH_MSGTYPE_IPC_DATA_ADDVALUE 0x400 /* AQH_AddValueDataIpcMsg */ #define AQH_MSGTYPE_IPC_DATA_ADDVALUE 0x0400 /* AQH_AddValueDataIpcMsg */
#define AQH_MSGTYPE_IPC_DATA_GETDATA_REQ 0x500 /* AQH_GetDataDataIpcMsg */ #define AQH_MSGTYPE_IPC_DATA_GETDATA_REQ 0x0500 /* AQH_GetDataDataIpcMsg */
#define AQH_MSGTYPE_IPC_DATA_GETDATA_RSP 0x600 /* AQH_MultiDataDataIpcMsg */ #define AQH_MSGTYPE_IPC_DATA_GETDATA_RSP 0x0600 /* AQH_MultiDataDataIpcMsg */
#define AQH_MSGTYPE_IPC_DATA_GETLASTDATA_REQ 0x700 /* AQH_GetDataDataIpcMsg */ #define AQH_MSGTYPE_IPC_DATA_GETLASTDATA_REQ 0x0700 /* AQH_GetDataDataIpcMsg */
#define AQH_MSGTYPE_IPC_DATA_GETLASTDATA_RSP 0x800 /* AQH_MultiDataDataIpcMsg */ #define AQH_MSGTYPE_IPC_DATA_GETLASTDATA_RSP 0x0800 /* AQH_MultiDataDataIpcMsg */
#define AQH_MSGTYPE_IPC_DATA_GETVALUES_REQ 0x900 /* GWEN_IpcMsg */ #define AQH_MSGTYPE_IPC_DATA_GETVALUES_REQ 0x0900 /* GWEN_IpcMsg */
#define AQH_MSGTYPE_IPC_DATA_GETVALUES_RSP 0xa00 /* AQH_ValuesDataIpcMsg */ #define AQH_MSGTYPE_IPC_DATA_GETVALUES_RSP 0x0a00 /* AQH_ValuesDataIpcMsg */
#define AQH_MSGTYPE_IPC_DATA_GETDEVICES_REQ 0xb00 /* GWEN_IpcMsg */ #define AQH_MSGTYPE_IPC_DATA_GETDEVICES_REQ 0x0b00 /* GWEN_IpcMsg */
#define AQH_MSGTYPE_IPC_DATA_GETDEVICES_RSP 0xc00 /* AQH_DevicesDataIpcMsg */ #define AQH_MSGTYPE_IPC_DATA_GETDEVICES_RSP 0x0c00 /* AQH_DevicesDataIpcMsg */
#define AQH_MSGTYPE_IPC_DATA_MODDEVICE_REQ 0xd00 /* AQH_DevicesDataIpcMsg */ #define AQH_MSGTYPE_IPC_DATA_MODDEVICE_REQ 0x0d00 /* AQH_DevicesDataIpcMsg */
#define AQH_MSGTYPE_IPC_DATA_ANNOUNCEVALUE 0xe00 /* AQH_ValuesDataIpcMsg */ #define AQH_MSGTYPE_IPC_DATA_ANNOUNCEVALUE 0x0e00 /* AQH_ValuesDataIpcMsg */

View File

@@ -27,7 +27,9 @@
GWEN_MSG *AQH_ConnectDataIpcMsg_new(uint16_t code, const char *clientId, const char *userId, const char *password, uint32_t flags) GWEN_MSG *AQH_ConnectDataIpcMsg_new(uint16_t code,
uint32_t msgId, uint32_t refMsgId,
const char *clientId, const char *userId, const char *password, uint32_t flags)
{ {
GWEN_MSG *msg; GWEN_MSG *msg;
GWEN_BUFFER *buf; GWEN_BUFFER *buf;
@@ -41,7 +43,7 @@ GWEN_MSG *AQH_ConnectDataIpcMsg_new(uint16_t code, const char *clientId, const c
GWEN_Tag16_WriteStringTagToBuffer(AQH_MSGDATA_CONNECT_TAGS_PASSWORD, password, buf); GWEN_Tag16_WriteStringTagToBuffer(AQH_MSGDATA_CONNECT_TAGS_PASSWORD, password, buf);
GWEN_Tag16_WriteUint32TagToBuffer(AQH_MSGDATA_CONNECT_TAGS_FLAGS, flags, buf); GWEN_Tag16_WriteUint32TagToBuffer(AQH_MSGDATA_CONNECT_TAGS_FLAGS, flags, buf);
msg=AQH_Tag16IpcMsg_new(AQH_IPC_PROTOCOL_DATA_ID, AQH_IPC_PROTOCOL_DATA_VERSION, code, msg=AQH_Tag16IpcMsg_new(AQH_IPC_PROTOCOL_DATA_ID, AQH_IPC_PROTOCOL_DATA_VERSION, code, msgId, refMsgId,
GWEN_Buffer_GetUsedBytes(buf), (const uint8_t*) GWEN_Buffer_GetStart(buf)); GWEN_Buffer_GetUsedBytes(buf), (const uint8_t*) GWEN_Buffer_GetStart(buf));
GWEN_Buffer_free(buf); GWEN_Buffer_free(buf);
return msg; return msg;

View File

@@ -31,6 +31,7 @@
AQHOME_API GWEN_MSG *AQH_ConnectDataIpcMsg_new(uint16_t code, AQHOME_API GWEN_MSG *AQH_ConnectDataIpcMsg_new(uint16_t code,
uint32_t msgId, uint32_t refMsgId,
const char *clientId, const char *clientId,
const char *userId, const char *password, const char *userId, const char *password,
uint32_t flags); uint32_t flags);

View File

@@ -34,86 +34,38 @@
#define AQH_MSGDATA_DATAPOINTS_MINSIZE (GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGDATA_DATAPOINTS_OFFS_VALUES) #define AQH_MSGDATA_DATAPOINTS_PAYLOADSIZE (AQH_MSGDATA_DATAPOINTS_OFFS_VALUES)
#define AQH_MSGDATA_DATAPOINTS_MINSIZE (GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGDATA_DATAPOINTS_PAYLOADSIZE)
static void _writeQword(uint64_t i64, uint8_t *ptr);
GWEN_MSG *AQH_DataPointsDataIpcMsg_new(uint16_t code, uint32_t flags, GWEN_MSG *AQH_DataPointsDataIpcMsg_new(uint16_t code, uint32_t msgId, uint32_t refMsgId, uint32_t flags,
uint64_t valueId, const char *valueName, const char *units, uint64_t valueId, const char *valueName, const char *units,
const uint64_t *i64Ptr, int numOfDataPoints) const uint64_t *i64Ptr, int numOfDataPoints)
{ {
GWEN_MSG *msg; GWEN_MSG *msg;
uint8_t *ptr;
int payloadSize;
int i; int i;
payloadSize=AQH_MSGDATA_DATAPOINTS_OFFS_VALUES+(numOfDataPoints*16); msg=GWEN_IpcMsg_new(AQH_IPC_PROTOCOL_DATA_ID, AQH_IPC_PROTOCOL_DATA_VERSION, code, msgId, refMsgId, 0, NULL);
GWEN_Msg_AddUint32(msg, flags);
msg=GWEN_IpcMsg_new(AQH_IPC_PROTOCOL_DATA_ID, AQH_IPC_PROTOCOL_DATA_VERSION, code, payloadSize, NULL); GWEN_Msg_AddUint32(msg, numOfDataPoints);
ptr=GWEN_Msg_GetBuffer(msg)+GWEN_MSGIPC_OFFS_PAYLOAD; GWEN_Msg_AddUint64(msg, valueId);
*(ptr++)=flags & 0xff;
*(ptr++)=(flags>>8) & 0xff;
*(ptr++)=(flags>>16) & 0xff;
*(ptr++)=(flags>>24) & 0xff;
*(ptr++)=numOfDataPoints & 0xff;
*(ptr++)=(numOfDataPoints>>8) & 0xff;
*(ptr++)=(numOfDataPoints>>16) & 0xff;
*(ptr++)=(numOfDataPoints>>24) & 0xff;
_writeQword(valueId, ptr);
ptr+=8;
if (valueName) {
strncpy((char*) ptr, valueName, AQH_MSGDATA_DATAPOINTS_SIZE_VALUENAME-1);
ptr[AQH_MSGDATA_DATAPOINTS_SIZE_VALUENAME-1]=0;
}
else
memset(ptr, 0, AQH_MSGDATA_DATAPOINTS_SIZE_VALUENAME);
ptr+=AQH_MSGDATA_DATAPOINTS_SIZE_VALUENAME;
if (units) {
strncpy((char*) ptr, units, AQH_MSGDATA_DATAPOINTS_SIZE_VALUEUNITS-1);
ptr[AQH_MSGDATA_DATAPOINTS_SIZE_VALUEUNITS-1]=0;
}
else
memset(ptr, 0, AQH_MSGDATA_DATAPOINTS_SIZE_VALUEUNITS);
ptr+=AQH_MSGDATA_DATAPOINTS_SIZE_VALUEUNITS;
GWEN_Msg_AddStringWithTrailingNull(msg, valueName, AQH_MSGDATA_DATAPOINTS_SIZE_VALUENAME, 0);
GWEN_Msg_AddStringWithTrailingNull(msg, units, AQH_MSGDATA_DATAPOINTS_SIZE_VALUEUNITS, 0);
for (i=0; i<numOfDataPoints; i++) { for (i=0; i<numOfDataPoints; i++) {
_writeQword(*i64Ptr, ptr); GWEN_Msg_AddUint64(msg, *(i64Ptr++)); /* timestamp */
i64Ptr++; GWEN_Msg_AddUint64(msg, *(i64Ptr++)); /* value */
ptr+=8;
_writeQword(*i64Ptr, ptr);
i64Ptr++;
ptr+=8;
} }
GWEN_IpcMsg_AdjustMsgSize(msg);
return msg; return msg;
} }
void _writeQword(uint64_t i64, uint8_t *ptr)
{
*(ptr++)=i64 & 0xff;
*(ptr++)=(i64>>8) & 0xff;
*(ptr++)=(i64>>16) & 0xff;
*(ptr++)=(i64>>24) & 0xff;
*(ptr++)=(i64>>32) & 0xff;
*(ptr++)=(i64>>40) & 0xff;
*(ptr++)=(i64>>48) & 0xff;
*(ptr++)=(i64>>56) & 0xff;
}
uint32_t AQH_DataPointsDataIpcMsg_GetFlags(const GWEN_MSG *msg) uint32_t AQH_DataPointsDataIpcMsg_GetFlags(const GWEN_MSG *msg)
{ {
return GWEN_Msg_GetUint32At(msg, GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGDATA_DATAPOINTS_OFFS_FLAGS, 0); return GWEN_Msg_GetUint32At(msg, GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGDATA_DATAPOINTS_OFFS_FLAGS, 0);
@@ -204,7 +156,8 @@ void AQH_DataPointsDataIpcMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbu
valueName=AQH_DataPointsDataIpcMsg_GetValueName(msg); valueName=AQH_DataPointsDataIpcMsg_GetValueName(msg);
GWEN_Buffer_AppendArgs(dbuf, GWEN_Buffer_AppendArgs(dbuf,
"DATAPOINTS (code=%d, proto=%d, proto version=%d, flags=0x%08x, valueName=%s, values=%d)\n", "DATAPOINTS %s (code=%d, proto=%d, proto version=%d, flags=0x%08x, valueName=%s, values=%d)\n",
sText?sText:"",
GWEN_IpcMsg_GetCode(msg), GWEN_IpcMsg_GetCode(msg),
GWEN_IpcMsg_GetProtoId(msg), GWEN_IpcMsg_GetProtoId(msg),
GWEN_IpcMsg_GetProtoVersion(msg), GWEN_IpcMsg_GetProtoVersion(msg),

View File

@@ -21,7 +21,9 @@
AQHOME_API GWEN_MSG *AQH_DataPointsDataIpcMsg_new(uint16_t code, uint32_t flags, AQHOME_API GWEN_MSG *AQH_DataPointsDataIpcMsg_new(uint16_t code,
uint32_t msgId, uint32_t refMsgId,
uint32_t flags,
uint64_t valueId, const char *valueName, const char *units, uint64_t valueId, const char *valueName, const char *units,
const uint64_t *i64Ptr, int numOfDataPoints); const uint64_t *i64Ptr, int numOfDataPoints);

View File

@@ -41,7 +41,8 @@
* ------------------------------------------------------------------------------------------------ * ------------------------------------------------------------------------------------------------
*/ */
GWEN_MSG *AQH_DevicesDataIpcMsg_new(uint16_t code, uint32_t flags, const AQH_DEVICE_LIST *deviceList) GWEN_MSG *AQH_DevicesDataIpcMsg_new(uint16_t code, uint32_t msgId, uint32_t refMsgId,
uint32_t flags, const AQH_DEVICE_LIST *deviceList)
{ {
GWEN_MSG *msg; GWEN_MSG *msg;
GWEN_BUFFER *buf; GWEN_BUFFER *buf;
@@ -56,7 +57,7 @@ GWEN_MSG *AQH_DevicesDataIpcMsg_new(uint16_t code, uint32_t flags, const AQH_DEV
return NULL; return NULL;
} }
msg=AQH_Tag16IpcMsg_new(AQH_IPC_PROTOCOL_DATA_ID, AQH_IPC_PROTOCOL_DATA_VERSION, code, msg=AQH_Tag16IpcMsg_new(AQH_IPC_PROTOCOL_DATA_ID, AQH_IPC_PROTOCOL_DATA_VERSION, code, msgId, refMsgId,
GWEN_Buffer_GetUsedBytes(buf), (const uint8_t*) GWEN_Buffer_GetStart(buf)); GWEN_Buffer_GetUsedBytes(buf), (const uint8_t*) GWEN_Buffer_GetStart(buf));
GWEN_Buffer_free(buf); GWEN_Buffer_free(buf);
return msg; return msg;
@@ -64,7 +65,8 @@ GWEN_MSG *AQH_DevicesDataIpcMsg_new(uint16_t code, uint32_t flags, const AQH_DEV
GWEN_MSG *AQH_DevicesDataIpcMsg_newForOneDevice(uint16_t code, uint32_t flags, const AQH_DEVICE *device) GWEN_MSG *AQH_DevicesDataIpcMsg_newForOneDevice(uint16_t code, uint32_t msgId, uint32_t refMsgId,
uint32_t flags, const AQH_DEVICE *device)
{ {
GWEN_MSG *msg; GWEN_MSG *msg;
GWEN_BUFFER *buf; GWEN_BUFFER *buf;
@@ -79,7 +81,7 @@ GWEN_MSG *AQH_DevicesDataIpcMsg_newForOneDevice(uint16_t code, uint32_t flags, c
return NULL; return NULL;
} }
msg=AQH_Tag16IpcMsg_new(AQH_IPC_PROTOCOL_DATA_ID, AQH_IPC_PROTOCOL_DATA_VERSION, code, msg=AQH_Tag16IpcMsg_new(AQH_IPC_PROTOCOL_DATA_ID, AQH_IPC_PROTOCOL_DATA_VERSION, code, msgId, refMsgId,
GWEN_Buffer_GetUsedBytes(buf), (const uint8_t*) GWEN_Buffer_GetStart(buf)); GWEN_Buffer_GetUsedBytes(buf), (const uint8_t*) GWEN_Buffer_GetStart(buf));
GWEN_Buffer_free(buf); GWEN_Buffer_free(buf);
return msg; return msg;

View File

@@ -27,8 +27,10 @@
#define AQH_MSGDATA_DEVICES_TAGS_DEVICE 0xc2 #define AQH_MSGDATA_DEVICES_TAGS_DEVICE 0xc2
AQHOME_API GWEN_MSG *AQH_DevicesDataIpcMsg_new(uint16_t code, uint32_t flags, const AQH_DEVICE_LIST *deviceList); AQHOME_API GWEN_MSG *AQH_DevicesDataIpcMsg_new(uint16_t code, uint32_t msgId, uint32_t refMsgId,
AQHOME_API GWEN_MSG *AQH_DevicesDataIpcMsg_newForOneDevice(uint16_t code, uint32_t flags, const AQH_DEVICE *device); uint32_t flags, const AQH_DEVICE_LIST *deviceList);
AQHOME_API GWEN_MSG *AQH_DevicesDataIpcMsg_newForOneDevice(uint16_t code, uint32_t msgId, uint32_t refMsgId,
uint32_t flags, const AQH_DEVICE *device);
AQHOME_API void AQH_DevicesDataIpcMsg_Parse(GWEN_MSG *msg, int doCopy); AQHOME_API void AQH_DevicesDataIpcMsg_Parse(GWEN_MSG *msg, int doCopy);

View File

@@ -27,7 +27,9 @@
GWEN_MSG *AQH_GetDataDataIpcMsg_new(uint16_t code, const char *valueName, uint64_t tsBegin, uint64_t tsEnd, uint64_t num) GWEN_MSG *AQH_GetDataDataIpcMsg_new(uint16_t code,
uint32_t msgId, uint32_t refMsgId,
const char *valueName, uint64_t tsBegin, uint64_t tsEnd, uint64_t num)
{ {
GWEN_MSG *msg; GWEN_MSG *msg;
GWEN_BUFFER *buf; GWEN_BUFFER *buf;
@@ -39,7 +41,7 @@ GWEN_MSG *AQH_GetDataDataIpcMsg_new(uint16_t code, const char *valueName, uint64
GWEN_Tag16_WriteUint64TagToBuffer(AQH_MSGDATA_GETDATA_TAGS_END, tsEnd, buf); GWEN_Tag16_WriteUint64TagToBuffer(AQH_MSGDATA_GETDATA_TAGS_END, tsEnd, buf);
GWEN_Tag16_WriteUint64TagToBuffer(AQH_MSGDATA_GETDATA_TAGS_NUM, num, buf); GWEN_Tag16_WriteUint64TagToBuffer(AQH_MSGDATA_GETDATA_TAGS_NUM, num, buf);
msg=AQH_Tag16IpcMsg_new(AQH_IPC_PROTOCOL_DATA_ID, AQH_IPC_PROTOCOL_DATA_VERSION, code, msg=AQH_Tag16IpcMsg_new(AQH_IPC_PROTOCOL_DATA_ID, AQH_IPC_PROTOCOL_DATA_VERSION, code, msgId, refMsgId,
GWEN_Buffer_GetUsedBytes(buf), (const uint8_t*) GWEN_Buffer_GetStart(buf)); GWEN_Buffer_GetUsedBytes(buf), (const uint8_t*) GWEN_Buffer_GetStart(buf));
GWEN_Buffer_free(buf); GWEN_Buffer_free(buf);
return msg; return msg;

View File

@@ -28,7 +28,9 @@
AQHOME_API GWEN_MSG *AQH_GetDataDataIpcMsg_new(uint16_t code, const char *valueName, uint64_t tsBegin, uint64_t tsEnd, uint64_t num); AQHOME_API GWEN_MSG *AQH_GetDataDataIpcMsg_new(uint16_t code,
uint32_t msgId, uint32_t refMsgId,
const char *valueName, uint64_t tsBegin, uint64_t tsEnd, uint64_t num);
AQHOME_API void AQH_GetDataDataIpcMsg_Parse(GWEN_MSG *msg, int doCopy); AQHOME_API void AQH_GetDataDataIpcMsg_Parse(GWEN_MSG *msg, int doCopy);

View File

@@ -27,7 +27,9 @@
GWEN_MSG *AQH_MultiDataDataIpcMsg_new(uint16_t code, const AQH_VALUE *value, const uint64_t *i64Ptr, int numOfDataPoints) GWEN_MSG *AQH_MultiDataDataIpcMsg_new(uint16_t code,
uint32_t msgId, uint32_t refMsgId,
const AQH_VALUE *value, const uint64_t *i64Ptr, int numOfDataPoints)
{ {
GWEN_MSG *msg; GWEN_MSG *msg;
GWEN_BUFFER *buf; GWEN_BUFFER *buf;
@@ -45,7 +47,7 @@ GWEN_MSG *AQH_MultiDataDataIpcMsg_new(uint16_t code, const AQH_VALUE *value, con
if (i64Ptr && numOfDataPoints) if (i64Ptr && numOfDataPoints)
GWEN_Tag16_WriteTagToBuffer(AQH_MSGDATA_MULTIDATA_TAGS_DATA, (const uint8_t*)i64Ptr, numOfDataPoints*2*sizeof(uint64_t), buf); GWEN_Tag16_WriteTagToBuffer(AQH_MSGDATA_MULTIDATA_TAGS_DATA, (const uint8_t*)i64Ptr, numOfDataPoints*2*sizeof(uint64_t), buf);
msg=AQH_Tag16IpcMsg_new(AQH_IPC_PROTOCOL_DATA_ID, AQH_IPC_PROTOCOL_DATA_VERSION, code, msg=AQH_Tag16IpcMsg_new(AQH_IPC_PROTOCOL_DATA_ID, AQH_IPC_PROTOCOL_DATA_VERSION, code, msgId, refMsgId,
GWEN_Buffer_GetUsedBytes(buf), (const uint8_t*) GWEN_Buffer_GetStart(buf)); GWEN_Buffer_GetUsedBytes(buf), (const uint8_t*) GWEN_Buffer_GetStart(buf));
GWEN_Buffer_free(buf); GWEN_Buffer_free(buf);
return msg; return msg;
@@ -53,7 +55,9 @@ GWEN_MSG *AQH_MultiDataDataIpcMsg_new(uint16_t code, const AQH_VALUE *value, con
GWEN_MSG *AQH_MultiDataDataIpcMsg_newForOne(uint16_t code, const AQH_VALUE *value, uint64_t timeStamp, double dataPoint) GWEN_MSG *AQH_MultiDataDataIpcMsg_newForOne(uint16_t code,
uint32_t msgId, uint32_t refMsgId,
const AQH_VALUE *value, uint64_t timeStamp, double dataPoint)
{ {
GWEN_MSG *msg; GWEN_MSG *msg;
GWEN_BUFFER *buf; GWEN_BUFFER *buf;
@@ -75,7 +79,7 @@ GWEN_MSG *AQH_MultiDataDataIpcMsg_newForOne(uint16_t code, const AQH_VALUE *valu
arrayToSend[1]=u.i; arrayToSend[1]=u.i;
GWEN_Tag16_WriteTagToBuffer(AQH_MSGDATA_MULTIDATA_TAGS_DATA, (const uint8_t*) arrayToSend, 2*sizeof(uint64_t), buf); GWEN_Tag16_WriteTagToBuffer(AQH_MSGDATA_MULTIDATA_TAGS_DATA, (const uint8_t*) arrayToSend, 2*sizeof(uint64_t), buf);
msg=AQH_Tag16IpcMsg_new(AQH_IPC_PROTOCOL_DATA_ID, AQH_IPC_PROTOCOL_DATA_VERSION, code, msg=AQH_Tag16IpcMsg_new(AQH_IPC_PROTOCOL_DATA_ID, AQH_IPC_PROTOCOL_DATA_VERSION, code, msgId, refMsgId,
GWEN_Buffer_GetUsedBytes(buf), (const uint8_t*) GWEN_Buffer_GetStart(buf)); GWEN_Buffer_GetUsedBytes(buf), (const uint8_t*) GWEN_Buffer_GetStart(buf));
GWEN_Buffer_free(buf); GWEN_Buffer_free(buf);
return msg; return msg;

View File

@@ -22,8 +22,12 @@
AQHOME_API GWEN_MSG *AQH_MultiDataDataIpcMsg_new(uint16_t code, const AQH_VALUE *value, const uint64_t *i64Ptr, int numOfDataPoints); AQHOME_API GWEN_MSG *AQH_MultiDataDataIpcMsg_new(uint16_t code,
AQHOME_API GWEN_MSG *AQH_MultiDataDataIpcMsg_newForOne(uint16_t code, const AQH_VALUE *value, uint64_t timeStamp, double dataPoint); uint32_t msgId, uint32_t refMsgId,
const AQH_VALUE *value, const uint64_t *i64Ptr, int numOfDataPoints);
AQHOME_API GWEN_MSG *AQH_MultiDataDataIpcMsg_newForOne(uint16_t code,
uint32_t msgId, uint32_t refMsgId,
const AQH_VALUE *value, uint64_t timeStamp, double dataPoint);
AQHOME_API void AQH_MultiDataDataIpcMsg_Parse(GWEN_MSG *msg, int doCopy); AQHOME_API void AQH_MultiDataDataIpcMsg_Parse(GWEN_MSG *msg, int doCopy);
AQHOME_API AQH_VALUE *AQH_MultiDataDataIpcMsg_ReadValue(const GWEN_MSG *msg); AQHOME_API AQH_VALUE *AQH_MultiDataDataIpcMsg_ReadValue(const GWEN_MSG *msg);

View File

@@ -41,7 +41,9 @@
* ------------------------------------------------------------------------------------------------ * ------------------------------------------------------------------------------------------------
*/ */
GWEN_MSG *AQH_SetDataIpcMsg_new(uint16_t code, const AQH_VALUE *value, const char *data) GWEN_MSG *AQH_SetDataIpcMsg_new(uint16_t code,
uint32_t msgId, uint32_t refMsgId,
const AQH_VALUE *value, const char *data)
{ {
GWEN_MSG *msg; GWEN_MSG *msg;
GWEN_BUFFER *buf; GWEN_BUFFER *buf;
@@ -58,7 +60,7 @@ GWEN_MSG *AQH_SetDataIpcMsg_new(uint16_t code, const AQH_VALUE *value, const cha
GWEN_Tag16_WriteStringTagToBuffer(AQH_MSGDATA_SET_TAGS_DATA, data, buf); GWEN_Tag16_WriteStringTagToBuffer(AQH_MSGDATA_SET_TAGS_DATA, data, buf);
msg=AQH_Tag16IpcMsg_new(AQH_IPC_PROTOCOL_DATA_ID, AQH_IPC_PROTOCOL_DATA_VERSION, code, msg=AQH_Tag16IpcMsg_new(AQH_IPC_PROTOCOL_DATA_ID, AQH_IPC_PROTOCOL_DATA_VERSION, code, msgId, refMsgId,
GWEN_Buffer_GetUsedBytes(buf), (const uint8_t*) GWEN_Buffer_GetStart(buf)); GWEN_Buffer_GetUsedBytes(buf), (const uint8_t*) GWEN_Buffer_GetStart(buf));
GWEN_Buffer_free(buf); GWEN_Buffer_free(buf);
return msg; return msg;

View File

@@ -24,7 +24,9 @@
#define AQH_MSGDATA_SET_TAGS_DATA 0x02 #define AQH_MSGDATA_SET_TAGS_DATA 0x02
AQHOME_API GWEN_MSG *AQH_SetDataIpcMsg_new(uint16_t code, const AQH_VALUE *value, const char *data); AQHOME_API GWEN_MSG *AQH_SetDataIpcMsg_new(uint16_t code,
uint32_t msgId, uint32_t refMsgId,
const AQH_VALUE *value, const char *data);
AQHOME_API void AQH_SetDataIpcMsg_Parse(GWEN_MSG *msg, int doCopy); AQHOME_API void AQH_SetDataIpcMsg_Parse(GWEN_MSG *msg, int doCopy);
AQHOME_API AQH_VALUE *AQH_SetDataIpcMsg_ReadValue(const GWEN_MSG *msg); AQHOME_API AQH_VALUE *AQH_SetDataIpcMsg_ReadValue(const GWEN_MSG *msg);
AQHOME_API char *AQH_SetDataIpcMsg_ReadData(const GWEN_MSG *msg); AQHOME_API char *AQH_SetDataIpcMsg_ReadData(const GWEN_MSG *msg);

View File

@@ -41,7 +41,9 @@
* ------------------------------------------------------------------------------------------------ * ------------------------------------------------------------------------------------------------
*/ */
GWEN_MSG *AQH_ValuesDataIpcMsg_new(uint16_t code, uint32_t flags, const AQH_VALUE_LIST *valueList) GWEN_MSG *AQH_ValuesDataIpcMsg_new(uint16_t code,
uint32_t msgId, uint32_t refMsgId,
uint32_t flags, const AQH_VALUE_LIST *valueList)
{ {
GWEN_MSG *msg; GWEN_MSG *msg;
GWEN_BUFFER *buf; GWEN_BUFFER *buf;
@@ -56,7 +58,7 @@ GWEN_MSG *AQH_ValuesDataIpcMsg_new(uint16_t code, uint32_t flags, const AQH_VALU
return NULL; return NULL;
} }
msg=AQH_Tag16IpcMsg_new(AQH_IPC_PROTOCOL_DATA_ID, AQH_IPC_PROTOCOL_DATA_VERSION, code, msg=AQH_Tag16IpcMsg_new(AQH_IPC_PROTOCOL_DATA_ID, AQH_IPC_PROTOCOL_DATA_VERSION, code, msgId, refMsgId,
GWEN_Buffer_GetUsedBytes(buf), (const uint8_t*) GWEN_Buffer_GetStart(buf)); GWEN_Buffer_GetUsedBytes(buf), (const uint8_t*) GWEN_Buffer_GetStart(buf));
GWEN_Buffer_free(buf); GWEN_Buffer_free(buf);
return msg; return msg;
@@ -64,7 +66,9 @@ GWEN_MSG *AQH_ValuesDataIpcMsg_new(uint16_t code, uint32_t flags, const AQH_VALU
GWEN_MSG *AQH_ValuesDataIpcMsg_newForOneValue(uint16_t code, uint32_t flags, const AQH_VALUE *value) GWEN_MSG *AQH_ValuesDataIpcMsg_newForOneValue(uint16_t code,
uint32_t msgId, uint32_t refMsgId,
uint32_t flags, const AQH_VALUE *value)
{ {
GWEN_MSG *msg; GWEN_MSG *msg;
GWEN_BUFFER *buf; GWEN_BUFFER *buf;
@@ -79,7 +83,7 @@ GWEN_MSG *AQH_ValuesDataIpcMsg_newForOneValue(uint16_t code, uint32_t flags, con
return NULL; return NULL;
} }
msg=AQH_Tag16IpcMsg_new(AQH_IPC_PROTOCOL_DATA_ID, AQH_IPC_PROTOCOL_DATA_VERSION, code, msg=AQH_Tag16IpcMsg_new(AQH_IPC_PROTOCOL_DATA_ID, AQH_IPC_PROTOCOL_DATA_VERSION, code, msgId, refMsgId,
GWEN_Buffer_GetUsedBytes(buf), (const uint8_t*) GWEN_Buffer_GetStart(buf)); GWEN_Buffer_GetUsedBytes(buf), (const uint8_t*) GWEN_Buffer_GetStart(buf));
GWEN_Buffer_free(buf); GWEN_Buffer_free(buf);
return msg; return msg;

View File

@@ -27,8 +27,12 @@
#define AQH_MSGDATA_VALUES_TAGS_VALUE 0xc2 #define AQH_MSGDATA_VALUES_TAGS_VALUE 0xc2
AQHOME_API GWEN_MSG *AQH_ValuesDataIpcMsg_new(uint16_t code, uint32_t flags, const AQH_VALUE_LIST *valueList); AQHOME_API GWEN_MSG *AQH_ValuesDataIpcMsg_new(uint16_t code,
AQHOME_API GWEN_MSG *AQH_ValuesDataIpcMsg_newForOneValue(uint16_t code, uint32_t flags, const AQH_VALUE *value); uint32_t msgId, uint32_t refMsgId,
uint32_t flags, const AQH_VALUE_LIST *valueList);
AQHOME_API GWEN_MSG *AQH_ValuesDataIpcMsg_newForOneValue(uint16_t code,
uint32_t msgId, uint32_t refMsgId,
uint32_t flags, const AQH_VALUE *value);
AQHOME_API void AQH_ValuesDataIpcMsg_Parse(GWEN_MSG *msg, int doCopy); AQHOME_API void AQH_ValuesDataIpcMsg_Parse(GWEN_MSG *msg, int doCopy);

View File

@@ -73,6 +73,7 @@ int _startConnect(GWEN_MSG_ENDPOINT *ep, GWEN_MSG_ENDPOINT *epChild)
return rv; return rv;
} }
msg=AQH_ConnectDataIpcMsg_new(AQH_MSGTYPE_IPC_DATA_CONNECT_REQ, msg=AQH_ConnectDataIpcMsg_new(AQH_MSGTYPE_IPC_DATA_CONNECT_REQ,
GWEN_MsgEndpoint_GetNextMessageId(epChild), 0,
AQH_IpcEndpoint_GetServiceName(epChild), AQH_IpcEndpoint_GetServiceName(epChild),
AQH_IpcEndpoint_GetUserName(epChild), AQH_IpcEndpoint_GetUserName(epChild),
AQH_IpcEndpoint_GetPassword(epChild), AQH_IpcEndpoint_GetPassword(epChild),

View File

@@ -26,61 +26,35 @@
#define AQH_MSGDATA_QWORDS_OFFS_VALUES 8 /* 8 byte */ #define AQH_MSGDATA_QWORDS_OFFS_VALUES 8 /* 8 byte */
#define AQH_MSGDATA_QWORDS_MINSIZE (GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGDATA_QWORDS_OFFS_VALUES) #define AQH_MSGDATA_QWORDS_PAYLOADSIZE (AQH_MSGDATA_QWORDS_OFFS_VALUES)
#define AQH_MSGDATA_QWORDS_MINSIZE (GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGDATA_QWORDS_PAYLOADSIZE)
static void _writeQword(uint64_t i64, uint8_t *ptr);
GWEN_MSG *AQH_QwordsIpcMsg_new(uint8_t protoId, uint8_t protoVer, uint16_t code, uint32_t flags, const uint64_t *i64Ptr, int count) GWEN_MSG *AQH_QwordsIpcMsg_new(uint8_t protoId, uint8_t protoVer, uint16_t code,
uint32_t msgId, uint32_t refMsgId,
uint32_t flags, const uint64_t *i64Ptr, int count)
{ {
GWEN_MSG *msg; GWEN_MSG *msg;
uint8_t *ptr; uint8_t *ptr;
int payloadSize; int payloadSize;
int i; int i;
payloadSize=AQH_MSGDATA_QWORDS_OFFS_VALUES+(count*8); payloadSize=AQH_MSGDATA_QWORDS_PAYLOADSIZE+(count*8);
msg=GWEN_IpcMsg_new(protoId, protoVer, code, payloadSize, NULL); msg=GWEN_IpcMsg_new(protoId, protoVer, code, msgId, refMsgId, payloadSize, NULL);
ptr=GWEN_Msg_GetBuffer(msg)+GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGDATA_QWORDS_OFFS_VALUES; GWEN_Msg_AddUint32(msg, flags);
GWEN_Msg_AddUint32(msg, count);
*(ptr++)=flags & 0xff; for(i=0; i<count; i++)
*(ptr++)=(flags>>8) & 0xff; GWEN_Msg_AddUint64(msg, *(i64Ptr++));
*(ptr++)=(flags>>16) & 0xff;
*(ptr++)=(flags>>24) & 0xff;
*(ptr++)=count & 0xff;
*(ptr++)=(count>>8) & 0xff;
*(ptr++)=(count>>16) & 0xff;
*(ptr++)=(count>>24) & 0xff;
for(i=0; i<count; i++) {
_writeQword(*i64Ptr, ptr);
ptr+=8;
i64Ptr++;
}
return msg; return msg;
} }
void _writeQword(uint64_t i64, uint8_t *ptr)
{
*(ptr++)=i64 & 0xff;
*(ptr++)=(i64>>8) & 0xff;
*(ptr++)=(i64>>16) & 0xff;
*(ptr++)=(i64>>24) & 0xff;
*(ptr++)=(i64>>32) & 0xff;
*(ptr++)=(i64>>40) & 0xff;
*(ptr++)=(i64>>48) & 0xff;
*(ptr++)=(i64>>56) & 0xff;
}
uint32_t AQH_QwordsIpcMsg_GetFlags(const GWEN_MSG *msg) uint32_t AQH_QwordsIpcMsg_GetFlags(const GWEN_MSG *msg)
{ {
return GWEN_Msg_GetUint32At(msg, GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGDATA_QWORDS_OFFS_FLAGS, 0); return GWEN_Msg_GetUint32At(msg, GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGDATA_QWORDS_OFFS_FLAGS, 0);

View File

@@ -19,6 +19,7 @@
AQHOME_API GWEN_MSG *AQH_QwordsIpcMsg_new(uint8_t protoId, uint8_t protoVer, uint16_t code, AQHOME_API GWEN_MSG *AQH_QwordsIpcMsg_new(uint8_t protoId, uint8_t protoVer, uint16_t code,
uint32_t msgId, uint32_t refMsgId,
uint32_t flags, const uint64_t *i64Ptr, int count); uint32_t flags, const uint64_t *i64Ptr, int count);
AQHOME_API uint32_t AQH_QwordsIpcMsg_GetFlags(const GWEN_MSG *msg); AQHOME_API uint32_t AQH_QwordsIpcMsg_GetFlags(const GWEN_MSG *msg);

View File

@@ -26,24 +26,21 @@
#define AQH_MSGIPC_RESULT_OFFS_RESULTCODE 0 /* 4 bytes */ #define AQH_MSGIPC_RESULT_OFFS_RESULTCODE 0 /* 4 bytes */
//#define AQH_MSGIPC_RESULT_MINSIZE (GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_RESULT_OFFS_RESULTCODE+4) #define AQH_MSGIPC_RESULT_PAYLOADSIZE (AQH_MSGIPC_RESULT_OFFS_RESULTCODE+4)
#define AQH_MSGIPC_RESULT_MINSIZE (AQH_MSGIPC_RESULT_OFFS_RESULTCODE+4) #define AQH_MSGIPC_RESULT_MINSIZE (GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_RESULT_PAYLOADSIZE)
GWEN_MSG *AQH_ResultIpcMsg_new(uint16_t code, uint32_t resultCode) GWEN_MSG *AQH_ResultIpcMsg_new(uint16_t code, uint32_t msgId, uint32_t refMsgId, uint32_t resultCode)
{ {
GWEN_MSG *msg; GWEN_MSG *msg;
uint8_t *ptr; uint8_t *ptr;
msg=GWEN_IpcMsg_new(AQH_IPC_PROTOCOL_RESULT_ID, AQH_IPC_PROTOCOL_RESULT_VERSION, code, AQH_MSGIPC_RESULT_MINSIZE, NULL); msg=GWEN_IpcMsg_new(AQH_IPC_PROTOCOL_RESULT_ID, AQH_IPC_PROTOCOL_RESULT_VERSION, code,
ptr=GWEN_Msg_GetBuffer(msg); msgId, refMsgId,
ptr[GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_RESULT_OFFS_RESULTCODE+0]=resultCode & 0xff; AQH_MSGIPC_RESULT_PAYLOADSIZE, NULL);
ptr[GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_RESULT_OFFS_RESULTCODE+1]=(resultCode>>8) & 0xff; GWEN_Msg_AddUint32(msg, resultCode);
ptr[GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_RESULT_OFFS_RESULTCODE+2]=(resultCode>>16) & 0xff;
ptr[GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_RESULT_OFFS_RESULTCODE+3]=(resultCode>>24) & 0xff;
return msg; return msg;
} }
@@ -62,11 +59,13 @@ void AQH_ResultIpcMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const
{ {
if (GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSGIPC_RESULT_MINSIZE) { if (GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSGIPC_RESULT_MINSIZE) {
GWEN_Buffer_AppendArgs(dbuf, GWEN_Buffer_AppendArgs(dbuf,
"ERROR (code=%d, proto=%d, proto version=%d, error=%d)\n", "ERROR (code=%d, proto=%d, proto version=%d, error=%d, msgId=%d, refMsgId=%d)\n",
GWEN_IpcMsg_GetCode(msg), GWEN_IpcMsg_GetCode(msg),
GWEN_IpcMsg_GetProtoId(msg), GWEN_IpcMsg_GetProtoId(msg),
GWEN_IpcMsg_GetProtoVersion(msg), GWEN_IpcMsg_GetProtoVersion(msg),
AQH_ResultIpcMsg_GetResultCode(msg)); AQH_ResultIpcMsg_GetResultCode(msg),
GWEN_IpcMsg_GetMsgId(msg),
GWEN_IpcMsg_GetRefMsgId(msg));
} }
} }

View File

@@ -32,7 +32,7 @@
#define AQH_MSG_IPC_ERROR_NOTFOUND 7 #define AQH_MSG_IPC_ERROR_NOTFOUND 7
AQHOME_API GWEN_MSG *AQH_ResultIpcMsg_new(uint16_t code, uint32_t resultCode); AQHOME_API GWEN_MSG *AQH_ResultIpcMsg_new(uint16_t code, uint32_t msgId, uint32_t refMsgId, uint32_t resultCode);
AQHOME_API uint32_t AQH_ResultIpcMsg_GetResultCode(const GWEN_MSG *msg); AQHOME_API uint32_t AQH_ResultIpcMsg_GetResultCode(const GWEN_MSG *msg);
AQHOME_API void AQH_ResultIpcMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText); AQHOME_API void AQH_ResultIpcMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText);

View File

@@ -36,11 +36,13 @@ GWEN_INHERIT(GWEN_MSG, AQH_MSG_IPC_TAG16);
GWEN_MSG *AQH_Tag16IpcMsg_new(uint8_t protoId, uint8_t protoVer, uint16_t code, uint32_t payloadLen, const uint8_t *payload) GWEN_MSG *AQH_Tag16IpcMsg_new(uint8_t protoId, uint8_t protoVer, uint16_t code,
uint32_t msgId, uint32_t refMsgId,
uint32_t payloadLen, const uint8_t *payload)
{ {
GWEN_MSG *msg; GWEN_MSG *msg;
msg=GWEN_IpcMsg_new(protoId, protoVer, code, payloadLen, payload); msg=GWEN_IpcMsg_new(protoId, protoVer, code, msgId, refMsgId, payloadLen, payload);
AQH_Tag16IpcMsg_Extend(msg); AQH_Tag16IpcMsg_Extend(msg);
return msg; return msg;
} }

View File

@@ -17,7 +17,9 @@
#include <gwenhywfar/tag16.h> #include <gwenhywfar/tag16.h>
AQHOME_API GWEN_MSG *AQH_Tag16IpcMsg_new(uint8_t protoId, uint8_t protoVer, uint16_t code, uint32_t payloadLen, const uint8_t *payload); AQHOME_API GWEN_MSG *AQH_Tag16IpcMsg_new(uint8_t protoId, uint8_t protoVer, uint16_t code,
uint32_t msgId, uint32_t refMsgId,
uint32_t payloadLen, const uint8_t *payload);
AQHOME_API void AQH_Tag16IpcMsg_ExtendAndParse(GWEN_MSG *msg, int doCopy); AQHOME_API void AQH_Tag16IpcMsg_ExtendAndParse(GWEN_MSG *msg, int doCopy);
AQHOME_API void AQH_Tag16IpcMsg_Extend(GWEN_MSG *msg); AQHOME_API void AQH_Tag16IpcMsg_Extend(GWEN_MSG *msg);

View File

@@ -20,14 +20,14 @@
#define AQH_IPC_PROTOCOL_NODES_VERSION 1 #define AQH_IPC_PROTOCOL_NODES_VERSION 1
#define AQH_MSGTYPE_IPC_NODES_RESULT 0x001 #define AQH_MSGTYPE_IPC_NODES_RESULT 0xf001
#define AQH_MSGTYPE_IPC_NODES_FORWARD 0x100 #define AQH_MSGTYPE_IPC_NODES_FORWARD 0xf100
#define AQH_MSGTYPE_IPC_NODES_VALUE 0x200 #define AQH_MSGTYPE_IPC_NODES_VALUE 0xf200
#define AQH_MSGTYPE_IPC_NODES_PING 0x300 #define AQH_MSGTYPE_IPC_NODES_PING 0xf300
#define AQH_MSGTYPE_IPC_NODES_SETACCMSGGRPS 0x400 #define AQH_MSGTYPE_IPC_NODES_SETACCMSGGRPS 0xf400
#define AQH_MSGTYPE_IPC_NODES_GETDEVICES_REQ 0x500 #define AQH_MSGTYPE_IPC_NODES_GETDEVICES_REQ 0xf500
#define AQH_MSGTYPE_IPC_NODES_GETDEVICES_RSP 0x600 #define AQH_MSGTYPE_IPC_NODES_GETDEVICES_RSP 0xf600

View File

@@ -30,9 +30,11 @@
GWEN_MSG *AQH_ForwardIpcMsg_new(uint16_t code, const uint8_t *ptr, uint32_t len) GWEN_MSG *AQH_ForwardIpcMsg_new(uint16_t code,
uint32_t msgId, uint32_t refMsgId,
const uint8_t *ptr, uint32_t len)
{ {
return GWEN_IpcMsg_new(AQH_IPC_PROTOCOL_NODES_ID, AQH_IPC_PROTOCOL_NODES_VERSION, code, len, ptr); return GWEN_IpcMsg_new(AQH_IPC_PROTOCOL_NODES_ID, AQH_IPC_PROTOCOL_NODES_VERSION, code, msgId, refMsgId, len, ptr);
} }

View File

@@ -19,7 +19,7 @@
AQHOME_API GWEN_MSG *AQH_ForwardIpcMsg_new(uint16_t code, const uint8_t *ptr, uint32_t len); AQHOME_API GWEN_MSG *AQH_ForwardIpcMsg_new(uint16_t code, uint32_t msgId, uint32_t refMsgId, const uint8_t *ptr, uint32_t len);
AQHOME_API const uint8_t *AQH_ForwardIpcMsg_GetMsgPtr(const GWEN_MSG *msg); AQHOME_API const uint8_t *AQH_ForwardIpcMsg_GetMsgPtr(const GWEN_MSG *msg);
AQHOME_API uint32_t AQH_ForwardIpcMsg_GetMsgLen(const GWEN_MSG *msg); AQHOME_API uint32_t AQH_ForwardIpcMsg_GetMsgLen(const GWEN_MSG *msg);
AQHOME_API GWEN_MSG *AQH_ForwardIpcMsg_GetCopyOfNodeMsg(const GWEN_MSG *msg); AQHOME_API GWEN_MSG *AQH_ForwardIpcMsg_GetCopyOfNodeMsg(const GWEN_MSG *msg);

View File

@@ -23,14 +23,16 @@
#include <gwenhywfar/msg_ipc.h> #include <gwenhywfar/msg_ipc.h>
#define AQH_MSGIPC_GETDEVICES_REQ_MINSIZE (GWEN_MSGIPC_OFFS_PAYLOAD) #define AQH_MSGIPC_GETDEVICES_REQ_PAYLOADSIZE 0
#define AQH_MSGIPC_GETDEVICES_REQ_MINSIZE (GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_GETDEVICES_REQ_PAYLOADSIZE)
GWEN_MSG *AQH_GetDevicesRequestIpcMsg_new(uint16_t code) GWEN_MSG *AQH_GetDevicesRequestIpcMsg_new(uint16_t code, uint32_t msgId, uint32_t refMsgId)
{ {
return GWEN_IpcMsg_new(AQH_IPC_PROTOCOL_NODES_ID, AQH_IPC_PROTOCOL_NODES_VERSION, code, AQH_MSGIPC_GETDEVICES_REQ_MINSIZE, NULL); return GWEN_IpcMsg_new(AQH_IPC_PROTOCOL_NODES_ID, AQH_IPC_PROTOCOL_NODES_VERSION, code,
msgId, refMsgId, AQH_MSGIPC_GETDEVICES_REQ_PAYLOADSIZE, NULL);
} }
@@ -39,10 +41,13 @@ void AQH_GetDevicesRequestIpcMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *
{ {
if (GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSGIPC_GETDEVICES_REQ_MINSIZE) { if (GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSGIPC_GETDEVICES_REQ_MINSIZE) {
GWEN_Buffer_AppendArgs(dbuf, GWEN_Buffer_AppendArgs(dbuf,
"GET_DEVICES REQ (code=%d, proto=%d, proto version=%d)\n", "GET_DEVICES REQ %s (code=%d, proto=%d, proto version=%d, msgId=%d, refMsgId=%d)\n",
sText?sText:"",
GWEN_IpcMsg_GetCode(msg), GWEN_IpcMsg_GetCode(msg),
GWEN_IpcMsg_GetProtoId(msg), GWEN_IpcMsg_GetProtoId(msg),
GWEN_IpcMsg_GetProtoVersion(msg)); GWEN_IpcMsg_GetProtoVersion(msg),
GWEN_IpcMsg_GetMsgId(msg),
GWEN_IpcMsg_GetRefMsgId(msg));
} }
} }

View File

@@ -17,7 +17,7 @@
#include <gwenhywfar/buffer.h> #include <gwenhywfar/buffer.h>
AQHOME_API GWEN_MSG *AQH_GetDevicesRequestIpcMsg_new(uint16_t code); AQHOME_API GWEN_MSG *AQH_GetDevicesRequestIpcMsg_new(uint16_t code, uint32_t msgId, uint32_t refMsgId);
AQHOME_API void AQH_GetDevicesRequestIpcMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText); AQHOME_API void AQH_GetDevicesRequestIpcMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText);

View File

@@ -42,39 +42,31 @@
#define AQH_MSGIPC_GETDEVICES_RSP_MINSIZE (GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_GETDEVICES_RSP_OFFS_IO+2) #define AQH_MSGIPC_GETDEVICES_RSP_MINSIZE (GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_GETDEVICES_RSP_OFFS_IO+2)
static void _addU16t(uint8_t **pPtr, uint16_t i);
static void _addU32t(uint8_t **pPtr, uint32_t i);
static void _addU64t(uint8_t **pPtr, uint64_t i);
GWEN_MSG *AQH_GetDevicesResponseIpcMsg_new(uint16_t code, uint32_t msgId, uint32_t refMsgId, uint8_t flags, const AQH_NODE_INFO *ni)
GWEN_MSG *AQH_GetDevicesResponseIpcMsg_new(uint16_t code, uint8_t flags, const AQH_NODE_INFO *ni)
{ {
GWEN_MSG *msg; GWEN_MSG *msg;
uint8_t *ptr;
const GWEN_TIMESTAMP *t; const GWEN_TIMESTAMP *t;
msg=GWEN_IpcMsg_new(AQH_IPC_PROTOCOL_NODES_ID, AQH_IPC_PROTOCOL_NODES_VERSION, code, AQH_MSGIPC_GETDEVICES_RSP_MINSIZE, NULL); msg=GWEN_IpcMsg_new(AQH_IPC_PROTOCOL_NODES_ID, AQH_IPC_PROTOCOL_NODES_VERSION, code, msgId, refMsgId, 0, NULL);
ptr=GWEN_Msg_GetBuffer(msg)+GWEN_MSGIPC_OFFS_PAYLOAD; GWEN_Msg_AddUint8(msg, flags & 0xff);
GWEN_Msg_AddUint8(msg, AQH_NodeInfo_GetBusAddress(ni));
GWEN_Msg_AddUint32(msg, AQH_NodeInfo_GetUid(ni));
*(ptr++)=flags & 0xff; GWEN_Msg_AddUint32(msg, AQH_NodeInfo_GetManufacturer(ni));
GWEN_Msg_AddUint16(msg, AQH_NodeInfo_GetDeviceType(ni));
*(ptr++)=AQH_NodeInfo_GetBusAddress(ni); GWEN_Msg_AddUint16(msg, AQH_NodeInfo_GetDeviceVersion(ni));
_addU32t(&ptr, AQH_NodeInfo_GetUid(ni)); GWEN_Msg_AddUint32(msg, AQH_NodeInfo_GetFirmwareVersion(ni));
_addU32t(&ptr, AQH_NodeInfo_GetManufacturer(ni));
_addU16t(&ptr, AQH_NodeInfo_GetDeviceType(ni));
_addU16t(&ptr, AQH_NodeInfo_GetDeviceVersion(ni));
_addU32t(&ptr, AQH_NodeInfo_GetFirmwareVersion(ni));
t=AQH_NodeInfo_GetTimestampLastChange(ni); t=AQH_NodeInfo_GetTimestampLastChange(ni);
_addU64t(&ptr, t?((uint64_t)GWEN_Timestamp_toInt64(t)):0L); GWEN_Msg_AddUint64(msg, t?((uint64_t)GWEN_Timestamp_toInt64(t)):0L);
_addU16t(&ptr, AQH_NodeInfo_GetStatsPacketsOut(ni)); GWEN_Msg_AddUint16(msg, AQH_NodeInfo_GetStatsPacketsOut(ni));
_addU16t(&ptr, AQH_NodeInfo_GetStatsPacketsIn(ni)); GWEN_Msg_AddUint16(msg, AQH_NodeInfo_GetStatsPacketsIn(ni));
_addU16t(&ptr, AQH_NodeInfo_GetStatsCollisions(ni)); GWEN_Msg_AddUint16(msg, AQH_NodeInfo_GetStatsCollisions(ni));
_addU16t(&ptr, AQH_NodeInfo_GetStatsBusy(ni)); GWEN_Msg_AddUint16(msg, AQH_NodeInfo_GetStatsBusy(ni));
_addU16t(&ptr, AQH_NodeInfo_GetStatsCrcErrors(ni)); GWEN_Msg_AddUint16(msg, AQH_NodeInfo_GetStatsCrcErrors(ni));
_addU16t(&ptr, AQH_NodeInfo_GetStatsIoErrors(ni)); GWEN_Msg_AddUint16(msg, AQH_NodeInfo_GetStatsIoErrors(ni));
GWEN_IpcMsg_AdjustMsgSize(msg);
return msg; return msg;
} }
@@ -132,11 +124,7 @@ uint32_t AQH_GetDevicesResponseIpcMsg_GetFirmwareVersion(const GWEN_MSG *msg)
int64_t AQH_GetDevicesResponseIpcMsg_GetTimestamp(const GWEN_MSG *msg) int64_t AQH_GetDevicesResponseIpcMsg_GetTimestamp(const GWEN_MSG *msg)
{ {
uint64_t v; return GWEN_Msg_GetUint64At(msg, GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_GETDEVICES_RSP_OFFS_LASTCHG, 0);
v=(uint64_t) GWEN_Msg_GetUint32At(msg, GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_GETDEVICES_RSP_OFFS_LASTCHG, 0);
v|=((uint64_t)GWEN_Msg_GetUint32At(msg, GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_GETDEVICES_RSP_OFFS_LASTCHG+4, 0))<<32;
return (int64_t) v;
} }
@@ -199,49 +187,3 @@ void AQH_GetDevicesResponseIpcMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER
} }
void _addU16t(uint8_t **pPtr, uint16_t i)
{
uint8_t *ptr=*pPtr;
*(ptr++)=i & 0xff;
*(ptr++)=(i>>8) & 0xff;
*pPtr=ptr;
}
void _addU32t(uint8_t **pPtr, uint32_t i)
{
uint8_t *ptr=*pPtr;
*(ptr++)=i & 0xff;
*(ptr++)=(i>>8) & 0xff;
*(ptr++)=(i>>16) & 0xff;
*(ptr++)=(i>>24) & 0xff;
*pPtr=ptr;
}
void _addU64t(uint8_t **pPtr, uint64_t i)
{
uint8_t *ptr=*pPtr;
*(ptr++)=i & 0xff;
*(ptr++)=(i>>8) & 0xff;
*(ptr++)=(i>>16) & 0xff;
*(ptr++)=(i>>24) & 0xff;
*(ptr++)=(i>>32) & 0xff;
*(ptr++)=(i>>40) & 0xff;
*(ptr++)=(i>>48) & 0xff;
*(ptr++)=(i>>56) & 0xff;
*pPtr=ptr;
}

View File

@@ -21,7 +21,9 @@
#define AQH_MSGIPC_GETDEVICES_RSP_FLAGS_LAST 0x01 #define AQH_MSGIPC_GETDEVICES_RSP_FLAGS_LAST 0x01
AQHOME_API GWEN_MSG *AQH_GetDevicesResponseIpcMsg_new(uint16_t code, uint8_t flags, const AQH_NODE_INFO *ni); AQHOME_API GWEN_MSG *AQH_GetDevicesResponseIpcMsg_new(uint16_t code,
uint32_t msgId, uint32_t refMsgId,
uint8_t flags, const AQH_NODE_INFO *ni);
AQHOME_API uint8_t AQH_GetDevicesResponseIpcMsg_GetFlags(const GWEN_MSG *msg); AQHOME_API uint8_t AQH_GetDevicesResponseIpcMsg_GetFlags(const GWEN_MSG *msg);
AQHOME_API uint8_t AQH_GetDevicesResponseIpcMsg_GetBusAddress(const GWEN_MSG *msg); AQHOME_API uint8_t AQH_GetDevicesResponseIpcMsg_GetBusAddress(const GWEN_MSG *msg);

View File

@@ -25,17 +25,20 @@
#define AQH_MSGIPC_PING_OFFS_DESTADDR 0 /* 1 bytes */ #define AQH_MSGIPC_PING_OFFS_DESTADDR 0 /* 1 bytes */
#define AQH_MSGIPC_PING_MINSIZE (GWEN_MSGIPC_OFFS_PAYLOAD+1) #define AQH_MSGIPC_PING_PAYLOADSIZE 1
#define AQH_MSGIPC_PING_MINSIZE (GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_PING_PAYLOADSIZE)
GWEN_MSG *AQH_PingIpcMsg_new(uint16_t code, uint8_t destAddr) GWEN_MSG *AQH_PingIpcMsg_new(uint16_t code, uint32_t msgId, uint32_t refMsgId, uint8_t destAddr)
{ {
GWEN_MSG *msg; GWEN_MSG *msg;
uint8_t *ptr; uint8_t *ptr;
msg=GWEN_IpcMsg_new(AQH_IPC_PROTOCOL_NODES_ID, AQH_IPC_PROTOCOL_NODES_VERSION, code, AQH_MSGIPC_PING_MINSIZE, NULL); msg=GWEN_IpcMsg_new(AQH_IPC_PROTOCOL_NODES_ID, AQH_IPC_PROTOCOL_NODES_VERSION, code,
msgId, refMsgId,
AQH_MSGIPC_PING_PAYLOADSIZE, NULL);
ptr=GWEN_Msg_GetBuffer(msg); ptr=GWEN_Msg_GetBuffer(msg);
ptr[GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_PING_OFFS_DESTADDR]=destAddr & 0xff; ptr[GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_PING_OFFS_DESTADDR]=destAddr & 0xff;
@@ -55,7 +58,8 @@ void AQH_PingIpcMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const c
{ {
if (GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSGIPC_PING_MINSIZE) { if (GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSGIPC_PING_MINSIZE) {
GWEN_Buffer_AppendArgs(dbuf, GWEN_Buffer_AppendArgs(dbuf,
"PING (code=%d, proto=%d, proto version=%d, dest addr=%02x)\n", "PING %s (code=%d, proto=%d, proto version=%d, dest addr=%02x)\n",
sText?sText:"",
GWEN_IpcMsg_GetCode(msg), GWEN_IpcMsg_GetCode(msg),
GWEN_IpcMsg_GetProtoId(msg), GWEN_IpcMsg_GetProtoId(msg),
GWEN_IpcMsg_GetProtoVersion(msg), GWEN_IpcMsg_GetProtoVersion(msg),

View File

@@ -17,7 +17,7 @@
#include <gwenhywfar/buffer.h> #include <gwenhywfar/buffer.h>
AQHOME_API GWEN_MSG *AQH_PingIpcMsg_new(uint16_t code, uint8_t destAddr); AQHOME_API GWEN_MSG *AQH_PingIpcMsg_new(uint16_t code, uint32_t msgId, uint32_t refMsgId, uint8_t destAddr);
AQHOME_API uint8_t AQH_PingIpcMsg_GetDestAddr(const GWEN_MSG *msg); AQHOME_API uint8_t AQH_PingIpcMsg_GetDestAddr(const GWEN_MSG *msg);

View File

@@ -25,23 +25,21 @@
#define AQH_MSGIPC_SETACCEPTEDMSGGRPS_OFFS_GROUPS 0 /* 4 bytes */ #define AQH_MSGIPC_SETACCEPTEDMSGGRPS_OFFS_GROUPS 0 /* 4 bytes */
#define AQH_MSGIPC_SETACCEPTEDMSGGRPS_MINSIZE (GWEN_MSGIPC_OFFS_PAYLOAD+4) #define AQH_MSGIPC_SETACCEPTEDMSGGRPS_PAYLOADSIZE (AQH_MSGIPC_SETACCEPTEDMSGGRPS_OFFS_GROUPS+4)
#define AQH_MSGIPC_SETACCEPTEDMSGGRPS_MINSIZE (GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_SETACCEPTEDMSGGRPS_PAYLOADSIZE)
GWEN_MSG *AQH_SetAcceptedMsgGroupsIpcMsg_new(uint16_t code, uint32_t groups) GWEN_MSG *AQH_SetAcceptedMsgGroupsIpcMsg_new(uint16_t code, uint32_t msgId, uint32_t refMsgId, uint32_t groups)
{ {
GWEN_MSG *msg; GWEN_MSG *msg;
uint8_t *ptr; uint8_t *ptr;
msg=GWEN_IpcMsg_new(AQH_IPC_PROTOCOL_NODES_ID, AQH_IPC_PROTOCOL_NODES_VERSION, code, AQH_MSGIPC_SETACCEPTEDMSGGRPS_MINSIZE, NULL); msg=GWEN_IpcMsg_new(AQH_IPC_PROTOCOL_NODES_ID, AQH_IPC_PROTOCOL_NODES_VERSION, code,
ptr=GWEN_Msg_GetBuffer(msg); msgId, refMsgId,
ptr[GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_SETACCEPTEDMSGGRPS_OFFS_GROUPS+0]=groups & 0xff; AQH_MSGIPC_SETACCEPTEDMSGGRPS_PAYLOADSIZE, NULL);
ptr[GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_SETACCEPTEDMSGGRPS_OFFS_GROUPS+1]=(groups>>8) & 0xff; GWEN_Msg_AddUint32(msg, groups);
ptr[GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_SETACCEPTEDMSGGRPS_OFFS_GROUPS+2]=(groups>>16) & 0xff;
ptr[GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_SETACCEPTEDMSGGRPS_OFFS_GROUPS+3]=(groups>>24) & 0xff;
return msg; return msg;
} }
@@ -68,5 +66,3 @@ void AQH_SetAcceptedMsgGroupsIpcMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFE

View File

@@ -17,7 +17,7 @@
#include <gwenhywfar/buffer.h> #include <gwenhywfar/buffer.h>
AQHOME_API GWEN_MSG *AQH_SetAcceptedMsgGroupsIpcMsg_new(uint16_t code, uint32_t groups); AQHOME_API GWEN_MSG *AQH_SetAcceptedMsgGroupsIpcMsg_new(uint16_t code, uint32_t msgId, uint32_t refMsgId, uint32_t groups);
AQHOME_API uint32_t AQH_SetAcceptedMsgGroupsIpcMsg_GetMsgGroups(const GWEN_MSG *msg); AQHOME_API uint32_t AQH_SetAcceptedMsgGroupsIpcMsg_GetMsgGroups(const GWEN_MSG *msg);

View File

@@ -29,12 +29,13 @@
#define AQH_MSGIPC_VALUE_OFFS_VALUE_NOM 6 /* 2 bytes */ #define AQH_MSGIPC_VALUE_OFFS_VALUE_NOM 6 /* 2 bytes */
#define AQH_MSGIPC_VALUE_OFFS_VALUE_DENOM 8 /* 2 bytes */ #define AQH_MSGIPC_VALUE_OFFS_VALUE_DENOM 8 /* 2 bytes */
#define AQH_MSGIPC_VALUE_MINSIZE (GWEN_MSGIPC_OFFS_PAYLOAD+10) #define AQH_MSGIPC_VALUE_PAYLOADIZE (AQH_MSGIPC_VALUE_OFFS_UID+10)
#define AQH_MSGIPC_VALUE_MINSIZE (GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_VALUE_PAYLOADIZE)
GWEN_MSG *AQH_ValueIpcMsg_new(uint16_t code, GWEN_MSG *AQH_ValueIpcMsg_new(uint16_t code, uint32_t msgId, uint32_t refMsgId,
uint32_t uid, uint32_t uid,
uint8_t valueId, uint8_t valueId,
uint8_t valueType, uint8_t valueType,
@@ -44,21 +45,13 @@ GWEN_MSG *AQH_ValueIpcMsg_new(uint16_t code,
GWEN_MSG *msg; GWEN_MSG *msg;
uint8_t *ptr; uint8_t *ptr;
msg=GWEN_IpcMsg_new(AQH_IPC_PROTOCOL_NODES_ID, AQH_IPC_PROTOCOL_NODES_VERSION, code, AQH_MSGIPC_VALUE_MINSIZE, NULL); msg=GWEN_IpcMsg_new(AQH_IPC_PROTOCOL_NODES_ID, AQH_IPC_PROTOCOL_NODES_VERSION, code,
ptr=GWEN_Msg_GetBuffer(msg); msgId, refMsgId, AQH_MSGIPC_VALUE_PAYLOADIZE, NULL);
ptr[GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_VALUE_OFFS_UID+0]=uid & 0xff; GWEN_Msg_AddUint32(msg, uid);
ptr[GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_VALUE_OFFS_UID+1]=(uid>>8) & 0xff; GWEN_Msg_AddUint8(msg, valueId);
ptr[GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_VALUE_OFFS_UID+2]=(uid>>16) & 0xff; GWEN_Msg_AddUint8(msg, valueType);
ptr[GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_VALUE_OFFS_UID+3]=(uid>>24) & 0xff; GWEN_Msg_AddUint16(msg, valueNom);
GWEN_Msg_AddUint16(msg, valueDenom);
ptr[GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_VALUE_OFFS_VALUEID]=valueId;
ptr[GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_VALUE_OFFS_VALUETYPE]=valueType;
ptr[GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_VALUE_OFFS_VALUE_NOM+0]=valueNom & 0xff;
ptr[GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_VALUE_OFFS_VALUE_NOM+1]=(valueNom>>8) & 0xff;
ptr[GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_VALUE_OFFS_VALUE_DENOM+0]=valueDenom & 0xff;
ptr[GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_VALUE_OFFS_VALUE_DENOM+1]=(valueDenom>>8) & 0xff;
return msg; return msg;
} }

View File

@@ -19,7 +19,7 @@
AQHOME_API GWEN_MSG *AQH_ValueIpcMsg_new(uint16_t code, AQHOME_API GWEN_MSG *AQH_ValueIpcMsg_new(uint16_t code, uint32_t msgId, uint32_t refMsgId,
uint32_t uid, uint32_t uid,
uint8_t valueId, uint8_t valueId,
uint8_t valueType, uint8_t valueType,

View File

@@ -141,13 +141,25 @@ void AQH_NodeDb_fromDb(AQH_NODE_DB *ndb, GWEN_DB_NODE *dbDatabase)
GWEN_DB_NODE *dbNodeInfo; GWEN_DB_NODE *dbNodeInfo;
AQH_NodeInfo_List_Clear(ndb->nodeList); AQH_NodeInfo_List_Clear(ndb->nodeList);
dbNodeInfo=GWEN_DB_FindFirstGroup(dbDatabase, "nodeinfo"); dbNodeInfo=GWEN_DB_FindFirstGroup(dbDatabase, "nodeinfo");
while(dbNodeInfo) { while(dbNodeInfo) {
AQH_NODE_INFO *ni; AQH_NODE_INFO *ni;
ni=AQH_NodeInfo_fromDb(dbNodeInfo); ni=AQH_NodeInfo_fromDb(dbNodeInfo);
if (ni) if (ni) {
const char *deviceId;
deviceId=AQH_NodeInfo_GetDeviceId(ni);
DBG_ERROR(AQH_LOGDOMAIN,
"Adding node %08x (%s, %04x:%02x:%04x)",
AQH_NodeInfo_GetUid(ni),
deviceId?deviceId:"<no device id>",
AQH_NodeInfo_GetManufacturer(ni),
AQH_NodeInfo_GetDeviceType(ni),
AQH_NodeInfo_GetDeviceVersion(ni));
AQH_NodeInfo_List_Add(ni, ndb->nodeList); AQH_NodeInfo_List_Add(ni, ndb->nodeList);
}
dbNodeInfo=GWEN_DB_FindNextGroup(dbNodeInfo, "nodeinfo"); dbNodeInfo=GWEN_DB_FindNextGroup(dbNodeInfo, "nodeinfo");
} }

View File

@@ -32,6 +32,13 @@
<members> <members>
<member name="deviceId" type="char_ptr" maxlen="128">
<default>NULL</default>
<preset>NULL</preset>
<access>public</access>
<flags>own</flags>
</member>
<member name="busAddress" type="uint8_t" maxlen="8"> <member name="busAddress" type="uint8_t" maxlen="8">
<default>0</default> <default>0</default>
<preset>0</preset> <preset>0</preset>

View File

@@ -4,6 +4,7 @@
<subdirs> <subdirs>
mqtt mqtt
nodes
</subdirs> </subdirs>
</gwbuild> </gwbuild>

9
devices/nodes/0BUILD Normal file
View File

@@ -0,0 +1,9 @@
<?xml?>
<gwbuild>
<data dist="true" install="$(datadir)/aqhome/devices/nodes">
aqua_n11.xml
aqua_n14.xml
</data>
</gwbuild>

View File

@@ -0,0 +1,17 @@
<device name="aqua_n11" driver="nodes">
<manufacturer>AQUA</manufacturer>
<devicetype>N</devicetype>
<deviceversion>11</deviceversion>
<values>
<value name="SI7021_TEMP" id="0x01" type="sensor" dataType="rational" modality="temperature" units="C" />
<value name="SI7021_HUM" id="0x02" type="sensor" dataType="rational" modality="humidity" units="%" />
<value name="REED1" id="0x04" type="sensor" dataType="rational" modality="door" />
<value name="REED2" id="0x05" type="sensor" dataType="rational" modality="door" />
<value name="DS18B20_TEMP" id="0x06" type="sensor" dataType="rational" modality="temperature" units="C" />
<value name="REEDCONF" id="0x81" type="actor" dataType="int" />
</values>
</device>

View File

@@ -0,0 +1,19 @@
<device name="aqua_n14" driver="nodes">
<manufacturer>AQUA</manufacturer>
<devicetype>N</devicetype>
<deviceversion>14</deviceversion>
<values>
<value name="SI7021_TEMP" id="0x01" type="sensor" dataType="rational" modality="temperature" units="C" />
<value name="SI7021_HUM" id="0x02" type="sensor" dataType="rational" modality="humidity" units="%" />
<value name="REED1" id="0x04" type="sensor" dataType="rational" modality="door" />
<value name="REED2" id="0x05" type="sensor" dataType="rational" modality="door" />
<value name="DS18B20_TEMP" id="0x06" type="sensor" dataType="rational" modality="temperature" units="C" />
<value name="REEDCONF" id="0x81" type="actor" dataType="int" />
<value name="NUMLEDS" id="0x82" type="actor" dataType="int" />
<value name="RGBWVALUE" id="0x83" type="actor" dataType="dword" />
</values>
</device>