Files
aqhomecontrol/aqhome/msg.h
Martin Preuss caa85edfc6 More work on node/pc interface.
- added AQH_MSG_ENDPOINT
- added AQH_MsgEndpointLog
- added AQH_MsgEndpointTcp
- added AQH_MsgEndpointTty
- added AQH_MsgEndpointMgr
2023-02-20 23:45:10 +01:00

84 lines
2.6 KiB
C

/****************************************************************************
* 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_H
#define AQH_MSG_H
#define AQH_MAXMSGSIZE 16
#include <aqhome/api.h>
#include <gwenhywfar/list.h>
#include <gwenhywfar/buffer.h>
#define AQH_MSG_OFFS_ALL_DEST_ADDRESS 0
#define AQH_MSG_OFFS_ALL_PAYLOAD_LEN 1
#define AQH_MSG_OFFS_ALL_PAYLOAD_BEGIN 2
#define AQH_MSG_OFFS_ALL_MSG_TYPE 2
#define AQH_MSG_OFFS_ALL_SRC_ADDRESS 3
#define AQH_MSG_OFFS_ALL_DATA_BEGIN 4
#define AQH_MSG_TYPE_PING 10
#define AQH_MSG_TYPE_PONG 11
#define AQH_MSG_TYPE_COMSENDSTATS 20
#define AQH_MSG_TYPE_COMRECVSTATS 21
#define AQH_MSG_TYPE_TWIBUSMEMBER 30
#define AQH_MSG_TYPE_DEBUG 40
#define AQH_MSG_TYPE_VALUE 50
#define AQH_MSG_TYPE_NEED_ADDRESS 60
#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
/* internal msg types via NET interface */
#define AQH_MSG_TYPE_NET_SET_ACCEPTED_MSGGROUPS 200
typedef struct AQH_MSG AQH_MSG;
GWEN_LIST_FUNCTION_LIB_DEFS(AQH_MSG, AQH_Msg, AQHOME_API)
AQHOME_API AQH_MSG *AQH_Msg_new();
AQHOME_API void AQH_Msg_free(AQH_MSG *msg);
AQHOME_API AQH_MSG *AQH_Msg_dup(const AQH_MSG *srcMsg);
AQHOME_API uint8_t *AQH_Msg_GetBuffer(AQH_MSG *msg);
AQHOME_API const uint8_t *AQH_Msg_GetConstBuffer(const AQH_MSG *msg);
AQHOME_API uint8_t AQH_Msg_GetBytesInBuffer(const AQH_MSG *msg);
AQHOME_API uint8_t AQH_Msg_GetCurrentPos(const AQH_MSG *msg);
AQHOME_API int AQH_Msg_AddByte(AQH_MSG *msg, uint8_t b);
AQHOME_API int AQH_Msg_ReadNextByte(AQH_MSG *msg);
AQHOME_API int AQH_Msg_IncCurrentPos(AQH_MSG *msg, uint8_t i);
AQHOME_API int AQH_Msg_GetRemainingBytes(const AQH_MSG *msg);
AQHOME_API int AQH_Msg_RewindCurrentPos(AQH_MSG *msg);
AQHOME_API uint8_t AQH_Msg_GetDestAddress(const AQH_MSG *msg);
AQHOME_API uint8_t AQH_Msg_GetMsgType(const AQH_MSG *msg);
AQHOME_API uint8_t AQH_Msg_GetSourceAddress(const AQH_MSG *msg);
AQHOME_API uint8_t AQH_Msg_GetMsgPayloadLen(const AQH_MSG *msg);
AQHOME_API int AQH_Msg_IsMsgComplete(const AQH_MSG *msg);
AQHOME_API int AQH_Msg_IsChecksumValid(const AQH_MSG *msg);
AQHOME_API int AQH_Msg_AddChecksum(AQH_MSG *msg);
AQHOME_API void AQH_Msg_DumpToBuffer(const AQH_MSG *msg, GWEN_BUFFER *dbuf, const char *sText);
#endif