/**@brief Initialization of the Alert Notification Service Client. */ static void alert_notification_init(void) { uint32_t err_code; ble_ans_c_init_t ans_init_obj; bool services_delete; memset(&ans_init_obj, 0, sizeof(ans_init_obj)); memset(m_alert_message_buffer, 0, MESSAGE_BUFFER_SIZE); ans_init_obj.evt_handler = on_ans_c_evt; ans_init_obj.message_buffer_size = MESSAGE_BUFFER_SIZE; ans_init_obj.p_message_buffer = m_alert_message_buffer; ans_init_obj.flash_page_num = ANS_FLASH_PAGE; ans_init_obj.error_handler = alert_notification_error_handler; err_code = ble_ans_c_init(&m_ans_c, &ans_init_obj); APP_ERROR_CHECK(err_code); // Clear all discovered and stored services if the "non-connectable advertisement start" // button is pushed err_code = app_button_is_pushed(BONDMNGR_DELETE_BUTTON_PIN_NO, &services_delete); APP_ERROR_CHECK(err_code); if (services_delete) { err_code = ble_ans_c_service_delete(); APP_ERROR_CHECK(err_code); } err_code = ble_ans_c_service_load(&m_ans_c); APP_ERROR_CHECK(err_code); }
static void service_add(void) { ble_ancs_c_init_t ancs_init_obj; ble_uuid_t service_uuid; uint32_t err_code; bool services_delete; err_code = sd_ble_uuid_vs_add(&ble_ancs_base_uuid128, &m_ancs_uuid_type); APP_ERROR_CHECK(err_code); err_code = sd_ble_uuid_vs_add(&ble_ancs_cp_base_uuid128, &service_uuid.type); APP_ERROR_CHECK(err_code); err_code = sd_ble_uuid_vs_add(&ble_ancs_ns_base_uuid128, &service_uuid.type); APP_ERROR_CHECK(err_code); err_code = sd_ble_uuid_vs_add(&ble_ancs_ds_base_uuid128, &service_uuid.type); APP_ERROR_CHECK(err_code); memset(&ancs_init_obj, 0, sizeof(ancs_init_obj)); memset(m_apple_message_buffer, 0, MESSAGE_BUFFER_SIZE); ancs_init_obj.evt_handler = on_ancs_c_evt; ancs_init_obj.message_buffer_size = MESSAGE_BUFFER_SIZE; ancs_init_obj.p_message_buffer = m_apple_message_buffer; ancs_init_obj.error_handler = apple_notification_error_handler; err_code = ble_ancs_c_init(&m_ancs_c, &ancs_init_obj); APP_ERROR_CHECK(err_code); // Clear all discovered and stored services if the "delete all bonds" button is pushed. err_code = bsp_button_is_pressed(BOND_DELETE_ALL_WAKEUP_BUTTON_ID,&(services_delete)); APP_ERROR_CHECK(err_code); if (services_delete) { err_code = ble_ans_c_service_delete(); APP_ERROR_CHECK(err_code); } err_code = ble_ans_c_service_load(&m_ancs_c); APP_ERROR_CHECK(err_code); }