AppTaskTcp.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. /****************************************************************************
  2. *
  3. * Copy right: Qx.Chen Jie
  4. * File name: TcpTask.h
  5. * Description: 网络发送接收任务
  6. * History: 2021-03-07
  7. *
  8. ****************************************************************************/
  9. #include "commontypedef.h"
  10. #include "bsp.h"
  11. #include "bsp_custom.h"
  12. #include "osasys.h"
  13. #include "ostask.h"
  14. #include "queue.h"
  15. #include "ps_event_callback.h"
  16. #include "cmisim.h"
  17. #include "cmimm.h"
  18. #include "cmips.h"
  19. #include "sockets.h"
  20. #include "psifevent.h"
  21. #include "ps_lib_api.h"
  22. #include "lwip/netdb.h"
  23. #include "debug_log.h"
  24. #include "slpman_ec616.h"
  25. #include "plat_config.h"
  26. #include "ec_tcpip_api.h"
  27. #include "hal_module_adapter.h"
  28. #include "timers.h"
  29. #include "AppSignal.h"
  30. #include "AppConfig.h"
  31. #include "AppFunc.h"
  32. #define PROC_TCP_TASK_STACK_SIZE (2048 + 1024)
  33. #define APP_EVENT_QUEUE_SIZE (10)
  34. #define QMSG_ID_BASE (0x16)
  35. #define QMSG_ID_NW_IP_READY (QMSG_ID_BASE)
  36. #define QMSG_ID_NW_IP_SUSPEND (QMSG_ID_BASE + 1)
  37. #define QMSG_ID_NW_IP_NOREACHABLE (QMSG_ID_BASE + 2)
  38. #define QMSG_ID_SOCK_SENDPKG (QMSG_ID_BASE + 4)
  39. #define QMSG_ID_SOCK_RECVPKG (QMSG_ID_BASE + 5)
  40. #define QMSG_ID_SOCK_LISTEN (QMSG_ID_BASE + 6)
  41. #define QMSG_ID_SOCK_EXIT (QMSG_ID_BASE + 7)
  42. // typedef struct BattInfoType
  43. // {
  44. // UINT8 sendTimeUTC[6];
  45. // UINT8 msgMark;
  46. // UINT8 msgCollectionTimeUTC[6];
  47. // UINT8 signalStrength;
  48. // UINT8 errClass;
  49. // UINT8 errCode[2];
  50. // UINT8 battI[2];
  51. // UINT8 battLinkVol[2];
  52. // UINT8 battPackVol[2];
  53. // UINT8 switchState;
  54. // UINT8 battSOC;
  55. // UINT8 battSOH;
  56. // UINT8 batCellBalenceState[4]; //uint32 should change to uint8[]: each bit stand for 1 cell, up to 1024
  57. // UINT8 battCellNum; //uint8 should change to uint16 (0~65535) //zhengchao 31
  58. // //UINT8 *battCellUPtr;
  59. // //+1
  60. // UINT16 battTempNum; //uint8 should change to uint16 (0~65535)
  61. // //UINT8 *battCellTempPtr;
  62. // //+3
  63. // UINT8 battWorkState;
  64. // UINT8 battHeatEnableState;
  65. // UINT8 battotherTempNum;
  66. // UINT8 battotherTemp[BMS_OTHER_TEMP+NB_OTHER_TEMP_NUM];
  67. // }BattInfoType;
  68. // typedef struct BattMsgtoTcpType
  69. // {
  70. // UINT8 startSymbol[2];
  71. // UINT8 cmdSymbol;
  72. // UINT8 ansSymbol;
  73. // UINT8 SN[BATT_SN_LEN];
  74. // UINT8 encryptMethod;
  75. // UINT8 dataLength[2];
  76. // BattInfoType battInfo;
  77. // UINT8 CRC;
  78. // }BattMsgtoTcpType;
  79. /*---------------------------------------------------------------------------*/
  80. typedef struct HeartMsgtoTcpType
  81. {
  82. UINT8 startSymbol[2];
  83. UINT8 cmdSymbol;
  84. UINT8 ansSymbol;
  85. UINT8 SN[BATT_SN_LEN];
  86. UINT8 encryptMethod;
  87. UINT8 dataLength[2];
  88. UINT8 CRC;
  89. }HeartMsgtoTcpType;
  90. typedef struct _GPSInfoType
  91. {
  92. UINT8 sendTimeUTC[6];
  93. UINT8 msgMark;
  94. UINT8 msgCollectionTimeUTC[6];
  95. UINT8 locateMark;
  96. UINT8 satelliteNum;
  97. UINT8 direction[2];
  98. UINT8 speed[2];
  99. UINT8 altitude[2];
  100. UINT8 latitude[4];
  101. UINT8 longitude[4];
  102. UINT8 AccMileage[4];
  103. UINT8 Tac[2];
  104. UINT8 CellID[4];
  105. }GPSInfoType;
  106. typedef struct GPSMsgtoTcpType
  107. {
  108. UINT8 startSymbol[2];
  109. UINT8 cmdSymbol;
  110. UINT8 ansSymbol;
  111. UINT8 SN[BATT_SN_LEN];
  112. UINT8 encryptMethod;
  113. UINT8 dataLength[2];
  114. GPSInfoType gpsInfo;
  115. UINT8 CRC;
  116. }GPSMsgtoTcpType;
  117. /*---------------------------------------------------------------------------*/
  118. typedef struct _VerInfoType
  119. {
  120. UINT8 sendTimeUTC[6];
  121. UINT8 msgMark;
  122. UINT8 msgCollectionTimeUTC[6];
  123. UINT8 ICCID[20];
  124. UINT8 IMEI[15];
  125. UINT8 BMSHwVersion[2];
  126. UINT8 BMSSwVersion[4];
  127. UINT8 NBHwVersion[2];
  128. UINT8 BLVersion[4];
  129. UINT8 DRVVersion[4];
  130. UINT8 APPVersion[4];
  131. UINT8 BmsType;
  132. UINT8 BmsInfo;
  133. UINT8 DataModuleType;
  134. }VerInfoType;
  135. typedef struct VersionMsgtoTcpType
  136. {
  137. UINT8 startSymbol[2];
  138. UINT8 cmdSymbol;
  139. UINT8 ansSymbol;
  140. UINT8 SN[BATT_SN_LEN];
  141. UINT8 encryptMethod;
  142. UINT8 dataLength[2];
  143. VerInfoType VerInfo;
  144. UINT8 CRC;
  145. }VersionMsgtoTcpType;
  146. typedef struct _DebugInfoType
  147. {
  148. UINT8 sendTimeUTC[6];
  149. UINT8 msgMark;
  150. UINT8 DebugLen[2];
  151. }DebugInfoType;
  152. typedef struct DebugMsgtoTcp_Type
  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. DebugInfoType DebugInfo;
  161. UINT8 CRC;
  162. }DebugMsgtoTcpType;
  163. typedef enum
  164. {
  165. APP_SOCKET_CONNECTION_CLOSED = 0,
  166. APP_SOCKET_CONNECTION_CONNECTING,
  167. APP_SOCKET_CONNECTION_CONNECTED,
  168. }AppSocketConnectionStatus;
  169. void AppTaskTcpInit(void *arg);
  170. void AppTaskTcpDeInit(void *arg);