Updating the Device Status
API Function
This API is used to update status information about devices, including directly and indirectly connected devices managed by the IoT platform. The device status can be updated through this API when the device is offline or online.
The status of directly connected devices is updated based on the device login status. If a directly connected device is disconnected from the IoT platform, its status becomes offline. If a directly connected device is connected or reconnected to the IoT platform, its status becomes online and does not need to be updated through this API. Therefore, it is recommended that you call this API to update the status of indirectly connected devices.
API Description
1 | HW_INT IOTA_DeviceStatusUpdate(HW_UINT uiCookie, const HW_CHAR *pcDeviceId, const HW_CHAR *pcStatus, const HW_CHAR *pcStatusDetail);
|
Parameter Description
| Parameter | Mandatory or Optional | Type | Description |
|---|---|---|---|
| uiCookie | Optional | HW_UINT | The value ranges from 1 to 65535. |
| pcDeviceId | Mandatory | HW_CHAR | Identifier of a device. The value must end with \0. |
| pcStatus | Mandatory | HW_CHAR | Device status. The value must end with \0.
|
| pcStatusDetail | Mandatory | HW_CHAR | Details about device status. The value must end with \0.
|
Return Value
For details, see Function Return Values.
Output
| Broadcast Name | Broadcast Parameter | Member | Description |
|---|---|---|---|
| IOTA_TOPIC_DEVUPDATE_RSP/{deviceId} | HW_MSG object | None | Device status update result. |
EN_IOTA_DEVUPDATE_IE_TYPE:
| Enumerated Item | Value | Type | Description |
|---|---|---|---|
| EN_IOTA_DEVUPDATE_IE_RESULT | 0 | unsigned int | Command execution result.
|
| EN_IOTA_DEVUPDATE_IE_DEVICEID | 1 | String | Identifier of a device. |
Example
1 2 3 | HW_CHAR *pcDeviceId = stDevice.pcDeviceId;
IOTA_DeviceStatusUpdate(0, pcDeviceId, "ONLINE", "NONE");
|
The device waits for the command execution result.
1 2 3 4 5 6 7 8 9 | //Call this API to register the function for subsequent processing after the device is updated.
HW_iNT Device_StatusUpdateHandler(HW_UiNT uiCookie, HW_MSG pstMsg)
{
HW_cHAR pcCmdContentl;
pcCmdContent = HW_MsgGetStr(pstMsg, EN_IOTA_DEVUPDATE_IE_RESULT);
pcCmdContent = HW_MsgGetStr(pstMsg, EN_IOTA_DEVUPDATE_IE_DEVICEID);
return 0;
}
//Bind the broadcast reception processing function HW_BroadCastReg ("IOTA_TOPIC_DEVUPDATE_RSP", Device_StatusUpdateHandler).
|
Last Article: Adding a Device
Next Article: Deleting a Device
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.