diff --git a/app/src/zsw_gatt_sensor_server.c b/app/src/zsw_gatt_sensor_server.c index 35d1f330..47c830a4 100644 --- a/app/src/zsw_gatt_sensor_server.c +++ b/app/src/zsw_gatt_sensor_server.c @@ -161,6 +161,7 @@ static void on_ccc_cfg_changed(const struct bt_gatt_attr *attr, uint16_t value) // TODO handle notifications per connection per service. if (!notif_enabled && (value == BT_GATT_CCC_NOTIFY)) { notif_enabled = true; + zsw_imu_feature_enable(ZSW_IMU_FEATURE_GYRO, false); ble_comm_short_connection_interval(); zsw_periodic_chan_add_obs(&periodic_event_fast_chan, &azsw_gatt_sensor_server_lis); } else if (notif_enabled && (value != BT_GATT_CCC_NOTIFY)) { @@ -168,6 +169,7 @@ static void on_ccc_cfg_changed(const struct bt_gatt_attr *attr, uint16_t value) // TODO Keep track of which ones have notify on. ble_comm_long_connection_interval(); zsw_periodic_chan_rm_obs(&periodic_event_fast_chan, &azsw_gatt_sensor_server_lis); + zsw_imu_feature_disable(ZSW_IMU_FEATURE_GYRO); notif_enabled = false; } } diff --git a/app/src/zsw_imu.c b/app/src/zsw_imu.c index 9b5f050a..83819bea 100644 --- a/app/src/zsw_imu.c +++ b/app/src/zsw_imu.c @@ -7,9 +7,6 @@ LOG_MODULE_REGISTER(accel, LOG_LEVEL_INF); -#define USE_ANYMOTION 1 -#define USE_GYRO 1 - /*! Earth's gravity in m/s^2 */ #define GRAVITY_EARTH (9.80665f) @@ -30,12 +27,8 @@ static int8_t configure_axis_remapping(struct bmi2_dev *bmi2_dev); static int8_t configure_enable_all_bmi270(struct bmi2_dev *bmi2_dev); static void configue_accel(struct bmi2_sens_config *config); static void configure_step_counter(struct bmi2_sens_config *config); -#if USE_GYRO static void configue_gyro(struct bmi2_sens_config *config); -#endif -#if USE_ANYMOTION static void configure_anymotion(struct bmi2_sens_config *config); -#endif static void configure_gesture_detect(struct bmi2_sens_config *config); static void configure_wrist_wakeup(struct bmi2_sens_config *config); static void configure_no_motion(struct bmi2_sens_config *config); @@ -47,15 +40,11 @@ static void bmi270_int2_work_cb(struct k_work *work); // List of the features used on the BMI270. static bmi270_feature_config_set_t bmi270_enabled_features[] = { { .sensor_id = BMI2_ACCEL, .cfg_func = configue_accel}, -#if USE_GYRO // Gyro not used for now, disable to keep power consumption down - { .sensor_id = BMI2_GYRO, .cfg_func = configue_gyro}, -#endif + { .sensor_id = BMI2_GYRO, .cfg_func = configue_gyro, .skip_enable = true}, { .sensor_id = BMI2_STEP_COUNTER, .cfg_func = configure_step_counter}, { .sensor_id = BMI2_SIG_MOTION, .cfg_func = NULL, .isr_disable = true}, -#if USE_ANYMOTION - { .sensor_id = BMI2_ANY_MOTION, .cfg_func = configure_anymotion, .isr_disable = true}, -#endif + { .sensor_id = BMI2_ANY_MOTION, .cfg_func = configure_anymotion, .isr_disable = true, .skip_enable = true}, { .sensor_id = BMI2_STEP_ACTIVITY, .cfg_func = NULL, .skip_enable = true}, { .sensor_id = BMI2_WRIST_GESTURE, .cfg_func = configure_gesture_detect}, { .sensor_id = BMI2_WRIST_WEAR_WAKE_UP, .cfg_func = configure_wrist_wakeup}, @@ -417,7 +406,6 @@ static void configue_accel(struct bmi2_sens_config *config) config->cfg.acc.filter_perf = BMI2_POWER_OPT_MODE; } -#if USE_GYRO static void configue_gyro(struct bmi2_sens_config *config) { /* The user can change the following configuration parameters according to their requirement. */ @@ -445,14 +433,12 @@ static void configue_gyro(struct bmi2_sens_config *config) */ config->cfg.gyr.filter_perf = BMI2_POWER_OPT_MODE; } -#endif static void configure_step_counter(struct bmi2_sens_config *config) { config->cfg.step_counter.watermark_level = 1; } -#if USE_ANYMOTION static void configure_anymotion(struct bmi2_sens_config *config) { /* 1LSB equals 20ms. Default is 100ms, setting to 80ms. */ @@ -461,7 +447,6 @@ static void configure_anymotion(struct bmi2_sens_config *config) /* 1LSB equals to 0.48mg. Default is 83mg, setting to 50mg. */ config->cfg.any_motion.threshold = 0x68; } -#endif static void configure_gesture_detect(struct bmi2_sens_config *config) {