![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Backing up an unused program in case of future need
Diff: at.cpp
- Revision:
- 4:e076884ef8bd
- Parent:
- 2:06fa34661f19
- Child:
- 6:be97d38e0b01
diff -r accba7e07a0d -r e076884ef8bd at.cpp --- a/at.cpp Sat Apr 23 20:00:04 2016 +0000 +++ b/at.cpp Tue May 03 09:23:26 2016 +0000 @@ -18,6 +18,9 @@ #define WAIT_FOR_SEND_OK 7 static int wait_for; +#define RESP_LENGTH 256 +static char resp[RESP_LENGTH]; + static int * pFeedback; static void startCommand(int* pStatus, int waitfor) { @@ -42,12 +45,12 @@ void AtConnect(const char *ssid, const char *password, int *pStatus) { startCommand(pStatus, WAIT_FOR_OK); - EspSendStringF("AT+CWJAP=\"%s\",\"%s\"\r\n", ssid, password); + EspSendStringF(resp, RESP_LENGTH, "AT+CWJAP=\"%s\",\"%s\"\r\n", ssid, password); } void AtAt(int *pStatus) { startCommand(pStatus, WAIT_FOR_OK); - EspSendString("AT\r\n"); + EspSendString(resp, RESP_LENGTH, "AT\r\n"); } void AtConnectId(int id, char * type, char * addr, int port, void * buffer, int bufferlength, int *pStatus) @@ -57,34 +60,34 @@ EspIpdBuffer[id] = buffer; EspIpdBufferLen[id] = bufferlength; - EspSendStringF("AT+CIPSTART=%d,\"%s\",\"%s\",%d\r\n", id, type, addr, port); + EspSendStringF(resp, RESP_LENGTH, "AT+CIPSTART=%d,\"%s\",\"%s\",%d\r\n", id, type, addr, port); } void AtStartServer(int port, int *pStatus) { startCommand(pStatus, WAIT_FOR_OK); - EspSendStringF("AT+CIPSERVER=1,%d\r\n", port); + EspSendStringF(resp, RESP_LENGTH, "AT+CIPSERVER=1,%d\r\n", port); } void AtClose(int id, int *pStatus) { startCommand(pStatus, WAIT_FOR_OK); - EspSendStringF("AT+CIPCLOSE=%d\r\n", id); + EspSendStringF(resp, RESP_LENGTH, "AT+CIPCLOSE=%d\r\n", id); } void AtMux(int *pStatus) { startCommand(pStatus, WAIT_FOR_OK); - EspSendString("AT+CIPMUX=1\r\n"); + EspSendString(resp, RESP_LENGTH, "AT+CIPMUX=1\r\n"); } void AtBaud(int baud, int *pStatus) { startCommand(pStatus, WAIT_FOR_OK); - EspSendStringF("AT+CIOBAUD=%d\r\n", baud); + EspSendStringF(resp, RESP_LENGTH, "AT+CIOBAUD=%d\r\n", baud); } int AtEspStatus; void AtGetEspStatus(int *pStatus) { AtEspStatus = 0; startCommand(pStatus, WAIT_FOR_STATUS); - EspSendString("AT+CIPSTATUS\r\n"); + EspSendString(resp, RESP_LENGTH, "AT+CIPSTATUS\r\n"); } char AtEspVersion[20]; static int versionlinecount; @@ -92,7 +95,7 @@ { AtEspVersion[0] = '\0'; startCommand(pStatus, WAIT_FOR_VERSION); - EspSendString("AT+GMR\r\n"); + EspSendString(resp, RESP_LENGTH, "AT+GMR\r\n"); versionlinecount = 0; } void AtSendData(int id, int length, const void * pdata, int *pStatus) @@ -100,7 +103,7 @@ startCommand(pStatus, WAIT_FOR_SEND_OK); EspLengthToSend = length; EspDataToSend = pdata; - EspSendStringF("AT+CIPSEND=%d,%d\r\n", id, length); + EspSendStringF(resp, RESP_LENGTH, "AT+CIPSEND=%d,%d\r\n", id, length); } int AtBusy()