chen
2025-02-26 acce179c49a6a9c625e9402e6f9046d1325ffcea
keil/include/src/TCPClient.c
@@ -74,7 +74,7 @@
uint16_t receive_id;
uint16_t g_com_position;
uint16_t g_com_num;
int16_t beepontime;
HIDO_UINT8 *_u8Data_temp1=NULL;
HIDO_UINT32 _u32Len_temp;
extern int32_t distance;
@@ -83,6 +83,7 @@
extern uint32_t u32GGaLenth;
extern char GGA_Final_message[1024];
extern uint32_t gga_num;
uint8_t beep_start_flag;
static HIDO_INT32 TCPClient_DataProc(HIDO_UINT8 *_u8Data, HIDO_UINT32 _u32Len)
{
    HIDO_CHAR *apcSplitStr[12];
@@ -202,7 +203,22 @@
            }
               Socket_Send(l_i32TCPClientID, (HIDO_UINT8 *)acReadponse, u32ReadResponseLen);
        }
    }
    }else if(STRCMP(_u8Data, "$control,") == 0)
      {
          u32SplitCnt = HIDO_UtilStrSplit((HIDO_CHAR *)_u8Data, ',', apcSplitStr, HIDO_ARRARY_COUNT(apcSplitStr));
        receive_id = HIDO_UtilHexStrToInt(apcSplitStr[1]);
       /* 设备ID开启震动 */
        if(receive_id == g_com_map[DEV_ID])
        {
            if(strcmp(apcSplitStr[2],"beeper")==0)
            {
                   beepontime = HIDO_UtilStrToInt(apcSplitStr[3]);
                    if(beepontime>0)
                              beep_start_flag=1;
            }
            }
      }
    return HIDO_OK;
}
@@ -297,13 +313,15 @@
//                               g_com_map[DEV_ID],GetUWBBindState(),g_com_map[BIND_DEV_ID],alarm_type,bat_percent,g_com_map[ALARM_DISTANCE1],g_com_map[ALARM_DISTANCE2],jd,wd,applyid,result,distance);
//    }
   
   u32HeartLen = snprintf(acHeart, sizeof(acHeart), "%s,%04x,%02u%%,%d,%d,0,0\r\n", \
   u32HeartLen = snprintf(acHeart, sizeof(acHeart), "%s,%04x,%x,%d,%d,0,0\r\n", \
                               GPS_GGAmessage,g_com_map[DEV_ID],bat_percent,userkey_state,gps_timeout_flag);
   
      
   if(gps_open_flag||userkey_state){
   if(gps_open_flag&&userkey_state!=1){
      Socket_Send(l_i32TCPClientID, (HIDO_UINT8 *)acHeart, u32HeartLen);
   }else{
   }
   if (userkey_state){
      TCPHeartBeatUpload();//立即上传心跳包
//     Socket_Send(l_i32TCPClientID, (HIDO_UINT8 *)GGA_Final_message, u32GGaLenth);
//      memset(GGA_Final_message, 0, sizeof(GGA_Final_message));//清空接收到的用完的数组
//      u32GGaLenth=0;
@@ -322,7 +340,7 @@
}
void TCPHeartBeatUpload(void)
{
    HIDO_CHAR acHeart[200];
    HIDO_CHAR acHeart1[200];
    HIDO_UINT32 u32HeartLen;
    ave_sp = g_spsum/g_snum;
    g_spsum = 0;
@@ -335,9 +353,12 @@
//        u32HeartLen = snprintf(acHeart, sizeof(acHeart), "$message,heart,%04x,%d,%04x,%d,%02u%%,%d,%d,%lf,%lf,%s,%d,%d,0\r\n", \
//                               g_com_map[DEV_ID],GetUWBBindState(),g_com_map[BIND_DEV_ID],alarm_type,bat_percent,g_com_map[ALARM_DISTANCE1],g_com_map[ALARM_DISTANCE2],jd,wd,applyid,result,distance);
//    }
   u32HeartLen = snprintf(acHeart, sizeof(acHeart), "%s,%04x,%02u%%\r\n", \
                               GPS_GGAmessage,g_com_map[DEV_ID],bat_percent);
    Socket_Send(l_i32TCPClientID, (HIDO_UINT8 *)acHeart, u32HeartLen);
   //         u32Len = HIDO_UtilSnprintf((HIDO_CHAR *)l_au8CmdBuff, sizeof(l_au8CmdBuff), "$XTB,%X,%02u%%,%d.%d,%s,%d,1.",
//                    g_com_map[DEV_ID], bat_percent2, g_com_map[VERSION]>>8,g_com_map[VERSION]&0xff, Module_GetCCID(),userkey_state4g,g_com_map[TCP_IP_0],g_com_map[TCP_IP_1],g_com_map[TCP_IP_2],g_com_map[TCP_IP_3],g_com_map[TCP_PORT]);
   u32HeartLen = snprintf(acHeart1, sizeof(acHeart1), "$XTB,%04x,%02u%%,%d.%d,%s,%d,0\r\n", \
                               g_com_map[DEV_ID],bat_percent,g_com_map[VERSION]>>8,g_com_map[VERSION]&0xff,Module_GetCCID(),userkey_state);
    Socket_Send(l_i32TCPClientID, (HIDO_UINT8 *)acHeart1, u32HeartLen);
}
void TCPReceiveMessageReply(void)
{
@@ -391,13 +412,14 @@
           
           //if ((u32CurTick - l_u32HeartBeatTick) >= HIDO_TIMER_TICK_S(15)||flag_first_TCPconnect)
                if ((u32CurTick - l_u32HeartBeatTick) >= HIDO_TIMER_TICK_S(g_com_map[SEND_4G_SECOND])||flag_first_TCPconnect)
           if ((u32CurTick - l_u32HeartBeatTick) >= HIDO_TIMER_TICK_S(60)||flag_first_TCPconnect)
                //if ((u32CurTick - l_u32HeartBeatTick) >= HIDO_TIMER_TICK_S(g_com_map[SEND_4G_SECOND])||flag_first_TCPconnect)
            {
                flag_first_TCPconnect = 0;
                l_u32HeartBeatTick = u32CurTick;
                // 这里是自定义心跳
                //TCPHeartBeatUpload();
                     if(g_com_map[HEARTBEAT])
                TCPHeartBeatUpload();
                        //UDPClient_UploadGPS();//先不弄心跳
//                HIDO_CHAR acHeart[128];
//                HIDO_UINT32 u32HeartLen = snprintf(acHeart, sizeof(acHeart), "$message heart,%04x,00001,1,50,50,50,,,,\r\n", g_com_map[DEV_ID]);