소스 검색

add: esptouch配网兼容腾讯连连

Wendal Chen 2 년 전
부모
커밋
8cd6c5e571
2개의 변경된 파일14개의 추가작업 그리고 2개의 파일을 삭제
  1. 1 1
      src/app/oneshotconfig/wm_oneshot_esp.h
  2. 13 1
      src/app/oneshotconfig/wm_wifi_oneshot.c

+ 1 - 1
src/app/oneshotconfig/wm_oneshot_esp.h

@@ -18,7 +18,7 @@
 #define ESP_ONESHOT_DEBUG 		0
 #define ESP_ONESHOT_DEBUG 		0
 
 
 #define ESP_REPLY_PORT			18266
 #define ESP_REPLY_PORT			18266
-#define ESP_REPLY_MAX_CNT		20
+#define ESP_REPLY_MAX_CNT		50
 
 
 
 
 typedef enum
 typedef enum

+ 13 - 1
src/app/oneshotconfig/wm_wifi_oneshot.c

@@ -52,6 +52,8 @@
 #define ONESHOT_INF(s, ...)
 #define ONESHOT_INF(s, ...)
 #endif
 #endif
 
 
+#include "lwip/inet.h"
+
 u32 oneshottime = 0;
 u32 oneshottime = 0;
 
 
 volatile u8 guconeshotflag = 0;
 volatile u8 guconeshotflag = 0;
@@ -576,6 +578,8 @@ void oneshot_esp_send_reply(void)
 	memcpy(&buf[1], mac_addr, 6);
 	memcpy(&buf[1], mac_addr, 6);
 	memcpy(&buf[7], (u8 *)&ethif->ip_addr.addr, 4);
 	memcpy(&buf[7], (u8 *)&ethif->ip_addr.addr, 4);
 
 
+	uint32_t ip_addr = addr.sin_addr.s_addr;
+
     for (idx = 0; idx < ESP_REPLY_MAX_CNT; idx++)
     for (idx = 0; idx < ESP_REPLY_MAX_CNT; idx++)
     {
     {
         if (tls_wifi_get_oneshot_flag())
         if (tls_wifi_get_oneshot_flag())
@@ -583,7 +587,15 @@ void oneshot_esp_send_reply(void)
             break;
             break;
         }
         }
         sendto(socket_num, buf, 11, 0, (struct sockaddr*) &addr, sizeof(struct sockaddr_in));
         sendto(socket_num, buf, 11, 0, (struct sockaddr*) &addr, sizeof(struct sockaddr_in));
-        tls_os_time_delay(10);
+		if (ip_addr != INADDR_BROADCAST) {
+            sendto(socket_num, buf, 11, 0, (struct sockaddr*) &addr, sizeof(struct sockaddr_in));
+            addr.sin_addr.s_addr = INADDR_BROADCAST;
+            sendto(socket_num, buf, 11, 0, (struct sockaddr*) &addr, sizeof(struct sockaddr_in));
+            addr.sin_addr.s_addr = ip_addr;
+        } else {
+            sendto(socket_num, buf, 11, 0, (struct sockaddr*) &addr, sizeof(struct sockaddr_in));
+        }
+        tls_os_time_delay(50);
     }
     }
 
 
     closesocket(socket_num);
     closesocket(socket_num);