uint32_t ble_dfu_transport_close(void) { uint32_t err_code = NRF_SUCCESS; if ((m_flags & DFU_BLE_FLAG_TEAR_DOWN_IN_PROGRESS) != 0) { return NRF_SUCCESS; } m_flags |= DFU_BLE_FLAG_TEAR_DOWN_IN_PROGRESS; NRF_LOG_INFO("Waiting for buffers to be cleared before disconnect\r\n"); nrf_delay_ms(MAX_CONN_INTERVAL_MS*4); NRF_LOG_INFO("Disconnecting\r\n"); if (m_conn_handle != BLE_CONN_HANDLE_INVALID) { // Disconnect from peer. err_code = sd_ble_gap_disconnect(m_conn_handle, BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION); VERIFY_SUCCESS(err_code); } else if ((m_flags & DFU_BLE_FLAG_IS_ADVERTISING) != 0) { // If not connected, then the device will be advertising. Hence stop the advertising. err_code = advertising_stop(); VERIFY_SUCCESS(err_code); } // Stop the timer, disregard the result. (void)ble_conn_params_stop(); return err_code; }
static void dfu_reset_prepare(void) { uint32_t err_code; if (m_conn_handle != BLE_CONN_HANDLE_INVALID) { // Disconnect from peer. err_code = sd_ble_gap_disconnect(m_conn_handle, BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION); APP_ERROR_CHECK(err_code); err_code = bsp_indication_set(BSP_INDICATE_IDLE); APP_ERROR_CHECK(err_code); } else { // If not connected, then the device will be advertising. Hence stop the advertising. ble_advertising_stop(); } err_code = ble_conn_params_stop(); APP_ERROR_CHECK(err_code); }
uint32_t dfu_transport_close() { uint32_t err_code; if (IS_CONNECTED()) { // Disconnect from peer. err_code = sd_ble_gap_disconnect(m_conn_handle, BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION); APP_ERROR_CHECK(err_code); } else { // If not connected, then the device will be advertising. Hence stop the advertising. advertising_stop(); } err_code = ble_conn_params_stop(); APP_ERROR_CHECK(err_code); return NRF_SUCCESS; }
/**@brief Function for preparing for system reset. * * @details This function implements @ref dfu_app_reset_prepare_t. It will be called by * @ref dfu_app_handler.c before entering the bootloader/DFU. * This allows the current running application to shut down gracefully. */ static void reset_prepare(void) { uint32_t err_code; if (_conn_handle != BLE_CONN_HANDLE_INVALID) { // Disconnect from peer. err_code = sd_ble_gap_disconnect(_conn_handle, BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION); APP_ERROR_CHECK(err_code); } else { // If not connected, the device will be advertising. Hence stop the advertising. advertising_stop(); } err_code = ble_conn_params_stop(); APP_ERROR_CHECK(err_code); nrf_delay_ms(500); }
void ble_hrs_app_stop(void) { uint32_t err_code; // Stop any impending connection parameters update. err_code = ble_conn_params_stop(); APP_ERROR_CHECK(err_code); // Stop application timers. err_code = app_timer_stop(m_battery_timer_id); APP_ERROR_CHECK(err_code); err_code = app_timer_stop(m_heart_rate_timer_id); APP_ERROR_CHECK(err_code); err_code = app_timer_stop(m_rr_interval_timer_id); APP_ERROR_CHECK(err_code); err_code = app_timer_stop(m_sensor_contact_timer_id); APP_ERROR_CHECK(err_code); }
/** @snippet [DFU BLE Reset prepare] */ static void reset_prepare(void) { uint32_t err_code; if (m_conn_handle != BLE_CONN_HANDLE_INVALID) { // Disconnect from peer. err_code = sd_ble_gap_disconnect(m_conn_handle, BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION); APP_ERROR_CHECK(err_code); } else { // If not connected, then the device will be advertising. Hence stop the advertising. advertising_stop(); } nrf_gpio_pin_clear(ADVERTISING_LED_PIN_NO); nrf_gpio_pin_clear(CONNECTED_LED_PIN_NO); err_code = ble_conn_params_stop(); APP_ERROR_CHECK(err_code); }