From 5ddc1877c99702b1d8b37a22c49f582471ca6f85 Mon Sep 17 00:00:00 2001 From: schneider <schneider@blinkenlichts.net> Date: Wed, 29 Apr 2020 22:18:43 +0200 Subject: [PATCH] fix(bsec): Reduce stack usage by reusing a buffer --- lib/vendor/Bosch/BSEC/examples/bsec_integration.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/vendor/Bosch/BSEC/examples/bsec_integration.c b/lib/vendor/Bosch/BSEC/examples/bsec_integration.c index 081f27b7d..49a862a37 100644 --- a/lib/vendor/Bosch/BSEC/examples/bsec_integration.c +++ b/lib/vendor/Bosch/BSEC/examples/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_PROPERTY_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_PROPERTY_BLOB_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