diff --git a/aqhome/msg/endpoint_log.c b/aqhome/msg/endpoint_log.c index 78ce8dc..6c95f5f 100644 --- a/aqhome/msg/endpoint_log.c +++ b/aqhome/msg/endpoint_log.c @@ -50,7 +50,6 @@ static void _writeToLogFile(const char *filename, const char *txt); GWEN_MSG_ENDPOINT *AQH_LogEndpoint_new(const char *filename, int groupId) { - int fd; GWEN_MSG_ENDPOINT *ep; AQH_MSG_ENDPOINT_LOG *xep; @@ -104,8 +103,6 @@ void _run(GWEN_MSG_ENDPOINT *ep) void _logMessage(GWEN_MSG_ENDPOINT *ep, const GWEN_MSG *msg) { AQH_MSG_ENDPOINT_LOG *xep; - const uint8_t *ptr; - uint8_t len; uint8_t msgType; int msgIsValid; GWEN_BUFFER *dbuf; @@ -120,25 +117,28 @@ void _logMessage(GWEN_MSG_ENDPOINT *ep, const GWEN_MSG *msg) ti=NULL; msgIsValid=(AQH_NodeMsg_IsChecksumValid(msg) && AQH_NodeMsg_IsMsgComplete(msg)); - ptr=GWEN_Msg_GetConstBuffer(msg); - len=GWEN_Msg_GetBytesInBuffer(msg); msgType=AQH_NodeMsg_GetMsgType(msg); - switch(msgType) { - case AQH_MSG_TYPE_PING: AQH_PingMsg_DumpToBuffer(msg, dbuf, "received"); break; - case AQH_MSG_TYPE_PONG: AQH_PongMsg_DumpToBuffer(msg, dbuf, "received"); break; - case AQH_MSG_TYPE_COMSENDSTATS: AQH_SendStatsMsg_DumpToBuffer(msg, dbuf, "received"); break; - case AQH_MSG_TYPE_COMRECVSTATS: AQH_RecvStatsMsg_DumpToBuffer(msg, dbuf, "received"); break; - case AQH_MSG_TYPE_TWIBUSMEMBER: AQH_NodeMsg_DumpToBuffer(msg, dbuf, "received"); break; - case AQH_MSG_TYPE_DEBUG: AQH_NodeMsg_DumpToBuffer(msg, dbuf, "received"); break; - case AQH_MSG_TYPE_VALUE: AQH_ValueMsg_DumpToBuffer(msg, dbuf, "received"); break; - case AQH_MSG_TYPE_VALUE2: AQH_Value2Msg_DumpToBuffer(msg, dbuf, "received"); break; - case AQH_MSG_TYPE_NEED_ADDRESS: AQH_NeedAddrMsg_DumpToBuffer(msg, dbuf, "received"); break; - case AQH_MSG_TYPE_CLAIM_ADDRESS: AQH_ClaimAddrMsg_DumpToBuffer(msg, dbuf, "received"); break; - case AQH_MSG_TYPE_HAVE_ADDRESS: AQH_HaveAddrMsg_DumpToBuffer(msg, dbuf, "received"); break; - case AQH_MSG_TYPE_DENY_ADDRESS: AQH_DenyAddrMsg_DumpToBuffer(msg, dbuf, "received"); break; - case AQH_MSG_TYPE_DEVICE: AQH_DeviceMsg_DumpToBuffer(msg, dbuf, "received"); break; - default: AQH_NodeMsg_DumpToBuffer(msg, dbuf, "received"); break; + if (msgIsValid) { + switch(msgType) { + case AQH_MSG_TYPE_PING: AQH_PingMsg_DumpToBuffer(msg, dbuf, "received"); break; + case AQH_MSG_TYPE_PONG: AQH_PongMsg_DumpToBuffer(msg, dbuf, "received"); break; + case AQH_MSG_TYPE_COMSENDSTATS: AQH_SendStatsMsg_DumpToBuffer(msg, dbuf, "received"); break; + case AQH_MSG_TYPE_COMRECVSTATS: AQH_RecvStatsMsg_DumpToBuffer(msg, dbuf, "received"); break; + case AQH_MSG_TYPE_TWIBUSMEMBER: AQH_NodeMsg_DumpToBuffer(msg, dbuf, "received"); break; + case AQH_MSG_TYPE_DEBUG: AQH_NodeMsg_DumpToBuffer(msg, dbuf, "received"); break; + case AQH_MSG_TYPE_VALUE: AQH_ValueMsg_DumpToBuffer(msg, dbuf, "received"); break; + case AQH_MSG_TYPE_VALUE2: AQH_Value2Msg_DumpToBuffer(msg, dbuf, "received"); break; + case AQH_MSG_TYPE_NEED_ADDRESS: AQH_NeedAddrMsg_DumpToBuffer(msg, dbuf, "received"); break; + case AQH_MSG_TYPE_CLAIM_ADDRESS: AQH_ClaimAddrMsg_DumpToBuffer(msg, dbuf, "received"); break; + case AQH_MSG_TYPE_HAVE_ADDRESS: AQH_HaveAddrMsg_DumpToBuffer(msg, dbuf, "received"); break; + case AQH_MSG_TYPE_DENY_ADDRESS: AQH_DenyAddrMsg_DumpToBuffer(msg, dbuf, "received"); break; + case AQH_MSG_TYPE_DEVICE: AQH_DeviceMsg_DumpToBuffer(msg, dbuf, "received"); break; + default: AQH_NodeMsg_DumpToBuffer(msg, dbuf, "received"); break; + } + } + else { + AQH_NodeMsg_DumpToBuffer(msg, dbuf, "(invalid) received"); } _writeToLogFile(xep->filename, GWEN_Buffer_GetStart(dbuf)); GWEN_Buffer_free(dbuf); diff --git a/aqhome/msg/endpoint_tty.c b/aqhome/msg/endpoint_tty.c index ea3b952..29d27bc 100644 --- a/aqhome/msg/endpoint_tty.c +++ b/aqhome/msg/endpoint_tty.c @@ -167,7 +167,7 @@ int _handleReadable(GWEN_MSG_ENDPOINT *ep, GWEN_UNUSED GWEN_MSG_ENDPOINT_MGR *em /* complete msg received, add to list */ if (!AQH_NodeMsg_IsChecksumValid(msg)) { DBG_ERROR(AQH_LOGDOMAIN, "Invalid checksum, discarding message"); - GWEN_Text_DumpString(GWEN_Msg_GetBuffer(msg), GWEN_Msg_GetBytesInBuffer(msg), 6); + GWEN_Text_DumpString((const char*) GWEN_Msg_GetBuffer(msg), GWEN_Msg_GetBytesInBuffer(msg), 6); GWEN_MsgEndpoint_SetCurrentlyReceivedMsg(ep, NULL); rv=GWEN_MsgEndpoint_DiscardInput(ep); if (rv<0) { @@ -254,11 +254,8 @@ int _openDevice(GWEN_MSG_ENDPOINT *ep) { AQH_MSG_ENDPOINT_TTY *xep; int fd; - int status; - int i; struct termios options; int rv; - int m; xep=GWEN_INHERIT_GETDATA(GWEN_MSG_ENDPOINT, AQH_MSG_ENDPOINT_TTY, ep); assert(xep); @@ -336,6 +333,7 @@ int _endMsg(GWEN_MSG_ENDPOINT *ep) { /* TODO: flush before releasing ATTN */ _attnHigh(ep); + return 0; }