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:
- 105:e5ce023eee93
- Parent:
- 104:11e9605093c9
- Child:
- 107:f1a83fd41b17
--- a/source/ATCmdManager.cpp Sun May 05 08:24:46 2019 +0000 +++ b/source/ATCmdManager.cpp Mon May 06 09:06:36 2019 +0000 @@ -219,7 +219,7 @@ dbg_printf(LOG, "\n [ATCMD MAN] WIFI HTTPS DOWNLOAD RESPONSE RECEIVED!!\r\n"); return_response(true); // set download paramter to true //_smutex.lock(); - sendAtConfirmation(OK_RESP); //_parser.send(OK_RESP); + //sendAtConfirmation(OK_RESP); //_parser.send(OK_RESP); //_smutex.unlock(); at_resp = AT_RESP_NONE; break; @@ -317,7 +317,7 @@ void ATCmdManager::sendConnectIndicationFreeMpool(const char *buf) { int len = strlen(buf); - outputEDMdata((const uint8_t *) buf, len, AT_MSG_ID, INDICATION_MSG_TYPE, NO_CHANNEL); + outputEDMdata((const uint8_t *) buf, len, AT_MSG_ID, CONFIRMATION_MSG_TYPE, NO_CHANNEL); _wiFi2ATDatamPool->free(resp_data); resp_data = NULL; } @@ -406,7 +406,9 @@ { n = sscanf(nxtPtr,"%s %s %s", s1, s2, s3); if(n!=3) return false; // error in input abort +#ifdef FULL_DEBUG_ENABLED dbg_printf(LOG, "\nmethod = %s\nuri = %s\nhttp_ver = %s",s1, s2, s3 ); +#endif //http_req.method = str2HttpMethod(s1.c_str()); http_req->method = str2HttpMethod(s1); http_req->request_URI = (char *) http_req->buffer; // point 1st string to start of buffer @@ -415,11 +417,13 @@ http_req->http_version = http_req->request_URI + len; // point 2nd string to after 1st len = strlen(s3)+1; strncpy(http_req->http_version, s3, len); +#ifdef FULL_DEBUG_ENABLED dbg_printf(LOG, "\nhttp_request 1st line:\n method = %d\nuri = %s\nhttp_ver = %s",http_req->method, http_req->request_URI, http_req->http_version ); dbg_printf(LOG, "\nhttp_request str ptrs\nuri = %X\nhttp_ver = %X",http_req->request_URI, http_req->http_version ); +#endif outPtr = http_req->http_version + len; // point output buffer ptr to after 2nd string } else{ // scan header pairs @@ -428,7 +432,9 @@ if(n!=2) return false; // error in input abort p = strstr(s1,":"); *p = NULL; +#ifdef FULL_DEBUG_ENABLED dbg_printf(LOG, "\nname = %s value = %s",s1, s2); +#endif if(strstr(s1, "Host")!= NULL){ http_req->hostName = outPtr; #ifdef BOX_UBLOX_DEMO_TESTING @@ -443,21 +449,27 @@ len = strlen(s2)+1; strncpy(outPtr, s2, len); #endif +#ifdef FULL_DEBUG_ENABLED dbg_printf(LOG, "\nname = %s value = %s",s1, outPtr); +#endif outPtr += len; // point output buffer ptr to after current string } else if(strstr(s1, "Accept")!= NULL){ http_req->AcceptVal = outPtr; len = strlen(s2)+1; strncpy(outPtr, s2, len); +#ifdef FULL_DEBUG_ENABLED dbg_printf(LOG, "\nname = %s value = %s",s1, outPtr); +#endif outPtr += len; // point output buffer ptr to after current string } else if(strstr(s1, "Content-Type")!= NULL){ http_req->contentType = outPtr; len = strlen(s2)+1; strncpy(outPtr, s2, len); +#ifdef FULL_DEBUG_ENABLED dbg_printf(LOG, "\nname = %s value = %s",s1, outPtr); +#endif outPtr += len; // point output buffer ptr to after current string } else if(strstr(s1, "Content-Length")!= NULL){ @@ -465,19 +477,27 @@ http_req->contentLen = outPtr; len = strlen(s2)+1; strncpy(outPtr, s2, len); +#ifdef FULL_DEBUG_ENABLED dbg_printf(LOG, "\nname = %s value = %s",s1, outPtr); +#endif outPtr += len; // point output buffer ptr to after current string } +#ifdef FULL_DEBUG_ENABLED dbg_printf(LOG, "\noutPtr = %X len = %d\n", outPtr, len); +#endif } nxtPtr = strstr(nxtPtr, "\r\n")+2; // goto next line if(nxtPtr >= p2) break; } // print header from http_req_struct +#ifdef FULL_DEBUG_ENABLED dbg_printf(LOG, "\nhttp request header: \n %s\n", http_req->buffer); +#endif int bodyLen = edm_hdr.payloadLen -(p2+7-strPtr); +#ifdef FULL_DEBUG_ENABLED dbg_printf(LOG, "\nLen = %d\n", bodyLen); +#endif http_req->body = (uint8_t *) outPtr; memcpy(outPtr, bodyPtr, bodyLen); if(bodyLen > 10){ @@ -487,9 +507,11 @@ outPtr += bodyLen; // move output pointer to end output (header + body) // package and send on wifi data queue data_msg.wifi_cmd = WIFI_CMD_SEND_HTTPS_REQ; + data_msg.dataLen = (uint8_t *)outPtr - http_req->buffer;//sizeof(http_request_t); +#ifdef FULL_DEBUG_ENABLED dbg_printf(LOG, "\nsizeof(http_req) on population = %d\n", sizeof(*http_req)); - data_msg.dataLen = (uint8_t *)outPtr - http_req->buffer;//sizeof(http_request_t); dbg_printf(LOG, "\ndata_msg.dataLen = %d\n", data_msg.dataLen); +#endif // queue next data request if(queueWiFiDataRequest(data_msg) == true) {