Fix callback sequence (#153)

Save-/restore callbacks need to be defined before knx.readMemory() to ensure the restore callback is called.
This commit is contained in:
Sonnengruesser 2021-12-13 11:17:36 +01:00 committed by GitHub
parent 616599cf8b
commit 87edd3dfe0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -53,6 +53,10 @@ void setup(void)
wifiManager.autoConnect("knx-bme680"); wifiManager.autoConnect("knx-bme680");
#endif #endif
// set save and restore callbacks
knx.setSaveCallback(saveBme680State);
knx.setRestoreCallback(loadBme680State);
// read adress table, association table, groupobject table and parameters from eeprom // read adress table, association table, groupobject table and parameters from eeprom
knx.readMemory(); knx.readMemory();
@ -60,7 +64,6 @@ void setup(void)
if(knx.configured()) if(knx.configured())
goTriggerSample.callback(triggerCallback); goTriggerSample.callback(triggerCallback);
// Configure Wire pins before this call if needed. // Configure Wire pins before this call if needed.
Wire.begin(); Wire.begin();
// depends on sensor board. Try BME680_I2C_ADDR_PRIMARY if it doen't work. // depends on sensor board. Try BME680_I2C_ADDR_PRIMARY if it doen't work.
@ -87,9 +90,6 @@ void setup(void)
BSEC_OUTPUT_GAS_PERCENTAGE BSEC_OUTPUT_GAS_PERCENTAGE
}; };
knx.setSaveCallback(saveBme680State);
knx.setRestoreCallback(loadBme680State);
if (knx.configured()) if (knx.configured())
{ {
cyclSend = knx.paramInt(0); cyclSend = knx.paramInt(0);