113 lines
4.0 KiB
C
113 lines
4.0 KiB
C
/****************************************************************************
|
|
|
|
Copyright(c) 2024 by Aerospace C.Power (Chongqing) Microelectronics. ALL RIGHTS RESERVED.
|
|
|
|
This Information is proprietary to Aerospace C.Power (Chongqing) Microelectronics and MAY NOT
|
|
be copied by any method or incorporated into another program without
|
|
the express written consent of Aerospace C.Power. This Information or any portion
|
|
thereof remains the property of Aerospace C.Power. The Information contained herein
|
|
is believed to be accurate and Aerospace C.Power assumes no responsibility or
|
|
liability for its use in any way and conveys no license or title under
|
|
any patent or copyright and makes no representation or warranty that this
|
|
Information is free from patent or copyright infringement.
|
|
|
|
****************************************************************************/
|
|
|
|
#ifndef PROTO_WAPPER_H
|
|
#define PROTO_WAPPER_H
|
|
|
|
#include "os_types_api.h"
|
|
#include "iot_utils_api.h"
|
|
#include "iot_pkt_api.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/* pack for the structures in the whole file */
|
|
#pragma pack(push) /* save the pack status */
|
|
#pragma pack(1) /* 1 byte align */
|
|
|
|
/* definition frame start char */
|
|
#define PROTO_WAPPER_START_CHAR 0x02
|
|
/* definition frame identification domain */
|
|
#define PROTO_WAPPER_ID_DOMAIN 0x0001
|
|
|
|
/* definition frame command */
|
|
#define PROTO_WAPPER_CMD_TRANS_REQ 0x77
|
|
#define PROTO_WAPPER_CMD_TRANS_RESP 0x88
|
|
#define PROTO_WAPPER_CMD_EVENT_REQ 0x99
|
|
|
|
/* definition frame len number */
|
|
#define PROTO_WAPPER_USER_DATA_LEN_NUM 2
|
|
#define PROTO_WAPPER_HEAD_LEN_NUM 2
|
|
|
|
/* frame head info of wapper protocol link layer frame */
|
|
typedef struct _proto_wapper_head {
|
|
/* start char, see PROTO_WAPPER_START_BYTE */
|
|
uint8_t start_char;
|
|
/* Length, Command len + User Data len + tail len */
|
|
uint8_t len[PROTO_WAPPER_HEAD_LEN_NUM];
|
|
/* Command, PROTO_WAPPER_CMD_XXX */
|
|
uint8_t cmd;
|
|
/* User Data */
|
|
uint8_t user_data[0];
|
|
} proto_wapper_head_t;
|
|
|
|
/* frame user data info of wapper protocol link layer frame */
|
|
typedef struct _proto_wapper_user_data {
|
|
/* identification domain */
|
|
uint16_t id_domain;
|
|
/* source address, big endian data */
|
|
uint16_t src_addr;
|
|
/* destination address, big endian data */
|
|
uint16_t dest_addr;
|
|
/* len, control len + infomation len */
|
|
uint8_t len[PROTO_WAPPER_USER_DATA_LEN_NUM];
|
|
/* control */
|
|
uint8_t ctrl;
|
|
/* infomation */
|
|
uint8_t info[0];
|
|
} proto_wapper_user_data_t;
|
|
|
|
/* frame tail info of wapper protocol link layer frame */
|
|
typedef struct _proto_wapper_tail {
|
|
/* CRC check data */
|
|
uint16_t fcs;
|
|
} proto_wapper_tail_t;
|
|
|
|
/* proto_wapper_user_data_check() - wapper protocol user data check
|
|
* @data: pointer to protocol data buffer
|
|
* @len: data length
|
|
* return
|
|
* NULL -- Incorrect protocol format.
|
|
* otherwise -- pointer to the wapper protocol user data.
|
|
*/
|
|
proto_wapper_user_data_t *proto_wapper_user_data_check(uint8_t *data,
|
|
uint32_t len);
|
|
|
|
/* proto_wapper_format_check() - wapper protocol format check
|
|
* @data: pointer to protocol data buffer
|
|
* @len: data length
|
|
* return
|
|
* NULL -- Incorrect protocol format.
|
|
* otherwise -- pointer to the wapper protocol header.
|
|
*/
|
|
proto_wapper_head_t *proto_wapper_format_check(uint8_t *data, uint32_t len);
|
|
|
|
/* proto_wapper_format_build() - wapper protocol format build
|
|
* @user_data: pointer to wapper protocol user data.
|
|
* @len: user data len.
|
|
* @cmd: user data command.
|
|
* return
|
|
* NULL -- for failure case.
|
|
* pkt -- the iot pkt buffer for wapper protocol.
|
|
*/
|
|
iot_pkt_t *proto_wapper_format_build(uint8_t *user_data, uint32_t len,
|
|
uint8_t cmd);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* PROTO_WAPPER_H */ |