HTTP指令
AT+HTTPTLS 设置HTTPS的TLS
Command | Possible response(s) |
+HTTPTLS=<tls> | OK ERROR |
+HTTPTLS? | +HTTPTLS:0 OK |
+HTTPTLS=? | +HTTPTLS:(0-1) OK |
参数
<tls> tls使能
-
0: 非tls
-
1: tls
注:在执行HTTPS后,硬件若未重新上电或者主动更改tls的值来执行HTTP,tls保持为1。
举例
发→◇AT+HTTPTLS=? 收←◆+HTTPTLS:(0-1) 收←◆OK
发→◇AT+HTTPTLS=1 //使能HTTPS 收←◆OK
发→◇AT+HTTPTLS? //查询HTTPS的TLS参数 收←◆+HTTPTLS:1 收←◆OK
AT+HTTPPARA 设HTTP参数
Command | Possible response(s) |
+HTTPPARA=[<httpparatag>:<httpparavalue>] | OK ERROR |
+HTTPPARA? | |
+HTTPPARA=? |
该命令用于HTTP 参数配置<httpparavalue> 参数说明:根据<httpparatag>参数类型给数据。
参数
<httpparatag>参数说明:
<URL>:必选参数,客户端 URL(http:\xxxx 或者 192.168.1.1或者192.168.1.1:80或者http:\xxxx:80),最长参数1024字节;
<PORT>: HTTP代理服务器的端口;
<TIMEOUT>:HTTP超时时间,默认时间50S;
<USRE>:HTTP user数据,最大长度512字节,(数据中“\r\n”需要转义)同AT+HTTPDATA;
<BODY>:HTTP body参数,最大长度512字节;
<MODE>:HTTP 数据主动读模式(0)和数据上报模式(>0)。
举例
发→◇AT+HTTPPARA =? 收←◆+HTTPPARA: [<httpparatag>:<httparavalue>] 收←◆OK
发→◇AT+HTTPPARA =xx,xxx //设置参数 收←◆OK
AT+HTTPDATA HTTP数据
Command | Possible response(s) |
+HTTPDATA=[<lent>,<data>] | OK ERROR |
+HTTPDATA=? | +HTTPDATA:<lent>,<data> |
参数
<lent>: http数据的长度
<data>:http数据
举例
发→◇AT+HTTPDATA=? 收←◆+HTTPDATA: <lent>,<data> 收←◆OK
发→◇AT+HTTPDATA=1,X 收←◆OK
AT+HTTPACTION HTTP激活模式
Command | Possible response(s) |
+HTTPACTION=<mode> | +HTTPACTION=<STATE>,<LENT> OK ERROR |
+HTTPACTION=? | +HTTPACTION:<mode> |
参数
<mode>激活模式:
- 0:get方式
- 1:head方式
- 2:put方式
- 3:post方式
<STATE> 返回HTTP响应状态;
- 0:HTTP操作成功
- 非0:失败错误码
<LENT> 返回HTTP后有效数据的长度
举例
发→◇AT+HTTPACTION=? 收←◆+HTTPACTION: (0-3) 收←◆OK
发→◇AT+HTTPACTION=0 收←◆+HTTPACTION=0,192 收←◆OK
AT+HTTPREAD 读取HTTP响应数据
Command | Possible response(s) |
+HTTPREAD | +HTTPREAD=<lent>,<data> OK ERROR |
+HTTPREAD=? | +HTTPREAD |
参数
<lent>: 读取的http数据的长度
<data>: 读取的http数据
举例
发→◇AT+HTTPREAD=? 收←◆+HTTPREAD 收←◆OK
发→◇AT+HTTPREAD //HTTP 读取响应数据 收←◆+HTTPREAD:XXX,XXX 收←◆OK
AT+HTTPTERM 关闭HTTP
Command | Possible response(s) |
+HTTPREAD | OK ERROR |
举例
发→◇AT+ HTTPTERM 收←◆OK
HTTP错误码
code | mean |
---|---|
0 | a successful operation |
101 | An invalid parameter was passed into an API function |
102 | Invalid payload |
103 | HTTPS message was too large to fit into a configured synchronous body buffer |
104 | Overflow occurred somewhere |
105 | A buffer provided could not hold data required by the library |
106 | Queue full |
107 | Operation retry. |
108 | Could not find an item specified by an API. Returned for not being able to find the address in a URL, the path in a URL, or a header field from the response headers. |
109 | The HTTP request message was finished being written and we cannot write more with @ref https_client_function_writerequestbody. |
201 | An error occurred internally to the library. |
202 | A network error occurred |
203 | A network connection error occurred. |
204 | A stream error occurred. |
205 | An authentication error occurred. |
206 | A TLS error occurred |
207 | An error occurred during the user callback. |
208 | The synchronous response could not be received in the specified timeout in @ref https_client_function_sendsync. |
209 | An error in the HTTP protocol. |
210 | The HTTPS request send was cancelled. |
211 | The HTTPS response receiving was cancelled. |
212 | The asynchronous request had an error being scheduled. |
213 | There was an error parsing the HTTP response |
901 | Fatal HTTP library error. |
902 | The connection is busy and cannot be cleaned up. The connection was closed, but @ref https_client_function_disconnect must be called again to cleanup connection resources. |
903 | Try again |
904 | Data exists. |
905 | The operation on the public API is not supported. |