This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Cannot disconnect the device once it is connected

Hello guys,

I have problem, I activate the BLE and connect it to my tablet application until then nothing wrong happens. But when I use sd_ble_gap_disconnect() to disconnect, I got error_code 0x3002 which prevent me to disconnect.

what I do to disconnect:

check = softdevice_handler_isEnabled();
if (check == true && m_conn_handle != BLE_CONN_HANDLE_INVALID)
{
	u32_err_code = sd_ble_gap_disconnect(m_conn_handle, BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION);
	m_conn_handle = BLE_CONN_HANDLE_INVALID;
    APP_ERROR_CHECK(u32_err_code); //err_code returned before check 0x3002
}
u32_err_code = sd_ble_gap_adv_stop();
APP_ERROR_CHECK(u32_err_code);  //err_code returned before check 0x0008

I use nrf52832, s132 softdevice with uart. I want to be disconnected and stop advertising, can any one please let me know how to correct this.

Thanks in advance for your time!

PS: The device is a peripheral one

Parents
  • i tried doing it adding brackets to my statement but nothing changed. And I also tried to trace the modification of m_conn_handle but I only modify it after being disconnected

    static void on_disconnect(ble_evt_t * p_ble_evt)
    {
        uint32_t err_code;
    
        m_conn_handle = BLE_CONN_HANDLE_INVALID;
    
        // Stop timer if running
        m_update_count = 0; // Connection parameters updates should happen during every connection
    
        err_code = app_timer_stop(m_conn_params_timer_id);
        if ((err_code != NRF_SUCCESS) && (m_conn_params_config.error_handler != NULL))
        {
            m_conn_params_config.error_handler(err_code);
        }
    }
    

    here is the code where it is modifed

  • Only modifying it on disconnect could also be a problem. It should be modified on connect to update it. This way, in the case you make a connection, lose it, reestablish the connect, and try to end it manually, it may no longer have the correct handle.

Reply Children
No Data
Related