AppTaskUart1.h 4.3 KB

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