From 8267e4e3b614c7a8334dd6f47717e51089ad5043 Mon Sep 17 00:00:00 2001 From: Klaus K Wilting Date: Tue, 1 Jan 2019 14:59:00 +0100 Subject: [PATCH] BME680: bugfix save state --- src/bme680mems.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/bme680mems.cpp b/src/bme680mems.cpp index 802221e3..b11c02e4 100644 --- a/src/bme680mems.cpp +++ b/src/bme680mems.cpp @@ -147,7 +147,7 @@ void updateState(void) { bool update = false; if (stateUpdateCounter == 0) { - /* First state update when IAQ accuracy is >= 1 */ + /* First state update when IAQ accuracy is >= 3 */ if (iaqSensor.iaqAccuracy >= 3) { update = true; stateUpdateCounter++; @@ -161,10 +161,10 @@ void updateState(void) { } if (update) { - memcpy(bsecstate_buffer, cfg.bsecstate, BSEC_MAX_STATE_BLOB_SIZE); - cfg.bsecstate[BSEC_MAX_STATE_BLOB_SIZE + 1] = BSEC_MAX_STATE_BLOB_SIZE; iaqSensor.getState(bsecstate_buffer); checkIaqSensorStatus(); + memcpy(cfg.bsecstate, bsecstate_buffer, BSEC_MAX_STATE_BLOB_SIZE); + cfg.bsecstate[BSEC_MAX_STATE_BLOB_SIZE + 1] = BSEC_MAX_STATE_BLOB_SIZE; ESP_LOGI(TAG, "saving BSEC state to NVRAM"); saveConfig(); }