Send command
Request format: POST
URL: http://api.onenet.hk.chinamobile.com/cmds
URL Parameters
Name |
Format |
Required or not |
Description |
device_id |
string |
Yes |
ID of the device receiving the data |
timeout |
int |
No |
Command validity period, 0 by default. 0: Online command. If the device is online, the command will be sent to the device. If the device is offline, the command will be discarded directly. >0: Offline command. If the device is online, the command will be sent to the device. If the device is offline, the command will be valid within the current time plus timeout. If the device is online within the validity period, the command will be sent to the device. Unit: second Valid range: 0-2678400 |
http body content
User-defined data: json, string, binary data (less than 64K)
http request return parameters
Name |
Format |
Description |
errno |
int |
Call error code, where 0 means success. |
error |
string |
Error description. “succ” means the call is successful. |
data |
json |
Device-related information returned after interface is successfully called. See the Data Description Table. |
Data Description Table
Name |
Format |
Description |
cmd_uuid |
string |
Command id, unique within the platform |
Request Example 1
POST http://api.onenet.hk.chinamobile.com/cmds?device_id=8029377 HTTP/1.1
api-key: l2aH*************BRtAo=
<this is a command>
Return example 1: Successfully create a command.
{
"errno": 0,
"error": "succ",
"data": {
"cmd_uuid": "81572aae-fc34-5deb-8f06-ab45d73cb12b"
}
}
Return example 2: The device is offline.
{
"errno": 10,
"error": "device not online: 8029377"
}
Request example 2: Send offline command
POST http://api.onenet.hk.chinamobile.com/cmds?device_id=8029377&timeout=3600 HTTP/1.1
api-key: l2aH*************BRtAo=
<this is a command>
Return example
{
"errno": 0,
"error": "succ",
"data": {
"cmd_uuid": "81572aae-fc34-5deb-8f06-ab45d73cb12b"
}
}