Hi BSTRobin, I get warning code when i call `bsec_sensor_control(time_stamp, &sensor_settings);` in bsec_iot_loop(); My program language is c. I already migrate my platform: using esp32 hal api and BSEC API for esp32s3. There is no delay function in bsec_iot_loop: void bsec_iot_loop(sleep_fct sleep_n, get_timestamp_us_fct get_timestamp_us, output_ready_fct_t output_ready,
state_save_fct state_save, uint32_t save_intvl)
{
/* Timestamp variables */
int64_t time_stamp = 0;
uint32_t tick_before, tick_after;
/* BSEC sensor settings struct */
bsec_bme_settings_t sensor_settings;
memset(&sensor_settings, 0, sizeof(sensor_settings));
/* BSEC sensor data */
struct bme68x_data data;
uint8_t nFieldsLeft = 0;
uint32_t bsec_state_len = 0;
uint32_t n_samples = 0;
int8_t ret_val;
opMode = sensor_settings.op_mode;
bsec_library_return_t bsec_status = BSEC_OK;
sensor_settings.next_call = 0;
while (1)
{
tick_before = get_timestamp();
/* get the timestamp in nanoseconds before calling bsec_sensor_control() */
// time_stamp = get_timestamp_us() * 1000;
time_stamp = get_timestamp_us() * 1000;
if (time_stamp >= sensor_settings.next_call)
{
printf("time stamp: %" PRId64 " next call: %" PRId64 "\r\n", time_stamp, sensor_settings.next_call);
/* Retrieve sensor settings to be used in this time instant by calling bsec_sensor_control */
bsec_status = bsec_sensor_control(time_stamp, &sensor_settings);
if (bsec_status != BSEC_OK)
{
if (bsec_status < BSEC_OK)
{
printf("ERROR: bsec_sensor_control: %d\n", bsec_status);
break;
}
else
{
printf("WARNING: bsec_sensor_control: %d\n", bsec_status);
}
}
switch (sensor_settings.op_mode)
{
case BME68X_FORCED_MODE:
setBme68xConfigForced(&sensor_settings);
break;
case BME68X_PARALLEL_MODE:
if (opMode != sensor_settings.op_mode)
{
setBme68xConfigParallel(&sensor_settings);
}
break;
case BME68X_SLEEP_MODE:
if (opMode != sensor_settings.op_mode)
{
ret_val = bme68x_set_op_mode(BME68X_SLEEP_MODE, &bme68x_g);
if ((ret_val == BME68X_OK) && (opMode != BME68X_SLEEP_MODE))
{
opMode = BME68X_SLEEP_MODE;
}
}
break;
}
if (sensor_settings.trigger_measurement && sensor_settings.op_mode != BME68X_SLEEP_MODE)
{
nFields = 0;
bme68x_get_data(lastOpMode, &sensor_data[0], &nFields, &bme68x_g);
iFields = 0;
if(nFields)
{
do
{
nFieldsLeft = getData(&data);
/* check for valid gas data */
if (data.status & BME68X_GASM_VALID_MSK)
{
if (!processData(time_stamp, data, sensor_settings.process_data, output_ready))
{
return;
}
}
}while(nFieldsLeft);
}
}
/* Increment sample counter */
n_samples++;
/* 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;
}
}
tick_after = get_timestamp();
printf("cost %u ms\r\n", (tick_after - tick_before)/1000);
}
}
... View more