瀏覽代碼

优化wifi传输问题

yidong 2 周之前
父節點
當前提交
6eba66c338
共有 3 個文件被更改,包括 19 次插入 和 10 次删除
  1. 9 4
      DriverInterface/ESP32_WROOM_32D.c
  2. 9 5
      DriverInterface/communication.c
  3. 1 1
      MDK-ARM/mini7_V2.uvprojx

+ 9 - 4
DriverInterface/ESP32_WROOM_32D.c

@@ -420,11 +420,16 @@ void WIFI_recv_deal(void)
         return;
 
     //判断是否接收完成
+   
     if(wifi_state > WIFI_LISTEN)
     {
-        if(data[g_wifi_rx_last-1] != '\n' && data[g_wifi_rx_last-2] != '\n')
+        if(data[g_wifi_rx_last-1] != '\n' && data[g_wifi_rx_last-2] != '\r')
         {
-            return;
+            if(wifi_state == WIFI_TRANS){
+                if(data[g_wifi_rx_last-1] != '>' && data[g_wifi_rx_last-2] != '>'){
+                     return;
+                }
+            }           
         }
     }
 
@@ -536,11 +541,11 @@ void WIFI_recv_deal(void)
             wifi_tx_len = 0;
             //  wifi_receive_clear();
 		}
-		 else if(NULL != find_str_loop(g_wifi_rx_buf, WIFI_RX_BUF_SIZE ,&g_wifi_rx_head, g_wifi_rx_last, "OK\r\n"))
+		 else if(NULL != find_str_loop(g_wifi_rx_buf, WIFI_RX_BUF_SIZE ,&g_wifi_rx_head, g_wifi_rx_last, ">"))
 		{
              wifi_receive_clear();
 		    Van_Device_Printf(VAN_LOG_WIFI,"\n--> OK W %d", wifi_tx_len); 
-			WriteComm2((char *)wifi_tx_buf, wifi_tx_len+1);
+			WriteComm2((char *)wifi_tx_buf, wifi_tx_len);
             wifi_ack_delay = 3000;
 		}
 		//  else if(NULL != find_str_loop(g_wifi_rx_buf, WIFI_RX_BUF_SIZE ,&g_wifi_rx_head, g_wifi_rx_last, ">"))

+ 9 - 5
DriverInterface/communication.c

@@ -101,9 +101,11 @@ int data_send_to_pc(pc_cmd_type cmd, char *data, unsigned short len)
 
 	if((sysinf.pc_channel_recv  == PC_CONNECT_TYPE_WIFI || cmd == PC_CMD_SETIP ) && ((PC_CMD_SETWIFI != cmd) && (PC_CMD_UPDATETEMP != cmd) && (PC_CMD_DATASCOPE != cmd)))
 	{	
-		wifi_tx_len = sendlen;		
-		memcpy(wifi_tx_buf, com_tx_buf, wifi_tx_len);
-		return WIFI_ReSend();
+         if(wifi_tx_len == 0){                
+            wifi_tx_len = sendlen;		
+            memcpy(wifi_tx_buf, com_tx_buf, wifi_tx_len);
+            return WIFI_ReSend();
+         }
 	}
 	else
 	{	
@@ -138,8 +140,10 @@ int data_send_to_pc_withindex(pc_cmd_type cmd, char *data, unsigned short len, u
 	}	
 	if((sysinf.pc_channel_recv  == PC_CONNECT_TYPE_WIFI || cmd == PC_CMD_SETIP ) && PC_CMD_SETWIFI != cmd)
 	{	
-		wifi_tx_len = MSG_CMDFRAME_LEN+len+2;			
-		return WIFI_ReSend();
+        if(wifi_tx_len == 0){
+            wifi_tx_len = MSG_CMDFRAME_LEN+len+2;			
+            return WIFI_ReSend();
+        }
 	}
 	else
 	{	

+ 1 - 1
MDK-ARM/mini7_V2.uvprojx

@@ -336,7 +336,7 @@
             <v6Rtti>0</v6Rtti>
             <VariousControls>
               <MiscControls></MiscControls>
-              <Define>USE_HAL_DRIVER,STM32F103xE,ONECHIP_MINI_PLUS</Define>
+              <Define>USE_HAL_DRIVER,STM32F103xE,ONECHIP_MINI_ONE</Define>
               <Undefine></Undefine>
               <IncludePath>../Core/Inc;../Drivers/STM32F1xx_HAL_Driver/Inc;../Drivers/STM32F1xx_HAL_Driver/Inc/Legacy;../Drivers/CMSIS/Device/ST/STM32F1xx/Include;../Drivers/CMSIS/Include;../BoardInterface;../DriverInterface;../tshell</IncludePath>
             </VariousControls>