SinricPro Library
ColorController< T >

ColorController. More...

Inheritance diagram for ColorController< T >:

Public Types

using ColorCallback = std::function< bool(const String &, byte &, byte &, byte &)>
 Callback definition for onColor function. More...
 

Public Member Functions

void onColor (ColorCallback cb)
 Set callback function for setColor request. More...
 
bool sendColorEvent (byte r, byte g, byte b, String cause="PHYSICAL_INTERACTION")
 Send setColor event to SinricPro Server indicating actual color. More...
 

Detailed Description

template<typename T>
class ColorController< T >

ColorController.

Member Typedef Documentation

◆ ColorCallback

using ColorCallback = std::function<bool(const String &, byte &, byte &, byte &)>

Callback definition for onColor function.

Gets called when device receive a setColor request

Parameters
[in]deviceIdString which contains the ID of device
[in]rByte value for red
[in]gByte value for green
[in]bByte value for blue
[out]rByte value for red
[out]gByte value for green
[out]bByte value for blue
Returns
the success of the request
Return values
truerequest handled properly
falserequest was not handled properly because of some error

Example-Code

bool onColor(const String &deviceId, byte &r, byte &g, byte &b) {
Serial.printf("Device %s color is set to red=%d, green=%d, blue=%d\r\n", deviceId.c_str(), r, g, b);
return true; // request handled properly
}
void onColor(ColorCallback cb)
Set callback function for setColor request.
Definition: ColorController.h:52

Member Function Documentation

◆ onColor()

void onColor ( ColorCallback  cb)

Set callback function for setColor request.

Parameters
cbFunction pointer to a ColorCallback function
Returns
void
See also
ColorCallback

◆ sendColorEvent()

bool sendColorEvent ( byte  r,
byte  g,
byte  b,
String  cause = "PHYSICAL_INTERACTION" 
)

Send setColor event to SinricPro Server indicating actual color.

Parameters
rByte value for red
gByte value for green
bByte value for blue
cause(optional) String reason why event is sent (default = "PHYSICAL_INTERACTION")
Returns
the success of sending the even
Return values
trueevent has been sent successfully
falseevent has not been sent, maybe you sent to much events in a short distance of time