BLE Disconnected error

Hello

Im using a Custom board and APP BLE UART  example

this is a pseudocode

void 	SensorFunction()// funcion que hace que cuando reciba la pabara pulso manda a leer el sensor 
{
  
  while(pulso == true)// mientras se cunpla conicion, esta leyendo los valores de MAx30105
	     { 
	       pulsoCount++;
	       // code
	       .
	       .
	       .
	       .
	       
	     if(pulsoCount >= 130)// condicion si ya supero el timepo de lectura y si detetcto la presencia del punto a medir comienza la envacion de los datos
				   {
				     pulso = false;
				   }
	     
	     
	     
	     
	     }

}


int main(void)//setup Main
{ 
 
    bool erase_bonds;
	bool cambio = true;;
    // Initialize.
    uart_init();
    log_init();
	
    timers_init();
    buttons_leds_init(&erase_bonds);//&erase_bonds
    power_management_init();
    ble_stack_init();
    gap_params_init();
    gatt_init();
	services_init();
    advertising_init();
    conn_params_init();
    gpiote_init();
	 
/////incializacion de sensores,botones y pantalla		 
	twi_master_init();// inicaliza la comunicaicon I2C para MPU
	  
	  	advertising_start();
	  	
	  for(;;)
	  {
	     
	      if(pulso == true) // cuando detecte que la app manda los caracteres puslo , esta condicion mandara a llamar la secuencia de pulso
				{
					SensorFunction();// inicia la secuencia de medicion de pulso
				}
	     
	     idle_state_handle();
	  }
	  	

}

when i call a SensorFunction() over NUS , the fucttion keep a ciclo while aprox, 15 to 25 seg, during  this time the BLE is Disconnected i can see in Nordic APP ( NRF Toolbox app) 

I was debugging but I could not to se a specific error , the function SensorFunction() works, but the bluetooth connection is lostest 

what is the posibble problem?

when i was using DK nrf52840 , this problem don't existed

thanks and regards 

Parents
  • Hello

    I could solve it, 

    the problem was in Advertising function 

    and this parameters 

    #define APP_BLE_OBSERVER_PRIO           3                                           /**< Application's BLE observer priority. You shouldn't need to modify this value. */
    
    #define APP_ADV_INTERVAL                64                                          /**< The advertising interval (in units of 0.625 ms. This value corresponds to 40 ms). */
    
    #define APP_ADV_DURATION                0//18000                                       /**< The advertising duration (180 seconds) in units of 10 milliseconds. */
    
    #define MIN_CONN_INTERVAL               MSEC_TO_UNITS(20, UNIT_1_25_MS)             /**< Minimum acceptable connection interval (20 ms), Connection interval uses 1.25 ms units. */
    #define MAX_CONN_INTERVAL               MSEC_TO_UNITS(75, UNIT_1_25_MS)             /**< Maximum acceptable connection interval (75 ms), Connection interval uses 1.25 ms units. */
    #define SLAVE_LATENCY                   0                                           /**< Slave latency. */
    #define CONN_SUP_TIMEOUT                MSEC_TO_UNITS(4000, UNIT_10_MS)             /**< Connection supervisory timeout (4 seconds), Supervision Timeout uses 10 ms units. */
    #define FIRST_CONN_PARAMS_UPDATE_DELAY  APP_TIMER_TICKS(5000)                       /**< Time from initiating event (connect or start of notification) to first time sd_ble_gap_conn_param_update is called (5 seconds). */
    #define NEXT_CONN_PARAMS_UPDATE_DELAY   APP_TIMER_TICKS(30000)                      /**< Time between each call to sd_ble_gap_conn_param_update after the first call (30 seconds). */
    #define MAX_CONN_PARAMS_UPDATE_COUNT    3                                           /**< Number of attempts before giving up the connection parameter negotiation. */
    
    
    static void advertising_init(void)// aqui solamente se configira nombre entre otros datos del dispocitivo 
    {
        uint32_t               err_code;
        ble_advertising_init_t init;
    
        memset(&init, 0, sizeof(init));
    
        init.advdata.name_type          = BLE_ADVDATA_FULL_NAME;
        init.advdata.include_appearance = false;
        init.advdata.flags              = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE;//BLE_GAP_ADV_FLAGS_LE_ONLY_LIMITED_DISC_MODE;
    
        init.srdata.uuids_complete.uuid_cnt = sizeof(m_adv_uuids) / sizeof(m_adv_uuids[0]);
        init.srdata.uuids_complete.p_uuids  = m_adv_uuids;
    
        init.config.ble_adv_fast_enabled  = true;
        init.config.ble_adv_fast_interval = APP_ADV_INTERVAL;
        init.config.ble_adv_fast_timeout  = APP_ADV_DURATION;
        init.evt_handler = on_adv_evt;
    
        err_code = ble_advertising_init(&m_advertising, &init);
        APP_ERROR_CHECK(err_code);
    
        ble_advertising_conn_cfg_tag_set(&m_advertising, APP_BLE_CONN_CFG_TAG);
    }
    

    I tested with other example uart ble and i saw the error 

    thanks a regards

