/* This API sets the oversampling, filter and standby duration (normal mode) settings in the sensor.  */
int8_t bme280_set_sensor_settings(uint8_t desired_settings, struct bme280_dev *dev)
/* This API sets the oversampling, filter and standby duration (normal mode) settings in the sensor.  */
int8_t bme280_set_sensor_settings(uint8_t desired_settings, struct bme280_dev *dev)
{
    int8_t rslt;
    uint8_t sensor_mode;
    rslt = null_ptr_check(dev);
    if (rslt == BME280_OK)
    {
        rslt = bme280_get_sensor_mode(&sensor_mode, dev);
        if ((rslt == BME280_OK) && (sensor_mode != BME280_SLEEP_MODE))
        {
            rslt = put_device_to_sleep(dev);
        }
        if (rslt == BME280_OK)
        {
            if (are_settings_changed(OVERSAMPLING_SETTINGS, desired_settings))
            {
                rslt = set_osr_settings(desired_settings, &dev->settings, dev);
            }
            if ((rslt == BME280_OK) && are_settings_changed(FILTER_STANDBY_SETTINGS, desired_settings))
            {
                rslt = set_filter_standby_settings(desired_settings, &dev->settings, dev);
            }
        }
    }
    return rslt;
}