*/ static void services_init(void) { uint32_t err_code; ble_hts_init_t hts_init; ble_bas_init_t bas_init; ble_dis_init_t dis_init; ble_dis_sys_id_t sys_id; // Initialize Health Thermometer Service memset(&hts_init, 0, sizeof(hts_init)); hts_init.evt_handler = on_hts_evt; hts_init.temp_type_as_characteristic = TEMP_TYPE_AS_CHARACTERISTIC; hts_init.temp_type = BLE_HTS_TEMP_TYPE_BODY; // Here the sec level for the Health Thermometer Service can be changed/increased. BLE_GAP_CONN_SEC_MODE_SET_ENC_NO_MITM(&hts_init.hts_meas_attr_md.cccd_write_perm); BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(&hts_init.hts_meas_attr_md.read_perm); BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(&hts_init.hts_meas_attr_md.write_perm); BLE_GAP_CONN_SEC_MODE_SET_OPEN(&hts_init.hts_temp_type_attr_md.read_perm); BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(&hts_init.hts_temp_type_attr_md.write_perm); err_code = ble_hts_init(&m_hts, &hts_init); APP_ERROR_CHECK(err_code); // 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_srv_ascii_to_utf8(&dis_init.model_num_str, MODEL_NUM); sys_id.manufacturer_id = MANUFACTURER_ID; sys_id.organizationally_unique_id = ORG_UNIQUE_ID; dis_init.p_sys_id = &sys_id; 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 Function for initializing services that will be used by the application. * * @details Initialize the Running Speed and Cadence, Battery and Device Information services. */ static void services_init(void) { uint32_t err_code; ble_rscs_init_t rscs_init; ble_bas_init_t bas_init; ble_dis_init_t dis_init; // Initialize Running Speed and Cadence Service memset(&rscs_init, 0, sizeof(rscs_init)); rscs_init.evt_handler = NULL; rscs_init.feature = BLE_RSCS_FEATURE_INSTANT_STRIDE_LEN_BIT | BLE_RSCS_FEATURE_WALKING_OR_RUNNING_STATUS_BIT; rscs_init.initial_rcm.is_inst_stride_len_present = true; rscs_init.initial_rcm.is_total_distance_present = false; rscs_init.initial_rcm.is_running = false; rscs_init.initial_rcm.inst_stride_length = 0; // Here the sec level for the Running Speed and Cadence Service can be changed/increased. BLE_GAP_CONN_SEC_MODE_SET_OPEN(&rscs_init.rsc_meas_attr_md.cccd_write_perm); BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(&rscs_init.rsc_meas_attr_md.read_perm); BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(&rscs_init.rsc_meas_attr_md.write_perm); BLE_GAP_CONN_SEC_MODE_SET_OPEN(&rscs_init.rsc_feature_attr_md.read_perm); BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(&rscs_init.rsc_feature_attr_md.write_perm); err_code = ble_rscs_init(&m_rscs, &rscs_init); APP_ERROR_CHECK(err_code); // 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); }
static void services_init(void){ uint32_t err_code; ble_bas_init_t bas_init; ble_nus_init_t nus_init; /* 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 = 0; err_code = ble_bas_init(&m_bas, &bas_init); APP_ERROR_CHECK(err_code); //Initialize nordic UART service memset(&nus_init, 0, sizeof(nus_init)); nus_init.data_handler = nus_data_handler; err_code = ble_nus_init(&m_nus, &nus_init); APP_ERROR_CHECK(err_code); }
/**@brief Initialize services that will be used by the application. * * @details Initialize the Blood Pressure, Battery and Device Information services. */ static void services_init(void) { uint32_t err_code; ble_bps_init_t bps_init; ble_bas_init_t bas_init; ble_dis_init_t dis_init; ble_dis_sys_id_t sys_id; // Initialize Blood Pressure Service memset(&bps_init, 0, sizeof(bps_init)); bps_init.evt_handler = on_bps_evt; bps_init.feature = BLE_BPS_FEATURE_BODY_MOVEMENT_BIT | BLE_BPS_FEATURE_MEASUREMENT_POSITION_BIT; // Here the sec level for the Blood Pressure Service can be changed/increased. BLE_GAP_CONN_SEC_MODE_SET_ENC_NO_MITM(&bps_init.bps_meas_attr_md.cccd_write_perm); BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(&bps_init.bps_meas_attr_md.read_perm); BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(&bps_init.bps_meas_attr_md.write_perm); BLE_GAP_CONN_SEC_MODE_SET_OPEN(&bps_init.bps_feature_attr_md.read_perm); BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(&bps_init.bps_feature_attr_md.write_perm); err_code = ble_bps_init(&m_bps, &bps_init); APP_ERROR_CHECK(err_code); // 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_srv_ascii_to_utf8(&dis_init.model_num_str, MODEL_NUM); sys_id.manufacturer_id = MANUFACTURER_ID; sys_id.organizationally_unique_id = ORG_UNIQUE_ID; dis_init.p_sys_id = &sys_id; 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 Function for initializing services that will be used by the application. * * @details Initialize the Heart Rate, Battery and Device Information services. */ static void services_init(void) { uint32_t err_code; ble_bas_init_t bas_init; ble_dis_init_t dis_init; ble_ossw_init_t ossw_init; memset(&ossw_init, 0, sizeof(ossw_init)); ossw_init.data_handler = ossw_data_handler; err_code = ble_ossw_init(&m_ossw, &ossw_init); APP_ERROR_CHECK(err_code); // 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, (char *)MANUFACTURER_NAME); ble_srv_ascii_to_utf8(&dis_init.fw_rev_str, (char *)FIRMWARE_VERSION); 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); #ifdef BLE_DFU_APP_SUPPORT /** @snippet [DFU BLE Service initialization] */ ble_dfu_init_t dfus_init; // Initialize the Device Firmware Update Service. memset(&dfus_init, 0, sizeof(dfus_init)); dfus_init.evt_handler = dfu_app_on_dfu_evt; dfus_init.error_handler = NULL; dfus_init.evt_handler = dfu_app_on_dfu_evt; dfus_init.revision = DFU_REVISION; err_code = ble_dfu_init(&m_dfus, &dfus_init); APP_ERROR_CHECK(err_code); dfu_app_reset_prepare_set(reset_prepare); dfu_app_dm_appl_instance_set(m_app_handle); /** @snippet [DFU BLE Service initialization] */ #endif // BLE_DFU_APP_SUPPORT }
/**@brief Function for initializing the services that will be used by the application. * * @details Initialize the Heart Rate, Battery and Device Information services. */ static void services_init(void) { uint32_t err_code; ble_hrs_init_t hrs_init; ble_bas_init_t bas_init; ble_dis_init_t dis_init; uint8_t body_sensor_location; /* // Initialize Heart Rate Service body_sensor_location = BLE_HRS_BODY_SENSOR_LOCATION_FINGER; memset(&hrs_init, 0, sizeof(hrs_init)); hrs_init.is_sensor_contact_supported = false; hrs_init.p_body_sensor_location = &body_sensor_location; // Here the sec level for the Heart Rate Service can be changed/increased. BLE_GAP_CONN_SEC_MODE_SET_OPEN(&hrs_init.hrs_hrm_attr_md.cccd_write_perm); BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(&hrs_init.hrs_hrm_attr_md.read_perm); BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(&hrs_init.hrs_hrm_attr_md.write_perm); BLE_GAP_CONN_SEC_MODE_SET_OPEN(&hrs_init.hrs_bsl_attr_md.read_perm); BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(&hrs_init.hrs_bsl_attr_md.write_perm); err_code = ble_hrs_init(&m_hrs, &hrs_init); APP_ERROR_CHECK(err_code); */ // 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(&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 Function for initializing services that will be used by the application. * * @details Initialize the Glucose, Battery and Device Information services. */ static void services_init(void) { uint32_t err_code; ble_gls_init_t gls_init; ble_dis_init_t dis_init; ble_bas_init_t bas_init; // Initialize Glucose Service - sample selection of feature bits. memset(&gls_init, 0, sizeof(gls_init)); gls_init.evt_handler = NULL; gls_init.error_handler = service_error_handler; gls_init.feature = 0; gls_init.feature |= BLE_GLS_FEATURE_LOW_BATT; gls_init.feature |= BLE_GLS_FEATURE_TEMP_HIGH_LOW; gls_init.feature |= BLE_GLS_FEATURE_GENERAL_FAULT; gls_init.is_context_supported = false; err_code = ble_gls_init(&m_gls, &gls_init); APP_ERROR_CHECK(err_code); // 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_srv_ascii_to_utf8(&dis_init.serial_num_str, MODEL_NUMBER); ble_dis_sys_id_t system_id; system_id.manufacturer_id = MANUFACTURER_ID; system_id.organizationally_unique_id = ORG_UNIQUE_ID; dis_init.p_sys_id = &system_id; 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 services that will be used by the application. * * @details Initialize the Cycling Speed and Cadence, Battery and Device Information services. */ static void services_init(void) { uint32_t err_code; ble_cscs_init_t cscs_init; ble_bas_init_t bas_init; ble_dis_init_t dis_init; // Initialize Cycling Speed and Cadence Service memset(&cscs_init, 0, sizeof(cscs_init)); cscs_init.evt_handler = NULL; cscs_init.feature = BLE_CSCS_FEATURE_WHEEL_REV_BIT | BLE_CSCS_FEATURE_CRANK_REV_BIT; // Here the sec level for the Cycling Speed and Cadence Service can be changed/increased. BLE_GAP_CONN_SEC_MODE_SET_OPEN(&cscs_init.csc_meas_attr_md.cccd_write_perm); BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(&cscs_init.csc_meas_attr_md.read_perm); BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(&cscs_init.csc_meas_attr_md.write_perm); BLE_GAP_CONN_SEC_MODE_SET_OPEN(&cscs_init.csc_feature_attr_md.read_perm); BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(&cscs_init.csc_feature_attr_md.write_perm); err_code = ble_cscs_init(&m_cscs, &cscs_init); APP_ERROR_CHECK(err_code); // 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); }
static void _ble_register_services(void) { /* GAP_SVC */ ble_gap_init(); pr_info(LOG_MODULE_BLE, "Registering %s", "GAP"); /* DIS_SVC */ ble_dis_init(); pr_info(LOG_MODULE_BLE, "Registering %s", "DIS"); /* BAS_SVC */ ble_bas_init(); pr_info(LOG_MODULE_BLE, "Registering %s", "BAS"); #ifdef CONFIG_BLE_HRS_LIB /* HRM_SVC */ ble_hrs_init(); pr_info(LOG_MODULE_BLE, "Registering %s", "HRM"); #endif #ifdef CONFIG_BLE_LNS_LIB /* LNS_SVC */ ble_lns_init(); pr_info(LOG_MODULE_BLE, "Registering %s", "LNS"); #endif #ifdef CONFIG_BLE_RSCS_LIB /* RSC_SVC */ ble_rscs_init(); pr_info(LOG_MODULE_BLE, "Registering %s", "RSC"); #endif #if defined(CONFIG_PACKAGE_ISPP) /* ISPP_SVC */ ble_ispp_init(); pr_info(LOG_MODULE_BLE, "Registering %s", "ISPP"); #endif #if defined(CONFIG_UAS) ble_uas_init(); pr_info(LOG_MODULE_BLE, "Registering %s", "UAS"); #endif on_ble_app_started(); }
/**@brief Function for initializing services that will be used by the application. * * @details Initialize the Glucose, Battery and Device Information services. */ static void services_init(void) { uint32_t err_code; ble_dis_init_t dis_init; ble_bas_init_t bas_init; // 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_srv_ascii_to_utf8(&dis_init.serial_num_str, MODEL_NUMBER); ble_dis_sys_id_t system_id; system_id.manufacturer_id = MANUFACTURER_ID; system_id.organizationally_unique_id = ORG_UNIQUE_ID; dis_init.p_sys_id = &system_id; 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 Function for initializing Battery Service. */ static void bas_init(void) { uint32_t err_code; ble_bas_init_t bascfg; memset(&bascfg, 0, sizeof(bascfg)); bascfg.evt_handler = NULL; bascfg.support_notification = true; bascfg.p_report_ref = NULL; bascfg.initial_batt_level = 100; BLE_GAP_CONN_SEC_MODE_SET_ENC_NO_MITM(&bascfg.battery_level_char_attr_md.cccd_write_perm); BLE_GAP_CONN_SEC_MODE_SET_ENC_NO_MITM(&bascfg.battery_level_char_attr_md.read_perm); BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(&bascfg.battery_level_char_attr_md.write_perm); BLE_GAP_CONN_SEC_MODE_SET_ENC_NO_MITM(&bascfg.battery_level_report_read_perm); err_code = ble_bas_init(&g_BatServ, &bascfg); APP_ERROR_CHECK(err_code); }
/**@brief Function for initializing the Battery Service. */ static void bas_init(void) { uint32_t err_code; ble_bas_init_t bas_init_obj; memset(&bas_init_obj, 0, sizeof(bas_init_obj)); bas_init_obj.evt_handler = on_bas_evt; bas_init_obj.support_notification = true; bas_init_obj.p_report_ref = NULL; bas_init_obj.initial_batt_level = 100; BLE_GAP_CONN_SEC_MODE_SET_OPEN(&bas_init_obj.battery_level_char_attr_md.cccd_write_perm); BLE_GAP_CONN_SEC_MODE_SET_OPEN(&bas_init_obj.battery_level_char_attr_md.read_perm); BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(&bas_init_obj.battery_level_char_attr_md.write_perm); BLE_GAP_CONN_SEC_MODE_SET_OPEN(&bas_init_obj.battery_level_report_read_perm); err_code = ble_bas_init(&m_bas, &bas_init_obj); APP_ERROR_CHECK(err_code); }
/**@brief Function for initializing services that will be used by the application. * * @details Initialize the Running Speed and Cadence, Battery and Device Information services. */ static void services_init(void) { uint32_t err_code; ble_rscs_init_t rscs_init; ble_bas_init_t bas_init; ble_dis_init_t dis_init; // Initialize Running Speed and Cadence Service memset(&rscs_init, 0, sizeof(rscs_init)); rscs_init.evt_handler = NULL; rscs_init.feature = BLE_RSCS_FEATURE_INSTANT_STRIDE_LEN_BIT | BLE_RSCS_FEATURE_WALKING_OR_RUNNING_STATUS_BIT; rscs_init.initial_rcm.is_inst_stride_len_present = true; rscs_init.initial_rcm.is_total_distance_present = false; rscs_init.initial_rcm.is_running = false; rscs_init.initial_rcm.inst_stride_length = 0; // Here the sec level for the Running Speed and Cadence Service can be changed/increased. BLE_GAP_CONN_SEC_MODE_SET_OPEN(&rscs_init.rsc_meas_attr_md.cccd_write_perm); BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(&rscs_init.rsc_meas_attr_md.read_perm); BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(&rscs_init.rsc_meas_attr_md.write_perm); BLE_GAP_CONN_SEC_MODE_SET_OPEN(&rscs_init.rsc_feature_attr_md.read_perm); BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(&rscs_init.rsc_feature_attr_md.write_perm); err_code = ble_rscs_init(&m_rscs, &rscs_init); APP_ERROR_CHECK(err_code); // 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); #ifdef BLE_DFU_APP_SUPPORT /** @snippet [DFU BLE Service initialization] */ ble_dfu_init_t dfus_init; // Initialize the Device Firmware Update Service. memset(&dfus_init, 0, sizeof(dfus_init)); dfus_init.evt_handler = dfu_app_on_dfu_evt; dfus_init.error_handler = NULL; dfus_init.evt_handler = dfu_app_on_dfu_evt; dfus_init.revision = DFU_REVISION; err_code = ble_dfu_init(&m_dfus, &dfus_init); APP_ERROR_CHECK(err_code); dfu_app_reset_prepare_set(reset_prepare); dfu_app_dm_appl_instance_set(m_app_handle); /** @snippet [DFU BLE Service initialization] */ #endif // BLE_DFU_APP_SUPPORT #ifdef BLE_DATA_SYNC_SUPPORT ble_data_sync_init_t data_syncs_init; memset(&data_syncs_init, 0, sizeof(data_syncs_init)); data_syncs_init.revision = 0X02; err_code = ble_data_sync_init(&m_data_syncs, &data_syncs_init); APP_ERROR_CHECK(err_code); #endif }
/**@brief Function for initializing services that will be used by the application. * * @details Initialize the Cycling Speed and Cadence, Battery and Device Information services. */ static void services_init(void) { uint32_t err_code; ble_cscs_init_t cscs_init; ble_bas_init_t bas_init; ble_dis_init_t dis_init; ble_sensor_location_t sensor_location; // Initialize Cycling Speed and Cadence Service. memset(&cscs_init, 0, sizeof(cscs_init)); cscs_init.evt_handler = NULL; cscs_init.feature = BLE_CSCS_FEATURE_WHEEL_REV_BIT | BLE_CSCS_FEATURE_CRANK_REV_BIT | BLE_CSCS_FEATURE_MULTIPLE_SENSORS_BIT; // Here the sec level for the Cycling Speed and Cadence Service can be changed/increased. BLE_GAP_CONN_SEC_MODE_SET_OPEN(&cscs_init.csc_meas_attr_md.cccd_write_perm); // for the measurement characteristic, only the CCCD write permission can be set by the application, others are mandated by service specification BLE_GAP_CONN_SEC_MODE_SET_OPEN(&cscs_init.csc_feature_attr_md.read_perm); // for the feature characteristic, only the read permission can be set by the application, others are mandated by service specification BLE_GAP_CONN_SEC_MODE_SET_OPEN(&cscs_init.csc_ctrlpt_attr_md.write_perm); // for the SC control point characteristic, only the write permission and CCCD write can be set by the application, others are mandated by service specification BLE_GAP_CONN_SEC_MODE_SET_OPEN(&cscs_init.csc_ctrlpt_attr_md.cccd_write_perm); // for the SC control point characteristic, only the write permission and CCCD write can be set by the application, others are mandated by service specification cscs_init.ctrplt_supported_functions = BLE_SRV_SC_CTRLPT_CUM_VAL_OP_SUPPORTED |BLE_SRV_SC_CTRLPT_SENSOR_LOCATIONS_OP_SUPPORTED |BLE_SRV_SC_CTRLPT_START_CALIB_OP_SUPPORTED; cscs_init.ctrlpt_evt_handler = sc_ctrlpt_event_handler; cscs_init.list_supported_locations = supported_locations; cscs_init.size_list_supported_locations = sizeof(supported_locations) / sizeof(ble_sensor_location_t); sensor_location = BLE_SENSOR_LOCATION_FRONT_WHEEL; // initializes the sensor location to add the sensor location characteristic. cscs_init.sensor_location = &sensor_location; BLE_GAP_CONN_SEC_MODE_SET_OPEN(&cscs_init.csc_sensor_loc_attr_md.read_perm); // for the sensor location characteristic, only the read permission can be set by the application, others are mendated by service specification err_code = ble_cscs_init(&m_cscs, &cscs_init); APP_ERROR_CHECK(err_code); // 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 Function for initializing services that will be used by the application. * * @details Initialize the Running Speed and Cadence, Battery and Device Information services. */ static void services_init(void) { uint32_t err_code; ble_hts_init_t hts_init; ble_rscs_init_t rscs_init; ble_bas_init_t bas_init; ble_dis_init_t dis_init; // Initialize Health Thermometer Service memset(&hts_init, 0, sizeof(hts_init)); hts_init.evt_handler = on_hts_evt; hts_init.temp_type_as_characteristic = 0; hts_init.temp_type = BLE_HTS_TEMP_TYPE_BODY; // Here the sec level for the Health Thermometer Service can be changed/increased. BLE_GAP_CONN_SEC_MODE_SET_ENC_NO_MITM(&hts_init.hts_meas_attr_md.cccd_write_perm); BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(&hts_init.hts_meas_attr_md.read_perm); BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(&hts_init.hts_meas_attr_md.write_perm); BLE_GAP_CONN_SEC_MODE_SET_OPEN(&hts_init.hts_temp_type_attr_md.read_perm); BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(&hts_init.hts_temp_type_attr_md.write_perm); err_code = ble_hts_init(&m_hts, &hts_init); APP_ERROR_CHECK(err_code); // Initialize Running Speed and Cadence Service memset(&rscs_init, 0, sizeof(rscs_init)); rscs_init.evt_handler = NULL; rscs_init.feature = BLE_RSCS_FEATURE_INSTANT_STRIDE_LEN_BIT| BLE_RSCS_FEATURE_TOTAL_DISTANCE_BIT| // BLE_RSCS_FEATURE_WALKING_OR_RUNNING_STATUS_BIT; // Here the sec level for the Running Speed and Cadence Service can be changed/increased. BLE_GAP_CONN_SEC_MODE_SET_OPEN(&rscs_init.rsc_meas_attr_md.cccd_write_perm); BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(&rscs_init.rsc_meas_attr_md.read_perm); BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(&rscs_init.rsc_meas_attr_md.write_perm); BLE_GAP_CONN_SEC_MODE_SET_OPEN(&rscs_init.rsc_feature_attr_md.read_perm); BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(&rscs_init.rsc_feature_attr_md.write_perm); err_code = ble_rscs_init(&m_rscs, &rscs_init); APP_ERROR_CHECK(err_code); // 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 Function for initializing services that will be used by the application. * * @details Initialize the Heart Rate, Battery and Device Information services. */ static void services_init(void) { uint32_t err_code; ble_bas_init_t bas_init; ble_dis_init_t dis_init; // 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); if (err_code == NRF_SUCCESS) debug_printf("Battery service initialised!\r\n"); else { debug_printf("Error with initialising battery service.\r\n"); APP_ERROR_CHECK(err_code); } // Initialize Device Information Service. memset(&dis_init, 0, sizeof(dis_init)); 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); if (err_code == NRF_SUCCESS) debug_printf("Device Information service initialised!\r\n"); else { debug_printf("Error with initialising device information service.\r\n"); APP_ERROR_CHECK(err_code); } // Initialize CCH custom Service. cch_service_init(&m_cch_service); #ifdef BLE_DFU_APP_SUPPORT /** @snippet [DFU BLE Service initialization] */ ble_dfu_init_t dfus_init; // Initialize the Device Firmware Update Service. memset(&dfus_init, 0, sizeof(dfus_init)); dfus_init.evt_handler = dfu_app_on_dfu_evt; dfus_init.error_handler = NULL; dfus_init.evt_handler = dfu_app_on_dfu_evt; dfus_init.revision = DFU_REVISION; err_code = ble_dfu_init(&m_dfus, &dfus_init); APP_ERROR_CHECK(err_code); dfu_app_reset_prepare_set(reset_prepare); dfu_app_dm_appl_instance_set(m_app_handle); /** @snippet [DFU BLE Service initialization] */ #endif // BLE_DFU_APP_SUPPORT }
/**@brief Function for initializing services that will be used by the application. * * @details Initialize the Heart Rate, Battery and Device Information services. */ static void services_init(void) { uint32_t err_code; ble_hrs_init_t hrs_init; ble_bas_init_t bas_init; ble_dis_init_t dis_init; uint8_t body_sensor_location; // Initialize Heart Rate Service. body_sensor_location = BLE_HRS_BODY_SENSOR_LOCATION_FINGER; memset(&hrs_init, 0, sizeof(hrs_init)); hrs_init.evt_handler = NULL; hrs_init.is_sensor_contact_supported = true; hrs_init.p_body_sensor_location = &body_sensor_location; // Here the sec level for the Heart Rate Service can be changed/increased. BLE_GAP_CONN_SEC_MODE_SET_OPEN(&hrs_init.hrs_hrm_attr_md.cccd_write_perm); //***************MODIFIED BLE_GAP_CONN_SEC_MODE_SET_OPEN(&hrs_init.hrs_hrm_attr_md.read_perm); BLE_GAP_CONN_SEC_MODE_SET_OPEN(&hrs_init.hrs_hrm_attr_md.write_perm); //********************* BLE_GAP_CONN_SEC_MODE_SET_OPEN(&hrs_init.hrs_bsl_attr_md.read_perm); BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(&hrs_init.hrs_bsl_attr_md.write_perm); err_code = ble_hrs_init(&m_hrs, &hrs_init); APP_ERROR_CHECK(err_code); // 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, (char *)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); #ifdef BLE_DFU_APP_SUPPORT /** @snippet [DFU BLE Service initialization] */ ble_dfu_init_t dfus_init; // Initialize the Device Firmware Update Service. memset(&dfus_init, 0, sizeof(dfus_init)); dfus_init.evt_handler = dfu_app_on_dfu_evt; dfus_init.error_handler = NULL; //service_error_handler - Not used as only the switch from app to DFU mode is required and not full dfu service. err_code = ble_dfu_init(&m_dfus, &dfus_init); APP_ERROR_CHECK(err_code); dfu_app_reset_prepare_set(reset_prepare); /** @snippet [DFU BLE Service initialization] */ #endif // BLE_DFU_APP_SUPPORT }
/**@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); }