Module Integration Guides
Arduino
Receiving actions
2 min
https //bytebeam io/docs/sxdq actions are commands that the platform sends to the client every action has a type and we need to register an action handler for each action type following example shows a way to create action handler and map it to a particular action // handler for toggleled action int toggleled handler(char args, char actionid) { // log the recieved arguments and action id to serial for the reference serial printf(" args %s , actionid %s \n", args, actionid); // // include command for toggling led over here // bool status = true; // this function allows platform to know about the completion of particuar action status = bytebeam publishactioncompleted(actionid); if(!status) { // // 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 // // toggleled hanlder pointer to action handler // toggleled action bytebeam addactionhandler(toggleled handler, "toggleled"); 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 // bool bytebeam publishactioncompleted(char actionid); // // action failed status response can be published by using below function // bool bytebeam publishactionfailed(char actionid, char error = "action failed"); // // action progress status response can be published by using below function // bool bytebeam publishactionprogress(char actionid, int progresspercentage, char status = "progress"); have a look at the https //github com/bytebeamio/bytebeam arduino sdk/tree/main/examples/esp32/toggleled example sketch for a full fledged example showing how to add the action and publish the action status response to bytebeam cloud
