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

Setting Gap Connection Event Length - BLE HRS C Demo

Why is the event length of the BLE Central HRS demo set to such a high value of 320*1.25ms = 400ms?

The demo seems to work ok with the BLE Peripheral HRS demo using the default value (BLE_GAP_EVENT_LENGTH_DEFAULT) of 3*1.25ms = 4.75ms.

What is the ATT MTU size's dependency on event length?

// Configure the maximum event length.
memset(&ble_cfg, 0x00, sizeof(ble_cfg));
ble_cfg.conn_cfg.conn_cfg_tag                     = CONN_CFG_TAG;
ble_cfg.conn_cfg.params.gap_conn_cfg.event_length = 320;
ble_cfg.conn_cfg.params.gap_conn_cfg.conn_count   = BLE_GAP_CONN_COUNT_DEFAULT;
err_code = sd_ble_cfg_set(BLE_CONN_CFG_GAP, &ble_cfg, ram_start);
APP_ERROR_CHECK(err_code);
  • Hi,

    The event_length for a given connection is the time set aside for that given connection every connection interval. The event_length can be adjust to ensure fair allocation of the available radio time resources between different concurrent connections. The ble_app_hrs_c example is by default configured for only one connection, and we want to set aside the whole connection interval for the given connection. In the ble_app_hrs example, the preferred minimum connection interval is set to 400ms.

    EDIT:

    The event length setting is primarily used for scheduling, i.e. to know how much time (minimum) to schedule for a connection event. When enabling Connection Event Length Extension, the connection event will continue past the event length setting, and last until either the peer drops out of the event or there is another timing event scheduled locally (e.g. another connection, a timeslot event, or other). The event length does not have to be changed, in order to use Connection Event Length Extension. Connection Event Length Extension is configured by the common_opt.conn_evt_ext field of the ble_opt_t structure passed to sd_ble_opt_set(). Setting it to true enables length extension. Extended connection events start out by using the configured event length (the conn_cfg.params.gap_conn_cfg.event_length passed to sd_ble_cfg_set()). Then it continues sending and receiving one packet pair at the time as long as the peer responds and as long as there is available time before the next scheduled timing event.

    The SoftDevice can be enabled to dynamically extend the connection event length to fit the maximum number of packets inside the connection event before the timing-event must be ended. The time extended will be in one packet pair at a time until the maximum extend time is reached. The connection event cannot be longer than the connection interval.

  • Hi, Sigurd.

    I have problem setting connection event length extension to my project. In you answer, you mentioned that event length does not have to be changed in order to use connection event length extension, but if my event length setting is set to use the maximum of the connection interval, will connection event length extension still happens?

  • Hi,

    Could you explain what problems you have with setting the connection event length extension?

    As long as you have set the event length to the maximum expected connection interval, the SoftDevice should be able to send packets for the entire connection interval.

    You can enable Connection Event Length Extension like this:

        ret_code_t err_code;
        ble_opt_t  opt;
    
        memset(&opt, 0x00, sizeof(opt));
        opt.common_opt.conn_evt_ext.enable = 1;
    
        err_code = sd_ble_opt_set(BLE_COMMON_OPT_CONN_EVT_EXT, &opt);
        APP_ERROR_CHECK(err_code);
    

Related