123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- /********************************************************************************
- * File Name: MyFoTa.h
- * Function Describe: Header file for MyFoTa.c
- * Explain:
- * Writer: ShiLiangWen
- * Date: 2019-2-17
- *******************************************************************************/
- #ifndef __MY_FOTA_H
- #define __MY_FOTA_H
- //-------------------------------------------------------------------------------
- #include "ProductPara.h"
- #include "ModemTask.h"
- #define TCP_PACKET_HEAD 0xAB
- //以下CMD用于FOTA数据上行和下行命令
- #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 APP_FILE_DATA_ADDR EXFLASH_FILE_DATA_ADDR //保存在外部FLASH哪个位置开始
- #define FOTA_RE_SEND_CT_MAX 5
- typedef enum
- {
- FOTA_END=0, //完成操作
- FOTA_GET_FILEINFO,//获取文件信息
- FOTA_GET_FILEDATA,//拉取文件内容
- }FOTA_STATUS;
- typedef struct SUT_FILE_INFO
- {
- 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 struct
- {
- FOTA_STATUS fotaStatus;
- unsigned char getFileInfoCt;//升级次数计数器
- unsigned char reSendCt;//不能间隔太快发连接TCP指令,这是间隔计数
- unsigned int time_10ms_cnt;
- unsigned char retryTime;
- unsigned short targetVersion;
- ////////////////////////////////////////////
-
- unsigned int fileLength;
- unsigned int lastOffset;//上一次 偏移
- unsigned int nextOffset;//下一次 偏移
- unsigned char encrypted;
- unsigned char key;
- unsigned char MD5[16];
-
- }__attribute__((packed)) SUT_FOTA_PARA;
- extern SUT_FOTA_PARA sutFotaPara;
- void MyFoTaInit(void);
- M_RESULT FoTaGetFileInfo(int type);
- M_RESULT FoTaGetFileData(int type);
- void FoTaRecvData(unsigned char *pData,unsigned short DataLen);
- //-------------------------------------------------------------------------------
- #endif
-
|