File tree 1 file changed +51
-0
lines changed
hardware/esp8266com/esp8266/libraries/ESP8266WiFi/examples
1 file changed +51
-0
lines changed Original file line number Diff line number Diff line change
1
+ #include <ESP8266WiFi.h>
2
+ #include <WiFiUdp.h>
3
+
4
+ WiFiUDP Udp;
5
+
6
+ void setup() {
7
+ uint8_t cnt = 0;
8
+
9
+ Serial.begin(115200);
10
+
11
+ WiFi.mode(WIFI_STA);
12
+ WiFi.begin();
13
+
14
+ while(WiFi.status() != WL_CONNECTED) {
15
+ delay(500);
16
+ Serial.print(".");
17
+ if(cnt++ >= 10){
18
+ WiFi.setSmartLink();
19
+ while(1){
20
+ delay(1000);
21
+ if(WiFi.getSmartlinkStatus() == SC_STATUS_LINK_OVER){
22
+ Serial.println("SmartConfig Success");
23
+ break;
24
+ }
25
+ }
26
+ }
27
+ }
28
+
29
+ Serial.println("");
30
+ Serial.println("");
31
+
32
+ WiFi.printDiag(Serial);
33
+
34
+ // Start the server
35
+ Udp.begin(49999);
36
+ Serial.println("USP Server started");
37
+
38
+ // Print the IP address
39
+ Serial.println(WiFi.localIP());
40
+ }
41
+
42
+ void loop() {
43
+ // Check if a client has connected
44
+ Udp.parsePacket();
45
+ while(Udp.available()){
46
+ Serial.println(Udp.remoteIP());
47
+ Udp.flush();
48
+ delay(5);
49
+ }
50
+ }
51
+
You can’t perform that action at this time.
0 commit comments