forked from gatsby/df_datalink
180 lines
4.7 KiB
C
180 lines
4.7 KiB
C
/*****************************************************************************/
|
|
/**
|
|
* @file msg_def.c
|
|
* @author FanHao ([email protected])
|
|
* @brief DF Linklayer message definition constants.
|
|
* @version 0.0
|
|
* @date 2023-05-06
|
|
*
|
|
* @copyright Copyright(c) 2024 Beijing Institute of Technology.\n
|
|
* Lab of Communication and Network
|
|
*
|
|
******************************************************************************/
|
|
|
|
/**
|
|
* @addtogroup LinkLayer
|
|
* @{
|
|
*/
|
|
|
|
/**
|
|
* @name LinkLayer_MSG_Constants
|
|
* @{
|
|
*/
|
|
#ifndef __L2_MSG_DEF_H_
|
|
#define __L2_MSG_DEF_H_
|
|
|
|
#define L2_PACK_LEN_MAX 2048 // bytes
|
|
|
|
#define L2_PAYLOAD_LEN_ADV 17
|
|
#define L2_PAYLOAD_LEN_ACK 9
|
|
#define L2_PAYLOAD_LEN_SVC_128K 42
|
|
#define L2_PAYLOAD_LEN_SVC_512K 267
|
|
#define L2_PAYLOAD_LEN_SVC_2M 1222
|
|
#define L2_MSG_CRC_LEN 1
|
|
|
|
|
|
// [bytes] [name]
|
|
// 1 udu number
|
|
// 10 crypto sync word
|
|
// 8 message authentication code
|
|
// 4 frame number
|
|
// 1 slot number
|
|
// 1 source id
|
|
// 1 destination id
|
|
// 1 message type
|
|
#define L2_MSG_UDU_NUM 0
|
|
#define L2_MSG_UDU_NUM_LEN 1
|
|
#define L2_MSG_SYNC_WORD 1
|
|
#define L2_MSG_SYNC_WORD_LEN 10
|
|
#define L2_MSG_AUTH_CODE 11
|
|
#define L2_MSG_AUTH_CODE_LEN 8
|
|
#define L2_MSG_FRAME_NUM 19
|
|
#define L2_MSG_FRAME_NUM_LEN 4
|
|
#define L2_MSG_SLOT_NUM 23
|
|
#define L2_MSG_SLOT_NUM_LEN 1
|
|
#define L2_MSG_SRC_ID 24
|
|
#define L2_MSG_SRC_ID_LEN 1
|
|
#define L2_MSG_DST_ID 25
|
|
#define L2_MSG_DST_ID_LEN 1
|
|
#define L2_MSG_TYPE 26
|
|
#define L2_MSG_TYPE_LEN 1
|
|
#define L2_MSG_PAYLOAD 27
|
|
|
|
#pragma pack(push, 1) // Force 1-byte alignment
|
|
|
|
/**
|
|
* @struct L2_MSG_COMMON
|
|
* @brief Link layer common message header, 27 byte / 216 bit in total.
|
|
*/
|
|
typedef struct
|
|
{
|
|
uint8_t uduNum; ///< udu (user data unit) number per pdu (packet data unit)
|
|
struct
|
|
{
|
|
uint8_t cryptoSyncWord[10];
|
|
uint8_t msgAuthCode[8];
|
|
} MSG_KEY;
|
|
|
|
uint32_t frameNum; ///< frame number
|
|
uint8_t slotNum; ///< slot number
|
|
uint8_t src; ///< source id
|
|
uint8_t dst; ///< destination id
|
|
uint8_t msgType; ///< message type
|
|
} L2_MSG_COMMON;
|
|
|
|
/**
|
|
* @struct L2_MSG_ADV
|
|
* @brief Link layer advertise message definition, 65 byte / 520 bit in total.
|
|
*/
|
|
typedef struct
|
|
{
|
|
L2_MSG_COMMON common; ///< common message header
|
|
float srcPosX; ///< position x
|
|
float srcPosY; ///< position y
|
|
float srcPosZ; ///< position z
|
|
uint32_t srcNetStatTime;///< net start time
|
|
uint32_t advDataId; ///< advertise payload id
|
|
uint8_t advData[L2_PAYLOAD_LEN_ADV]; ///< advertise payload data
|
|
uint8_t crc; ///< crc
|
|
} L2_MSG_ADV;
|
|
|
|
/**
|
|
* @struct L2_MSG_ACK
|
|
* @brief Link layer acknowledge message definition, 65 byte / 520 bit in total.
|
|
*/
|
|
typedef struct
|
|
{
|
|
L2_MSG_COMMON common; ///< common message header
|
|
float srcPosX; ///< position x
|
|
float srcPosY; ///< position y
|
|
float srcPosZ; ///< position z
|
|
float srcSpeedX; ///< speed x
|
|
float srcSpeedY; ///< speed y
|
|
float srcSpeedZ; ///< speed z
|
|
uint32_t ackDataId; ///< acknowledge payload id
|
|
uint8_t ackData[L2_PAYLOAD_LEN_ACK]; ///< acknowledge payload data
|
|
uint8_t crc; ///< crc
|
|
} L2_MSG_ACK;
|
|
|
|
/**
|
|
* @struct L2_MSG_SVC_128K
|
|
* @brief Link layer 128 kbps service message definition, 98 byte / 784 bit in total.
|
|
*/
|
|
typedef struct
|
|
{
|
|
L2_MSG_COMMON common; ///< common message header
|
|
float srcPosX; ///< position x
|
|
float srcPosY; ///< position y
|
|
float srcPosZ; ///< position z
|
|
float srcSpeedX; ///< speed x
|
|
float srcSpeedY; ///< speed y
|
|
float srcSpeedZ; ///< speed z
|
|
uint32_t svcDataId; ///< service payload id
|
|
uint8_t svcData[L2_PAYLOAD_LEN_SVC_128K]; ///< service payload data
|
|
uint8_t crc; ///< crc
|
|
} L2_MSG_SVC_128K;
|
|
|
|
/**
|
|
* @struct L2_MSG_SVC_512K
|
|
* @brief Link layer 512 kbps service message definition, 323 byte / 2584 bit in total.
|
|
*/
|
|
typedef struct
|
|
{
|
|
L2_MSG_COMMON common; ///< common message header
|
|
float srcPosX; ///< position x
|
|
float srcPosY; ///< position y
|
|
float srcPosZ; ///< position z
|
|
float srcSpeedX; ///< speed x
|
|
float srcSpeedY; ///< speed y
|
|
float srcSpeedZ; ///< speed z
|
|
uint32_t svcDataId; ///< service payload id
|
|
uint8_t svcData[L2_PAYLOAD_LEN_SVC_512K]; ///< service payload data
|
|
uint8_t crc; ///< crc
|
|
} L2_MSG_SVC_512K;
|
|
|
|
/**
|
|
* @struct L2_MSG_SVC_2M
|
|
* @brief Link layer 2 Mbps service message definition, 1278 byte / 10224 bit in total.
|
|
*/
|
|
typedef struct
|
|
{
|
|
L2_MSG_COMMON common; ///< common message header
|
|
float srcPosX; ///< position x
|
|
float srcPosY; ///< position y
|
|
float srcPosZ; ///< position z
|
|
float srcSpeedX; ///< speed x
|
|
float srcSpeedY; ///< speed y
|
|
float srcSpeedZ; ///< speed z
|
|
uint32_t svcDataId; ///< service payload id
|
|
uint8_t svcData[L2_PAYLOAD_LEN_SVC_2M]; ///< service payload data
|
|
uint8_t crc; ///< crc
|
|
} L2_MSG_SVC_2M;
|
|
|
|
#pragma pack(pop) // Restore original packing
|
|
|
|
#endif //__L2_MSG_DEF_H_
|
|
|
|
/** @} LinkLayer_MSG_Constants*/
|
|
|
|
/** @} LinkLayer*/
|