Writing Methods in C
A client application uses the action APIs to implement methods to call from Device Cloud.
When a method is executed from Device Cloud, the agent processes the registered action callback or command in a worker thread.
The function parameters max_time_out and txn are for future use.
The thing definition that corresponds to your application must have the method defined, including the notification variables (parameters). For more information about defining methods, see Device Cloud Management Portal User's Guide: Defining Methods.
You must have previously initialized your application (see Initializing Your C Application).
You need to know the method key defined in the thing definition.
For notification variables, you need to know the key and the data type.
To receive methods, the application must be connected to Device Cloud.
When your application runs, the method appears on the thing details page under the Methods tab.
When a method is executed, the return status and the value of any output parameters appear in the mailbox logs, and the output parameter values appear in the Output box when the method is called from the thing page.
Examples
The iot-app-simple-actions sample application provided with the agent shows example code for methods.
When you no longer need the command, call iot_action_deregister and iot_action_free to free the memory allocated for the action.