123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- /********************************************************************************
- * File Name: ProductPara.h
- * Function Describe: Header file for ProductPara.c
- * Explain:
- * Writer: ShiLiangWen
- * Date: 2015-7-6
- *******************************************************************************/
- #ifndef __PRODUCT_PARA_H
- #define __PRODUCT_PARA_H
- /*=============================================================================*/
- //调试信息打印
- #define SLW_DEBUG
- #ifdef ANT_TEST
- #define PRODUCT_NAME "RT231TEST" //产品型号名,字符串长度不能大于13个字符
- #else
- #define PRODUCT_NAME "RT231A" //产品型号名,字符串长度不能大于8个字符
- #endif
- #define SOFTWARE_VERSION 1206
- #define HARDWARE_VERSION 2
- #define STM32_FLASH_SIZE 64 //所选STM32的FLASH容量大小(单位为K)
- #define STM32_RAM_SIZE 20
- #define STM32_FLASH_BASE 0x08000000 //STM32 FLASH的起始地址
- #define PRODUCT_PARA_ADDR 0x0800F000 //0x0800F000~0x080FFFF 为系统参数区
- #define MCU_FLAG 32001
- #define PRODUCT_PARA_MARK 85613652
- #define MODEM_TYPE 1
- #define GNSS_TYPE 1
- #define SENSOR_TYPE 1
- //MAC 头2个字节
- #define MY_MAC_HEAD 0xF82387
- //服务器相关 默认
- #define APP_SERVER "47.106.242.14" //"120.27.39.29" // "joinSocket.topevery.com"
- #define APP_SPORT 19019
- #define FOTA_SERVER "fota.rtuol.com"
- #define FOTA_SPORT 9137
- //APN
- #define CARD_APN "cmnet"
- #define CARD_USER "card"
- #define CARD_PASS "card"
- //外部FLASH 存储空间定义
- #define EXFLASH_DEVICE_CONFIG_ADDR 0x00000000
- #define EXFLASH_SERVER_CONFIG_ADDR 0x00001000
- #define EXFLASH_FILE_DATA_ADDR 0x00002000
- #define DEVICE_CONFIG_ADDR EXFLASH_DEVICE_CONFIG_ADDR //设备配置参数存储地址 2K 允许运行中修改 存储在外部FLASH中
- //----------------------------------------------------------
- //产品配置 这里的参数只有通过串口才能修改,为最重要的参数。程序运行过程中禁止自动修改,避免参数丢失
- typedef struct SUT_PRODUCT_PARA
- {
- unsigned short McuFlag;
- char ProductName[8];//项目名
- unsigned short SoftwareVer; //版本号
- unsigned short HardwareVer; //Modem类型:预留
- unsigned char ModemType;//模块类型
- unsigned char GNSSType; //定位模块类型
- unsigned char SensorType;//传感器类型
- unsigned char OtherType; //其他类型
- unsigned long PSN; //终端编码
- unsigned long AKEY; //终端校验码(通过一定算法计算)
- char AppServer[40];//字符串形式
- unsigned short AppPort;
- char FotaServer[40];
- unsigned short FotaPort;
- char CardAPN[24];
- char CardUsrName[24];
- char CardUsrPass[24];
- unsigned char DeviceID[6];//部标协议中设备编号压缩BCD格式,如:PSN=190310001 则应该为0x00 0x01 0x90 0x31 0x00 0x01
- unsigned char MAC[6];
- unsigned long Mark;
- char proName[16];//生厂产家标识
- char devName[16];//产口型号
- char authServer[40];//字符串形式
- unsigned short authPort;
- }__attribute__((packed)) SUT_PRODUCT_PARA;
- extern SUT_PRODUCT_PARA sutProductPara;
- #define DEVICE_CONFIG_MARK 0x12345605
- //设备配置 这里的参数允许程序运行过程中自动修改,丢失会重置
- typedef struct SUT_DEVICE_CONFIG
- {
- unsigned long Mark1;//用于初始化
- char FoTaMark[4]; //FOTA标志 "FoTa"--空中升级,IAP需要从外部FLASH搬运代码到MCU中。搬运完成后需要修改为"FTOK"
- unsigned char MD5[16];//APP MD5
- unsigned long AppExAddr;//APP下载到的外部FLASH地址
- unsigned long AppLen;//APP 长度
- unsigned char DebugPrintEn;//打印调试是能
- unsigned char NetMode; //网络模式 1--4G only 2--LAN only 3--4G+LAN 4--LAN+4G
- unsigned char SamplingInterval;//采样间隔
- unsigned char UploadInterval; //上传间隔
- char CCID[20];
- unsigned char RES[36];//保留
- unsigned long Mark2;//用于初始化
- }__attribute__((packed)) SUT_DEVICE_CONFIG;
- extern SUT_DEVICE_CONFIG sutDeviceConfig;
- //这个结构体保存域名解析后得到的IP,单独放在外部FLASH的一个扇区
- typedef struct SUT_SERVER_IP
- {
- unsigned char AppServerIP[4];//域名获取到的应用服务器IP
- unsigned char FotaServerIP[4];//域名获取到的FOTA服务器IP
- }__attribute__((packed)) SUT_SERVER_IP;
- extern SUT_SERVER_IP sutServerIp;
- void getNetMacByPSN(unsigned char *MAC,unsigned long PSN);
- void ReadProductParaFromFlash(void);
- void SaveProductParaToFlash(void);
- void ReadDeviceConfigFromFlash(void);
- void SaveDeviceConfigToFlash(void);
- void DecToBCD(unsigned int Dec, unsigned char *Bcd, int length);
- void ReadServerIP(void);
- void SaveServerIP(void);
- /*=============================================================================*/
- #endif
- /************************************file begin*******************************/
|