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

Quick connection parameters update

Hello everyone,

I'm currently trying to change the connection parameters to be quick(100ms 0 slave latency) on a button press and after a timer timeout I go back to the low connection parameters.

I'm also sending a notification to an android application at the same time and then send back 2 characteristic ( LED toggle and a string for a LCD) .

It's working but it take quite a long time (10s) for my application to change the connection parameters so the 2 characteristic are not sent at quick connection parameters the first time but if I press a second time it's then updated and send it quickly.

Do you guys know a workaround this problem ?

  • i have some other problems now. The first one is that when I change the connection parameters (Smartphone one to my quick ones then quick to slow) I can't change it anymore by calling ble_conn_params_change_conn_params. i do this with a timer that is called each time in BLE_GAP_EVT_CONN_PARAM_UPDATE

    the second one is that when I call the change from Quick to slow in the Master control Panel I can see that it's doing 2 same request within 20ms gap and both are accepted(weird).

    And the last one is that if after the connection and FIRST_CONN_PARAMS_UPDATE_DELAY is passed I can't change the connection parameters anymore.

    for the last one I tought to solve the problem by sending connection parameter update when it's connected .

  • What do you mean when you say that you can't change the connection parameters? Do you mean that you do the API call successfully, but nothing happens, or do you get an error code from the API call? Please check that you don't get an error code when trying to change parameters.

  • In the Log window in the Master Control Panel their is nothing . It's like the call is not done.

    [08:44:27.8]Received Connection Parameter Update Request

    [08:44:27.8]ConnectionParameterUpdateResponse sent with ACCEPTED response

    [08:44:27.8]Connection Parameters Update sent. ConnInterval:100.0ms, SlaveLatency:0, SupervisionTimeout:600.0ms

    [08:44:28.3]Received a HandleValueNotification on handle 000E with value 01

    [08:44:28.7]Received a HandleValueNotification on handle 000E with value 00

    [08:44:38.4] Received Connection Parameter Update Request

    [08:44:38.4] ConnectionParameterUpdateResponse sent with ACCEPTED response

    [08:44:38.4] Connection Parameters Update sent. ConnInterval:100.0ms, SlaveLatency:0, SupervisionTimeout:600.0ms

    [08:44:56.5]Received a HandleValueNotification on handle 000E with value 01

    [08:44:56.9] Received a HandleValueNotification on handle 000E with value 00

  • So this morning it's worse than yesterday. It's not even sending the good parameters the second time to go back to slow connection parameters . And I've also seen that the button change is called 2 time when pushed and realeased , I don't know why.

  • This is my timer handler

       static void cp_timeout_handler(void * p_context) {
    	UNUSED_PARAMETER(p_context);
    
    		gap_params_low();}
    

    Those are the funstion that send the new parameters

    static void gap_params_high(void) {
    	ble_gap_conn_params_t gap_conn_params_high;
        gp=false;
    	memset(&gap_conn_params_high, 0, sizeof(gap_conn_params_high));
    
    	gap_conn_params_high.min_conn_interval = MIN_CONN_ITVL_UPDATE;
    	gap_conn_params_high.max_conn_interval = MAX_CONN_ITVL_UPDATE;
    	gap_conn_params_high.slave_latency = SLAVE_LATENCY_UPDATE;
    	gap_conn_params_high.conn_sup_timeout = CONN_SUP_TIMEOUT_UPDATE;
    
    	ble_conn_params_change_conn_params(&gap_conn_params_high);
    			
    
    
    }
    static void gap_params_low(void) {
    	ble_gap_conn_params_t gap_conn_params_low;
    
    	gp=true;
    	memset(&gap_conn_params_low, 0, sizeof(gap_conn_params_low));
    
    		gap_conn_params_low.min_conn_interval = MIN_CONN_INTERVAL;
    		gap_conn_params_low.slave_latency = SLAVE_LATENCY;
    		gap_conn_params_low.conn_sup_timeout = CONN_SUP_TIMEOUT;
    	ble_conn_params_change_conn_params(&gap_conn_params_low);
    
    			
    
    
    }
    

    This is my case in on_ble_evt

    case BLE_GAP_EVT_CONN_PARAM_UPDATE:
    		
    		app_timer_start(m_cp_timer_id, CP_INTERVAL,
    						NULL);
    
    			break;
    

    This is my button handler

    static void button_event_handler(uint8_t pin_no, uint8_t button_action) {
    	
         app_timer_stop(m_powermanage_timer_id);
             if (gp){
    		gap_params_high();
    	          }
    
    
    
    	/*Joue le son du Buzzer*/
    	set_frequency_and_duty_cycle((uint32_t) (1075), 50);
    	nrf_delay_ms(300);
    	nrf_pwm_set_enabled(0);
    
    	switch (pin_no) {
    	case BOUTON_SONNETTE_PIN_NO:
    
    
                    ble_lbs_on_button_change(&m_lbs,button_action);
    
    		nrf_gpio_pin_write(LED_LCD_PIN, 1);
    
    		gotoXY(12,2);
    		LCDString("Bienvenue",1);
    
    		break;
    
    
    	default:
    
    		break;
    	}
    
    app_timer_start(m_powermanage_timer_id, POWER_MANAGE_INTERVAL,
    				NULL);
    gp=false;
    pm=false;}
    

    gp is a static bool that I use because the event handler is called 2 times ( on push and release)

    pm is also a static bool that I use to not go into power manage as long as the smartphone send write(in the handler of some characteristics)

Related