我正在PIC单片机接口M95 GSM模块中处理称为HTTP的通信协议。我正在尝试HTTP POST方法。我已经成功发布并阅读了回复。问题是我无法从Api一致地阅读回应。我编写了代码,如果我在发布有效载荷后无法读取响应,我将再次发布相同的有效负载5次以读取响应。我附加的图片可以在发布一个有效负载后看到,我得到了“已创建响应”,但是你看到我在发布5次后没有看到响应。
部分帖子和阅读代码:
bool SendAtCommand_Response(char *command, char *response,int time);
....
SendAtCommand_Response("AT+QHTTPPOST=165,25,10\r","CONNECT",2000);
/*Stream forming*/
sprintf(stream_data,"Speed=0&Imei_no=%s&Battery_voltage=%f&Fuel_voltage=%f&Latitude=%f&Longitude=%f&Ignition=%s&Gps_valid=%s&Utc_Time=%s",imei_no(),bat_vol(),fuel_vol(),gps_lat(),gps_long(),ignition_status(),gps_va(),gps_utc());
printf("Length of stream:=%d\n",strlen(stream_data));
do
{
SendAtCommand_Response(stream_data,"OK",2000);
printf("%s\n",stream_data);
Delayms(500);
clear();
SendAtCommand_Response("AT+QHTTPREAD=30\r","CONNECT",3000);
if(strstr(gprs_buffer,"CREATED"))
{
//uart1str(gprs_buffer);
uart1str("Got created response\r\n");
uart1str("\r\n");
p=5;
}
p++;
}while(p<=4);
clear();
}