ESP8266
Dependencies: mbed
Diff: ESP8266.cpp
- Revision:
- 1:edcfe804de99
- Parent:
- 0:3222c85ebd43
--- a/ESP8266.cpp Sun Dec 10 06:10:50 2017 +0000 +++ b/ESP8266.cpp Sun Dec 10 08:08:29 2017 +0000 @@ -91,19 +91,23 @@ RcvReply(l, 5000); // Needs big timeout because it takes long to start replying } -void ESP8266::Join(char * id) { +void ESP8266::Join(char * id, char * pwd) { char cmd[255]; strcpy(cmd, "AT+CWJAP="); AddChar(cmd, 0x22); strcat(cmd, id); + AddChar(cmd, 0x22); + AddChar(cmd, 0x2C); + AddChar(cmd, 0x22); + strcat(cmd, pwd); + AddChar(cmd, 0x22); SendCMD(cmd); } -void ESP8266::Check(char * con) { - char cmd[15]; - strcpy(cmd, "AT+CWJAP?"); - SendCMD(cmd); - RcvReply(con, 2000); +void ESP8266::look(void) { + char rs[10]; + strcpy(rs, "AT+CWSAP?"); + SendCMD(rs); } void ESP8266::GetIP(char * ip) { @@ -119,11 +123,19 @@ SendCMD(cmd); } -void ESP8266::SetPath(int path) { - char rs[25]; - char t[4]; - strcpy(rs, "AT+CIPSERVER='TCP','192.168.4.1',"); - itoa(path, t); - strcat(rs, t); - SendCMD(rs); +void ESP8266::SetPath(char * t, char * o, char * v) { + char cmd[255]; + strcpy(cmd, "AT+CIPSTART="); + AddChar(cmd, 0x22); + strcat(cmd, t); + AddChar(cmd, 0x22); + AddChar(cmd, 0x2C); + AddChar(cmd, 0x22); + strcat(cmd, o); + AddChar(cmd, 0x22); + AddChar(cmd, 0x2C); + AddChar(cmd, 0x22); + strcat(cmd, v); + AddChar(cmd, 0x22); + SendCMD(cmd); }