Connect Wi-Fi
Fork of Server-ESP8266 by
Embed:
(wiki syntax)
Show/hide line numbers
main.cpp
00001 #include "mbed.h" 00002 #include <string> 00003 #include "ESP8266.h" 00004 //////////////// 00005 ESP8266 esp(D8, D2, 115200); 00006 Serial pc(D1, D0, 115200); 00007 00008 char snd[255], rcv[1000]; 00009 00010 int main() 00011 { 00012 pc.printf("Hello!! \n"); 00013 00014 pc.printf("Reset ESP\r\n"); 00015 esp.Reset(); 00016 esp.RcvReply(rcv, 400); 00017 pc.printf("%s", rcv); 00018 wait(2); 00019 00020 pc.printf("Sending AT\r\n"); 00021 strcpy(snd, "AT"); 00022 esp.SendCMD(snd); 00023 esp.RcvReply(rcv, 400); 00024 pc.printf("%s", rcv); 00025 wait(2); 00026 00027 pc.printf("Set mode to AP\r\n"); 00028 esp.SetMode(3); 00029 esp.RcvReply(rcv, 1000); 00030 pc.printf("%s", rcv); 00031 wait(2); 00032 00033 // 00034 // pc.printf("Receiving Wifi List\r\n"); 00035 // esp.GetList(rcv); 00036 // pc.printf("%s", rcv); 00037 00038 // pc.printf("Setting Wifi\r\n"); 00039 // esp.SetWiFi("ESP8266-MIND", "mindkafuu"); 00040 // esp.RcvReply(rcv, 1000); 00041 // pc.printf("%s", rcv); 00042 // wait(4); 00043 // 00044 pc.printf("Connecting to AP\r\n"); 00045 esp.Join("Mind", "mmmmmmmm"); // Replace MyAP and MyPasswd with your SSID and password 00046 esp.RcvReply(rcv, 5000); 00047 pc.printf("%s", rcv); 00048 wait(8); 00049 00050 pc.printf("Check Connected\r\n"); 00051 esp.check(); 00052 esp.RcvReply(rcv, 400); 00053 pc.printf("%s", rcv); 00054 wait(2); 00055 00056 pc.printf("Setting multiple connections\r\n"); 00057 esp.SetMultiple(); 00058 esp.RcvReply(rcv, 1000); 00059 pc.printf("%s", rcv); 00060 wait(4); 00061 00062 pc.printf("Start server mode on port 80\r\n"); 00063 esp.StartServerMode(); 00064 esp.RcvReply(rcv, 1000); 00065 pc.printf("%s", rcv); 00066 wait(4); 00067 00068 pc.printf("Getting IP\r\n"); 00069 esp.GetIP(rcv); 00070 pc.printf("%s", rcv); 00071 00072 // pc.printf("Connect to Server\r\n"); 00073 // esp.SetPath("TCP", "192.168.1.56", "80"); 00074 // esp.RcvReply(rcv, 1000); 00075 // pc.printf("%s", rcv); 00076 // wait(4); 00077 // 00078 //while(1) { 00079 // esp.Recieve(5); 00080 // esp.RcvReply(rcv, 1000); 00081 // pc.printf("%s", rcv); 00082 // wait(4); 00083 // } 00084 }
Generated on Mon Jul 18 2022 12:31:04 by
1.7.2
