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:
CheckModem- AT - OK
EchoOff- ATE0 - OK
SetBaud- AT+IPR=115200- OK
CheckSim- AT+CSMINS?-+CSMINS:1,1(ifSim present)
CheckNetwork- AT+CREG?-+CREG:0,1(ifNetwork present)
Attach GPRS - AT+CGATT=1- OK
SetContent 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
BearerProfile- AT+HTTPPARA="CID","1"- OK
URL - AT+HTTPPARA="URL","myurl.com"
SetJason- AT+HTTPPARA="CONTENT","application/json"- OK
PlaceData- 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=1command 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:
and this is how i am sending AT+HTPACTION=1 command:
Here is the screenshot of what happens in terminal
You can see i have received the response in terminal but this response is shown as garbage in debug. And this doesn't even happen always. It occurs sometimes then again for sometime everything is working just as expected.
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 what i need to do with this data.
Any suggestions will be really helpful
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:
CheckModem- AT - OK
EchoOff- ATE0 - OK
SetBaud- AT+IPR=115200- OK
CheckSim- AT+CSMINS?-+CSMINS:1,1(ifSim present)
CheckNetwork- AT+CREG?-+CREG:0,1(ifNetwork present)
Attach GPRS - AT+CGATT=1- OK
SetContent 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
BearerProfile- AT+HTTPPARA="CID","1"- OK
URL - AT+HTTPPARA="URL","myurl.com"
SetJason- AT+HTTPPARA="CONTENT","application/json"- OK
PlaceData- 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=1command 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:
C:
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);
}
}
C:
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,"200")) {Stablize_Buffer(); return ERR;}
if (strstr((char*)GSM_Buffer,"200")) {Stablize_Buffer(); return ERR;}
if (strstr((char*)GSM_Buffer,"200")) {Stablize_Buffer(); return ERR;}
HAL_Delay(50);
}
}
Stablize_Buffer();
return ERR;
}

You can see i have received the response in terminal but this response is shown as garbage in debug. And this doesn't even happen always. It occurs sometimes then again for sometime everything is working just as expected.
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 what i need to do with this data.
Any suggestions will be really helpful