IOTON boards API using mbed SDK - http://ioton.cc/plataforma-ton
Dependents: ton-bot_teste ton-bot_seguidor_linha ton-bot_seguidor_parede
Fork of IOTON-API by
Diff: ESP8266.h
- Revision:
- 1:3a73d77c2cef
- Parent:
- 0:cbba28a205fa
diff -r cbba28a205fa -r 3a73d77c2cef ESP8266.h --- a/ESP8266.h Tue Nov 08 00:17:12 2016 +0000 +++ b/ESP8266.h Thu Jun 29 20:11:00 2017 +0000 @@ -23,9 +23,19 @@ bool connect(const char* ssid, const char* pass, uint8_t mode = 0) { + // Set CWMODE to 1=Station,2=AP,3=BOTH, default mode 1 (Station) + strcpy(cmdbuff, "AT+CWMODE=1\r\n"); + sendCMD(); + getReply(500, 20); + + // DHCP Enabled in Station Mode + strcpy(cmdbuff, "AT+CWDHCP=1,1\r\n"); + sendCMD(); + getReply(500, 20); + sprintf(cmdbuff,"AT+CWJAP=\"%s\",\"%s\"\r\n", ssid, pass); sendCMD(); - getReply(8000, 50); + getReply(10000, 200); if (strstr(replybuff, "OK") == NULL) return false; @@ -144,6 +154,10 @@ sendCMD(); getReply(500, 10); + sprintf(cmdbuff, "AT+CIPCLOSE\r\n"); + sendCMD(); + getReply(500, 600); + return false; } else