Deleting a Device
API Function
This API is used to delete indirectly connected devices from the IoT platform when a new device needs to be removed from the gateway.
API Description
1 | public static boolean rmvDevice(int cookie, String deviceId);
|
Class
HubService
Parameter Description
| Parameter | Mandatory or Optional | Type | Description |
|---|---|---|---|
| cookie | Optional | int | The value ranges from 1 to 65535. |
| deviceId | Mandatory | String | Identifies a device. |
Return Value
| Return Value | Description |
|---|---|
| true | Success |
| false | Failure |
Return values only show API calling results. For example, the return value true indicates that the API is called successfully but does not indicate that the device is deleted successfully. The device is deleted successfully only after the TOPIC_RMVDEV_RSP broadcast is received.
Output
| Broadcast Name | Broadcast Parameter | Member | Description |
|---|---|---|---|
| TOPIC_ RMVDEV_RSP | IotaMessage (Obtained by using intent.getSerializableExtra(HubService.HUB_BROADCAST_IE_IOTAMSG)) | HUB_IE_RESULT | Specifies the device deleting result. |
| HUB_IE_COOKIE | The value ranges from 1 to 65535. |
Example
Call this API to delete a device.
1 | HubService.rmvDevice(122, deviceId);
|
The device waits for the result.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | //java code
BroadcastReceiver mRmvdeviceRsp;
mRmvdeviceRsp = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
//Do Something
IotaMessage iotaMsg = (IotaMessage)intent.getSerializableExtra(HubService. HUB_BROADCAST_IE_IOTAMSG);
int result = iotaMsg.getUint(HubService.HUB_IE_RESULT, 0);
int cookie = iotaMsg.getUint(HubService.HUB_IE_COOKIE, 0);
return;
}
};
mLocalBroadcastManager = LocalBroadcastManager.getInstance(this);
IntentFilter filterRmvDev = new IntentFilter(HubService.TOPIC_RMVDEV_RSP);
mLocalBroadcastManager.registerReceiver(mDeldeviceRsp, filterRmvDev);
|
What is your overall rating for this page?
Thank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot