aqhome-nodes: log outbound messages. too.

This commit is contained in:
Martin Preuss
2025-09-22 20:24:58 +02:00
parent 732eb4f53d
commit 90f0590d18
4 changed files with 27 additions and 0 deletions

View File

@@ -55,6 +55,7 @@ void AQH_NodeServer_HandleForward(AQH_OBJECT *o, AQH_OBJECT *ep, const AQH_MESSA
AQH_Message_SetData(nodeMsg, ptr, len);
AQH_Message_SetUsedSize(nodeMsg, len);
AQH_Endpoint_AddMsgOut(xo->ttyEndpoint, nodeMsg);
AQH_NodeServer_WriteTtyMsgToLogFile(o, nodeMsg, "sending");
DBG_ERROR(NULL, "Forwarding node message %d to node", AQH_NodeMessage_GetMsgType(nodeMsg));
}
else {

View File

@@ -274,6 +274,7 @@ AQH_MSG_REQUEST *_mkSubRequest_SetData(AQH_OBJECT *o, AQH_NODE_SERVER *xo,
AQH_MsgRequest_SetTimestamps(rq, R_SETDATA_SUBREQUEST_EXPIRE_SECS);
msgOut=AQH_ValueMessage_new(destAddr, xo->nodeAddress, AQH_MSG_TYPE_VALUE_SET, msgId, valueId, dataVal, dataDenom);
AQH_NodeServer_WriteTtyMsgToLogFile(o, msgOut, "sending");
AQH_Endpoint_AddMsgOut(xo->ttyEndpoint, msgOut);
return rq;

View File

@@ -1046,6 +1046,30 @@ void _setDeviceName(AQH_VALUE *value, uint32_t uid)
void AQH_NodeServer_WriteTtyMsgToLogFile(AQH_OBJECT *o, const AQH_MESSAGE *msg, const char *txt)
{
if (o && msg) {
AQH_NODE_SERVER *xo;
xo=GWEN_INHERIT_GETDATA(AQH_OBJECT, AQH_NODE_SERVER, o);
if (xo && xo->logFile) {
GWEN_BUFFER *dbuf;
GWEN_TIME *ti;
dbuf=GWEN_Buffer_new(0, 256, 0, 1);
ti=GWEN_CurrentTime();
GWEN_Time_toString(ti, "YYYY-MM-DD hh:mm:ss ", dbuf);
GWEN_Time_free(ti);
ti=NULL;
AQH_NodeMessage_DumpSpecificToBuffer(msg, dbuf, txt?txt:"");
_writeToLogFile(xo->logFile, GWEN_Buffer_GetStart(dbuf));
GWEN_Buffer_free(dbuf);
}
}
}
void _writeTtyMsgToLogFile(AQH_NODE_SERVER *xo, const AQH_MESSAGE *msg)
{
if (xo->logFile) {

View File

@@ -86,6 +86,7 @@ AQH_MSG_REQUEST *AQH_NodeServer_GetRequestTree(const AQH_OBJECT *o);
void AQH_NodeServer_AddRequestToTree(AQH_OBJECT *o, AQH_MSG_REQUEST *rq);
void AQH_NodeServer_CleanupRequests(AQH_OBJECT *o);
void AQH_NodeServer_WriteTtyMsgToLogFile(AQH_OBJECT *o, const AQH_MESSAGE *msg, const char *txt);