/**@brief Function for initializing the sensor simulators. */ static void sensor_simulator_init(void) { m_battery_sim_cfg.min = MIN_BATTERY_LEVEL; m_battery_sim_cfg.max = MAX_BATTERY_LEVEL; m_battery_sim_cfg.incr = BATTERY_LEVEL_INCREMENT; m_battery_sim_cfg.start_at_max = true; sensorsim_init(&m_battery_sim_state, &m_battery_sim_cfg); // speed is in units of meters per second divided by 256 m_speed_mps_sim_cfg.min = (uint32_t)(MIN_SPEED_MPS * 256); m_speed_mps_sim_cfg.max = (uint32_t)(MAX_SPEED_MPS * 256); m_speed_mps_sim_cfg.incr = (uint32_t)(SPEED_MPS_INCREMENT * 256); m_speed_mps_sim_cfg.start_at_max = false; sensorsim_init(&m_speed_mps_sim_state, &m_speed_mps_sim_cfg); m_cadence_rpm_sim_cfg.min = MIN_CADENCE_RPM; m_cadence_rpm_sim_cfg.max = MAX_CADENCE_RPM; m_cadence_rpm_sim_cfg.incr = CADENCE_RPM_INCREMENT; m_cadence_rpm_sim_cfg.start_at_max = false; sensorsim_init(&m_cadence_rpm_sim_state, &m_cadence_rpm_sim_cfg); m_cadence_stl_sim_cfg.min = MIN_STRIDE_LENGTH; m_cadence_stl_sim_cfg.max = MAX_STRIDE_LENGTH; m_cadence_stl_sim_cfg.incr = STRIDE_LENGTH_INCREMENT; m_cadence_stl_sim_cfg.start_at_max = false; sensorsim_init(&m_cadence_stl_sim_state, &m_cadence_stl_sim_cfg); }
/**@brief Function for initializing the sensor simulators. */ static void sensor_simulator_init(void) { m_battery_sim_cfg.min = MIN_BATTERY_LEVEL; m_battery_sim_cfg.max = MAX_BATTERY_LEVEL; m_battery_sim_cfg.incr = BATTERY_LEVEL_INCREMENT; m_battery_sim_cfg.start_at_max = true; sensorsim_init(&m_battery_sim_state, &m_battery_sim_cfg); m_speed_kph_sim_cfg.min = MIN_SPEED_KPH; m_speed_kph_sim_cfg.max = MAX_SPEED_KPH; m_speed_kph_sim_cfg.incr = SPEED_KPH_INCREMENT; m_speed_kph_sim_cfg.start_at_max = false; sensorsim_init(&m_speed_kph_sim_state, &m_speed_kph_sim_cfg); m_crank_rpm_sim_cfg.min = MIN_CRANK_RPM; m_crank_rpm_sim_cfg.max = MAX_CRANK_RPM; m_crank_rpm_sim_cfg.incr = CRANK_RPM_INCREMENT; m_crank_rpm_sim_cfg.start_at_max = false; sensorsim_init(&m_crank_rpm_sim_state, &m_crank_rpm_sim_cfg); m_cumulative_wheel_revs = 0; m_auto_calibration_in_progress = false; }
/**@brief Function for initializing the sensor simulators. */ static void sensor_simulator_init(void) { m_battery_sim_cfg.min = MIN_BATTERY_LEVEL; m_battery_sim_cfg.max = MAX_BATTERY_LEVEL; m_battery_sim_cfg.incr = BATTERY_LEVEL_INCREMENT; m_battery_sim_cfg.start_at_max = true; sensorsim_init(&m_battery_sim_state, &m_battery_sim_cfg); // Temperature is in celcius (it is multiplied by 100 to avoid floating point arithmetic). m_temp_celcius_sim_cfg.min = MIN_CELCIUS_DEGREES; m_temp_celcius_sim_cfg.max = MAX_CELCIUS_DEGRESS; m_temp_celcius_sim_cfg.incr = CELCIUS_DEGREES_INCREMENT; m_temp_celcius_sim_cfg.start_at_max = false; sensorsim_init(&m_temp_celcius_sim_state, &m_temp_celcius_sim_cfg); }
/**@brief Function for initializing the sensor simulators. */ static void sensor_simulator_init(void) { m_battery_sim_cfg.min = MIN_BATTERY_LEVEL; m_battery_sim_cfg.max = MAX_BATTERY_LEVEL; m_battery_sim_cfg.incr = BATTERY_LEVEL_INCREMENT; m_battery_sim_cfg.start_at_max = true; sensorsim_init(&m_battery_sim_state, &m_battery_sim_cfg); }
/**@brief Function for initializing the sensor simulators. */ static void sensor_simulator_init(void) { m_battery_sim_cfg.min = MIN_BATTERY_LEVEL; m_battery_sim_cfg.max = MAX_BATTERY_LEVEL; m_battery_sim_cfg.incr = BATTERY_LEVEL_INCREMENT; m_battery_sim_cfg.start_at_max = true; sensorsim_init(&m_battery_sim_state, &m_battery_sim_cfg); m_heart_rate_sim_cfg.min = MIN_HEART_RATE; m_heart_rate_sim_cfg.max = MAX_HEART_RATE; m_heart_rate_sim_cfg.incr = HEART_RATE_INCREMENT; m_heart_rate_sim_cfg.start_at_max = false; sensorsim_init(&m_heart_rate_sim_state, &m_heart_rate_sim_cfg); m_rr_interval_sim_cfg.min = MIN_RR_INTERVAL; m_rr_interval_sim_cfg.max = MAX_RR_INTERVAL; m_rr_interval_sim_cfg.incr = RR_INTERVAL_INCREMENT; m_rr_interval_sim_cfg.start_at_max = false; sensorsim_init(&m_rr_interval_sim_state, &m_rr_interval_sim_cfg); }
void ant_hrm_simulator_init(ant_hrm_simulator_t * p_simulator, ant_hrm_simulator_cfg_t const * p_config, bool auto_change) { p_simulator->p_profile = p_config->p_profile; p_simulator->_cb.sensorsim_cfg = p_config->sensorsim_cfg; p_simulator->_cb.auto_change = auto_change; p_simulator->_cb.sensorsim_state.current_val = p_simulator->_cb.sensorsim_cfg.min; p_simulator->_cb.time_since_last_hb = 0; p_simulator->_cb.fraction_since_last_hb = 0; sensorsim_init(&(p_simulator->_cb.sensorsim_state), &(p_simulator->_cb.sensorsim_cfg)); }
/**@brief Function for initializing the sensor simulators. */ static void sensor_simulator_init(void) { m_battery_sim_cfg.min = MIN_BATTERY_LEVEL; m_battery_sim_cfg.max = MAX_BATTERY_LEVEL; m_battery_sim_cfg.incr = BATTERY_LEVEL_INCREMENT; m_battery_sim_cfg.start_at_max = true; sensorsim_init(&m_battery_sim_state, &m_battery_sim_cfg); // Simulated measurement #1. m_bps_meas_sim_val[0].systolic.mantissa = SIM_MEAS_1_SYSTOLIC; m_bps_meas_sim_val[0].systolic.exponent = 0; m_bps_meas_sim_val[0].diastolic.mantissa = SIM_MEAS_1_DIASTOLIC; m_bps_meas_sim_val[0].diastolic.exponent = 0; m_bps_meas_sim_val[0].mean_arterial.mantissa = SIM_MEAS_1_MEAN_AP; m_bps_meas_sim_val[0].mean_arterial.exponent = 0; m_bps_meas_sim_val[0].pulse_rate.mantissa = SIM_MEAS_1_PULSE_RATE; m_bps_meas_sim_val[0].pulse_rate.exponent = 0; // Simulated measurement #2. m_bps_meas_sim_val[1].systolic.mantissa = SIM_MEAS_2_SYSTOLIC; m_bps_meas_sim_val[1].systolic.exponent = 0; m_bps_meas_sim_val[1].diastolic.mantissa = SIM_MEAS_2_DIASTOLIC; m_bps_meas_sim_val[1].diastolic.exponent = 0; m_bps_meas_sim_val[1].mean_arterial.mantissa = SIM_MEAS_2_MEAN_AP; m_bps_meas_sim_val[1].mean_arterial.exponent = 0; m_bps_meas_sim_val[1].pulse_rate.mantissa = SIM_MEAS_2_PULSE_RATE; m_bps_meas_sim_val[1].pulse_rate.exponent = 0; // Simulated measurement #3. m_bps_meas_sim_val[2].systolic.mantissa = SIM_MEAS_3_SYSTOLIC; m_bps_meas_sim_val[2].systolic.exponent = 0; m_bps_meas_sim_val[2].diastolic.mantissa = SIM_MEAS_3_DIASTOLIC; m_bps_meas_sim_val[2].diastolic.exponent = 0; m_bps_meas_sim_val[2].mean_arterial.mantissa = SIM_MEAS_3_MEAN_AP; m_bps_meas_sim_val[2].mean_arterial.exponent = 0; m_bps_meas_sim_val[2].pulse_rate.mantissa = SIM_MEAS_3_PULSE_RATE; m_bps_meas_sim_val[2].pulse_rate.exponent = 0; // Simulated measurement #4. m_bps_meas_sim_val[3].systolic.mantissa = SIM_MEAS_4_SYSTOLIC; m_bps_meas_sim_val[3].systolic.exponent = 0; m_bps_meas_sim_val[3].diastolic.mantissa = SIM_MEAS_4_DIASTOLIC; m_bps_meas_sim_val[3].diastolic.exponent = 0; m_bps_meas_sim_val[3].mean_arterial.mantissa = SIM_MEAS_4_MEAN_AP; m_bps_meas_sim_val[3].mean_arterial.exponent = 0; m_bps_meas_sim_val[3].pulse_rate.mantissa = SIM_MEAS_4_PULSE_RATE; m_bps_meas_sim_val[3].pulse_rate.exponent = 0; }
void ant_sdm_simulator_init(ant_sdm_simulator_t * p_simulator, ant_sdm_simulator_cfg_t const * p_config, bool auto_change) { p_simulator->p_profile = p_config->p_profile; p_simulator->_cb.stride_length = p_config->stride_length; p_simulator->_cb.burn_rate = p_config->burn_rate; p_simulator->_cb.sensorsim_cfg = p_config->sensorsim_cfg; p_simulator->_cb.auto_change = auto_change; p_simulator->_cb.sensorsim_state.current_val = p_simulator->_cb.sensorsim_cfg.min; p_simulator->_cb.stride_incr = 0; p_simulator->_cb.time = 0; sensorsim_init(&(p_simulator->_cb.sensorsim_state), &(p_simulator->_cb.sensorsim_cfg)); }
void puls_simulate_init( ant_hrm_profile_t * p_related_profile, uint8_t init_heart_rate, bool auto_change) { mp_related_hrm_profile = p_related_profile; m_heart_rate_value = init_heart_rate; m_auto_change = auto_change; if (m_auto_change) { sensorsim_init( &m_sensorsim_state, &m_sensorsim_cfg); } m_time_since_last_hb = 0; m_fraction_since_last_hb = 0; }
/**@brief Initialize services that will be used by the application. * * @details Initialize the Location and Navigation, Battery and Device Information services. */ static void services_init(void) { uint32_t err_code; ble_lns_init_t lns_init; ble_bas_init_t bas_init; ble_dis_init_t dis_init; memset(&lns_init, 0, sizeof(lns_init)); lns_init.evt_handler = on_lns_evt; lns_init.lncp_evt_handler = on_ln_ctrlpt_evt; lns_init.error_handler = lns_error_handler; lns_init.is_position_quality_present = true; lns_init.is_control_point_present = true; lns_init.is_navigation_present = true; lns_init.available_features = BLE_LNS_FEATURE_INSTANT_SPEED_SUPPORTED | BLE_LNS_FEATURE_TOTAL_DISTANCE_SUPPORTED | BLE_LNS_FEATURE_LOCATION_SUPPORTED | BLE_LNS_FEATURE_ELEVATION_SUPPORTED | BLE_LNS_FEATURE_HEADING_SUPPORTED | BLE_LNS_FEATURE_ROLLING_TIME_SUPPORTED | BLE_LNS_FEATURE_UTC_TIME_SUPPORTED | BLE_LNS_FEATURE_REMAINING_DISTANCE_SUPPORTED | BLE_LNS_FEATURE_REMAINING_VERT_DISTANCE_SUPPORTED | BLE_LNS_FEATURE_EST_TIME_OF_ARRIVAL_SUPPORTED | BLE_LNS_FEATURE_NUM_SATS_IN_SOLUTION_SUPPORTED | BLE_LNS_FEATURE_NUM_SATS_IN_VIEW_SUPPORTED | BLE_LNS_FEATURE_TIME_TO_FIRST_FIX_SUPPORTED | BLE_LNS_FEATURE_EST_HORZ_POS_ERROR_SUPPORTED | BLE_LNS_FEATURE_EST_VERT_POS_ERROR_SUPPORTED | BLE_LNS_FEATURE_HORZ_DILUTION_OF_PRECISION_SUPPORTED | BLE_LNS_FEATURE_VERT_DILUTION_OF_PRECISION_SUPPORTED | BLE_LNS_FEATURE_LOC_AND_SPEED_CONTENT_MASKING_SUPPORTED | BLE_LNS_FEATURE_FIX_RATE_SETTING_SUPPORTED | BLE_LNS_FEATURE_ELEVATION_SETTING_SUPPORTED | BLE_LNS_FEATURE_POSITION_STATUS_SUPPORTED; m_sim_location_speed = initial_lns_location_speed; m_sim_position_quality = initial_lns_pos_quality; m_sim_navigation = initial_lns_navigation; lns_init.p_location_speed = &m_sim_location_speed; lns_init.p_position_quality = &m_sim_position_quality; lns_init.p_navigation = &m_sim_navigation; lns_init.loc_nav_feature_security_req_read_perm = SEC_OPEN; lns_init.loc_speed_security_req_cccd_write_perm = SEC_OPEN; lns_init.position_quality_security_req_read_perm = SEC_OPEN; lns_init.navigation_security_req_cccd_write_perm = SEC_OPEN; lns_init.ctrl_point_security_req_write_perm = SEC_OPEN; lns_init.ctrl_point_security_req_cccd_write_perm = SEC_OPEN; err_code = ble_lns_init(&m_lns, &lns_init); APP_ERROR_CHECK(err_code); ble_lns_route_t route1 = {.route_name = "Route one"}; err_code = ble_lns_add_route(&m_lns, &route1); ble_lns_route_t route2 = {.route_name = "Route two"}; err_code = ble_lns_add_route(&m_lns, &route2); // Initialize Battery Service memset(&bas_init, 0, sizeof(bas_init)); // Here the sec level for the Battery Service can be changed/increased. BLE_GAP_CONN_SEC_MODE_SET_OPEN(&bas_init.battery_level_char_attr_md.cccd_write_perm); BLE_GAP_CONN_SEC_MODE_SET_OPEN(&bas_init.battery_level_char_attr_md.read_perm); BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(&bas_init.battery_level_char_attr_md.write_perm); BLE_GAP_CONN_SEC_MODE_SET_OPEN(&bas_init.battery_level_report_read_perm); bas_init.evt_handler = NULL; bas_init.support_notification = true; bas_init.p_report_ref = NULL; bas_init.initial_batt_level = 100; err_code = ble_bas_init(&m_bas, &bas_init); APP_ERROR_CHECK(err_code); // Initialize Device Information Service memset(&dis_init, 0, sizeof(dis_init)); ble_srv_ascii_to_utf8(&dis_init.manufact_name_str, MANUFACTURER_NAME); BLE_GAP_CONN_SEC_MODE_SET_OPEN(&dis_init.dis_attr_md.read_perm); BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(&dis_init.dis_attr_md.write_perm); err_code = ble_dis_init(&dis_init); APP_ERROR_CHECK(err_code); } /**@brief Initialize the simulators. */ static void sim_init(void) { // battery simulation m_battery_sim_cfg.min = MIN_BATTERY_LEVEL; m_battery_sim_cfg.max = MAX_BATTERY_LEVEL; m_battery_sim_cfg.incr = BATTERY_LEVEL_INCREMENT; m_battery_sim_cfg.start_at_max = true; sensorsim_init(&m_battery_sim_state, &m_battery_sim_cfg); } /**@brief Start application timers. */ static void application_timers_start(void) { uint32_t err_code; // Start application timers err_code = app_timer_start(m_battery_timer_id, BATTERY_LEVEL_MEAS_INTERVAL, NULL); APP_ERROR_CHECK(err_code); err_code = app_timer_start(m_loc_and_nav_timer_id, LOC_AND_NAV_DATA_INTERVAL, NULL); APP_ERROR_CHECK(err_code); }