90 lines
		
	
	
		
			2.8 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
		
		
			
		
	
	
			90 lines
		
	
	
		
			2.8 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 IOT_CLI_HOST_PIB_H
 | ||
|  | #define IOT_CLI_HOST_PIB_H
 | ||
|  | 
 | ||
|  | #include "iot_utils_api.h"
 | ||
|  | 
 | ||
|  | #ifdef __cplusplus
 | ||
|  | extern "C" { | ||
|  | #endif
 | ||
|  | 
 | ||
|  | #pragma pack(push)  // save the pack status
 | ||
|  | #pragma pack(1)     // one byte align
 | ||
|  | 
 | ||
|  | /* default seg len */ | ||
|  | #define IOT_CLI_HOST_PIB_DEFAULT_SEG_LEN            400
 | ||
|  | 
 | ||
|  | /* pib write error code for plc mgr */ | ||
|  | #define IOT_CLI_HOST_PIB_WRITE_SUCCESS              0
 | ||
|  | #define IOT_CLI_HOST_PIB_WRITE_CRC_ERROR            1
 | ||
|  | #define IOT_CLI_HOST_PIB_WRITE_BLOCK_IDX_ERROR      2
 | ||
|  | 
 | ||
|  | /* read pib */ | ||
|  | typedef struct _iot_cli_host_pib_read_dl_t { | ||
|  |     /* mac to read */ | ||
|  |     uint8_t             mac[IOT_MAC_ADDR_LEN]; | ||
|  |     /* current segment index */ | ||
|  |     uint16_t            seg_index; | ||
|  |     /* segment len */ | ||
|  |     uint16_t            seg_len; | ||
|  | } iot_cli_host_pib_read_dl_t; | ||
|  | 
 | ||
|  | /* pib info */ | ||
|  | typedef struct _iot_cli_host_pib_data_t { | ||
|  |     /* current segment index */ | ||
|  |     uint16_t            seg_index; | ||
|  |     /* total upgrade segment count */ | ||
|  |     uint16_t            total_seg_count; | ||
|  |     /* segment len */ | ||
|  |     uint16_t            seg_len; | ||
|  |     /* data len in current packet */ | ||
|  |     uint16_t            data_len; | ||
|  |     /* crc 32 check sum */ | ||
|  |     uint32_t            crc_code; | ||
|  |     /* data content */ | ||
|  |     uint8_t             data[0]; | ||
|  | } iot_cli_host_pib_data_t; | ||
|  | 
 | ||
|  | /* write pib info ack */ | ||
|  | typedef struct _iot_cli_host_pib_write_ack_ul_t { | ||
|  |     /* seg index */ | ||
|  |     uint16_t            seg_index; | ||
|  |     /* error code for pib write */ | ||
|  |     uint8_t             error_code; | ||
|  | }iot_cli_host_pib_write_ack_ul_t; | ||
|  | 
 | ||
|  | /**
 | ||
|  |  * @brief cli_read_pib_handler - read pib | ||
|  |  * @param buf:              data from plc mgr | ||
|  |  * @param bufferlen:        data len | ||
|  |  */ | ||
|  | void cli_read_pib_handler(uint8_t *buffer, uint32_t bufferlen, uint8_t *src_mac); | ||
|  | 
 | ||
|  | /**
 | ||
|  |  * @brief cli_read_pib_handler - read pib | ||
|  |  * @param buf:              data from plc mgr | ||
|  |  * @param bufferlen:        data len | ||
|  |  */ | ||
|  | void cli_write_pib_handler(uint8_t *buffer, uint32_t bufferlen, uint8_t *src_mac); | ||
|  | 
 | ||
|  | #pragma pack(pop)
 | ||
|  | 
 | ||
|  | #ifdef __cplusplus
 | ||
|  | } | ||
|  | #endif
 | ||
|  | 
 | ||
|  | #endif
 |