Sending Alarms to Device Cloud in C
A client application can send alarms to indicate an occurrence on the device to Device Cloud using the alarm APIs.
You can publish the alarm state or the alarm state and a message.
Alarms appear on the thing definition page. Click the View icon of the alarm to view the alarm details and history in chart, graph, and table format. You can also overlay alarm data on the property data in the property graph view. For more information about viewing alarms, see the following:
- Device Cloud Management Portal User's Guide: Viewing and Updating the Alarms of a Thing
- Device Cloud Management Portal User's Guide: Viewing the Properties of a Thing
In the options parameter of the API, you can specify additional, optional information, including the following:
-
location (latitude and longitude) where the alarm occurred, specified as a location object
-
maximum time to wait for the publish operation to complete
-
timestamp of the alarm
-
whether to publish the alarm value even if the value has not changed since the alarm was published previously
The function parameter txn is for future use.
You must have initialized your application (see Initializing Your C Application).
The thing definition that corresponds to your application must have the alarm defined and you must know the numeric values of the alarm states defined. For more information about defining alarms, see Device Cloud Management Portal User's Guide: Defining Alarms.
To send alarms to Device Cloud, your application must be connected to Device Cloud.
When you no longer need to send the alarm, call the iot_alarm_deregister function and if applicable, the iot_option_free function, to free the associated memory.