Connect Wi-Fi

Dependencies:   mbed

Fork of Server-ESP8266 by Digital dog

Revision:
3:e1042768703b
Parent:
2:6738db3eb2ed
Child:
4:217a562d8950
diff -r 6738db3eb2ed -r e1042768703b main.cpp
--- a/main.cpp	Sat Dec 09 22:20:18 2017 +0000
+++ b/main.cpp	Sun Dec 10 08:08:41 2017 +0000
@@ -24,36 +24,50 @@
     wait(2);
     
     pc.printf("Set mode to AP\r\n");
-    esp.SetMode(3);
+    esp.SetMode(1);
     esp.RcvReply(rcv, 1000);
     pc.printf("%s", rcv);
+    wait(2);
     
     pc.printf("Receiving Wifi List\r\n");
     esp.GetList(rcv);
     pc.printf("%s", rcv);
     
+//    pc.printf("Setting Wifi\r\n");
+//    esp.SetWiFi("ESP8266-MIND", "mindkafuu");
+//    esp.RcvReply(rcv, 1000);
+//    pc.printf("%s", rcv);
+//    wait(4);
+            
     pc.printf("Connecting to AP\r\n");
     esp.Join("Mind", "00000000"); // Replace MyAP and MyPasswd with your SSID and password
     esp.RcvReply(rcv, 1000);
     pc.printf("%s", rcv);
+    wait(8);
+    
+    pc.printf("Check Connected\r\n");
+    esp.check();
+    esp.RcvReply(rcv, 400);
+    pc.printf("%s", rcv);
     wait(2);
     
-    pc.printf("Check Connect\r\n");
-    esp.Check(rcv);
-    esp.RcvReply(rcv, 200);
+    pc.printf("Check Wifi\r\n");
+    esp.look();
+    esp.RcvReply(rcv, 400);
     pc.printf("%s", rcv);
+    wait(2);
     
     pc.printf("Getting IP\r\n");
     esp.GetIP(rcv);
     pc.printf("%s", rcv);
     
-    pc.printf("Setting multiple connections\r\n");
+    pc.printf("Setting single connections\r\n");
     esp.SetMultiple();
     esp.RcvReply(rcv, 1000);
     pc.printf("%s", rcv);
     wait(4);
     
-    pc.printf("Start server mode on port 81\r\n");
+    pc.printf("Start server mode on port 9999\r\n");
     esp.StartServerMode(9999);
     esp.RcvReply(rcv, 1000);
     pc.printf("%s", rcv);