Deleting a Device

API Function

This API is used to delete indirectly connected devices from the platform.

API Description

1
HW_INT IOTA_HubDeviceRemove(HW_UINT uiCookie, const HW_CHAR *pcDeviceId);

Parameter Description

Parameter

Mandatory or Optional

Type

Description

uiCookie

Optional

HW_UINT

The value ranges from 1 to 65535.

pcDeviceId

Mandatory

String

Identifier of a device. The value must end with \0.

Return Value

For details, see Function Return Values.

Output

Broadcast Name

Broadcast Parameter

Member

Description

IOTA_TOPIC_HUB_RMVDEV_RSP

HW_MSG object

EN_IOTA_HUB_IE_TYPE

Device deletion result.

EN_IOTA_HUB_IE_TYPE:

Enumerated Item

Value

Type

Description

EN_IOTA_HUB_IE_RESULT

0

EN_IOTA_HUB_RESULT_TYPE

Device addition or deletion result.

EN_IOTA_HUB_IE_DEVICEID

1

String

Identifier of the device assigned after successful addition.

EN_IOTA_HUB_RESULT_TYPE:

Enumerated Item

Value

Description

EN_IOTA_HUB_RESULT_SUCCESS

0

The device is added or deleted.

EN_IOTA_HUB_RESULT_DEVICE_EXIST

1

The device already exists.

EN_IOTA_HUB_RESULT_DEVICE_NOTEXIST

2

The device does not exist.

EN_IOTA_HUB_RESULT_DEVICE_FAILED

255

The execution fails.

Example

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
// Call this API to delete a device.
HW_cHAR *pcDeviceId = stDevice.pcDeviceId;
IOTA_HubDeviceRemove(HW_NULL, pcDeviceId);
The caller waits for the result.
HW_iNT Device_RemoveResultHandler(HW_UiNT uiCookie, HW_MSG pstMsg) 
{
    uiResult = HW_MsgGetUint (pstMsg, EN_IOTA_HUB_IE_RESULT);
    if (EN_IOTA_HUB_RESULT_SUCCESS != uiResult) 
    {
        // retry with uiCookie 
        return 0;
    }
    return 0;
}
HW_BroadCastReg("IOTA_TOPIC_HUB_RMVDEV_RSP", Device_RemovResultHandler);