123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192 |
- /****************************************************************************
- *
- * Copy right: Qx.Chen Jie
- * File name: TcpTask.h
- * Description: 网络发送接收任务
- * History: 2021-03-07
- *
- ****************************************************************************/
- #include "app.h"
- extern UINT32 TcpService;
- #define PROC_TCP_TASK_STACK_SIZE (2048+1024)
- #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 APP_EVENT_QUEUE_SIZE (10)
- #define CHRG_END_DELAY (300)
- #define RUN_END_DELAY (100)
- #define QX_TCP_ADD "iotp.fast-fun.cn"
- #define QX_TCP_PORT 8712
- // #define QX_TCP_IPADRRES "47.97.127.222"
- // #define QX_TCP_PORT 8712
- /*---------------测试IP地址-----------------------------------*/
- // #define QX_TCP_IPADRRES "39.103.177.126"
- // #define QX_TCP_PORT 8712
- // #define QX_TCP_ADD "rpi.it5000.com"
- // #define QX_TCP_PORT 8812
- /*---------------测试IP地址END-----------------------------------*/
- #define BATT_SN_LEN 17
- #define TCP_START_SYM1 0x23
- #define TCP_START_SYM2 0x23
- #define TCP_CMD_SYM 0x02 //实时信息上报是0x02
- #define TCP_ANS_SYM 0xFE
- /*-------以下为下行指令定义区----------*/
- #define TCP_QUERY_SYM 0x80
- #define TCP_SETCMD_SYM 0x81
- #define TCP_CONCMD_SYM 0x82
- /*----------------end----------------*/
- //encrypt methord
- #define TCP_ENCPT_ENABLE 0x00
- #define TCP_ENCPT_DISABLE 0x01
- //message type mark 0x02上报数据单元定义区
- #define BATTMSG 0x80
- #define GPSMSG 0x82
- #define STATESMSG 0x85
- #define VERSIONMSG 0x86
- #define DEBUGMSG 0x8C
- 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 switchState;
- UINT8 battSOC;
- UINT8 battSOH;
- UINT8 batCellBalenceState[4]; //uint32 should change to uint8[]: each bit stand for 1 cell, up to 1024
- UINT8 battCellNum; //uint8 should change to uint16 (0~65535) //zhengchao
- UINT8 battCellU[BATT_CELL_VOL_NUM_2];
- UINT8 battTempNum; //uint8 should change to uint16 (0~65535)
- UINT8 battCellTemp[BATT_TEMP_NUM];
- UINT8 battWorkState;
- UINT8 battHeatEnableState;
- UINT8 battotherTempNum;
- UINT8 battotherTemp[BATT_OTHER_TEMP_NUM+NB_OTHER_TEMP_NUM];
- }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];
- UINT8 AccMileage[4];
- UINT8 Tac[2];
- UINT8 CellId[4];
- UINT8 xData[2];
- UINT8 yData[2];
- UINT8 zData[2];
- }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 struct _VerInfoType
- {
- UINT8 sendTimeUTC[6];
- UINT8 msgMark;
- UINT8 msgCollectionTimeUTC[6];
- UINT8 ICCID[20];
- UINT8 IMEI[15];
- UINT8 BMSHwVersion[2];
- UINT8 BMSSwVersion[4];
- UINT8 NBHwVersion[2];
- UINT8 BLVersion[4];
- UINT8 DRVVersion[4];
- UINT8 APPVersion[4];
- UINT8 BmsType;
- UINT8 BmsInfo;
- UINT8 DataModuleType;
- }VerInfoType;
- typedef struct VersionMsgtoTcpType
- {
- UINT8 startSymbol[2];
- UINT8 cmdSymbol;
- UINT8 ansSymbol;
- UINT8 SN[BATT_SN_LEN];
- UINT8 encryptMethod;
- UINT8 dataLength[2];
- VerInfoType VerInfo;
- UINT8 CRC;
- }VersionMsgtoTcpType;
- typedef struct _DebugInfoType
- {
- UINT8 sendTimeUTC[6];
- UINT8 msgMark;
- UINT8 DebugLen[2];
- }DebugInfoType;
- typedef struct DebugMsgtoTcp_Type
- {
- UINT8 startSymbol[2];
- UINT8 cmdSymbol;
- UINT8 ansSymbol;
- UINT8 SN[BATT_SN_LEN];
- UINT8 encryptMethod;
- UINT8 dataLength[2];
- DebugInfoType DebugInfo;
- UINT8 CRC;
- }DebugMsgtoTcpType;
- /*---------------------------------------------------------------------------*/
- typedef enum
- {
- APP_SOCKET_CONNECTION_CLOSED = 0,
- APP_SOCKET_CONNECTION_CONNECTING,
- APP_SOCKET_CONNECTION_CONNECTED,
- }AppSocketConnectionStatus;
- typedef struct AppSocketConnectionContext_Tag
- {
- INT32 id;
- INT32 status;
- }AppSocketConnectionContext;
- typedef enum
- {
- PROCESS_TCP_STATE_IDLE = 0,
- PROCESS_TCP_STATE_SEND,
- PROCESS_TCP_STATE_RECV,
- PROCESS_TCP_STATE_SLEEP
- }process_TCP;
- void TcpTaskInit(void *arg);
- void TcpTaskDeInit(void *arg);
|