Files
aqhomecontrol/aqhome/msg.h

73 lines
2.2 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>
#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_I2CBUSMEMBER 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
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 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);
#endif