Skip to content

Commit

Permalink
Create SmartConfig
Browse files Browse the repository at this point in the history
Use SmartConfig auto connect to AP, without manually input AP ssid and password.
  • Loading branch information
hwwr committed Apr 19, 2015
1 parent ec4f53e commit 56ceaa8
Showing 1 changed file with 51 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#include <ESP8266WiFi.h>
#include <WiFiUdp.h>

WiFiUDP Udp;

void setup() {
uint8_t cnt = 0;

Serial.begin(115200);

WiFi.mode(WIFI_STA);
WiFi.begin();

while(WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
if(cnt++ >= 10){
WiFi.setSmartLink();
while(1){
delay(1000);
if(WiFi.getSmartlinkStatus() == SC_STATUS_LINK_OVER){
Serial.println("SmartConfig Success");
break;
}
}
}
}

Serial.println("");
Serial.println("");

WiFi.printDiag(Serial);

// Start the server
Udp.begin(49999);
Serial.println("USP Server started");

// Print the IP address
Serial.println(WiFi.localIP());
}

void loop() {
// Check if a client has connected
Udp.parsePacket();
while(Udp.available()){
Serial.println(Udp.remoteIP());
Udp.flush();
delay(5);
}
}

0 comments on commit 56ceaa8

Please sign in to comment.