ProductPara.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /********************************************************************************
  2. * File Name: ProductPara.h
  3. * Function Describe: Header file for ProductPara.c
  4. * Explain:
  5. * Writer: ShiLiangWen
  6. * Date: 2015-7-6
  7. *******************************************************************************/
  8. #ifndef __PRODUCT_PARA_H
  9. #define __PRODUCT_PARA_H
  10. /*=============================================================================*/
  11. //调试信息打印
  12. #define SLW_DEBUG
  13. #ifdef ANT_TEST
  14. #define PRODUCT_NAME "RT231TEST" //产品型号名,字符串长度不能大于13个字符
  15. #else
  16. #define PRODUCT_NAME "RT231A" //产品型号名,字符串长度不能大于8个字符
  17. #endif
  18. #define SOFTWARE_VERSION 1206
  19. #define HARDWARE_VERSION 2
  20. #define STM32_FLASH_SIZE 64 //所选STM32的FLASH容量大小(单位为K)
  21. #define STM32_RAM_SIZE 20
  22. #define STM32_FLASH_BASE 0x08000000 //STM32 FLASH的起始地址
  23. #define PRODUCT_PARA_ADDR 0x0800F000 //0x0800F000~0x080FFFF 为系统参数区
  24. #define MCU_FLAG 32001
  25. #define PRODUCT_PARA_MARK 85613652
  26. #define MODEM_TYPE 1
  27. #define GNSS_TYPE 1
  28. #define SENSOR_TYPE 1
  29. //MAC 头2个字节
  30. #define MY_MAC_HEAD 0xF82387
  31. //服务器相关 默认
  32. #define APP_SERVER "47.106.242.14" //"120.27.39.29" // "joinSocket.topevery.com"
  33. #define APP_SPORT 19019
  34. #define FOTA_SERVER "fota.rtuol.com"
  35. #define FOTA_SPORT 9137
  36. //APN
  37. #define CARD_APN "cmnet"
  38. #define CARD_USER "card"
  39. #define CARD_PASS "card"
  40. //外部FLASH 存储空间定义
  41. #define EXFLASH_DEVICE_CONFIG_ADDR 0x00000000
  42. #define EXFLASH_SERVER_CONFIG_ADDR 0x00001000
  43. #define EXFLASH_FILE_DATA_ADDR 0x00002000
  44. #define DEVICE_CONFIG_ADDR EXFLASH_DEVICE_CONFIG_ADDR //设备配置参数存储地址 2K 允许运行中修改 存储在外部FLASH中
  45. //----------------------------------------------------------
  46. //产品配置 这里的参数只有通过串口才能修改,为最重要的参数。程序运行过程中禁止自动修改,避免参数丢失
  47. typedef struct SUT_PRODUCT_PARA
  48. {
  49. unsigned short McuFlag;
  50. char ProductName[8];//项目名
  51. unsigned short SoftwareVer; //版本号
  52. unsigned short HardwareVer; //Modem类型:预留
  53. unsigned char ModemType;//模块类型
  54. unsigned char GNSSType; //定位模块类型
  55. unsigned char SensorType;//传感器类型
  56. unsigned char OtherType; //其他类型
  57. unsigned long PSN; //终端编码
  58. unsigned long AKEY; //终端校验码(通过一定算法计算)
  59. char AppServer[40];//字符串形式
  60. unsigned short AppPort;
  61. char FotaServer[40];
  62. unsigned short FotaPort;
  63. char CardAPN[24];
  64. char CardUsrName[24];
  65. char CardUsrPass[24];
  66. unsigned char DeviceID[6];//部标协议中设备编号压缩BCD格式,如:PSN=190310001 则应该为0x00 0x01 0x90 0x31 0x00 0x01
  67. unsigned char MAC[6];
  68. unsigned long Mark;
  69. char proName[16];//生厂产家标识
  70. char devName[16];//产口型号
  71. char authServer[40];//字符串形式
  72. unsigned short authPort;
  73. }__attribute__((packed)) SUT_PRODUCT_PARA;
  74. extern SUT_PRODUCT_PARA sutProductPara;
  75. #define DEVICE_CONFIG_MARK 0x12345605
  76. //设备配置 这里的参数允许程序运行过程中自动修改,丢失会重置
  77. typedef struct SUT_DEVICE_CONFIG
  78. {
  79. unsigned long Mark1;//用于初始化
  80. char FoTaMark[4]; //FOTA标志 "FoTa"--空中升级,IAP需要从外部FLASH搬运代码到MCU中。搬运完成后需要修改为"FTOK"
  81. unsigned char MD5[16];//APP MD5
  82. unsigned long AppExAddr;//APP下载到的外部FLASH地址
  83. unsigned long AppLen;//APP 长度
  84. unsigned char DebugPrintEn;//打印调试是能
  85. unsigned char NetMode; //网络模式 1--4G only 2--LAN only 3--4G+LAN 4--LAN+4G
  86. unsigned char SamplingInterval;//采样间隔
  87. unsigned char UploadInterval; //上传间隔
  88. char CCID[20];
  89. unsigned char RES[36];//保留
  90. unsigned long Mark2;//用于初始化
  91. }__attribute__((packed)) SUT_DEVICE_CONFIG;
  92. extern SUT_DEVICE_CONFIG sutDeviceConfig;
  93. //这个结构体保存域名解析后得到的IP,单独放在外部FLASH的一个扇区
  94. typedef struct SUT_SERVER_IP
  95. {
  96. unsigned char AppServerIP[4];//域名获取到的应用服务器IP
  97. unsigned char FotaServerIP[4];//域名获取到的FOTA服务器IP
  98. }__attribute__((packed)) SUT_SERVER_IP;
  99. extern SUT_SERVER_IP sutServerIp;
  100. void getNetMacByPSN(unsigned char *MAC,unsigned long PSN);
  101. void ReadProductParaFromFlash(void);
  102. void SaveProductParaToFlash(void);
  103. void ReadDeviceConfigFromFlash(void);
  104. void SaveDeviceConfigToFlash(void);
  105. void DecToBCD(unsigned int Dec, unsigned char *Bcd, int length);
  106. void ReadServerIP(void);
  107. void SaveServerIP(void);
  108. /*=============================================================================*/
  109. #endif
  110. /************************************file begin*******************************/