Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: Smart_Lights_Midterm
Diff: ESP8266.cpp
- Revision:
- 3:4f24e7e803a1
- Parent:
- 2:77388e8f0697
- Child:
- 4:d8e538bd3a0b
--- a/ESP8266.cpp Sun Dec 28 21:58:49 2014 +0000 +++ b/ESP8266.cpp Sat Jun 11 14:05:06 2016 +0000 @@ -1,4 +1,7 @@ #include "ESP8266.h" +#define HTTPCMD "GET " +#define protocol " HTTP/1.0\n\n" + // Constructor ESP8266::ESP8266(PinName tx, PinName rx, int br) : comm(tx, rx) { @@ -62,7 +65,7 @@ } // Receive reply until no character is received after a given timeout in miliseconds -void ESP8266::RcvReply(char * r, int to) { +bool ESP8266::RcvReply(char * r, int to) { Timer t; bool ended = 0; char c; @@ -80,6 +83,7 @@ } } AddChar(r, 0x00); + return ended; } // Gets the AP list. Parameter: the string to receive the list @@ -165,4 +169,34 @@ char rs[20]; strcpy(rs, "AT+CIPSERVER=0"); SendCMD(rs); -} \ No newline at end of file +} + +void ESP8266::setTransparent(void){ + char rs[20]; + strcpy(rs, "AT+CIPMODE=0"); + SendCMD(rs); +} + +void ESP8266::startTCPConn(char *IP, int port){ + char rs[100]; + sprintf(rs, "AT+CIPSTART=\"TCP\",\"%s\",%d", IP, port); + SendCMD(rs); +} + +void ESP8266::sendURL(char *URL, char *command){ + char url[300], snd[300], http_cmd[300]; + + strcpy(http_cmd, HTTPCMD); + + strcat(http_cmd, URL); + strcat(http_cmd, protocol); + + strcpy(url, http_cmd); + sprintf(snd,"AT+CIPSENDEX=%d",strlen(url)); + strcpy(command, url); + SendCMD(snd); + wait(3); + SendCMD(url); +} + + \ No newline at end of file