Skip to content

Commit 3930017

Browse files
authored
feat(matter_example): use const char * instead of #define
1 parent ea2d6bd commit 3930017

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

Diff for: libraries/Matter/examples/MatterOnOffLight/MatterOnOffLight.ino

+5-5
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
MatterOnOffLight OnOffLight;
2323

2424
// it will keep last OnOff state stored, using Preferences
25-
Preferences lastStatePref;
26-
#define ON_OFF_PREF_KEY "lastOnOffState"
25+
Preferences statePref;
26+
const char *OnOffPrefKey = "OnOffState";
2727

2828
// set your board LED pin here
2929
#ifdef LED_BUILTIN
@@ -49,7 +49,7 @@ bool setLightOnOff(bool state) {
4949
digitalWrite(ledPin, LOW);
5050
}
5151
// store last OnOff state for when the Light is restarted / power goes off
52-
lastStatePref.putBool(ON_OFF_PREF_KEY, state);
52+
statePref.putBool(OnOffPrefKey, state);
5353
// This callback must return the success state to Matter core
5454
return true;
5555
}
@@ -83,8 +83,8 @@ void setup() {
8383
delay(500);
8484

8585
// Initialize Matter EndPoint
86-
lastStatePref.begin("matterLight", false);
87-
bool lastOnOffState = lastStatePref.getBool(ON_OFF_PREF_KEY, true);
86+
statePref.begin("matterLight", false);
87+
bool lastOnOffState = statePref.getBool(OnOffPrefKey, true);
8888
OnOffLight.begin(lastOnOffState);
8989
OnOffLight.onChange(setLightOnOff);
9090

0 commit comments

Comments
 (0)