From ee3e4cf7540aa10fe809a75b98c9275778e5482f Mon Sep 17 00:00:00 2001
From: schneider <schneider@blinkenlichts.net>
Date: Wed, 23 Dec 2020 22:55:02 +0100
Subject: [PATCH] fix(bsec): Reduce stack usage by reusing a buffer

---
 .../BSEC/examples/bsec_iot_example/bsec_integration.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/lib/vendor/Bosch/BSEC/examples/bsec_iot_example/bsec_integration.c b/lib/vendor/Bosch/BSEC/examples/bsec_iot_example/bsec_integration.c
index cc3e03600..6a9d1ffa3 100644
--- a/lib/vendor/Bosch/BSEC/examples/bsec_iot_example/bsec_integration.c
+++ b/lib/vendor/Bosch/BSEC/examples/bsec_iot_example/bsec_integration.c
@@ -162,8 +162,7 @@ return_values_init bsec_iot_init(float sample_rate, float temperature_offset, bm
     return_values_init ret = {BME680_OK, BSEC_OK};
     __attribute__((unused)) bsec_library_return_t bsec_status = BSEC_OK;
     
-    uint8_t bsec_state[BSEC_MAX_STATE_BLOB_SIZE] = {0};
-    uint8_t bsec_config[BSEC_MAX_PROPERTY_BLOB_SIZE] = {0};
+    uint8_t bsec_data[BSEC_MAX_PROPERTY_BLOB_SIZE] = {0};
     uint8_t work_buffer[BSEC_MAX_WORKBUFFER_SIZE] = {0};
     int bsec_state_len, bsec_config_len;
     
@@ -190,10 +189,10 @@ return_values_init bsec_iot_init(float sample_rate, float temperature_offset, bm
     }
     
     /* Load library config, if available */
-    bsec_config_len = config_load(bsec_config, sizeof(bsec_config));
+    bsec_config_len = config_load(bsec_data, sizeof(bsec_data));
     if (bsec_config_len != 0)
     {       
-        ret.bsec_status = bsec_set_configuration(bsec_config, bsec_config_len, work_buffer, sizeof(work_buffer));     
+        ret.bsec_status = bsec_set_configuration(bsec_data, bsec_config_len, work_buffer, sizeof(work_buffer));     
         if (ret.bsec_status != BSEC_OK)
         {
             return ret;
@@ -201,10 +200,10 @@ return_values_init bsec_iot_init(float sample_rate, float temperature_offset, bm
     }
     
     /* Load previous library state, if available */
-    bsec_state_len = state_load(bsec_state, sizeof(bsec_state));
+    bsec_state_len = state_load(bsec_data, sizeof(bsec_data));
     if (bsec_state_len != 0)
     {       
-        ret.bsec_status = bsec_set_state(bsec_state, bsec_state_len, work_buffer, sizeof(work_buffer));     
+        ret.bsec_status = bsec_set_state(bsec_data, bsec_state_len, work_buffer, sizeof(work_buffer));     
         if (ret.bsec_status != BSEC_OK)
         {
             return ret;
-- 
GitLab