Module Integration Guides
...
ESP-IDF
Receiving actions
2 min
docid 2on vzrfinigokbl7yn7b are commands that platform sends to the client the json format for actions would look like { "name" "toggle board led", "action id" "101", "payload" "on", "kind" "process" } on device end, we need to write an action handler for handling individual action based on the name following example shows a way to create action handler and mapping it to a particular action // handler for toggle led action int handle toggle led(bytebeam client t bytebeam client, char args, char action id) { // log the received arguments and action id to serial for refrence esp logi(tag, " args %s, action id %s ", args, action id); // // include command for toggling led over here // int ret val = 0; // this function allows platform to know about the completion of particular action ret val = bytebeam publish action completed(bytebeam client, action id); if(ret val != 0) { // // handle the publish action completed error here // return 1; } return 0; } / once you have created an action handler for particular action then it should be mapped with particular action below function call would do that mapping / // bytebeam client bytebeam client object // handle toggle led pointer to action handler // toggle board led action bytebeam add action handler(\&bytebeam client, handle toggle led, "toggle board led"); action status response while we execute the action, we need to send the progress back to the server so that the user can monitor the action remotely to do so the following apis can be used / action completed status response can be published by using below function / bytebeam err t bytebeam publish action completed(bytebeam client t bytebeam client, char action id); / action failed status response can be published by using below function / bytebeam err t bytebeam publish action failed(bytebeam client t bytebeam client, char action id); / action progress status response can be published by using below function / bytebeam err t bytebeam publish action progress(bytebeam client t bytebeam client, char action id, int progress percentage); / custom action status response can be published by using below function / bytebeam err t bytebeam publish action status(bytebeam client t bytebeam client, char action id, int percentage, char status, char error message); have a look at https //github com/bytebeamio/bytebeam esp idf sdk/tree/main/examples/receive data/toggle led example app for a full fledged example showing how to add the action and publish the action status response to bytebeam cloud


