Okundu Omeni
/
wifi-https-ble-sm-uart-atcmd-5-13-1
this is using the mbed os version 5-13-1
Diff: source/ATCmdManager.cpp
- Branch:
- PassingRegression
- Revision:
- 122:62166886db5f
- Parent:
- 121:ac4f59839e4f
- Child:
- 123:a49e9ffbaca6
--- a/source/ATCmdManager.cpp Sat Jun 01 15:29:03 2019 +0000 +++ b/source/ATCmdManager.cpp Tue Jun 11 20:23:43 2019 +0000 @@ -283,7 +283,9 @@ { // AT Event state dbg_printf(LOG, "\n [ATCMD MAN] AT_SOCKET_KEEP_ALIVE OK RESPONSE RECEIVED!!\r\n"); - sendAtEvent("\r\nCLOUD CONNECTION OK\r\n"); +#ifdef SEND_CLOUD_OK_MSG + sendAtConfirmation("\r\nCLOUD CONNECTION OK\r\n"); +#endif at_resp = AT_RESP_NONE; break; } @@ -291,7 +293,9 @@ { // AT Event state dbg_printf(LOG, "\n [ATCMD MAN] AT_SOCKET_KEEP_ALIVE FAILED RESPONSE RECEIVED!!\r\n"); +#ifdef SEND_CLOUD_OK_MSG sendAtEvent("\r\nCLOUD CONNECTION FAILED\r\n"); +#endif at_resp = AT_RESP_NONE; break; } @@ -1390,7 +1394,7 @@ break; case AT_EXT_DATA_MODE: { - outputEDMdata((const uint8_t *) buf, len, AT_MSG_ID, EVENT_MSG_TYPE, BLE_CHANNEL); + outputEDMdata((const uint8_t *) buf, len, AT_MSG_ID, EVENT_MSG_TYPE, NO_CHANNEL); break; } default: @@ -1485,7 +1489,30 @@ int msWait = (pLen + 5+20)/20; wait_ms(msWait); } - +void ATCmdManager::filterHttpResponse() +{ + char * respbuf = (char *) resp_data->buffer; + char * strPtr; + char * strPtr2; + dbg_printf(LOG, "Header before trim:\r\n%s\r\n", respbuf); + strPtr = strstr(respbuf, "Date:"); // find start of the last required entry + if(strPtr == NULL) return; + strPtr2 = strstr(respbuf, "Connection:"); // find start of the last required entry + if(strPtr == NULL) return; + if(strPtr2 > strPtr) + { + strPtr = strPtr2; + } + strPtr2 = strstr(strPtr, "\r\n"); // find end of the last required entry + if(strPtr2 == NULL) return; + strPtr = strstr(strPtr2, "\r\n\r\n"); // find start of body + if(strPtr == NULL) return; + int hdrLen = (strPtr - respbuf); + int bytes2trim = (strPtr - strPtr2); + memmove(strPtr2, strPtr, (resp_data->dataLen-(hdrLen-bytes2trim))); + resp_data->dataLen -= bytes2trim; // reduce the length by bytes to trim + dbg_printf(LOG, "Header after trim:\r\n%s\r\n", respbuf); +} void ATCmdManager::return_response(bool download) { char * resp = (char *) resp_data->buffer; dbg_printf(LOG, "\n[ATCMD MAN] received response:\n"); @@ -1497,6 +1524,13 @@ { printBufferInHex((uint8_t *)resp, resp_data->dataLen); } +#ifdef TRIM_AWS_HEADER_ENTRIES + int offset = resp - strstr(resp,"HTTP/1.1"); + if(offset >=0 && offset < 2) // must be at start of header + { + filterHttpResponse(); + } +#endif outputEDMdata((const uint8_t *)resp, resp_data->dataLen, DATA_MSG_ID, EVENT_MSG_TYPE, WIFI_CHANNEL); _wiFi2ATDatamPool->free(resp_data);