httpaction command's response is garbage value from gsm module

MCU USED: STM32F407VGT6
BOARD: STM32F4 Discovery
IDE: TrueStudio
ADDITIONAL: CubeMx
PERIPHERAL: SIM800C GSM Module

H I was trying communicating with website using my stm32 and came to this problem which I am not able to find solution for. I am able to send data to web server using post method.

Here is what I am doing:

Check Modem - AT - OK

Echo Off - ATE0 - OK 

Set Baud - AT+IPR=115200 - OK 

Check Sim - AT+CSMINS? - +CSMINS: 1,1 (if Sim present)

Check Network - AT+CREG?  - +CREG: 0,1 (if Network present)

Attach GPRS - AT+CGATT=1 - OK 

Set Content type - AT+SAPBR=3,1,"CONTYPE","GPRS" - OK

Set APN - AT+SAPBR=3,1,"APN","airtelgprs.com" - OK

Connect GPRS - AT+SAPBR=1,1 - OK

Initiate HTTP - AT+HTTPINIT - OK

Bearer Profile - AT+HTTPPARA="CID","1" - OK

URL - AT+HTTPPARA="URL","myurl.com"

Set Jason - AT+HTTPPARA="CONTENT","application/json" - OK

Place Data - AT+HTTPDATA=<data_len>,<time to input>
eg.  AT+HTTPDATA=124,20000 - wait for DOWNLOAD
Then place the data - OK

send using post - AT+HTTPACTION=1 - +HTTPACTION: 1,200,<response len> (if data sent perfectly)

De-init HTTP - AT+HTTPTERM - OK

GPRS OFF - AT+SAPBR=0,1 - OK

The problem happens occasionally. Sometimes when I send the data using AT+HTTPACTION=1 command I can see the response in the terminal(Tera Term in my case) but MCU misses it to read. So after further debugging my code I found that in that particular command(response), I get garbage values in my receive buffer. As i said the problem is not every time I send the data. Most of the times data is sent perfectly. May be one out of 5 time or 10 time the mcu gets garbage values on that response.

Here is code for receiving the data:

void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
{
    if (huart->Instance == huart2.Instance)
    {
        if (GSM_Data >= 32 && GSM_Data < 127)
            GSM_Buffer[GSM_write_pos++] = GSM_Data;
        if (GSM_write_pos >= 255)   {Stablize_Buffer();}
        HAL_UART_Receive_IT(&huart2, (uint8_t*)&GSM_Data, 1);
    }
}

and this is how i am sending AT+HTPACTION=1 command:

Status Activate_Send_Method(void)
{
    Stablize_Buffer();
    int timeOut = 0;
    HAL_UART_Transmit(&huart2, (uint8_t*)"AT+HTTPACTION=1\r\n", strlen("AT+HTTPACTION=1\r\n"), 1000);
    HAL_UART_Receive_IT(&huart2, (uint8_t*)&GSM_Data, 1);
    HAL_Delay(100);

    if (strstr((char*)GSM_Buffer, "OK"))
    {
        Stablize_Buffer();
        while (timeOut < 1000)
        {
            HAL_UART_Receive_IT(&huart2, (uint8_t*)&GSM_Data, 1);
            timeOut++;
            if (strstr((char*)GSM_Buffer,"200"))    {Stablize_Buffer(); return OK;}
            if (strstr((char*)GSM_Buffer,"601"))    {Stablize_Buffer(); return ERR;}
            if (strstr((char*)GSM_Buffer,"604"))    {Stablize_Buffer(); return ERR;}
            if (strstr((char*)GSM_Buffer,"603"))    {Stablize_Buffer(); return ERR;}
            if (strstr((char*)GSM_Buffer,"500"))    {Stablize_Buffer(); return ERR;}
            HAL_Delay(86);
        }
    }
    Stablize_Buffer();
    return ERR;
}

My other commands are successfully read. Only this response is having this kind of error. This is the only reason I am not able to understand what should i do. Is this some coding issue or circuit issue.?

The response is an important component as it is the only thing that determines weather my data is sent or not. Which will further determine that i need to send that data again or not.

Increase timeout of HTTPACTION command. It takes long to execute.

actually i don’t have any problem with time period. The case is i can receive the response I can see it in terminal but my rx buffer gets garbage value.

Are you seeing in Arduino terminal? or other terminal softwares?
If buffer is having garbage, mostly it will be wrong pointers.

AT+IPR=115200 CHANGE it to 19200 then turn it off and turn it on again it will work