123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222 |
- /****************************************************************************
- *
- * Copy right: 2017-, Copyrigths of EigenComm Ltd.
- * File name: app.h
- * Description: EC616 onenet demo entry header file
- * History: Rev1.0 2018-07-12
- *
- ****************************************************************************/
- #ifndef APP_H
- #define APP_H
- #ifdef __cplusplus
- extern "C" {
- #endif
- //全局定义声明区
- #define BAT4830
- #ifdef BAT4830
- #define BATT_CELL_VOL_NUM (14)
- #define BATT_TEMP_NUM (5)
- #else
- #define BATT_CELL_VOL_NUM (17)
- #define BATT_TEMP_NUM (7)
- #endif
- #define BATT_CELL_VOL_NUM_2 (BATT_CELL_VOL_NUM*2)
- #define BATT_SN_LEN 17
- #define SWVERSION 0xA21
- #define HWVERSION 0xB22
- //--------------------------------------------------------------------------------
- #define QMSG_ID_BASE (0x160)
- #define QMSG_ID_NW_IP_READY (QMSG_ID_BASE)
- #define QMSG_ID_NW_IP_SUSPEND (QMSG_ID_BASE + 1)
- #define QMSG_ID_NW_IP_NOREACHABLE (QMSG_ID_BASE + 2)
- #define QMSG_ID_SOCK_SENDPKG (QMSG_ID_BASE + 4)
- #define QMSG_ID_SOCK_RECVPKG (QMSG_ID_BASE + 5)
- #define QMSG_ID_SOCK_EXIT (QMSG_ID_BASE + 6)
- #define QX_TCP_IPADRRES "47.97.127.222"
- #define QX_TCP_PORT "8712"
- #define APP_CHARGING_WORK_TIME 30
- #define APP_WAKEUP_WORK_TIME 1
- #define APP_SLEEP_TIME 5
- #define TCP_START_SYM1 0x23
- #define TCP_START_SYM2 0x23
- #define TCP_CMD_SYM 0x02
- #define TCP_ANS_SYM 0xFE
- //encrypt methord
- #define TCP_ENCPT_ENABLE 0x00
- #define TCP_ENCPT_DISABLE 0x01
- //message type mark
- #define BATTMSG 0x80
- #define GPSMSG 0x82
- //tcp Send Msg Case period
- #define SENDMSG5s 01
- #define SENDMSG10s 02
- #define SENDMSG20s 04
- #define SENDMSG30s 06
- #define SENDMSG60s 12
- #define SENDMSG180s 36
- #define SENDMSG300s 60
- #define SENDMSG600s 120
- #define SENDMSGPRDMAX 200
- extern UINT8 IH_appChargEndWorkTime;
- extern UINT8 IH_appWakeupWorkTime;
- extern UINT8 IH_appSleepTime;
- extern UINT8 IH_isBattLocked;
- extern UINT8 OH_appChargEndWorkTime;
- extern UINT8 OH_appWakeupWorkTime;
- extern UINT8 OH_appSleepTime;
- extern UINT8 OH_isBattLocked;
- extern UINT8 BattSN[BATT_SN_LEN];
- extern CHAR TcpServerIpV4Address[16];
- extern CHAR TcpServerPort[5];
- typedef enum
- {
- PROCESS_CAN_STATE_IDLE = 0,
- PROCESS_CAN_STATE_WORK,
- PROCESS_CAN_STATE_SLEEP
- }process_CAN;
- typedef enum
- {
- PROCESS_TCP_STATE_IDLE = 0,
- PROCESS_TCP_STATE_LINK,
- PROCESS_TCP_STATE_WORK,
- PROCESS_TCP_STATE_SLEEP
- }process_TCP;
- typedef struct BattInfoType
- {
- UINT8 sendTimeUTC[6];
- UINT8 msgMark;
- UINT8 msgCollectionTimeUTC[6];
- UINT8 signalStrength;
- UINT8 errClass;
- UINT8 errCode[2];
- UINT8 battI[2];
- UINT8 battLinkVol[2];
- UINT8 battPackVol[2];
- UINT8 chrgState;
- UINT8 battSOC;
- UINT8 battSOH;
- UINT8 batCellBalenceState[4]; //uint32 should change to uint8[]: each bit stand for 1 cell, up to 1024
- UINT8 battCellNum[2]; //uint8 should change to uint16 (0~65535) //zhengchao
- UINT8 battCellU[BATT_CELL_VOL_NUM_2];
- UINT8 battTempNum[2]; //uint8 should change to uint16 (0~65535)
- UINT8 battCellTemp[BATT_TEMP_NUM];
- UINT8 battWorkState;
- UINT8 battHeatState;
- }BattInfoType;
- typedef struct BattMsgtoTcpType
- {
- UINT8 startSymbol[2];
- UINT8 cmdSymbol;
- UINT8 ansSymbol;
- UINT8 SN[BATT_SN_LEN];
- UINT8 encryptMethod;
- UINT8 dataLength[2];
- BattInfoType battInfo;
- UINT8 CRC;
- }BattMsgtoTcpType;
- typedef struct GPSInfoType
- {
- UINT8 sendTimeUTC[6];
- UINT8 msgMark;
- UINT8 msgCollectionTimeUTC[6];
- UINT8 locateMark;
- UINT8 satelliteNum;
- UINT8 direction[2];
- UINT8 speed[2];
- UINT8 altitude[2];
- UINT8 latitude[4];
- UINT8 longitude[4];
-
- }GPSInfoType;
- typedef struct GPSMsgtoTcpType
- {
- UINT8 startSymbol[2];
- UINT8 cmdSymbol;
- UINT8 ansSymbol;
- UINT8 SN[BATT_SN_LEN];
- UINT8 encryptMethod;
- UINT8 dataLength[2];
- GPSInfoType gpsInfo;
- UINT8 CRC;
- }GPSMsgtoTcpType;
- typedef enum
- {
- APP_INIT_STATE,
- APP_DEACTIVE_STATE,
- APP_IPREADY_STATE,
- APP_REPORT_STATE,
- APP_IDLE_STATE,
- APP_WAIT_STATE
- } appRunningState_t;
- typedef enum
- {
- APP_SOCKET_CONNECTION_CLOSED,
- APP_SOCKET_CONNECTION_CONNECTING,
- APP_SOCKET_CONNECTION_CONNECTED,
- }AppSocketConnectionStatus;
- typedef struct AppSocketConnectionContext_Tag
- {
- INT32 id;
- INT32 status;
- }AppSocketConnectionContext;
- typedef struct Fota_Type
- {
- bool Fota_update_flag ;
- bool Fota_update_error ;
- uint32_t Fota_All_Data_Len ;
- uint32_t Fota_Current_Addres ;
- uint8_t Fota_Recv_Data_Len ;
- uint8_t Fota_Recv_Data[100] ;
- uint32_t Fota_Flash_Addres;
- uint8_t Fota_CRC ;
- }Fota_Type;
- typedef struct _GPS_INFO
- {
- uint8_t timedata[6];
- uint8_t status;
- uint8_t satellite_num;
- uint16_t direction;
- uint16_t speed;
- uint16_t altitude;
- uint32_t latitude;
- uint32_t longitude;
- }GPS_INFO;
- //uint8_t* Uart_Receive_func(Uart_Receive_Type Uart_Receive_Msg,uint8_t* Uart_Rece_buffer,uint8_t Data_Len);
- #ifdef __cplusplus
- }
- #endif
- #endif /* APP_H */
|