SinricPro Library
BandsController< T >

BandsController. More...

Inheritance diagram for BandsController< T >:

Public Types

using SetBandsCallback = std::function< bool(const String &, const String &, int &)>
 Callback definition for onSetBands function. More...
 
using AdjustBandsCallback = std::function< bool(const String &, const String &, int &)>
 Callback definition for onAdjustBands function. More...
 
using ResetBandsCallback = std::function< bool(const String &, const String &, int &)>
 Callback definition for onResetBands function. More...
 

Public Member Functions

void onSetBands (SetBandsCallback cb)
 Set callback function for setBands request. More...
 
void onAdjustBands (AdjustBandsCallback cb)
 Set callback function for adjustBands request. More...
 
void onResetBands (ResetBandsCallback cb)
 Set callback function for resetBands request. More...
 
bool sendBandsEvent (String bands, int level, String cause="PHYSICAL_INTERACTION")
 Send setBands event to SinricPro Server indicating bands level has changed. More...
 

Detailed Description

template<typename T>
class BandsController< T >

BandsController.

Member Typedef Documentation

◆ AdjustBandsCallback

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

Callback definition for onAdjustBands function.

Gets called when device receive a adjustBands request

Parameters
[in]deviceIdString which contains the ID of device
[in]bandsString with requested bands to change
BASS, MIDRANGE, TREBBLE
[in]levelDeltaInteger with relative level value device should change bands about
[out]bandsString with changed bands
BASS, MIDRANGE, TREBBLE
[out]levelDeltaInteger value with level bands changed to
Returns
the success of the request
Return values
truerequest handled properly
falserequest was not handled properly because of some error

Example-Code

int globalBass;
int globalMidrange;
int globalTrebble;
bool onAdjustBands(const String &deviceId, String &bands, int &levelDelta) {
if (bands == "BASS") {
globalBass += levelDelta; // calculate absolute bass level
levelDelta = globalBass; // return absolute bass level
}
if (bands == "MIDRANGE") {
globalMidrange += levelDelta; // calculate absolute midrange level
levelDelta = globalMidrange; // return absolute midrange level
}
if (bands == "TREBBLE") {
globalMidrange += levelDelta; // calculate absolute trebble level
levelDelta = globalMidrange; // return absolute trebble level
}
Serial.printf("Device %s bands set to\r\n - BASS: %d\r\n - MIDRANGE: %d\r\n - TREBBLE: %d\r\n", deviceId.c_str(), globalBass, globalMidrange, globalTrebble);
return true; // request handled properly
}
void onAdjustBands(AdjustBandsCallback cb)
Set callback function for adjustBands request.
Definition: BandsController.h:98

◆ ResetBandsCallback

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

Callback definition for onResetBands function.

Gets called when device receive a onResetBands request

Parameters
[in]deviceIdString which contains the ID of device
[in]bandsString with requested bands to reset
BASS, MIDRANGE, TREBBLE
[out]bandsString with changed bands
BASS, MIDRANGE, TREBBLE
[out]levelInteger value with level bands changed to
Returns
the success of the request
Return values
truerequest handled properly
falserequest was not handled properly because of some error

Example-Code

int globalBass;
int globalMidrange;
int globalTrebble;
bool onAdjustBands(const String &deviceId, String &bands, int &level) {
if (bands == "BASS") {
globalBass = 0; // reset bass level to 0
level = globalBass; // return bass level
}
if (bands == "MIDRANGE") {
globalMidrange = 0; // reset midrange level to 0
level = globalMidrange; // return midrange level
}
if (bands == "TREBBLE") {
globalMidrange = 0; // reset trebble level to 0
level = globalMidrange; // return trebble level
}
Serial.printf("Device %s bands reset to\r\n - BASS: %d\r\n - MIDRANGE: %d\r\n - TREBBLE: %d\r\n", deviceId.c_str(), globalBass, globalMidrange, globalTrebble);
return true; // request handled properly
}

◆ SetBandsCallback

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

Callback definition for onSetBands function.

Gets called when device receive a setBands request

Parameters
[in]deviceIdString which contains the ID of device
[in]bandsString with requested bands to change
BASS, MIDRANGE, TREBBLE
[in]levelInteger value with level bands should set to
[out]bandsString with changed bands
BASS, MIDRANGE, TREBBLE
[out]levelInteger value with level bands changed to
Returns
the success of the request
Return values
truerequest handled properly
falserequest was not handled properly because of some error

Example-Code

bool onSetBands(const String &deviceId, String &bands, int &level) {
Serial.printf("Device %s bands %s set to %d\r\n", deviceId.c_str(), bands.c_str(), level);
return true; // request handled properly
}
void onSetBands(SetBandsCallback cb)
Set callback function for setBands request.
Definition: BandsController.h:88

Member Function Documentation

◆ onAdjustBands()

void onAdjustBands ( AdjustBandsCallback  cb)

Set callback function for adjustBands request.

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

◆ onResetBands()

void onResetBands ( ResetBandsCallback  cb)

Set callback function for resetBands request.

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

◆ onSetBands()

void onSetBands ( SetBandsCallback  cb)

Set callback function for setBands request.

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

◆ sendBandsEvent()

bool sendBandsEvent ( String  bands,
int  level,
String  cause = "PHYSICAL_INTERACTION" 
)

Send setBands event to SinricPro Server indicating bands level has changed.

Parameters
bandsString which bands has changed
BASS, MIDRANGE, TREBBLE
levelInteger with changed bands level
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