app.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. /****************************************************************************
  2. *
  3. * Copy right: 2017-, Copyrigths of EigenComm Ltd.
  4. * File name: app.h
  5. * Description: EC616 onenet demo entry header file
  6. * History: Rev1.0 2018-07-12
  7. *
  8. ****************************************************************************/
  9. #ifndef APP_H
  10. #define APP_H
  11. #ifdef __cplusplus
  12. extern "C" {
  13. #endif
  14. //全局定义声明区
  15. #define BAT4830
  16. #ifdef BAT4830
  17. #define BATT_CELL_VOL_NUM (14)
  18. #define BATT_TEMP_NUM (5)
  19. #else
  20. #define BATT_CELL_VOL_NUM (17)
  21. #define BATT_TEMP_NUM (7)
  22. #endif
  23. #define BATT_CELL_VOL_NUM_2 (BATT_CELL_VOL_NUM*2)
  24. #define BATT_SN_LEN 17
  25. #define SWVERSION 0xA21
  26. #define HWVERSION 0xB22
  27. //--------------------------------------------------------------------------------
  28. #define QMSG_ID_BASE (0x160)
  29. #define QMSG_ID_NW_IP_READY (QMSG_ID_BASE)
  30. #define QMSG_ID_NW_IP_SUSPEND (QMSG_ID_BASE + 1)
  31. #define QMSG_ID_NW_IP_NOREACHABLE (QMSG_ID_BASE + 2)
  32. #define QMSG_ID_SOCK_SENDPKG (QMSG_ID_BASE + 4)
  33. #define QMSG_ID_SOCK_RECVPKG (QMSG_ID_BASE + 5)
  34. #define QMSG_ID_SOCK_EXIT (QMSG_ID_BASE + 6)
  35. #define QX_TCP_IPADRRES "47.97.127.222"
  36. #define QX_TCP_PORT "8712"
  37. #define APP_CHARGING_WORK_TIME 30
  38. #define APP_WAKEUP_WORK_TIME 1
  39. #define APP_SLEEP_TIME 5
  40. #define TCP_START_SYM1 0x23
  41. #define TCP_START_SYM2 0x23
  42. #define TCP_CMD_SYM 0x02
  43. #define TCP_ANS_SYM 0xFE
  44. //encrypt methord
  45. #define TCP_ENCPT_ENABLE 0x00
  46. #define TCP_ENCPT_DISABLE 0x01
  47. //message type mark
  48. #define BATTMSG 0x80
  49. #define GPSMSG 0x82
  50. //tcp Send Msg Case period
  51. #define SENDMSG5s 01
  52. #define SENDMSG10s 02
  53. #define SENDMSG20s 04
  54. #define SENDMSG30s 06
  55. #define SENDMSG60s 12
  56. #define SENDMSG180s 36
  57. #define SENDMSG300s 60
  58. #define SENDMSG600s 120
  59. #define SENDMSGPRDMAX 200
  60. extern UINT8 IH_appChargEndWorkTime;
  61. extern UINT8 IH_appWakeupWorkTime;
  62. extern UINT8 IH_appSleepTime;
  63. extern UINT8 IH_isBattLocked;
  64. extern UINT8 OH_appChargEndWorkTime;
  65. extern UINT8 OH_appWakeupWorkTime;
  66. extern UINT8 OH_appSleepTime;
  67. extern UINT8 OH_isBattLocked;
  68. extern UINT8 BattSN[BATT_SN_LEN];
  69. extern CHAR TcpServerIpV4Address[16];
  70. extern CHAR TcpServerPort[5];
  71. typedef enum
  72. {
  73. PROCESS_CAN_STATE_IDLE = 0,
  74. PROCESS_CAN_STATE_WORK,
  75. PROCESS_CAN_STATE_SLEEP
  76. }process_CAN;
  77. typedef enum
  78. {
  79. PROCESS_TCP_STATE_IDLE = 0,
  80. PROCESS_TCP_STATE_LINK,
  81. PROCESS_TCP_STATE_WORK,
  82. PROCESS_TCP_STATE_SLEEP
  83. }process_TCP;
  84. typedef struct BattInfoType
  85. {
  86. UINT8 sendTimeUTC[6];
  87. UINT8 msgMark;
  88. UINT8 msgCollectionTimeUTC[6];
  89. UINT8 signalStrength;
  90. UINT8 errClass;
  91. UINT8 errCode[2];
  92. UINT8 battI[2];
  93. UINT8 battLinkVol[2];
  94. UINT8 battPackVol[2];
  95. UINT8 chrgState;
  96. UINT8 battSOC;
  97. UINT8 battSOH;
  98. UINT8 batCellBalenceState[4]; //uint32 should change to uint8[]: each bit stand for 1 cell, up to 1024
  99. UINT8 battCellNum[2]; //uint8 should change to uint16 (0~65535) //zhengchao
  100. UINT8 battCellU[BATT_CELL_VOL_NUM_2];
  101. UINT8 battTempNum[2]; //uint8 should change to uint16 (0~65535)
  102. UINT8 battCellTemp[BATT_TEMP_NUM];
  103. UINT8 battWorkState;
  104. UINT8 battHeatState;
  105. }BattInfoType;
  106. typedef struct BattMsgtoTcpType
  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. BattInfoType battInfo;
  115. UINT8 CRC;
  116. }BattMsgtoTcpType;
  117. typedef struct GPSInfoType
  118. {
  119. UINT8 sendTimeUTC[6];
  120. UINT8 msgMark;
  121. UINT8 msgCollectionTimeUTC[6];
  122. UINT8 locateMark;
  123. UINT8 satelliteNum;
  124. UINT8 direction[2];
  125. UINT8 speed[2];
  126. UINT8 altitude[2];
  127. UINT8 latitude[4];
  128. UINT8 longitude[4];
  129. }GPSInfoType;
  130. typedef struct GPSMsgtoTcpType
  131. {
  132. UINT8 startSymbol[2];
  133. UINT8 cmdSymbol;
  134. UINT8 ansSymbol;
  135. UINT8 SN[BATT_SN_LEN];
  136. UINT8 encryptMethod;
  137. UINT8 dataLength[2];
  138. GPSInfoType gpsInfo;
  139. UINT8 CRC;
  140. }GPSMsgtoTcpType;
  141. typedef enum
  142. {
  143. APP_INIT_STATE,
  144. APP_DEACTIVE_STATE,
  145. APP_IPREADY_STATE,
  146. APP_REPORT_STATE,
  147. APP_IDLE_STATE,
  148. APP_WAIT_STATE
  149. } appRunningState_t;
  150. typedef enum
  151. {
  152. APP_SOCKET_CONNECTION_CLOSED,
  153. APP_SOCKET_CONNECTION_CONNECTING,
  154. APP_SOCKET_CONNECTION_CONNECTED,
  155. }AppSocketConnectionStatus;
  156. typedef struct AppSocketConnectionContext_Tag
  157. {
  158. INT32 id;
  159. INT32 status;
  160. }AppSocketConnectionContext;
  161. typedef struct Fota_Type
  162. {
  163. bool Fota_update_flag ;
  164. bool Fota_update_error ;
  165. uint32_t Fota_All_Data_Len ;
  166. uint32_t Fota_Current_Addres ;
  167. uint8_t Fota_Recv_Data_Len ;
  168. uint8_t Fota_Recv_Data[100] ;
  169. uint32_t Fota_Flash_Addres;
  170. uint8_t Fota_CRC ;
  171. }Fota_Type;
  172. typedef struct _GPS_INFO
  173. {
  174. uint8_t timedata[6];
  175. uint8_t status;
  176. uint8_t satellite_num;
  177. uint16_t direction;
  178. uint16_t speed;
  179. uint16_t altitude;
  180. uint32_t latitude;
  181. uint32_t longitude;
  182. }GPS_INFO;
  183. //uint8_t* Uart_Receive_func(Uart_Receive_Type Uart_Receive_Msg,uint8_t* Uart_Rece_buffer,uint8_t Data_Len);
  184. #ifdef __cplusplus
  185. }
  186. #endif
  187. #endif /* APP_H */