SIM7000E - 带有 AT 命令的 HTTP POST

SIM7000E - HTTP POST with AT Commands

我正在使用 SIM7000E 模块,我通过 UART 向其发送 AT 命令。我配置发送以下命令集的模块:

AT+CPIN=1234
AT+CREG=1
AT+CGATT=1
AT+CIPSTATUS
AT+CIPMUX=0
AT+CSTT="vpn","user","password"
AT+CIICR
AT+CIFSR
AT+CIPSTART="TCP","xxx.xxx.xxx.xxx","80"

在此之前一切正常。

但是,我想使用 POST 方法注册一个变量:

AT+CIPSEND  
> POST /register.node#1 HTTP/1.1
Host: xxx.xxx.xxx.xxx
Content-Type: application/x-www-form-urlencoded
cache-control: no-cache
Postman-Token: be423989-072e-4262-857a-f985157ec720
(Empty line)
(Ctrl+z)

C中的命令是:

"POST /register.node#1 HTTP/1.1\r\nHost: xxx.xxx.xxx.xxx\r\nContent-Type: application/x-www-form-urlencoded\r\ncache-control: no-cache\r\nPostman-Token: be423989-072e-4262-857a-f985157ec720\r\n\r\n"

我得到的回复是:

SEND OK
HTTP/1.1 400 Bad Request
Date: Wed, 21 Nov 2018 21:54:00 GMT
Server: Apache/2.4.25 (Debian)
Content-Length: 295
Connection: close
Content-Type: text/html; charset=iso-8859-1

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
 <html>
        <head>
              <title>400 Bad Request</title>
        </head>
        <body>                                                                                                    
              <h1>Bad Request</h1>

              <p>Your browser sent a request that this server could not understand.<br/>
              </p>
              <hr>

              <address>Apache/2.4.25 (Debian) Server at ::1 Port 80</address>

        </body>
</html>

CLOSED

我不知道代码有什么问题。我下载了 Postman 应用程序,制作了相同的 POST 并且它按预期工作:

您可以尝试 AT+HTTPPARA 命令。您可以使用此命令为其提供 url,并指定 USERDATA 以使用这些命令进行发布,以及其他请求 headers。

AT+HTTPPARA="URL","website.com"
AT+HTTPPARA="USERDATA","KEY=VALUE&KEY=VALUE"
AT+HTTPACTION=2 #this says submit as a POST request
AT+HTTPREAD #returns the reply from the server