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

Increase Service Discovery Speed by Master

Hi, So i'm working on an android app that communicates with two nrf51822 devices on the s110 softdevice by switching between them continuously (connecting one, disconnecting the other and vice versa). My issue is that the service discovery seems to take more time than my desired switching period. Each of the devices have only one custom service as well as the standard Generic Profile and Generic Access services (no battery or DIS services). It worked for switching every 10 seconds but I need to switch every second or so. Is it possible to vastly reduce the discovery time; and if so, please how can this be achieved?? I am testing on a Samsung Galaxy s3 running Android 4.3. Thanks

Parents
  • What do you set your preferred Connection Parameters to? When do you request the Connection Parameter Update?

    Your only options of increasing Discovery Speed are using the fastest Connection Parameters, and streamlining your Service. Meaning remove anything characteristic that are unnecessary and reduce the characteristic sizes to only required size. i.e. don't create a uint32_t characteristic that will only use 0-255 values.

Reply
  • What do you set your preferred Connection Parameters to? When do you request the Connection Parameter Update?

    Your only options of increasing Discovery Speed are using the fastest Connection Parameters, and streamlining your Service. Meaning remove anything characteristic that are unnecessary and reduce the characteristic sizes to only required size. i.e. don't create a uint32_t characteristic that will only use 0-255 values.

Children
  • Each sensor service uses only "notify" characteristic and all values are uint_8. My initialised connection parameters are:

    static void conn_params_init(void)
    {
        uint32_t               err_code;
        ble_conn_params_init_t cp_init;
    
        memset(&cp_init, 0, sizeof(cp_init));
    
        cp_init.p_conn_params                  = NULL;
        cp_init.first_conn_params_update_delay = FIRST_CONN_PARAMS_UPDATE_DELAY;
        cp_init.next_conn_params_update_delay  = NEXT_CONN_PARAMS_UPDATE_DELAY;
        cp_init.max_conn_params_update_count   = MAX_CONN_PARAMS_UPDATE_COUNT;
        cp_init.start_on_notify_cccd_handle    = BLE_GATT_HANDLE_INVALID;
        cp_init.disconnect_on_fail             = false;
        cp_init.evt_handler                    = on_conn_params_evt;
        cp_init.error_handler                  = conn_params_error_handler;
    
        err_code = ble_conn_params_init(&cp_init);
        APP_ERROR_CHECK(err_code);
    }
    
  • What are your preferred connection parameters?

    What do you have FIRST_CONN_PARAMS_UPDATE_DELAY set to?

  • Its set to 20s but my services don't take that long so I included this aspect of my code; maybe it'll help. Thanks for your help so far.

     #define MIN_CONN_INTERVAL               MSEC_TO_UNITS(100, UNIT_1_25_MS)            /**< Minimum acceptable connection interval (0.5 seconds). */
        #define MAX_CONN_INTERVAL               MSEC_TO_UNITS(200, UNIT_1_25_MS)            /**< Maximum acceptable connection interval (1 second). */
        #define SLAVE_LATENCY                   0                                           /**< Slave latency. */
        #define CONN_SUP_TIMEOUT                MSEC_TO_UNITS(4000, UNIT_10_MS)             /**< Connection supervisory timeout (4 seconds). */
        #define FIRST_CONN_PARAMS_UPDATE_DELAY  APP_TIMER_TICKS(20000, APP_TIMER_PRESCALER) /**< Time from initiating event (connect or start of notification) to first time sd_ble_gap_conn_param_update is called (15 seconds). */
        #define NEXT_CONN_PARAMS_UPDATE_DELAY   APP_TIMER_TICKS(5000, APP_TIMER_PRESCALER)  /**< Time between each call to sd_ble_gap_conn_param_update after the first call (5 seconds). */
        #define MAX_CONN_PARAMS_UPDATE_COUNT    3                                           /**< Number of attempts before giving up the connection parameter negotiation. */
    
  • #define MIN_CONN_INTERVAL MSEC_TO_UNITS(22, UNIT_1_25_MS)
    #define MAX_CONN_INTERVAL MSEC_TO_UNITS(46, UNIT_1_25_MS) #define SLAVE_LATENCY 0 /**< Slave latency. */ #define CONN_SUP_TIMEOUT MSEC_TO_UNITS(200, UNIT_10_MS)

    You likely are not updating your parameters before discovery, meaning you are relying on the default Connection Parameters of the Android phone to be fast enough. If this is not the case, you need to send a Connection Parameter update sooner.

  • So all I need to do is change the parameters to your suggested values?? Or is there a way to check if my parameters are updating before discovery?

Related