chen
2024-11-27 b3a401224cebaa7e938df4295841f8d2f702b11c
keil/include/src/TCPClient.c
@@ -73,29 +73,41 @@
char applyid[10];
uint16_t receive_id;
uint16_t g_com_position;
uint16_t g_com_num;
HIDO_UINT8 *_u8Data_temp1=NULL;
HIDO_UINT32 _u32Len_temp;
static HIDO_INT32 TCPClient_DataProc(HIDO_UINT8 *_u8Data, HIDO_UINT32 _u32Len)
{
    HIDO_CHAR *apcSplitStr[12];
    HIDO_UINT32 u32SplitCnt = 0;
      HIDO_CHAR acResponse[200];
      HIDO_CHAR temp_acResponse[200];
      _u8Data_temp1=_u8Data;
      _u32Len_temp=_u32Len;
      HIDO_CHAR acReadponse[200];
      HIDO_UINT32 datalenth;
      HIDO_UINT32 u32ResponseLen;
      HIDO_UINT32 u32ReadResponseLen;
    LOG_INFO(TRACE_MODULE_APP, "收到数据\r\n");
    if(STRCMP(_u8Data, "$setpara,") == 0)
    {
            u32ResponseLen = snprintf(acResponse, sizeof(acResponse), "$setparaok,%s\r\n", \
            u32ResponseLen = snprintf(acResponse, 12+_u32Len, "$setparaok,%s\r\n", \
                              _u8Data);
            Socket_Send(l_i32TCPClientID, (HIDO_UINT8 *)acResponse, u32ResponseLen);
            memcpy(temp_acResponse,acResponse,sizeof(acResponse));
        u32SplitCnt = HIDO_UtilStrSplit((HIDO_CHAR *)_u8Data, ',', apcSplitStr, HIDO_ARRARY_COUNT(apcSplitStr));
        receive_id = HIDO_UtilHexStrToInt(apcSplitStr[1]);
            
        if(g_com_map[DEV_ID]==receive_id)
        {
           g_com_position=HIDO_UtilStrToInt(apcSplitStr[2]);
                  g_com_map[g_com_position]=HIDO_UtilStrToInt(apcSplitStr[3]);
                if(g_com_map[SEND_4G_SECOND]<30)
                  g_com_position=HIDO_UtilStrToInt(apcSplitStr[2]);
                      if(g_com_position!=CNT_RESTART&&g_com_position!=0&&g_com_position!=CNT_UPDATE)
                     {
                        Socket_Send(l_i32TCPClientID, (HIDO_UINT8 *)temp_acResponse, u32ResponseLen);
                        g_com_map[g_com_position]=HIDO_UtilStrToInt(apcSplitStr[3]);
                     }
                        if(g_com_map[SEND_4G_SECOND]<30)
                     {
                     gps_open_flag=0;
                     gps_wait_count=0;
@@ -170,6 +182,16 @@
        receive_id = HIDO_UtilHexStrToInt(apcSplitStr[1]);
        if(g_com_map[DEV_ID]==receive_id)
        {
                g_com_position=HIDO_UtilStrToInt(apcSplitStr[2]);
                g_com_num=   HIDO_UtilStrToInt(apcSplitStr[3]);
               u32ReadResponseLen = snprintf(acReadponse, sizeof(acReadponse), "$replypara,%04x,%d", \
                              receive_id,g_com_position);
               for(uint16_t i=0;i<g_com_num;i++)
            {
                datalenth = sprintf((HIDO_CHAR *)&acReadponse[u32ReadResponseLen],",%d",g_com_map[g_com_position+i]);
                u32ReadResponseLen += datalenth;
            }
               Socket_Send(l_i32TCPClientID, (HIDO_UINT8 *)acReadponse, u32ReadResponseLen);
        }
    }
    return HIDO_OK;
@@ -218,10 +240,12 @@
        HIDO_UINT32 u32RecvLen = 0;
        i32Ret = Socket_Recv(l_i32TCPClientID, l_au8CmdBuff, sizeof(l_au8CmdBuff) - 1, &u32RecvLen);
        if(HIDO_OK == i32Ret)
        {
            TCPClient_DataProc(l_au8CmdBuff, u32RecvLen);
        }
            memset(l_au8CmdBuff,0,sizeof(l_au8CmdBuff));
        break;
    }
    default: