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

How to calculate NRF_SDH_BLE_GAP_EVENT_LENGTH in SDK15 for determinded NRF_SDH_BLE_GATT_MAX_MTU_SIZE ?

Hello,

I would like to know how can I configure the parameter  NRF_SDH_BLE_GAP_EVENT_LENGTH for a determined NRF_SDH_BLE_GATT_MAX_MTU_SIZE  when enabling data extension.

I have defined my NRF_SDH_BLE_GATT_MAX_MTU_SIZE   as 158 bytes  set my softdevice to use 7 characteristics and to use the connection event lenght extension as shown below

void gatt_mtu_set(uint16_t att_mtu)
{
    ret_code_t err_code;

    err_code = nrf_ble_gatt_att_mtu_periph_set(&m_gatt, att_mtu);
    APP_ERROR_CHECK(err_code);
    err_code = nrf_ble_gatt_att_mtu_central_set(&m_gatt, att_mtu);
    APP_ERROR_CHECK(err_code);
}


void conn_evt_len_ext_set(bool status)
{
    ret_code_t err_code;
    ble_opt_t  opt;

    memset(&opt, 0x00, sizeof(opt));
    opt.common_opt.conn_evt_ext.enable = status ? 1 : 0;

    err_code = sd_ble_opt_set(BLE_COMMON_OPT_CONN_EVT_EXT, &opt);
    APP_ERROR_CHECK(err_code);
}

void data_len_set(uint8_t value)
{
    ret_code_t err_code;
    err_code = nrf_ble_gatt_data_length_set(&m_gatt, BLE_CONN_HANDLE_INVALID, value);
    APP_ERROR_CHECK(err_code);

    m_test_params.data_len = value;
}

static void ble_stack_init(void)
{
    uint32_t err_code;


    err_code = nrf_sdh_enable_request();
    APP_ERROR_CHECK(err_code);

    
    // Configure the BLE stack using the default settings.
    // Fetch the start address of the application RAM.
    uint32_t ram_start = 0;
    err_code = nrf_sdh_ble_default_cfg_set(APP_BLE_CONN_CFG_TAG, &ram_start);
    APP_ERROR_CHECK(err_code);


    // BLE Configuration
    ble_cfg_t ble_cfg;

    // Max Packets Per Connection Event
    memset(&ble_cfg, 0, sizeof ble_cfg);
    ble_cfg.conn_cfg.conn_cfg_tag                            = APP_BLE_CONN_CFG_TAG;
    ble_cfg.conn_cfg.params.gatts_conn_cfg.hvn_tx_queue_size = 7;
    err_code = sd_ble_cfg_set(BLE_CONN_CFG_GATTS, &ble_cfg, ram_start);
    APP_ERROR_CHECK(err_code);


    // Enable BLE stack.
    err_code = nrf_sdh_ble_enable(&ram_start);
    APP_ERROR_CHECK(err_code);

    // Register a handler for BLE events.
    NRF_SDH_BLE_OBSERVER(m_ble_observer, APP_BLE_OBSERVER_PRIO, ble_evt_handler, NULL);
}

However,  I do not know what are the righet values for NRF_SDH_BLE_GAP_EVENT_LENGTH  and how shoud I suppose to calculte it. Could you provide me some hints about it?

Thanks in advance,

Kind regards

Related