Bosch Sensortec Community

    cancel
    Showing results for 
    Search instead for 
    Did you mean: 
    SOLVED

    BME680 BSEC - the lenth of state ?

    BME680 BSEC - the lenth of state ?

    wcx8229
    Member

    Hello

    I'm using BSEC_1.4.7.4_Generic_Release .

    I find the lenth of  bsec_state is different between in functionbsec_iot_init() and bsec_iot_loop().

    One is 454 bytes and another is 139.

    Why? how to save?

    reference :

    return_values_init bsec_iot_init(float sample_rate, float temperature_offset, bme680_com_fptr_t bus_write,
    bme680_com_fptr_t bus_read, sleep_fct sleep, state_load_fct state_load, config_load_fct config_load)
    {
    return_values_init ret = {BME680_OK, BSEC_OK};
    bsec_library_return_t bsec_status = BSEC_OK;

    uint8_t bsec_state[BSEC_MAX_PROPERTY_BLOB_SIZE] = {0};   //454 Bytes
    uint8_t bsec_config[BSEC_MAX_PROPERTY_BLOB_SIZE] = {0};
    uint8_t work_buffer[BSEC_MAX_PROPERTY_BLOB_SIZE] = {0};
    int bsec_state_len, bsec_config_len;

    ...................

    /* Load library config, if available */
    bsec_config_len = config_load(bsec_config, sizeof(bsec_config));
    if (bsec_config_len != 0)
    {
    ret.bsec_status = bsec_set_configuration(bsec_config, bsec_config_len, work_buffer, sizeof(work_buffer));
    if (ret.bsec_status != BSEC_OK)
    {
    return ret;
    }
    }

    /* Load previous library state, if available */
    bsec_state_len = state_load(bsec_state, sizeof(bsec_state));
    if (bsec_state_len != 0)
    {
    ret.bsec_status = bsec_set_state(bsec_state, bsec_state_len, work_buffer, sizeof(work_buffer));
    if (ret.bsec_status != BSEC_OK)
    {
    return ret;
    }
    }

    ...................
    }

    //-------------------------------------------------------------

    void bsec_iot_loop(sleep_fct sleep, get_timestamp_us_fct get_timestamp_us, output_ready_fct output_ready,
    state_save_fct state_save, uint32_t save_intvl)
    {
    ................................
    uint8_t bsec_state[BSEC_MAX_STATE_BLOB_SIZE];   139 Bytes
    uint8_t work_buffer[BSEC_MAX_STATE_BLOB_SIZE];
    uint32_t bsec_state_len = 0;
    uint32_t n_samples = 0;

    bsec_library_return_t bsec_status = BSEC_OK;

    while (1)
    {

    .....................

    /* Retrieve and store state if the passed save_intvl */
    if (n_samples >= save_intvl)
    {
    bsec_status = bsec_get_state(0, bsec_state, sizeof(bsec_state), work_buffer, sizeof(work_buffer), &bsec_state_len);
    if (bsec_status == BSEC_OK)
    {
    state_save(bsec_state, bsec_state_len);
    }
    n_samples = 0;
    }
    ...................

    }
    }

     

    2 REPLIES 2

    Vincent
    Community Moderator
    Community Moderator

    The length of state shall be BSEC_MAX_STATE_BLOB_SIZE,

    BSEC_MAX_PROPERTY_BLOB_SIZE used for state in bsec_iot_init is not accurate, it shall be BSEC_MAX_STATE_BLOB_SIZE.

    We will correct this part in new version release.

    OK

    Thank you!

    Icon--AD-black-48x48Icon--address-consumer-data-black-48x48Icon--appointment-black-48x48Icon--back-left-black-48x48Icon--calendar-black-48x48Icon--center-alignedIcon--Checkbox-checkIcon--clock-black-48x48Icon--close-black-48x48Icon--compare-black-48x48Icon--confirmation-black-48x48Icon--dealer-details-black-48x48Icon--delete-black-48x48Icon--delivery-black-48x48Icon--down-black-48x48Icon--download-black-48x48Ic-OverlayAlertIcon--externallink-black-48x48Icon-Filledforward-right_adjustedIcon--grid-view-black-48x48IC_gd_Check-Circle170821_Icons_Community170823_Bosch_Icons170823_Bosch_Icons170821_Icons_CommunityIC-logout170821_Icons_Community170825_Bosch_Icons170821_Icons_CommunityIC-shopping-cart2170821_Icons_CommunityIC-upIC_UserIcon--imageIcon--info-i-black-48x48Icon--left-alignedIcon--Less-minimize-black-48x48Icon-FilledIcon--List-Check-grennIcon--List-Check-blackIcon--List-Cross-blackIcon--list-view-mobile-black-48x48Icon--list-view-black-48x48Icon--More-Maximize-black-48x48Icon--my-product-black-48x48Icon--newsletter-black-48x48Icon--payment-black-48x48Icon--print-black-48x48Icon--promotion-black-48x48Icon--registration-black-48x48Icon--Reset-black-48x48Icon--right-alignedshare-circle1Icon--share-black-48x48Icon--shopping-bag-black-48x48Icon-shopping-cartIcon--start-play-black-48x48Icon--store-locator-black-48x48Ic-OverlayAlertIcon--summary-black-48x48tumblrIcon-FilledvineIc-OverlayAlertwhishlist