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:
- 127:a21788227ca6
- Parent:
- 126:9bc33f8b57d5
- Child:
- 128:3a641aaad2d9
- Child:
- 129:590bdc2dcf5b
--- a/source/ATCmdManager.cpp Sun Jul 07 20:36:41 2019 +0000 +++ b/source/ATCmdManager.cpp Mon Jul 15 21:37:22 2019 +0000 @@ -90,13 +90,14 @@ _parser.oob("AT+UFACTORY", callback(this, &ATCmdManager::_oob_factoryReset)); _parser.oob("AT+UDELCFG=", callback(this, &ATCmdManager::_oob_deleteConfiguration)); + _parser.oob("AT+SDBGFLG", callback(this, &ATCmdManager::_oob_set_debug_flag)); //_parser.oob("AT+UWSC=0,5", callback(this, &ATCmdManager::_oob_sendHttpMessage)); //sendAtConfirmation("Testing:: +UBTLE:2\r\nOK\r\n"); dbg_printf(LOG, "\n --- ATCmdManager constructor completed ---\n"); at_resp = AT_RESP_NONE; dataMode = AT_CMD_DATA_MODE; - debug_flag = 0; + debug_flags_map = 0; wifiStateControl = AT_RESP_NONE; //_event_queue.call_in(10, &print_heap_and_isr_stack_info); //print_heap_and_isr_stack_info(); @@ -451,6 +452,7 @@ } wifiBusyTimeOut = 0; #endif + bool full_debug_ena = (debug_flags_map & ATCMD_MGR_FULL_DEBUG_ENA) != 0x00; http_request_t *http_req; // = new http_request_t; wifi_data_msg_t data_msg; http_req = (http_request_t *)data_msg.buffer; @@ -472,9 +474,10 @@ { 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 + if(full_debug_ena) + { + dbg_printf(LOG, "\nmethod = %s\nuri = %s\nhttp_ver = %s",s1, s2, s3 ); + } //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 @@ -483,13 +486,14 @@ 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 + if(full_debug_ena) + { + 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 ); + } outPtr = http_req->http_version + len; // point output buffer ptr to after 2nd string } else{ // scan header pairs @@ -497,9 +501,10 @@ 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(full_debug_ena) + { + dbg_printf(LOG, "\nname = %s value = %s",s1, s2); + } if(strstr(s1, "Host")!= NULL){ http_req->hostName = outPtr; #ifdef BOX_UBLOX_DEMO_TESTING @@ -514,54 +519,74 @@ len = strlen(s2)+1; strncpy(outPtr, s2, len); #endif -#ifdef FULL_DEBUG_ENABLED - dbg_printf(LOG, "\nname = %s value = %s",s1, outPtr); -#endif + if(full_debug_ena) + { + dbg_printf(LOG, "\nname = %s value = %s",s1, outPtr); + } 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 + if(full_debug_ena) + { + dbg_printf(LOG, "\nname = %s value = %s",s1, outPtr); + } 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 + if(full_debug_ena) + { + dbg_printf(LOG, "\nname = %s value = %s",s1, outPtr); + } outPtr += len; // point output buffer ptr to after current string } else if(strstr(s1, "Content-Length")!= NULL){ 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 + if(full_debug_ena) + { + dbg_printf(LOG, "\nname = %s value = %s",s1, outPtr); + } + outPtr += len; // point output buffer ptr to after current string + } + else if(strstr(s1, "X-Amz-Target")!= NULL){ + http_req->X_Amz_Target = outPtr; + len = strlen(s2)+1; + strncpy(outPtr, s2, len); + if(full_debug_ena) + { + dbg_printf(LOG, "\nname = %s value = %s",s1, outPtr); + } 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 + + + if(full_debug_ena) + { + dbg_printf(LOG, "\noutPtr = %X len = %d\n", outPtr, len); + } } 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 + if(full_debug_ena) + { + dbg_printf(LOG, "\nhttp request header: \n %s\n", http_req->buffer); + } int bodyLen = edm_hdr.payloadLen -(p2+7-strPtr); -#ifdef FULL_DEBUG_ENABLED - dbg_printf(LOG, "\nLen = %d\n", bodyLen); -#endif + if(full_debug_ena) + { + dbg_printf(LOG, "\nLen = %d\n", bodyLen); + } + uint32_t msecsSinceLastMsg = Kernel::get_ms_count() - lastHttpRespTime; if((lastCloudMsgType == BAR_DB_MSGTYPE || lastCloudMsgType == REC_DB_MSGTYPE) && lastCloudMsgType == (uint8_t) bodyPtr[8] && @@ -580,10 +605,11 @@ // 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)); - dbg_printf(LOG, "\ndata_msg.dataLen = %d\n", data_msg.dataLen); -#endif + if(full_debug_ena) + { + dbg_printf(LOG, "\nsizeof(http_req) on population = %d\n", sizeof(*http_req)); + dbg_printf(LOG, "\ndata_msg.dataLen = %d\n", data_msg.dataLen); + } // queue next data request if(queueWiFiDataRequest(data_msg) == true) { @@ -844,6 +870,17 @@ #endif } + +void ATCmdManager::_oob_set_debug_flag() +{ + int rdFlag; + if(_parser.scanf("=%3d", &rdFlag) >0) + { + debug_flags_map = rdFlag; + dbg_printf(LOG, "\n Changing debug_flags_map to %d %d\n", rdFlag, debug_flags_map); + sendAtConfirmation(OK_RESP); + } +} #define TTP_DEBUGGING #define TTP_DEBUGGING_UART_NOCHANGE void ATCmdManager::_oob_uart_setup(){ @@ -1329,8 +1366,6 @@ wifiCmd->wifi_cmd = cmd; _aT2WiFiCmdQueue->put(wifiCmd); dbg_printf(LOG, "[ATCMD MAN] queued wifi_cmd = %d\n", wifiCmd->wifi_cmd); - if((int)cmd == 5) - debug_flag = 3; return true; }