Skip to content

Commit c28aec9

Browse files
adding onGetState to FauxmoPhilipsLight_Basic
Added some comments for FauxmoBelkinPlug_Basic.
1 parent 42b5598 commit c28aec9

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

examples/FauxmoBelkinPlug_Basic/FauxmoBelkinPlug_Basic.ino

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
fauxmoESP fauxmo;
2424

25+
// This is for one device only. You need an array for multiple devices.
2526
bool SwitchState = false;
2627

2728
// -----------------------------------------------------------------------------
@@ -87,12 +88,15 @@ void setup() {
8788
// this way it's easier to match devices to action without having to compare strings. (value is not functional)
8889
fauxmo.onSetState([](unsigned char device_id, const char * device_name, bool state, unsigned char value) {
8990
Serial.printf("[MAIN] Device #%d (%s) state: %s\n", device_id, device_name, state ? "ON" : "OFF");
90-
SwitchState = state;
9191
digitalWrite(LED, state);
92+
// This is for one device only. You need an array for multiple devices.
93+
SwitchState = state;
9294
});
9395

9496
// Callback to retrieve current state (for GetBinaryState queries) (value is not functional)
9597
fauxmo.onGetState([](unsigned char device_id, const char * device_name, bool &state, unsigned char &value) {
98+
Serial.println("onGetStateCallback");
99+
// This is for one device only. You need an array for multiple devices.
96100
state = SwitchState;
97101
});
98102

examples/FauxmoPhilipsLight_Basic/FauxmoPhilipsLight_Basic.ino

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919

2020
fauxmoESP fauxmo;
2121

22+
// This is for one device only. You need an array for multiple devices.
23+
bool SwitchState = false;
24+
2225
// -----------------------------------------------------------------------------
2326

2427
#define SERIAL_BAUDRATE 115200
@@ -134,7 +137,15 @@ void setup() {
134137
} else if (strcmp(device_name, ID_WHITE)==0) {
135138
digitalWrite(LED_WHITE, state ? HIGH : LOW);
136139
}*/
140+
// This is for one device only. You need an array for multiple devices.
141+
SwitchState = state;
142+
});
137143

144+
// Callback to retrieve current state
145+
fauxmo.onGetState([](unsigned char device_id, const char * device_name, bool &state, unsigned char &value) {
146+
Serial.println("onGetStateCallback");
147+
// This is for one device only. You need an array for multiple devices.
148+
state = SwitchState;
138149
});
139150

140151
}

0 commit comments

Comments
 (0)