Gateway devices can enable, disable, or delete sub-devices.
Disables a sub-device
The following topics are used when IoT Platform sends requests to a device and the device sends responses to IoT Platform:
- Request topic:
/sys/${productKey}/${deviceName}/thing/disable. - Response topic:
/sys/${productKey}/${deviceName}/thing/disable_reply.
A gateway device can disable a sub-device by using the preceding topics. IoT Platform sends a message to the request topic in an asynchronous manner to instruct a gateway device to disable a sub-device. The sub-device subscribes to the request topic by using the gateway device. Then, the sub-device can obtain the message from the request topic.
Sample request in the Alink JSON format:
{
"id": "123",
"version": "1.0",
"params": {},
"method": "thing.disable"
}Sample response in the Alink JSON format:
{
"id": "123",
"code": 200,
"data": {}
}The following table describes the parameters.
| Parameter | Type | Description |
|---|---|---|
| id | String |
The ID of the message. Valid values: 0 to 4294967295. Each message ID must be unique for the device. |
| version | String | The version of the protocol. Valid value: 1.0. |
| params | Object | The request parameters. You can leave the params parameter empty. |
| method | String | The request method. Valid value: thing.disable. |
| code | Integer | The status code in the response. For more information, see Common codes on devices. |
Enable a sub-device that is disabled
The following topics are used when IoT Platform sends requests to a device and the device sends responses to IoT Platform:
- After a gateway sub-device is connected to IoT Platform over MQTT, the sub-device must subscribe to topics by using the gateway device. Then, the sub-device can obtain messages from the topics. If a sub-device is disabled, the sub-device is in the offline state and cannot obtain messages from the topics to which the sub-device subscribes. A disabled gateway sub-device cannot be enabled by using the following topics. To enable the sub-device, you must modify the topological relationship. For more information about topics, see Notify gateways of changes of topological relationships.
- After a device is connected to IoT Platform by using the IoT as Bridge SDK, the device can receive downstream messages without the need to subscribe to topics. If a sub-device is disabled, the following topics can be used to enable the sub-device:
- Request topic:
/sys/${productKey}/${deviceName}/thing/enable. - Response topic:
/sys/${productKey}/${deviceName}/thing/enable_reply.
A gateway device can enable a disabled sub-device by using the preceding topics. IoT Platform sends a message to the request topic in an asynchronous manner to instruct a gateway device to enable a sub-device. The sub-device subscribes to the request topic and obtains the message from the request topic.
Sample request in the Alink JSON format:
{
"id": "123",
"version": "1.0",
"params": {},
"method": "thing.enable"
}Sample response in the Alink JSON format:
{
"id": "123",
"code": 200,
"data": {}
}Parameter description
| Parameter | Type | Description |
|---|---|---|
| id | String |
The ID of the message. Valid values: 0 to 4294967295. Each message ID must be unique for the device. |
| version | String | The version of the protocol. Valid value: 1.0. |
| params | Object | The request parameters. You can leave the params parameter empty. |
| method | String | The request method. Valid value: thing.enable. |
| code | Integer | The status code in the response. For more information, see Common codes returned by devices. |
Delete a sub-device
The following topics are used when IoT Platform sends requests to a device and the device sends responses to IoT Platform:
- Request topic:
/sys/${productKey}/${deviceName}/thing/delete. - Response topic:
/sys/${productKey}/${deviceName}/thing/delete_reply.
A gateway device can delete a sub-device by using the preceding topics. IoT Platform sends a message to the request topic in an asynchronous manner to instruct a gateway device to delete a sub-device. The sub-device subscribes to the request topic by using the gateway device. Then, the sub-device can obtain the message from the request topic.
Sample request in the Alink JSON format:
{
"id": "123",
"version": "1.0",
"params": {},
"method": "thing.delete"
}Sample response in the Alink JSON format:
{
"id": "123",
"code": 200,
"data": {}
}The following table describes the parameters.
| Parameter | Type | Description |
|---|---|---|
| id | String |
The ID of the message. Valid values: 0 to 4294967295. Each message ID must be unique for the device. |
| version | String | The version of the protocol. Valid value: 1.0. |
| params | Object | The request parameters. You can leave the params parameter empty. |
| method | String | The request method. Valid value: thing.delete. |
| code | String | The status code in the response. For more information, see Common codes returned by devices. |