Pārlūkot izejas kodu

增加域名解析和GPS累计里程上报

CHENJIE-PC\QiXiang_CHENJIE 3 gadi atpakaļ
vecāks
revīzija
70bf930544
2 mainītis faili ar 23 papildinājumiem un 3 dzēšanām
  1. 1 1
      inc/app.h
  2. 22 2
      src/TcpTask.c

+ 1 - 1
inc/app.h

@@ -16,7 +16,7 @@ extern "C" {
 #define BMS_MANUFACTURE (2) //BMS制造商表示1-超力源,2-美顺
 #define DATA_MODULE_TYPE (1) //1表示NB模块,2表示4G cat1
 #define BMS_INFO  (1)       //1-1表示超力源4830,1-2表示超力源6060,2-1表示美顺6455
-#define EOLSTATE (0) //1标识下线检测跳过,使用默认值
+#define EOLSTATE (1) //1标识下线检测跳过,使用默认值
 
 #if  BMS_MANUFACTURE==1
     #if BMS_INFO==1

+ 22 - 2
src/TcpTask.c

@@ -38,7 +38,7 @@ UINT8 WorkFlag=0;
 extern UINT32 Timer_count;
 extern volatile BOOL Sleep_flag;
 extern osMutexId_t GpsMutex;
-extern UINT8 GpsData[16];
+extern UINT8 GpsData[20];
 extern AppNVMDataType AppNVMData;
 extern AppDataBody AppDataInfo;
 extern QueueHandle_t UartWriteCmdHandle;
@@ -113,7 +113,27 @@ static void TcpTask(void* arg)
                 case QMSG_ID_NW_IP_READY:
                     if(connectionId < 0)
                     {
-                        connectionId = tcpipConnectionCreate(TCPIP_CONNECTION_PROTOCOL_TCP, PNULL, 0, QX_TCP_IPADRRES, QX_TCP_PORT, socketAppConnectionCallBack);
+                        struct addrinfo hints;
+                        struct addrinfo *servinfo = NULL;
+                        char *Tcp_ip_des;
+                        memset(&hints, 0, sizeof(hints));
+                        hints.ai_family = AF_INET;
+                        hints.ai_socktype = SOCK_STREAM;
+                        getaddrinfo(QX_TCP_ADD, NULL, &hints, &servinfo);
+                        Tcp_ip_des = ip4addr_ntoa((const ip4_addr_t *)(&(servinfo->ai_addr->sa_data[2])));
+                        #ifdef USING_PRINTF
+                            printf("\nservinfo-%d:\n",servinfo->ai_addr->sa_len);
+                            for(int i=0;i<4;i++)
+                                printf("%d ",servinfo->ai_addr->sa_data[2+i]);
+                            printf("\nTcp_ip_des-%d:\n",sizeof(Tcp_ip_des));
+                            for(int i=0;i<16;i++)
+                                printf("%c",*(Tcp_ip_des+i));
+                        #endif
+                        connectionId = tcpipConnectionCreate(TCPIP_CONNECTION_PROTOCOL_TCP, PNULL, 0, Tcp_ip_des, QX_TCP_PORT, socketAppConnectionCallBack);
+                        if (NULL != servinfo) {
+                            freeaddrinfo(servinfo);
+                        }
+
                     }
                     if(connectionId >= 0)
                     {