SinricPro Library
ModeController< T >

ModeController. More...

Inheritance diagram for ModeController< T >:

Public Types

using ModeCallback = std::function< bool(const String &, String &)>
 Callback definition for onSetMode function. More...
 
using GenericModeCallback = std::function< bool(const String &, const String &, String &)>
 Callback definition for onSetMode function for a specific instance. More...
 

Public Member Functions

void onSetMode (ModeCallback cb)
 Set callback function for setMode request. More...
 
void onSetMode (const String &instance, GenericModeCallback cb)
 Set callback function for setMode request on a specific instance. More...
 
bool sendModeEvent (String mode, String cause="PHYSICAL_INTERACTION")
 Send setMode event to SinricPro Server indicating the mode has changed. More...
 
bool sendModeEvent (String instance, String mode, String cause="PHYSICAL_INTERACTION")
 Send setMode event to SinricPro Server indicating the mode on a specific instance has changed. More...
 

Detailed Description

template<typename T>
class ModeController< T >

ModeController.

Member Typedef Documentation

◆ GenericModeCallback

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

Callback definition for onSetMode function for a specific instance.

Gets called when device receive a setBands request

Parameters
[in]deviceIdString which contains the ID of device
[in]instanceString name of the instance
[in]modeString device mode should set to
[out]modeString devices mode is set to
Returns
the success of the request
Return values
truerequest handled properly
falserequest was not handled properly because of some error

Example-Code

bool onSetMode(const String &deviceId, const String &instance, String &mode) {
Serial.printf("Device %s mode %s set to %s\r\n", deviceId.c_str(), instance.c_str(), mode);
return true; // request handled properly
}
void onSetMode(ModeCallback cb)
Set callback function for setMode request.
Definition: ModeController.h:69

◆ ModeCallback

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

Callback definition for onSetMode function.

Gets called when device receive a setBands request

Parameters
[in]deviceIdString which contains the ID of device
[in]modeString device mode should set to
MOVIE, MUSIC, NIGHT, SPORT, TV
[out]modeString devices mode is set to
MOVIE, MUSIC, NIGHT, SPORT, TV
Returns
the success of the request
Return values
truerequest handled properly
falserequest was not handled properly because of some error

Example-Code

bool onSetMode(const String &deviceId, String &mode) {
Serial.printf("Device %s is set to mode %s\r\n", deviceId.c_str(), mode);
return true; // request handled properly
}

Member Function Documentation

◆ onSetMode() [1/2]

void onSetMode ( const String &  instance,
GenericModeCallback  cb 
)

Set callback function for setMode request on a specific instance.

Parameters
instanceString with instance name
cbFunction pointer to a ModeCallback function
Returns
void
See also
ModeCallback

◆ onSetMode() [2/2]

void onSetMode ( ModeCallback  cb)

Set callback function for setMode request.

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

◆ sendModeEvent() [1/2]

bool sendModeEvent ( String  instance,
String  mode,
String  cause = "PHYSICAL_INTERACTION" 
)

Send setMode event to SinricPro Server indicating the mode on a specific instance has changed.

Parameters
instanceString instance name
modeString with actual mode device is set to
MOVIE, MUSIC, NIGHT, SPORT, TV
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

◆ sendModeEvent() [2/2]

bool sendModeEvent ( String  mode,
String  cause = "PHYSICAL_INTERACTION" 
)

Send setMode event to SinricPro Server indicating the mode has changed.

Parameters
modeString with actual mode device is set to
MOVIE, MUSIC, NIGHT, SPORT, TV
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