Skip to content

Commit

Permalink
Fixed callback example for onToggleState
Browse files Browse the repository at this point in the history
  • Loading branch information
sivar2311 committed Feb 25, 2021
1 parent f20c559 commit 26f98c2
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions doc-examples/callbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ bool onPowerState(const String &deviceId, bool &state) {
//! [onPowerState]

//! [onToggleState]
bool onToggleState(const String &deviceId, bool &state) {
Serial.printf("Function turned %s\r\n", state ? "on" : "off");
bool onToggleState(const String &deviceId, const String &instance, bool &state) {
Serial.printf("Device %s state \"%s\" turned %s\r\n", deviceId.c_str(), instance.c_str(), state ? "on" : "off");
return true; // request handled properly
}
//! [onToggleState]
Expand Down Expand Up @@ -125,7 +125,7 @@ bool onAdjustRangeValue(const String &deviceId, int &rangeValueDelta) {
int globalRangeValue;

bool onAdjustRangeValue(const String &deviceId, const String& instance, int &rangeValueDelta) {
globalRangeValue += rangeValue; // calculate absolute rangeValue
globalRangeValue += rangeValueDelta; // calculate absolute rangeValue
Serial.printf("Device %s range value for %s has been changed about %i to %d\r\n", deviceId.c_str(), instance.c_str(), rangeValueDelta, globalRangeValue);
rangeValueDelta = globalRangeValue; // return absolute rangeValue
return true; // request handled properly
Expand Down

0 comments on commit 26f98c2

Please sign in to comment.