Reply
  • Hello

    I could solve it, 

    the problem was in Advertising function 

    and this parameters 

    #define APP_BLE_OBSERVER_PRIO           3                                           /**< Application's BLE observer priority. You shouldn't need to modify this value. */
    
    #define APP_ADV_INTERVAL                64                                          /**< The advertising interval (in units of 0.625 ms. This value corresponds to 40 ms). */
    
    #define APP_ADV_DURATION                0//18000                                       /**< The advertising duration (180 seconds) in units of 10 milliseconds. */
    
    #define MIN_CONN_INTERVAL               MSEC_TO_UNITS(20, UNIT_1_25_MS)             /**< Minimum acceptable connection interval (20 ms), Connection interval uses 1.25 ms units. */
    #define MAX_CONN_INTERVAL               MSEC_TO_UNITS(75, UNIT_1_25_MS)             /**< Maximum acceptable connection interval (75 ms), Connection interval uses 1.25 ms units. */
    #define SLAVE_LATENCY                   0                                           /**< Slave latency. */
    #define CONN_SUP_TIMEOUT                MSEC_TO_UNITS(4000, UNIT_10_MS)             /**< Connection supervisory timeout (4 seconds), Supervision Timeout uses 10 ms units. */
    #define FIRST_CONN_PARAMS_UPDATE_DELAY  APP_TIMER_TICKS(5000)                       /**< Time from initiating event (connect or start of notification) to first time sd_ble_gap_conn_param_update is called (5 seconds). */
    #define NEXT_CONN_PARAMS_UPDATE_DELAY   APP_TIMER_TICKS(30000)                      /**< Time between each call to sd_ble_gap_conn_param_update after the first call (30 seconds). */
    #define MAX_CONN_PARAMS_UPDATE_COUNT    3                                           /**< Number of attempts before giving up the connection parameter negotiation. */
    
    
    static void advertising_init(void)// aqui solamente se configira nombre entre otros datos del dispocitivo 
    {
        uint32_t               err_code;
        ble_advertising_init_t init;
    
        memset(&init, 0, sizeof(init));
    
        init.advdata.name_type          = BLE_ADVDATA_FULL_NAME;
        init.advdata.include_appearance = false;
        init.advdata.flags              = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE;//BLE_GAP_ADV_FLAGS_LE_ONLY_LIMITED_DISC_MODE;
    
        init.srdata.uuids_complete.uuid_cnt = sizeof(m_adv_uuids) / sizeof(m_adv_uuids[0]);
        init.srdata.uuids_complete.p_uuids  = m_adv_uuids;
    
        init.config.ble_adv_fast_enabled  = true;
        init.config.ble_adv_fast_interval = APP_ADV_INTERVAL;
        init.config.ble_adv_fast_timeout  = APP_ADV_DURATION;
        init.evt_handler = on_adv_evt;
    
        err_code = ble_advertising_init(&m_advertising, &init);
        APP_ERROR_CHECK(err_code);
    
        ble_advertising_conn_cfg_tag_set(&m_advertising, APP_BLE_CONN_CFG_TAG);
    }
    

    I tested with other example uart ble and i saw the error 

    thanks a regards

Children
  • Hello,

    I am glad to hear that you were able to resolve your issue, thought it is still not entirely clear to me what this issue was from reading your initial ticket.
    For future reference please make sure to elaborate thoroughly on the issue or questions that you have, and include all necessary information.
    The initial ticket also includes words from another language than English, which makes it less accurate and harder to understand.

    As a general tip I would recommend that you make sure to have set DEBUG in your preprocessor defines like shown in the included image:

    Since this will make your logger output a detailed error message whenever a non-NRF_SUCCESS error code is passed to an APP_ERROR_CHECK.

    Please do not hesitate to open another ticket if you should encounter any other issues or questions in the future.

    Good luck with your development! :) 

    Best regards,
    Karl

Related