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

BLE disconnect & adv_stop

Hi,

I have some problems with functions sd_ble_gap_disconnect and sd_ble_gap_adv_stop.

I got critical error when i try to disconnect or stop_adv and my phone is connected with my board.

code :

void advertising_stop(void){
	uint32_t err_code;
	err_code = sd_ble_gap_disconnect(m_conn_handle, BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION);
	APP_ERROR_CHECK(err_code);
	err_code = sd_ble_gap_adv_stop();
	APP_ERROR_CHECK(err_code);
}

I tried to disconnect only with :

void advertising_stop(void){
	uint32_t err_code;
	err_code = sd_ble_gap_adv_stop();
	APP_ERROR_CHECK(err_code);
}

But when i'm connected to my phone, the software of the board bug (critical error).

When my phone is not connected to my board, all is right, my board stop advertising.

Regards

Parents
  • thx for your anwser.

    now that is my function :

    static void advertising_stop(void){
    	uint32_t err_code;
    	if(isConnectedBle){
    		err_code = sd_ble_gap_disconnect(m_conn_handle, BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION);
    		APP_ERROR_CHECK(err_code);
    	}
    	err_code = sd_ble_gap_adv_stop();
    	APP_ERROR_CHECK(err_code);
    }
    

    isconnectedble is a bool wich turn true if connected event come and false if disconnected event come. I tried to use => m_conn_handle != BLE_CONN_HANDLE_INVALID to know if there are a connection in run but doesnt work.

    The sd_ble_gap_disconnect() works.

    The sd_ble_gap_adv_stop() give me an NRF_ERROR_INVALID_STATE which mean that there are no advertissement ready.

    But when i dont use sd_ble_gap_adv_stop(), sd_ble_adv_disconnect() disconnect my phone and after that, launch advertising.

    I dont really understand the problem.

    Regards,

    EDIT ANSWER :

    i didnt touch the library file and i just add a nrf_delay that allow times to softdevice to enable advertising and i stop it just after that.

    Regards,

    PS: my code here :

    static void advertising_stop(void){
    	uint32_t err_code;
    	if(isConnectedBle){
    		err_code = sd_ble_gap_disconnect(m_conn_handle, BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION);
    		APP_ERROR_CHECK(err_code);
    	}
    	nrf_delay_ms(1000);
    	err_code = sd_ble_gap_adv_stop();
    	APP_ERROR_CHECK(err_code);
    }
    
  • In ble_advertising.c there are a function which enable advertising. If these error occure, i think this function is called after sd_ble_gap_adv_stop(). I'll try.

Reply Children
No Data
Related