website logo
BlogPlansAbout UsCareersSignup
⌘K
Introduction
Getting started on Bytebeam Cloud
Concepts
Projects
Streams
Device Shadow
Device Metadata
Actions
Module Integration Guides
ESP32
Arduino
Console Guides
Device Management
Dashboards
Streams (Tables)
Actions
Users
Roles
Release Notes
R10 24-May-2023
R9 10-May-2023
R8 26-Apr-2023
R7 05-Apr-2023
R6 22-Mar-2023
R5 08-Mar-2023
R4 22-Feb-2023
R3 10-Feb-2023
R2 01-Feb-2023
R1 19-Jan-2023
Docs powered by archbee 

Receiving actions

2min

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:

C++
|
// 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:

C++
|
//
//  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 ToggleLED example sketch for a full-fledged example showing how to add the action and publish the action status response to bytebeam cloud.



Updated 17 May 2023
Did this page help you?
Yes
No
PREVIOUS
Pushing data to Bytebeam
NEXT
Integrate Over the Air Updates
Docs powered by archbee 
TABLE OF CONTENTS
Action status response