![Texas Instruments CC3220 Скачать руководство пользователя страница 142](http://html.mh-extra.com/html/texas-instruments/cc3220/cc3220_programmers-manual_1094609142.webp)
RESTful API Processing
142
SWRU455A – February 2017 – Revised March 2017
Copyright © 2017, Texas Instruments Incorporated
HTTP Server
9.4
RESTful API Processing
The SimpleLink HTTP server recognizes dedicated resource names and treats them as APIs. A POST
request to these names executes the API without any involvement from the host application. All HTTP API
requests must have the encoding of
application/x-www-form-urlencoded
. Most APIs require one or more
parameters. These parameters are passed as part of the message body and have a rigid structure. They
begin with the prefix “__SL_P_”, followed by three characters for the parameter ID, followed by an equal
sign, and then by the parameter value (such as __SL_P_T.A=192.168.10.10).
Several parameters can be chained together with the ampersand operator (such as
__SL_P_T.A=192.168.10.10& postPingSetPktSize=64). Blank spaces that are not part of the parameter
value are not allowed. All parameters relevant to an API should be provided in the body of the same
request. However, if a parameter was omitted, its previously known value is used. This feature is enabled
by default (see
for details).
9.4.1 Ping
The device has a built-in ping utility for testing and troubleshooting network connectivity issues. Ping is
started by posting the following parameters to
/api/1/netapp/ping
, as shown in
Table 9-3. Ping Options
Name (code)
Description
Example
Target IP (__SL_P_T.A)
IPv4 target address of ping requests.
(__SL_P_T.A=192.168.10.10)
Ping packet size (__SL_P_T.B)
Size of the ping payload in bytes (from 1
to 1472).
(__SL_P_T.B=1024)
Packets to send (__SL_P_T.C)
Number of packets to send (from 1 to
255).
(__SL_P_T.C=4)
For example, the following request will send 4 ping packets, each of size 1024 bytes, to IP 10.123.45.2:
POST /api/1/netapp/ping HTTP/1.1
Host: mysimplelink.net
Content-Type: application/x-www-form-urlencoded
__SL_P_T.C=4&__SL_P_T.B=1024&__SL_P_T.A=10.123.45.2
The ping process stops automatically when the requested number of packets is sent. To manually stop it
beforehand, a post request should be sent to
/api/1/netapp/ping_stop
(no parameters are necessary). The
results can be retrieved by requesting the token __SL_G_T.D (see
for details).
9.4.2 IP Configuration
Many IP settings can be configured from the HTTP interface by sending a POST request to either
/api/1/netapp/netcfg_sta
,
/api/1/netapp/netcfg_sta_ipv6
, or
/api/1/netapp/netcfg_ap
URLs with some (or all)
of the parameters listed in
Table 9-4. IP Configurations
Name (code)
Description
Example
STA mode IP (__SL_P_N.A)
Device IP in station mode
(__SL_P_N.A=192.168.10.10)
AP mode IP (__SL_P_N.P)
Device IP in AP mode
(__SL_P_N.P=192.168.10.10)
STA mode netmask (__SL_P_N.B)
Device subnet mask in station mode
(__SL_P_N.B=255.255.255.0)
AP mode netmask (__SL_P_N.Q)
Device subnet mask in access point mode
(__SL_P_N.Q=255.255.255.0)
STA Gateway (__SL_P_N.C)
Network gateway IP in station mode
(__SL_P_N.C=192.168.10.1)
AP Gateway (__SL_P_N.T)
Network gateway IP in AP mode
(__SL_P_N.T=192.168.10.1)
Address of primary STA DNS server
(__SL_P_N.H)
Address of primary DNS server in station
mode
(__SL_P_N.H=8.8.8.8)
Address of primary AP DNS server
(__SL_P_N.U)
Address of primary DNS server in AP
mode
(__SL_P_N.U=8.8.8.8)