aqhome: implemented IPC client, fixed some bugs.
sending a PING request and retrieving the PONG response works now.
This commit is contained in:
@@ -11,22 +11,53 @@
|
||||
#endif
|
||||
|
||||
#include "aqhome/msg/msg_ping.h"
|
||||
#include "aqhome/msg/msg_node.h"
|
||||
|
||||
#include <gwenhywfar/misc.h>
|
||||
#include <gwenhywfar/list.h>
|
||||
#include <gwenhywfar/error.h>
|
||||
#include <gwenhywfar/debug.h>
|
||||
|
||||
#include <gwenhywfar/text.h>
|
||||
|
||||
|
||||
#define AQH_MSG_OFFS_PING_TIMESTAMP 0
|
||||
|
||||
#define AQH_MSG_PING_MINSIZE (AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_PING_TIMESTAMP+4)
|
||||
#define AQH_MSG_PING_MINSIZE (AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_PING_TIMESTAMP+4+1)
|
||||
|
||||
|
||||
|
||||
|
||||
GWEN_MSG *AQH_PingMsg_new(uint8_t srcAddr, uint8_t destAddr, uint8_t code)
|
||||
{
|
||||
GWEN_MSG *msg;
|
||||
uint8_t *ptr;
|
||||
int rv;
|
||||
|
||||
msg=AQH_NodeMsg_new(destAddr, srcAddr, code, 4, NULL);
|
||||
ptr=GWEN_Msg_GetBuffer(msg)+AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_PING_TIMESTAMP;
|
||||
*(ptr++)=0; /* timestamp */
|
||||
*(ptr++)=0;
|
||||
*(ptr++)=0;
|
||||
*ptr=0;
|
||||
|
||||
GWEN_Msg_IncCurrentPos(msg, 4);
|
||||
|
||||
rv=AQH_NodeMsg_AddChecksum(msg);
|
||||
if (rv<0) {
|
||||
DBG_INFO(AQH_LOGDOMAIN, "here (%d)", rv);
|
||||
GWEN_Msg_free(msg);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint32_t AQH_PingMsg_GetTimestamp(const GWEN_MSG *msg)
|
||||
{
|
||||
return AQH_NodeMsg_GetUint32At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_PING_TIMESTAMP, 0);
|
||||
return GWEN_Msg_GetUint32At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_PING_TIMESTAMP, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user