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

sd_ble_gap_conn_param_update error 8

I have an application where my nrf52832 acts as a peripheral and I can connect to it without problems, but after some time like aprox 10 minutes when I try to connect to it again it doesn't accept the connection until it resets and then the cycle restarts.

I'm trying to debug this problem and the function "sd_ble_gap_conn_param_update" gives me "error 8 - Invalid state" following the previous pattern... Why? The connection parameters seems ok...

SD 3.0.0, sdk 12.2.

define MIN_CONN_INTERVAL MSEC_TO_UNITS(250, UNIT_1_25_MS)

define MAX_CONN_INTERVAL MSEC_TO_UNITS(350, UNIT_1_25_MS)

define SLAVE_LATENCY 0

define CONN_SUP_TIMEOUT MSEC_TO_UNITS(1500, UNIT_10_MS)

define FIRST_CONN_PARAMS_UPDATE_DELAY APP_TIMER_TICKS(5000,APP_TIMER_PRESCALER)

define NEXT_CONN_PARAMS_UPDATE_DELAY APP_TIMER_TICKS(30000, APP_TIMER_PRESCALER)

define MAX_CONN_PARAMS_UPDATE_COUNT 3

Thank you!

Daniel.

  • Omg... Now I discovered that I have a connection timeout that executes instantly when someone establishes a connection. This timer is started when the connection starts (BLE_GAP_EVT_CONNECTED) and it kills the connection if the phone gets stuck with it... but is configured to kill the connection after 50 sec and this number is a constant so I don't know why this timer randomly executes insantly, any ideas?

    #define TIMEOUT_CONNECTION	APP_TIMER_TICKS(50000, APP_TIMER_PRESCALER)
    
    case BLE_GAP_EVT_CONNECTED:
    m_conn_handle = p_ble_evt->evt.gap_evt.conn_handle;
    	if (first_time){
    		err_code= app_timer_start(m_timeout_timer_id, FIRST_TIMEOUT_CONNECTION, NULL);
    	}else{
    		err_code= app_timer_start(m_timeout_timer_id, TIMEOUT_CONNECTION, NULL);
    	}
    	timeout_timer_running=true;
    	APP_ERROR_CHECK(err_code);
    	led_write_handler_led(1,LED_RED_CH);
    break;
    
  • The timeout connection handler... The other times the timer works well...

    static void connection_timeout_handler(void * p_context){
                UNUSED_PARAMETER(p_context);
            	  uint32_t err_code = sd_ble_gap_disconnect(m_conn_handle, BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION);
                APP_ERROR_CHECK(err_code);
            		timeout_timer_running=false;
            }
    
  • Ok I tested the solution proposed by this post: devzone.nordicsemi.com/.../

    And now it works! The problem was a timeout timer that executes inmediately after some time... I got my board running for 24h without any errors so I think that the timer library was the problem.

    This is the timer.c file with the proposed fixes by the other post applied on the SDK 12.2: app_timer.c

  • Great that you found the cause of the problem (and the solution)! I will tell the developers that this needs to be looked at.

Related