123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- #ifndef __FOTA__H
- #define __FOTA__H
- #define FOTA_DEBUG 0
- #define FOTA_SOCKET '2'
- #define APP_FILE_DATA_ADDR 0 //保存在外部FLASH哪个位置开始
- #define PACKET_HEAD 0xAB
- #define CMD_GET_FILE_INFO 0x6A
- #define CMD_GET_FILE_INFO_ACK 0x6B
- #define CMD_GET_FILE_DATA 0x7A
- #define CMD_GET_FILE_DATA_ACK 0x7B
- #define TIMEOUT_10MS_FILE 500 //间隔5秒进行一次文件请求
- #define TIMEOUT_10MS_DATA 300 //间隔3秒进行一次数据请求
- #define MAX_TIME_GET_FILE 3 //最多请求文件3次[连续]
- #define MAX_TIME_GET_DATA 5 //最多请求数据5次[连续]
- #define DATA_DRAT_SIZE_PER_TIME 1024 //每一次数据请求包大小
- typedef struct SUT_FILE_INFO2
- {
- unsigned char encrypted; //文件数据是否已加密? 0--未加密 1--加密算法1:各字节和key直接异或运算; 2--加密算法2:将key转为key1后再与各字节异或运算; 3...其他
- unsigned char key; //加密用的key
- char FileName[20]; //文件名。一般情况下,文件名=ProductName_Vxxx 其中xxx为版本号
- unsigned int FileLength; //文件总长度
- unsigned char MD5[16]; //文件MD5码. 如果文件已加密,此MD5为加密后的文件的MD5
- }__attribute__((packed)) SUT_FILE_INFO;
- typedef enum
- {
- FOTA_OFF,
- FOTA_ON
- }FOTA_TYPE;
- typedef enum
- {
- LOAD_GET_FILEINFO,//获取文件信息
- LOAD_GET_FILEDATA,//拉取文件内容
- LOAD_FILE_CHECK, //较验文件MD5
- LOAD_DONE //完成操作
- }LOADFILE_TYPE;
- typedef struct
- {
- unsigned char init_tcpStatus:1;
- unsigned char tcpCnt;//不能间隔太快发连接TCP指令,这是间隔计数
- unsigned int time_10ms_cnt;
- unsigned char retryTime;
- unsigned short targetVersion;
- ////////////////////////////////////////////
- unsigned int fileLength;
- unsigned char encrypted;
- unsigned char key;
- unsigned char MD5[16];
- unsigned int lastOffset;//用于数据包重传请求
- FOTA_TYPE fotaFlag;
- LOADFILE_TYPE fotaStatus;
- }__attribute__((packed)) SUT_FOTA_PARA;
- extern SUT_FOTA_PARA sutFotaPara;
- void FotaDataInit(void);
- void FotaHandle(void);
- void TriggerFotaOption(FOTA_TYPE fotaStatus);
- void HGS_FotaHandle(unsigned char *data, unsigned short len);
- void FotaTest(void);
- #endif
|