75 lines
		
	
	
		
			2.4 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			75 lines
		
	
	
		
			2.4 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
/****************************************************************************
 | 
						|
 | 
						|
Copyright(c) 2019 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 _APP_PROTO_H_
 | 
						|
#define _APP_PROTO_H_
 | 
						|
 | 
						|
#include "app_types.h"
 | 
						|
#include "app_common.h"
 | 
						|
#include "app_main.h"
 | 
						|
 | 
						|
#ifdef __cplusplus
 | 
						|
extern "C" {
 | 
						|
#endif
 | 
						|
 | 
						|
#define APP_FRAME_HEAD_BYTE         (0x48)
 | 
						|
#define APP_FRAME_MIN_LEN           (10)
 | 
						|
#define APP_FRAME_MAX_LEN           (512)
 | 
						|
 | 
						|
#define PROTO_CTRL_DIR_DN           (0x00)
 | 
						|
#define PROTO_CTRL_DIR_UP           (0x80)
 | 
						|
#define PROTO_CTRL_DIR_MASK         (0x80)
 | 
						|
#define PROTO_CTRL_PRM_HOST         (0x40)
 | 
						|
#define PROTO_CTRL_PRM_SLAVE        (0x00)
 | 
						|
#define PROTO_CTRL_PRM_MASK         (0x40)
 | 
						|
#define PROTO_CTRL_RESPONSE         (PROTO_CTRL_DIR_UP | PROTO_CTRL_PRM_SLAVE)
 | 
						|
#define PROTO_CTRL_REQ              (PROTO_CTRL_DIR_DN | PROTO_CTRL_PRM_HOST)
 | 
						|
#define PROTO_CRC_SIZE              2
 | 
						|
#define APP_PROTO_MSG_PARAM_INDEX0  0
 | 
						|
#define APP_PROTO_MSG_PARAM_INDEX1  1
 | 
						|
#define APP_PROTO_MSG_PARAM_INDEX2  2
 | 
						|
#define APP_PROTO_MSG_PARAM_INDEX3  3
 | 
						|
 | 
						|
/* pack for the structures in the whole file */
 | 
						|
#pragma pack(push)  // save the pack status
 | 
						|
#pragma pack(1)     // 1 byte align
 | 
						|
 | 
						|
typedef struct {
 | 
						|
    uint8_t head;
 | 
						|
    uint8_t ctrl;
 | 
						|
    uint16_t cmd;
 | 
						|
    uint16_t seq;
 | 
						|
    uint16_t length;
 | 
						|
    uint8_t data[0];
 | 
						|
} app_proto_frame_head;
 | 
						|
 | 
						|
typedef struct {
 | 
						|
    app_custom_data cus_data;
 | 
						|
    uint16_t payload_length;          /* Data frame length */
 | 
						|
    iot_pkt_t *payload;               /* Data frame payload */
 | 
						|
} app_plc_frame_data;
 | 
						|
 | 
						|
#pragma pack(pop)    /* restore the pack status */
 | 
						|
 | 
						|
void app_proto_init();
 | 
						|
uint8_t check_app_proto_frame(uint8_t * data, uint16_t data_length);
 | 
						|
 | 
						|
#ifdef __cplusplus
 | 
						|
}
 | 
						|
#endif
 | 
						|
 | 
						|
#endif  /* _APP_PROTO_H_ */
 | 
						|
 |