AppTaskTcp.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  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. GPSInfo GpsInfoData;
  96. UINT8 Tac[2];
  97. UINT8 CellID[4];
  98. UINT8 xData[2];
  99. UINT8 yData[2];
  100. UINT8 zData[2];
  101. } GPSInfoType;
  102. typedef struct GPSMsgtoTcpType
  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. GPSInfoType gpsInfo;
  111. UINT8 CRC;
  112. } GPSMsgtoTcpType;
  113. /*---------------------------------------------------------------------------*/
  114. typedef struct _VerInfoType
  115. {
  116. UINT8 sendTimeUTC[6];
  117. UINT8 msgMark;
  118. UINT8 msgCollectionTimeUTC[6];
  119. UINT8 ICCID[20];
  120. UINT8 IMEI[15];
  121. UINT8 BMSHwVersion[2];
  122. UINT8 BMSSwVersion[4];
  123. UINT8 NBHwVersion[2];
  124. UINT8 BLVersion[4];
  125. UINT8 DRVVersion[4];
  126. UINT8 APPVersion[4];
  127. UINT8 BmsType;
  128. UINT8 BmsInfo;
  129. UINT8 DataModuleType;
  130. } VerInfoType;
  131. typedef struct VersionMsgtoTcpType
  132. {
  133. UINT8 startSymbol[2];
  134. UINT8 cmdSymbol;
  135. UINT8 ansSymbol;
  136. UINT8 SN[BATT_SN_LEN];
  137. UINT8 encryptMethod;
  138. UINT8 dataLength[2];
  139. VerInfoType VerInfo;
  140. UINT8 CRC;
  141. } VersionMsgtoTcpType;
  142. typedef struct _DebugInfoType
  143. {
  144. UINT8 sendTimeUTC[6];
  145. UINT8 msgMark;
  146. UINT8 DebugLen[2];
  147. } DebugInfoType;
  148. typedef struct DebugMsgtoTcp_Type
  149. {
  150. UINT8 startSymbol[2];
  151. UINT8 cmdSymbol;
  152. UINT8 ansSymbol;
  153. UINT8 SN[BATT_SN_LEN];
  154. UINT8 encryptMethod;
  155. UINT8 dataLength[2];
  156. DebugInfoType DebugInfo;
  157. UINT8 CRC;
  158. } DebugMsgtoTcpType;
  159. typedef enum
  160. {
  161. APP_SOCKET_CONNECTION_CLOSED = 0,
  162. APP_SOCKET_CONNECTION_CONNECTING,
  163. APP_SOCKET_CONNECTION_CONNECTED,
  164. } AppSocketConnectionStatus;
  165. void AppTaskTcpInit(void *arg);
  166. void AppTaskTcpDeInit(void *arg);