program to receive data using esp8266
Dependencies: ESC ESP8266 mbed
Diff: main.cpp
- Revision:
- 0:4a98e43af2d0
diff -r 000000000000 -r 4a98e43af2d0 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Nov 15 12:48:07 2016 +0000 @@ -0,0 +1,74 @@ +#include "mbed.h" +#include "ESP8266.h" + + +ESP8266 esp(PTC4,PTC3,115200); +Serial pc(USBTX, USBRX); + +char rcv[1000]; + +int main () +{ + + char atr[20]; + //char ip[16]; + // esp.CheckAT(atr); + //pc.printf(atr); + + pc.printf("Receiving Wifi List\r\n"); + esp.GetList(rcv); + pc.printf("%s", rcv); + wait(7); + + /*char cmd[100]; + strcpy(cmd, "AT+CWSAP=\"esp_123\",\"1234test\",5,3"); + esp.SendCMD(cmd); + esp.RcvReply(rcv, 2000); + pc.printf("%s", rcv); + wait(10);*/ + + /*pc.printf("Connecting to AP\r\n"); + esp.Join("esp_1", "123testt"); // Replace MyAP and MyPasswd with your SSID and password + esp.RcvReply(rcv, 1000); + pc.printf("%s", rcv); + wait(10); + */ + pc.printf("Setting Mode=2\r\n"); + esp.SetMode(2); + esp.RcvReply(rcv, 1000); + pc.printf("%s", rcv); + wait(5); + + pc.printf("Setting AT+CIPMUX=1\r\n"); + esp.SetMultiple(); + esp.RcvReply(rcv, 1000); + pc.printf("%s", rcv); + wait(5); + + pc.printf("Starting server mode\r\n"); + esp.StartServerMode(333); + esp.RcvReply(rcv, 1000); + pc.printf("%s", rcv); + wait(5); + + pc.printf("Getting IP\r\n"); + esp.GetIP(rcv); + pc.printf("%s", rcv); + wait(10); + + pc.printf("Getting Connection Status\r\n"); + esp.GetConnStatus(rcv); + pc.printf("%s", rcv); + + while(1) + { + /*pc.printf("Getting Connection Status\r\n"); + esp.GetConnStatus(rcv); + pc.printf("%s", rcv); + wait(3);*/ + + esp.RcvReply(rcv, 1000); + pc.printf("%s", rcv); + wait(0.1); + } +} \ No newline at end of file