mirror of
				https://github.com/0xFEEDC0DE64/arduino-esp32.git
				synced 2025-10-26 11:41:42 +01:00 
			
		
		
		
	* smartConfig support * fixed bug, added example * added _smartConfigDone = ture * changed example name, added explanation
		
			
				
	
	
		
			37 lines
		
	
	
		
			725 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			37 lines
		
	
	
		
			725 B
		
	
	
	
		
			C++
		
	
	
	
	
	
| #include "WiFi.h"
 | |
| 
 | |
| void setup() {
 | |
|   Serial.begin(115200);
 | |
| 
 | |
|   //Init WiFi as Station, start SmartConfig
 | |
|   WiFi.mode(WIFI_AP_STA);
 | |
|   WiFi.beginSmartConfig();
 | |
| 
 | |
|   //Wait for SmartConfig packet from mobile
 | |
|   Serial.println("Waiting for SmartConfig.");
 | |
|   while (!WiFi.smartConfigDone()) {
 | |
|     delay(500);
 | |
|     Serial.print(".");
 | |
|   }
 | |
| 
 | |
|   Serial.println("");
 | |
|   Serial.println("SmartConfig received.");
 | |
| 
 | |
|   //Wait for WiFi to connect to AP
 | |
|   Serial.println("Waiting for WiFi");
 | |
|   while (WiFi.status() != WL_CONNECTED) {
 | |
|     delay(500);
 | |
|     Serial.print(".");
 | |
|   }
 | |
| 
 | |
|   Serial.println("WiFi Connected.");
 | |
| 
 | |
|   Serial.print("IP Address: ");
 | |
|   Serial.println(WiFi.localIP());
 | |
| }
 | |
| 
 | |
| void loop() {
 | |
|   // put your main code here, to run repeatedly:
 | |
| 
 | |
| }
 |