123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- /********************************************************************************
- * File Name: IAP.h
- * Function Describe: Header file for IAP.c
- * Explain:
- * Writer: ShiLiangWen
- * Date: 2015-1-30
- 兼容FOTA升级
- 支持串口升级
- *******************************************************************************/
- #ifndef __IAP_H
- #define __IAP_H
- /***********************************************************************************/
- #include "stdint.h"
- #define IAP_VERSION_NAME "Higos IAP V1.1\r\n"
- #define PRODUCT_NAME "NULL"
- #define MCU_FLAG 144 //MCU标志128KB+16KB=144
- enum {
- MODEM_TYPE_NONE=0,
- MODEM_TYPE_MG2639,
- MODEM_TYPE_MC8332,
- };
- #define MODEM_TYPE MODEM_TYPE_MC8332
- #define FOTA_ENABLE //使能空中升级
- #define IAP_RX_BUF (1024+52)
- //保留0X08000000~0X08003FFF 的空间(16KB)为IAP使用
- #define FLASH_APP1_ADDR 0x08004000 //APP应用程序起始地址(存放在FLASH)
- #define APP_CONFIG_ADDR 0X08003C00 //0x08003C00~0x0804000 为系统参数区
- //#define APP_CONFIG_ADDR 0X0801FC00 //0x0801FC00~0x0802000 为系统参数区
- #define FOTA_MAGIC 0x41544f46 // "FOTA"
- #define PCTA_MAGIC 0x41544350 // "PCTA"
- #define UPDATE_PROTOCOL 0x80
- #define UPDATE_CODE_VERSION_REQ 0x00
- #define UPDATE_CODE_DATA_REQ 0x01
- #define UPDATE_CODE_DATA_WITH_CRC_REQ 0x02
- #define UPDATE_DEV_ID_SIZE 16
- typedef struct SUT_PRODUCT_PARA
- {
- unsigned char McuFlag; //MCU标识 101 --STM32F101CB
- unsigned char IapFlag; //IAP标志 0x00或0xff--无应用程序; 0x55--需要空中升级; 0x88--正常运行应用程序
- unsigned char ModemType; //Modem类型:0-无Modem 1-GSM 2-CDMA
- unsigned char GpsType; //GPS类型:0-无GPS 1-GP 2-BD 4-GL 3-GP+BD 5-GP+GL 6-BD+GL 7-GP+BD+GL (GP=Gps,BD=Beidou,GL=Glonass)
- unsigned char Rand; //伪随机数,用于存储加密,对后面的数字加密
- unsigned char FoTaServerSel; //远程升级服务器IP选择,0--放在对讲服务器,1--放在GPS服务器
- char ProductName[14]; //项目名
- unsigned short ProductVersion; //版本号
- unsigned short PocPort; //POC Port
- unsigned short GpsPort; //GPS Port
- unsigned short FoTaProt; //FOTA Server Port
- unsigned long PSN; //产品序列号
- char PIP[40]; //POC IP
- char GIP[40]; //GPS IP
- char MEID[16]; //MEID
- char VPN[16]; //VPN
- char VPNPass[16]; //VPN Password
- }SUT_PRODUCT_PARA;
- typedef struct
- {
- uint32_t magic; // UPDATE_MAGIC
- uint8_t protocol;
- uint8_t code;
- char dev_id[UPDATE_DEV_ID_SIZE];
- uint16_t tid;
- uint16_t count; // 除本结构外后续数据长度
- } __attribute__((packed)) update_hdr_t; //sizeof()=4+2+16+2+2=26
- typedef struct
- {
- update_hdr_t hdr;
- char product[16];
- uint16_t version;
- } __attribute__((packed)) update_version_req_t;
- typedef struct
- {
- update_hdr_t hdr;
- uint8_t version_md5[16]; // 升级包 MD5
- uint32_t size; // 升级包大小
- } __attribute__((packed)) update_version_rsp_t;
- typedef struct
- {
- update_hdr_t hdr;
- uint8_t version_md5[16]; // 升级包 MD5
- uint32_t offset;
- uint32_t length;
- } __attribute__((packed)) update_data_req_t;
- typedef struct
- {
- update_hdr_t hdr; //26
- uint8_t version_md5[16]; // 升级包 MD5
- uint32_t offset;
- uint32_t length;
- uint8_t data[1];
- } __attribute__((packed)) update_data_rsp_t;
- extern int g_iFotaCt;
- extern int g_ulOffset;
- extern uint8_t IapRxBuf[IAP_RX_BUF];
- extern uint16_t IapRxLen;
- extern SUT_PRODUCT_PARA sutProductPara;
- void IapGetUpdateVersion(uint32_t magic);
- void IapGetUpdateData(uint32_t magic,uint32_t offset);
- int IapRecvMsgHandle(unsigned char *pData, unsigned short DataLen);
- typedef void (*iapfun)(void);//定义一个函数类型的参数.
- void iap_jump_app_s();
- /***********************************************************************************/
- #endif
- /***********************************************************************************/
|