AppTaskUart1.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. /*
  2. * @Author : ChenJie
  3. * @Date : 2022-02-10 11:44:08
  4. * @Version : V3.0
  5. * @LastEditors : ChenJie
  6. * @LastEditTime : 2022-05-17 16:22:56
  7. * @Description : file content
  8. * @FilePath : \S32K146_4G\src\AppTaskUart1.h
  9. */
  10. /*
  11. * AppTaskUart2.h
  12. *4G的串口函数
  13. * Created on: 2022年2月10日
  14. * Author: QiXiang_CHENJIE
  15. */
  16. #ifndef APPTASKUART1_H_
  17. #define APPTASKUART1_H_
  18. #include "hal_adapter.h"
  19. #include "AppFunclib.h"
  20. #include "AppGlobalVar.h"
  21. #include "AppTaskGps.h"
  22. #define CRLF "\r\n"
  23. #define BATT_SN_LEN 17
  24. #define TCP_START_SYM1 0x23
  25. #define TCP_START_SYM2 0x23
  26. #define TCP_CMD_SYM 0x02 //实时信息上报是0x02
  27. #define TCP_HEART_SYM 0x07 //心跳包标志
  28. #define TCP_ANS_SYM 0xFE
  29. #define TCP_ENCPT_ENABLE 0x00
  30. #define TCP_ENCPT_DISABLE 0x01
  31. #define BattMsg (0x80)
  32. #define GpsMsg (0x82)
  33. #define VerMsg (0x86)
  34. #define TruckBattMsg (0x91)
  35. #define TruckVehiMsg (0x90)
  36. #define TruckAcclMsg (0x92)
  37. #define TCP_QUERY_SYM 0x80
  38. #define TCP_SETCMD_SYM 0x81
  39. #define TCP_CONCMD_SYM 0x82
  40. #define TCP_UDSCMD_SYM 0x83
  41. typedef struct _GPSInfoType
  42. {
  43. uint8 sendTimeUTC[6];
  44. uint8 msgMark;
  45. uint8 msgCollectionTimeUTC[6];
  46. GPSInfo GpsInfoData;
  47. uint8 Tac[2];
  48. uint8 CellID[4];
  49. uint8 xData[2];
  50. uint8 yData[2];
  51. uint8 zData[2];
  52. } GPSInfoType;
  53. typedef struct GPSMsgtoTcpType
  54. {
  55. uint8 startSymbol[2];
  56. uint8 cmdSymbol;
  57. uint8 ansSymbol;
  58. uint8 SN[BATT_SN_LEN];
  59. uint8 encryptMethod;
  60. uint8 dataLength[2];
  61. GPSInfoType gpsInfo;
  62. uint8 CRC;
  63. } GPSMsgtoTcpType;
  64. typedef struct _VerInfoType
  65. {
  66. uint8 sendTimeUTC[6];
  67. uint8 msgMark;
  68. uint8 msgCollectionTimeUTC[6];
  69. uint8 ICCID[20];
  70. uint8 IMEI[15];
  71. uint8 BMSHwVersion[2];
  72. uint8 BMSSwVersion[4];
  73. uint8 HwVersion[2];
  74. uint8 BLVersion[4];
  75. uint8 DRVVersion[4];
  76. uint8 APPVersion[4];
  77. uint8 BmsType;
  78. uint8 BmsInfo;
  79. uint8 DataModuleType;
  80. } VerInfoType;
  81. typedef struct VersionMsgtoTcpType
  82. {
  83. uint8 startSymbol[2];
  84. uint8 cmdSymbol;
  85. uint8 ansSymbol;
  86. uint8 SN[BATT_SN_LEN];
  87. uint8 encryptMethod;
  88. uint8 dataLength[2];
  89. VerInfoType VerInfo;
  90. uint8 CRC;
  91. } VersionMsgtoTcpType;
  92. typedef struct StorageInfoType
  93. {
  94. uint8 sendTimeUTC[6];
  95. uint8 msgMark;
  96. uint8 msgCollectionTimeUTC[6];
  97. uint8 RelayState;
  98. uint8 FanState;
  99. uint8 HeatState;
  100. uint8 ConvertState;
  101. } StorageInfo;
  102. typedef struct StorageInfoToTcpType
  103. {
  104. uint8 startSymbol[2];
  105. uint8 cmdSymbol;
  106. uint8 ansSymbol;
  107. uint8 SN[BATT_SN_LEN];
  108. uint8 encryptMethod;
  109. uint8 dataLength[2];
  110. StorageInfo StorageMsg;
  111. uint8 CRC;
  112. } StorageInfoToTcp;
  113. typedef struct StorageInfoType2
  114. {
  115. uint8 sendTimeUTC[6];
  116. uint8 msgMark;
  117. uint8 msgCollectionTimeUTC[6];
  118. uint8 meter1AllPwr[4];
  119. uint8 meter1PosPwr[4];
  120. uint8 meter1NegPwr[4];
  121. uint8 meter2AllPwr[4];
  122. uint8 meter2PosPwr[4];
  123. uint8 meter2NegPwr[4];
  124. } StorageInfo2;
  125. typedef struct StorageInfoToTcpType2
  126. {
  127. uint8 startSymbol[2];
  128. uint8 cmdSymbol;
  129. uint8 ansSymbol;
  130. uint8 SN[BATT_SN_LEN];
  131. uint8 encryptMethod;
  132. uint8 dataLength[2];
  133. StorageInfo2 StorageMsg2;
  134. uint8 CRC;
  135. } StorageInfoToTcp2;
  136. typedef struct AccInfoType
  137. {
  138. uint8 sendTimeUTC[6];
  139. uint8 msgMark;
  140. uint8 msgCollectionTimeUTC[6];
  141. uint8 accOnlineDays[2];
  142. uint8 accDrvMiles[2];
  143. uint8 sohNoCalibrTime[2];
  144. uint8 accChrgEng[4];
  145. uint8 accDischrgEng[4];
  146. uint8 accChrgCap[4];
  147. uint8 accDischrgCap[4];
  148. uint8 accOverChrgTimes;
  149. uint8 accOverDischrgTimes;
  150. uint8 accCycleTimes[2];
  151. }AccInfo;
  152. typedef struct AccInfoToTcpType
  153. {
  154. uint8 startSymbol[2];
  155. uint8 cmdSymbol;
  156. uint8 ansSymbol;
  157. uint8 SN[BATT_SN_LEN];
  158. uint8 encryptMethod;
  159. uint8 dataLength[2];
  160. AccInfo AccMsg;
  161. uint8 CRC;
  162. }AccInfoToTcp;
  163. typedef struct UTC8Time_Type
  164. {
  165. uint8 year;
  166. uint8 month;
  167. uint8 day;
  168. uint8 hour;
  169. uint8 minute;
  170. uint8 second;
  171. } UTC8TimeType;
  172. typedef enum
  173. {
  174. AT_CMD_TEST = 0,
  175. AT_ATE0,
  176. AT_SIMREADY,
  177. AT_GETICCID,
  178. AT_CGREG,
  179. AT_CSQ,
  180. AT_NETOPEN,
  181. AT_CGIP,
  182. AT_CONNECT,
  183. AT_CONNECTCHK,
  184. AT_SEND,
  185. AT_DISCON,
  186. AT_NETCLOSE,
  187. AT_CGNSSPWR
  188. } ATCmd;
  189. typedef sint8 (*pFunc)(char *PSendStr, char *pReadStr, uint8 CmdIdx, uint16 pReadLen);
  190. sint8 at_callbackFunc(char *PSendStr, char *pReadStr, uint8 CmdIdx, uint16 pReadLen);
  191. typedef struct
  192. {
  193. ATCmd cmd; /*指令序号*/
  194. char *str; /*指令内容*/
  195. pFunc cb; /*对应的执行*/
  196. } ATCmdFunc;
  197. typedef enum
  198. {
  199. PROCESS_TCP_IDLE = 0,
  200. PROCESS_TCP_ATSYS,
  201. PROCESS_TCP_REGCHK,
  202. PROCESS_TCP_CONNECT,
  203. PROCESS_TCP_SEND,
  204. PROCESS_TCP_RECV,
  205. PROCESS_TCP_HEART,
  206. PROCESS_TCP_SLEEP,
  207. PROCESS_TCP_ERROR
  208. } process_Tcp;
  209. void Uart_4G_Task(void *pvParameters);
  210. sint8 tcpipConnectionSend(uint8 TcpConnectId, uint8 *SendDataPtr, uint16 SendDataLen);
  211. #endif /* APPTASKUART1_H_ */