SinricPro Library
VolumeController< T >

VolumeController. More...

Inheritance diagram for VolumeController< T >:

Public Types

using SetVolumeCallback = std::function< bool(const String &, int &)>
 Callback definition for onSetVolume function. More...
 
using AdjustVolumeCallback = std::function< bool(const String &, int &, bool)>
 Callback definition for onAdjustVolume function. More...
 

Public Member Functions

void onSetVolume (SetVolumeCallback cb)
 Set callback function for setVolume request. More...
 
void onAdjustVolume (AdjustVolumeCallback cb)
 Set callback function for adjustVolume request. More...
 
bool sendVolumeEvent (int volume, String cause="PHYSICAL_INTERACTION")
 Send setVolume event to SinricPro Server indicating actual volume has changed. More...
 

Detailed Description

template<typename T>
class VolumeController< T >

VolumeController.

Member Typedef Documentation

◆ AdjustVolumeCallback

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

Callback definition for onAdjustVolume function.

Gets called when device receive a adjustVolume request

Parameters
[in]deviceIdString which contains the ID of device
[in]volumeDeltaInteger with relative volume the device should change about (-100..100)
[out]volumeDeltaInteger with absolute volume device has been set to
[in]volumeDefaultBool false if the user specified the amount by which to change the volume; otherwise true
Returns
the success of the request
Return values
truerequest handled properly
falserequest was not handled properly because of some error

Example-Code

int absoluteVolume;
bool onAdjustVolume(const String &deviceId, int &volumeDelta, bool volumeDefault) {
absoluteVolume += volumeDelta; // calculate absolute volume
Serial.printf("Device %s volume changed about %i to %d (default: %s)\r\n", deviceId.c_str(), volumeDelta, absoluteVolume, volumeDefault);
volumeDelta = absoluteVolume; // return absolute volume
return true; // request handled properly
}
void onAdjustVolume(AdjustVolumeCallback cb)
Set callback function for adjustVolume request.
Definition: VolumeController.h:78

◆ SetVolumeCallback

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

Callback definition for onSetVolume function.

Gets called when device receive a setVolume request

Parameters
[in]deviceIdString which contains the ID of device
[in]volumeInteger with volume device should set to
[out]volumeInteger with volume device has been 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 onSetVolume(const String &deviceId, int &volume) {
Serial.printf("Device %s volume set to %d\r\n", deviceId.c_str(), volume);
return true; // request handled properly
}
void onSetVolume(SetVolumeCallback cb)
Set callback function for setVolume request.
Definition: VolumeController.h:68

Member Function Documentation

◆ onAdjustVolume()

void onAdjustVolume ( AdjustVolumeCallback  cb)

Set callback function for adjustVolume request.

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

◆ onSetVolume()

void onSetVolume ( SetVolumeCallback  cb)

Set callback function for setVolume request.

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

◆ sendVolumeEvent()

bool sendVolumeEvent ( int  volume,
String  cause = "PHYSICAL_INTERACTION" 
)

Send setVolume event to SinricPro Server indicating actual volume has changed.

Parameters
volumeInteger reporting the volume that the device have been set to
cause(optional) Reason why event is sent (default = "PHYSICAL_INTERACTION")
Returns
the success of sending the event
Return values
trueevent has been sent successfully
falseevent has not been sent, maybe you sent to much events in a short distance of time