VolumeController.
More...
|
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...
|
|
template<typename T>
class VolumeController< T >
VolumeController.
◆ AdjustVolumeCallback
Callback definition for onAdjustVolume function.
Gets called when device receive a adjustVolume
request
- Parameters
-
[in] | deviceId | String which contains the ID of device |
[in] | volumeDelta | Integer with relative volume the device should change about (-100..100) |
[out] | volumeDelta | Integer with absolute volume device has been set to |
[in] | volumeDefault | Bool false if the user specified the amount by which to change the volume; otherwise true |
- Returns
- the success of the request
- Return values
-
true | request handled properly |
false | request was not handled properly because of some error |
Example-Code
int absoluteVolume;
bool onAdjustVolume(
const String &deviceId,
int &volumeDelta,
bool volumeDefault) {
absoluteVolume += volumeDelta;
Serial.printf("Device %s volume changed about %i to %d (default: %s)\r\n", deviceId.c_str(), volumeDelta, absoluteVolume, volumeDefault);
volumeDelta = absoluteVolume;
return true;
}
void onAdjustVolume(AdjustVolumeCallback cb)
Set callback function for adjustVolume request.
Definition: VolumeController.h:78
◆ SetVolumeCallback
Callback definition for onSetVolume function.
Gets called when device receive a setVolume
request
- Parameters
-
[in] | deviceId | String which contains the ID of device |
[in] | volume | Integer with volume device should set to |
[out] | volume | Integer with volume device has been set to |
- Returns
- the success of the request
- Return values
-
true | request handled properly |
false | request 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;
}
void onSetVolume(SetVolumeCallback cb)
Set callback function for setVolume request.
Definition: VolumeController.h:68
◆ onAdjustVolume()
Set callback function for adjustVolume
request.
- Parameters
-
cb | Function pointer to a AdjustVolumeCallback function |
- Returns
- void
- See also
- AdjustVolumeCallback
◆ onSetVolume()
Set callback function for setVolume
request.
- Parameters
-
cb | Function 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
-
volume | Integer 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
-
true | event has been sent successfully |
false | event has not been sent, maybe you sent to much events in a short distance of time |