aqhome: added more parsers.
This commit is contained in:
@@ -52,7 +52,11 @@
|
|||||||
msg_value.h
|
msg_value.h
|
||||||
msg_sendstats.h
|
msg_sendstats.h
|
||||||
msg_ping.h
|
msg_ping.h
|
||||||
|
msg_pong.h
|
||||||
msg_needaddr.h
|
msg_needaddr.h
|
||||||
|
msg_haveaddr.h
|
||||||
|
msg_claimaddr.h
|
||||||
|
msg_denyaddr.h
|
||||||
</headers>
|
</headers>
|
||||||
|
|
||||||
|
|
||||||
@@ -63,7 +67,11 @@
|
|||||||
msg_value.c
|
msg_value.c
|
||||||
msg_sendstats.c
|
msg_sendstats.c
|
||||||
msg_ping.c
|
msg_ping.c
|
||||||
|
msg_pong.c
|
||||||
msg_needaddr.c
|
msg_needaddr.c
|
||||||
|
msg_haveaddr.c
|
||||||
|
msg_claimaddr.c
|
||||||
|
msg_denyaddr.c
|
||||||
</sources>
|
</sources>
|
||||||
|
|
||||||
<useTargets>
|
<useTargets>
|
||||||
|
|||||||
@@ -7,7 +7,11 @@
|
|||||||
#include "aqhome/msg_value.h"
|
#include "aqhome/msg_value.h"
|
||||||
#include "aqhome/msg_sendstats.h"
|
#include "aqhome/msg_sendstats.h"
|
||||||
#include "aqhome/msg_ping.h"
|
#include "aqhome/msg_ping.h"
|
||||||
|
#include "aqhome/msg_pong.h"
|
||||||
#include "aqhome/msg_needaddr.h"
|
#include "aqhome/msg_needaddr.h"
|
||||||
|
#include "aqhome/msg_claimaddr.h"
|
||||||
|
#include "aqhome/msg_haveaddr.h"
|
||||||
|
#include "aqhome/msg_denyaddr.h"
|
||||||
|
|
||||||
#include <gwenhywfar/debug.h>
|
#include <gwenhywfar/debug.h>
|
||||||
#include <gwenhywfar/text.h>
|
#include <gwenhywfar/text.h>
|
||||||
@@ -129,6 +133,10 @@ void _packetReceived(AQH_SERIAL *sr, AQH_MSG *msg)
|
|||||||
AQH_MsgPing_DumpToBuffer(msg, dbuf, "received");
|
AQH_MsgPing_DumpToBuffer(msg, dbuf, "received");
|
||||||
fprintf(stdout, "%s", GWEN_Buffer_GetStart(dbuf));
|
fprintf(stdout, "%s", GWEN_Buffer_GetStart(dbuf));
|
||||||
}
|
}
|
||||||
|
else if (msgType==AQH_MSG_TYPE_PONG) {
|
||||||
|
AQH_MsgPong_DumpToBuffer(msg, dbuf, "received");
|
||||||
|
fprintf(stdout, "%s", GWEN_Buffer_GetStart(dbuf));
|
||||||
|
}
|
||||||
else if (msgType==AQH_MSG_TYPE_COMSENDSTATS) { /* CPRO_CMD_COMSENDSTATS */
|
else if (msgType==AQH_MSG_TYPE_COMSENDSTATS) { /* CPRO_CMD_COMSENDSTATS */
|
||||||
AQH_MsgSendStats_DumpToBuffer(msg, dbuf, "received");
|
AQH_MsgSendStats_DumpToBuffer(msg, dbuf, "received");
|
||||||
fprintf(stdout, "%s", GWEN_Buffer_GetStart(dbuf));
|
fprintf(stdout, "%s", GWEN_Buffer_GetStart(dbuf));
|
||||||
@@ -157,6 +165,18 @@ void _packetReceived(AQH_SERIAL *sr, AQH_MSG *msg)
|
|||||||
AQH_MsgNeedAddr_DumpToBuffer(msg, dbuf, "received");
|
AQH_MsgNeedAddr_DumpToBuffer(msg, dbuf, "received");
|
||||||
fprintf(stdout, "%s", GWEN_Buffer_GetStart(dbuf));
|
fprintf(stdout, "%s", GWEN_Buffer_GetStart(dbuf));
|
||||||
}
|
}
|
||||||
|
else if (msgType==AQH_MSG_TYPE_CLAIM_ADDRESS) {
|
||||||
|
AQH_MsgClaimAddr_DumpToBuffer(msg, dbuf, "received");
|
||||||
|
fprintf(stdout, "%s", GWEN_Buffer_GetStart(dbuf));
|
||||||
|
}
|
||||||
|
else if (msgType==AQH_MSG_TYPE_HAVE_ADDRESS) {
|
||||||
|
AQH_MsgHaveAddr_DumpToBuffer(msg, dbuf, "received");
|
||||||
|
fprintf(stdout, "%s", GWEN_Buffer_GetStart(dbuf));
|
||||||
|
}
|
||||||
|
else if (msgType==AQH_MSG_TYPE_DENY_ADDRESS) {
|
||||||
|
AQH_MsgDenyAddr_DumpToBuffer(msg, dbuf, "received");
|
||||||
|
fprintf(stdout, "%s", GWEN_Buffer_GetStart(dbuf));
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
fprintf(stdout, " %s: Received (%d):\n", GWEN_Buffer_GetStart(dbuf), msgType);
|
fprintf(stdout, " %s: Received (%d):\n", GWEN_Buffer_GetStart(dbuf), msgType);
|
||||||
GWEN_Text_DumpString(ptr, len, 6);
|
GWEN_Text_DumpString(ptr, len, 6);
|
||||||
@@ -186,7 +206,7 @@ AQH_MSG *createPingMsg(AQH_SERIAL *sr, uint8_t destAddr)
|
|||||||
AQH_Msg_free(msg);
|
AQH_Msg_free(msg);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
rv=AQH_Msg_AddByte(msg, 10); /* ping */
|
rv=AQH_Msg_AddByte(msg, AQH_MSG_TYPE_PING); /* ping */
|
||||||
if (rv<0) {
|
if (rv<0) {
|
||||||
fprintf(stderr, "ERROR3: %d\n", rv);
|
fprintf(stderr, "ERROR3: %d\n", rv);
|
||||||
AQH_Msg_free(msg);
|
AQH_Msg_free(msg);
|
||||||
@@ -267,7 +287,7 @@ int testLoop()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
t=time(NULL);
|
t=time(NULL);
|
||||||
if (difftime(t, tLast)>10) {
|
if (difftime(t, tLast)>61) {
|
||||||
AQH_MSG *msg;
|
AQH_MSG *msg;
|
||||||
|
|
||||||
msg=createPingMsg(sr, 1);
|
msg=createPingMsg(sr, 1);
|
||||||
|
|||||||
@@ -35,6 +35,10 @@
|
|||||||
#define AQH_MSG_TYPE_VALUE 50
|
#define AQH_MSG_TYPE_VALUE 50
|
||||||
#define AQH_MSG_TYPE_NEED_ADDRESS 60
|
#define AQH_MSG_TYPE_NEED_ADDRESS 60
|
||||||
#define AQH_MSG_TYPE_HAVE_ADDRESS 61
|
#define AQH_MSG_TYPE_HAVE_ADDRESS 61
|
||||||
|
#define AQH_MSG_TYPE_CLAIM_ADDRESS 62
|
||||||
|
#define AQH_MSG_TYPE_DENY_ADDRESS 63
|
||||||
|
#define AQH_MSG_TYPE_ADDRESS_RANGE 64
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
68
aqhome/msg_claimaddr.c
Normal file
68
aqhome/msg_claimaddr.c
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* This file is part of the project AqHome.
|
||||||
|
* AqHome (c) by 2023 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 "aqhome/msg_claimaddr.h"
|
||||||
|
|
||||||
|
#include <gwenhywfar/misc.h>
|
||||||
|
#include <gwenhywfar/list.h>
|
||||||
|
#include <gwenhywfar/error.h>
|
||||||
|
#include <gwenhywfar/debug.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
uint32_t AQH_MsgClaimAddr_GetUid(const AQH_MSG *msg)
|
||||||
|
{
|
||||||
|
if ((AQH_Msg_GetMsgType(msg)==AQH_MSG_TYPE_CLAIM_ADDRESS) &&
|
||||||
|
(AQH_Msg_GetBytesInBuffer(msg)>=AQH_MSG_CLAIMADDR_MINSIZE)) {
|
||||||
|
const uint8_t *ptr;
|
||||||
|
|
||||||
|
ptr=AQH_Msg_GetConstBuffer(msg)+AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_CLAIMADDR_UID;
|
||||||
|
return (uint32_t)(ptr[0])+(ptr[1]<<8)+(ptr[2]<<16)+(ptr[3]<<24);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
uint8_t AQH_MsgClaimAddr_GetAddress(const AQH_MSG *msg)
|
||||||
|
{
|
||||||
|
if ((AQH_Msg_GetMsgType(msg)==AQH_MSG_TYPE_CLAIM_ADDRESS) &&
|
||||||
|
(AQH_Msg_GetBytesInBuffer(msg)>=AQH_MSG_CLAIMADDR_MINSIZE)) {
|
||||||
|
const uint8_t *ptr;
|
||||||
|
|
||||||
|
ptr=AQH_Msg_GetConstBuffer(msg)+AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_CLAIMADDR_ADDR;
|
||||||
|
return ptr[0];
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void AQH_MsgClaimAddr_DumpToBuffer(const AQH_MSG *msg, GWEN_BUFFER *dbuf, const char *sText)
|
||||||
|
{
|
||||||
|
if ((AQH_Msg_GetMsgType(msg)==AQH_MSG_TYPE_CLAIM_ADDRESS) &&
|
||||||
|
(AQH_Msg_GetBytesInBuffer(msg)>=AQH_MSG_CLAIMADDR_MINSIZE)) {
|
||||||
|
GWEN_Buffer_AppendArgs(dbuf,
|
||||||
|
"0x%02x->0x%02x: CLAIM_ADDRESS %s (uid=0x%08x, address=0x%02x)\n",
|
||||||
|
AQH_Msg_GetSourceAddress(msg),
|
||||||
|
AQH_Msg_GetDestAddress(msg),
|
||||||
|
sText,
|
||||||
|
(unsigned int) AQH_MsgClaimAddr_GetUid(msg),
|
||||||
|
AQH_MsgClaimAddr_GetAddress(msg));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
38
aqhome/msg_claimaddr.h
Normal file
38
aqhome/msg_claimaddr.h
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* This file is part of the project AqHome.
|
||||||
|
* AqHome (c) by 2023 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 AQH_MSG_CLAIMADDR_H
|
||||||
|
#define AQH_MSG_CLAIMADDR_H
|
||||||
|
|
||||||
|
|
||||||
|
#include <aqhome/api.h>
|
||||||
|
|
||||||
|
#include "aqhome/msg.h"
|
||||||
|
|
||||||
|
#include <gwenhywfar/list.h>
|
||||||
|
#include <gwenhywfar/buffer.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#define AQH_MSG_OFFS_CLAIMADDR_UID 0
|
||||||
|
#define AQH_MSG_OFFS_CLAIMADDR_ADDR 4
|
||||||
|
|
||||||
|
#define AQH_MSG_CLAIMADDR_MINSIZE (AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_CLAIMADDR_ADDR+1)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
AQHOME_API uint32_t AQH_MsgClaimAddr_GetUid(const AQH_MSG *msg);
|
||||||
|
AQHOME_API uint8_t AQH_MsgClaimAddr_GetAddress(const AQH_MSG *msg);
|
||||||
|
AQHOME_API void AQH_MsgClaimAddr_DumpToBuffer(const AQH_MSG *msg, GWEN_BUFFER *dbuf, const char *sText);
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
68
aqhome/msg_denyaddr.c
Normal file
68
aqhome/msg_denyaddr.c
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* This file is part of the project AqHome.
|
||||||
|
* AqHome (c) by 2023 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 "aqhome/msg_denyaddr.h"
|
||||||
|
|
||||||
|
#include <gwenhywfar/misc.h>
|
||||||
|
#include <gwenhywfar/list.h>
|
||||||
|
#include <gwenhywfar/error.h>
|
||||||
|
#include <gwenhywfar/debug.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
uint32_t AQH_MsgDenyAddr_GetUid(const AQH_MSG *msg)
|
||||||
|
{
|
||||||
|
if ((AQH_Msg_GetMsgType(msg)==AQH_MSG_TYPE_DENY_ADDRESS) &&
|
||||||
|
(AQH_Msg_GetBytesInBuffer(msg)>=AQH_MSG_DENYADDR_MINSIZE)) {
|
||||||
|
const uint8_t *ptr;
|
||||||
|
|
||||||
|
ptr=AQH_Msg_GetConstBuffer(msg)+AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_DENYADDR_UID;
|
||||||
|
return (uint32_t)(ptr[0])+(ptr[1]<<8)+(ptr[2]<<16)+(ptr[3]<<24);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
uint8_t AQH_MsgDenyAddr_GetAddress(const AQH_MSG *msg)
|
||||||
|
{
|
||||||
|
if ((AQH_Msg_GetMsgType(msg)==AQH_MSG_TYPE_DENY_ADDRESS) &&
|
||||||
|
(AQH_Msg_GetBytesInBuffer(msg)>=AQH_MSG_DENYADDR_MINSIZE)) {
|
||||||
|
const uint8_t *ptr;
|
||||||
|
|
||||||
|
ptr=AQH_Msg_GetConstBuffer(msg)+AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_DENYADDR_ADDR;
|
||||||
|
return ptr[0];
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void AQH_MsgDenyAddr_DumpToBuffer(const AQH_MSG *msg, GWEN_BUFFER *dbuf, const char *sText)
|
||||||
|
{
|
||||||
|
if ((AQH_Msg_GetMsgType(msg)==AQH_MSG_TYPE_DENY_ADDRESS) &&
|
||||||
|
(AQH_Msg_GetBytesInBuffer(msg)>=AQH_MSG_DENYADDR_MINSIZE)) {
|
||||||
|
GWEN_Buffer_AppendArgs(dbuf,
|
||||||
|
"0x%02x->0x%02x: DENY_ADDRESS %s (uid=0x%08x, address=0x%02x)\n",
|
||||||
|
AQH_Msg_GetSourceAddress(msg),
|
||||||
|
AQH_Msg_GetDestAddress(msg),
|
||||||
|
sText,
|
||||||
|
(unsigned int) AQH_MsgDenyAddr_GetUid(msg),
|
||||||
|
AQH_MsgDenyAddr_GetAddress(msg));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
38
aqhome/msg_denyaddr.h
Normal file
38
aqhome/msg_denyaddr.h
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* This file is part of the project AqHome.
|
||||||
|
* AqHome (c) by 2023 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 AQH_MSG_DENYADDR_H
|
||||||
|
#define AQH_MSG_DENYADDR_H
|
||||||
|
|
||||||
|
|
||||||
|
#include <aqhome/api.h>
|
||||||
|
|
||||||
|
#include "aqhome/msg.h"
|
||||||
|
|
||||||
|
#include <gwenhywfar/list.h>
|
||||||
|
#include <gwenhywfar/buffer.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#define AQH_MSG_OFFS_DENYADDR_UID 0
|
||||||
|
#define AQH_MSG_OFFS_DENYADDR_ADDR 4
|
||||||
|
|
||||||
|
#define AQH_MSG_DENYADDR_MINSIZE (AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_DENYADDR_ADDR+1)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
AQHOME_API uint32_t AQH_MsgDenyAddr_GetUid(const AQH_MSG *msg);
|
||||||
|
AQHOME_API uint8_t AQH_MsgDenyAddr_GetAddress(const AQH_MSG *msg);
|
||||||
|
AQHOME_API void AQH_MsgDenyAddr_DumpToBuffer(const AQH_MSG *msg, GWEN_BUFFER *dbuf, const char *sText);
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
68
aqhome/msg_haveaddr.c
Normal file
68
aqhome/msg_haveaddr.c
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* This file is part of the project AqHome.
|
||||||
|
* AqHome (c) by 2023 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 "aqhome/msg_haveaddr.h"
|
||||||
|
|
||||||
|
#include <gwenhywfar/misc.h>
|
||||||
|
#include <gwenhywfar/list.h>
|
||||||
|
#include <gwenhywfar/error.h>
|
||||||
|
#include <gwenhywfar/debug.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
uint32_t AQH_MsgHaveAddr_GetUid(const AQH_MSG *msg)
|
||||||
|
{
|
||||||
|
if ((AQH_Msg_GetMsgType(msg)==AQH_MSG_TYPE_HAVE_ADDRESS) &&
|
||||||
|
(AQH_Msg_GetBytesInBuffer(msg)>=AQH_MSG_HAVEADDR_MINSIZE)) {
|
||||||
|
const uint8_t *ptr;
|
||||||
|
|
||||||
|
ptr=AQH_Msg_GetConstBuffer(msg)+AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_HAVEADDR_UID;
|
||||||
|
return (uint32_t)(ptr[0])+(ptr[1]<<8)+(ptr[2]<<16)+(ptr[3]<<24);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
uint8_t AQH_MsgHaveAddr_GetAddress(const AQH_MSG *msg)
|
||||||
|
{
|
||||||
|
if ((AQH_Msg_GetMsgType(msg)==AQH_MSG_TYPE_HAVE_ADDRESS) &&
|
||||||
|
(AQH_Msg_GetBytesInBuffer(msg)>=AQH_MSG_HAVEADDR_MINSIZE)) {
|
||||||
|
const uint8_t *ptr;
|
||||||
|
|
||||||
|
ptr=AQH_Msg_GetConstBuffer(msg)+AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_HAVEADDR_ADDR;
|
||||||
|
return ptr[0];
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void AQH_MsgHaveAddr_DumpToBuffer(const AQH_MSG *msg, GWEN_BUFFER *dbuf, const char *sText)
|
||||||
|
{
|
||||||
|
if ((AQH_Msg_GetMsgType(msg)==AQH_MSG_TYPE_HAVE_ADDRESS) &&
|
||||||
|
(AQH_Msg_GetBytesInBuffer(msg)>=AQH_MSG_HAVEADDR_MINSIZE)) {
|
||||||
|
GWEN_Buffer_AppendArgs(dbuf,
|
||||||
|
"0x%02x->0x%02x: HAVE_ADDRESS %s (uid=0x%08x, address=0x%02x)\n",
|
||||||
|
AQH_Msg_GetSourceAddress(msg),
|
||||||
|
AQH_Msg_GetDestAddress(msg),
|
||||||
|
sText,
|
||||||
|
(unsigned int) AQH_MsgHaveAddr_GetUid(msg),
|
||||||
|
AQH_MsgHaveAddr_GetAddress(msg));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
38
aqhome/msg_haveaddr.h
Normal file
38
aqhome/msg_haveaddr.h
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* This file is part of the project AqHome.
|
||||||
|
* AqHome (c) by 2023 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 AQH_MSG_HAVEADDR_H
|
||||||
|
#define AQH_MSG_HAVEADDR_H
|
||||||
|
|
||||||
|
|
||||||
|
#include <aqhome/api.h>
|
||||||
|
|
||||||
|
#include "aqhome/msg.h"
|
||||||
|
|
||||||
|
#include <gwenhywfar/list.h>
|
||||||
|
#include <gwenhywfar/buffer.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#define AQH_MSG_OFFS_HAVEADDR_UID 0
|
||||||
|
#define AQH_MSG_OFFS_HAVEADDR_ADDR 4
|
||||||
|
|
||||||
|
#define AQH_MSG_HAVEADDR_MINSIZE (AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_HAVEADDR_ADDR+1)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
AQHOME_API uint32_t AQH_MsgHaveAddr_GetUid(const AQH_MSG *msg);
|
||||||
|
AQHOME_API uint8_t AQH_MsgHaveAddr_GetAddress(const AQH_MSG *msg);
|
||||||
|
AQHOME_API void AQH_MsgHaveAddr_DumpToBuffer(const AQH_MSG *msg, GWEN_BUFFER *dbuf, const char *sText);
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
53
aqhome/msg_pong.c
Normal file
53
aqhome/msg_pong.c
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* This file is part of the project AqHome.
|
||||||
|
* AqHome (c) by 2023 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 "aqhome/msg_pong.h"
|
||||||
|
|
||||||
|
#include <gwenhywfar/misc.h>
|
||||||
|
#include <gwenhywfar/list.h>
|
||||||
|
#include <gwenhywfar/error.h>
|
||||||
|
#include <gwenhywfar/debug.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
uint32_t AQH_MsgPong_GetTimestamp(const AQH_MSG *msg)
|
||||||
|
{
|
||||||
|
if ((AQH_Msg_GetMsgType(msg)==AQH_MSG_TYPE_PONG) &&
|
||||||
|
(AQH_Msg_GetBytesInBuffer(msg)>=AQH_MSG_PONG_MINSIZE)) {
|
||||||
|
const uint8_t *ptr;
|
||||||
|
|
||||||
|
ptr=AQH_Msg_GetConstBuffer(msg)+AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_PONG_TIMESTAMP;
|
||||||
|
return (uint32_t)(ptr[0])+(ptr[1]<<8)+(ptr[2]<<16)+(ptr[3]<<24);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void AQH_MsgPong_DumpToBuffer(const AQH_MSG *msg, GWEN_BUFFER *dbuf, const char *sText)
|
||||||
|
{
|
||||||
|
if ((AQH_Msg_GetMsgType(msg)==AQH_MSG_TYPE_PONG) &&
|
||||||
|
(AQH_Msg_GetBytesInBuffer(msg)>=AQH_MSG_PONG_MINSIZE)) {
|
||||||
|
GWEN_Buffer_AppendArgs(dbuf,
|
||||||
|
"0x%02x->0x%02x: PONG %s (timestamp=0x%08x)\n",
|
||||||
|
AQH_Msg_GetSourceAddress(msg),
|
||||||
|
AQH_Msg_GetDestAddress(msg),
|
||||||
|
sText,
|
||||||
|
(unsigned int) AQH_MsgPong_GetTimestamp(msg));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
37
aqhome/msg_pong.h
Normal file
37
aqhome/msg_pong.h
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* This file is part of the project AqHome.
|
||||||
|
* AqHome (c) by 2023 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 AQH_MSG_PONG_H
|
||||||
|
#define AQH_MSG_PONG_H
|
||||||
|
|
||||||
|
|
||||||
|
#include <aqhome/api.h>
|
||||||
|
|
||||||
|
#include "aqhome/msg.h"
|
||||||
|
|
||||||
|
#include <gwenhywfar/list.h>
|
||||||
|
#include <gwenhywfar/buffer.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#define AQH_MSG_OFFS_PONG_TIMESTAMP 0
|
||||||
|
|
||||||
|
#define AQH_MSG_PONG_MINSIZE (AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_PONG_TIMESTAMP+4)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
AQHOME_API uint32_t AQH_MsgPong_GetTimestamp(const AQH_MSG *msg);
|
||||||
|
AQHOME_API void AQH_MsgPong_DumpToBuffer(const AQH_MSG *msg, GWEN_BUFFER *dbuf, const char *sText);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user