AppTaskTcp.h 4.2 KB

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