我正在使用PIC24F微控制器中的HTTP协议与M95 quectel调制解调器连接。
我正在尝试" POST"方法。我已经阅读了quectel的HTTP协议数据表。
以下是发送HTTP post Request AT命令:
AT+QIFGCNT
AT+QHTTPURL
AT+QHTTPPOST
AT+QHTTPREAD
AT+QIDEACT
我根据此流程序列编写代码。我把这些命令放在无限循环中。 好的,我第一次成功地从服务器读取响应,但后来我收到类似" http响应失败的错误"要么 " http没有请求"在AT + QHTTPREAD。
我是否必须重复整个HTTP post AT命令,或者我只是重复AT + QHTTPREAD?
CODE:
bool SendAtCommand_Response(char *command, char *response,int Delay);
while(1)
{
SendAtCommand_Response("AT\r","OK",500);
uart1str("Modem is ready\r\n");
Delayms(2000);
uart1str("\r\n");
clear(); //clear response buffer
SendAtCommand_Response("AT+CPIN?\r","OK",2000);
Delayms(300);
uart1str("\r\n");
clear();
SendAtCommand_Response("AT+QIFGCNT=0\r","OK",500);
Delayms(300);
uart1str("\r\n");
clear();
SendAtCommand_Response("AT+QICSGP=1,\"airtelGPRS.com\"\r","OK",500);
Delayms(500);
uart1str("APN is set\r\n");
uart1str("\r\n");
clear();
SendAtCommand_Response("AT+QHTTPURL=37,30\r","CONNECT",500);
uart1str("URL is set\r\n");
clear();
SendAtCommand_Response(HTTP_POST_URL_HS ,"OK",500);
Delayms(500);
uart1str("URL Sent\r\n");
clear();
SendAtCommand_Response("AT+QHTTPPOST=22,25,10\r","CONNECT",1000);
Delayms(1000);
uart1str("\r\n");
clear();
SendAtCommand_Response("imeino=865733024598757","OK",100);
Delayms(1000);
uart1str("HTTP data sent\r\n");
uart1str("\r\n");
clear();
SendAtCommand_Response("AT+QHTTPREAD=30\r","CONNECT",3000);
Delayms(200);
clear();
SendAtCommand_Response("AT+QIDEACT\r","DEACT OK",500);
Delayms(200);
clear();
}
答案 0 :(得分:0)
如果您使用相同的URL,则无需使用,只需从AT + QHTTPPOST开始。
如果将另一个URL用于其他内容,则从AT + GHTTPURL开始