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

How to transmit 6 packets in S130 Uart central

Hi there,

I am struct for two days trying to send 6 packets of 20 bytes as central. I use ble app uart central sample from nrf5_sdk11.0 with nrf51 S130 v2.0 softdevice.

I start believing that this sample and softdevice can only transmit 3 packets per connection interval. As I debug in the central side, it can only execute write command with out response 3 times then a buffer full occurs. When I get the sd_ble_tx_packet_count_get during connection it is only 3. I expect that is 6...for 6 tx? I also monitor the write event in the peripheral side I can only get 3 write interrupt.

I try to use the sd_ble_opt_set(BLE_COMMON_OPT_CONN_BW, &ble_opt) setting the tx and rx bandwidth to BLE_CONN_BW_HIGH but won't work out. I use this API during stack initialization and also right after sd_ble_gap_connect. It seems it only accept BLE_CONN_BW_MID

What would be my configuration to make to transmit 6 packets per connection interval. My connection interval is only 100msec and using S310 version 3.0 in the peripheral side.

Thank you for helping me out. -Mc

  • Are you actually configuring the BLE stack when you initialise it to have available high bandwidth central connections? the sd_ble_opt_set() is used to tell the softdevice on a per-connection basis which of the configured bandwidths to use, but if you haven't allocated any high-bandwidth central connections when you enabled the softdevice in the first place, there aren't any available.

    Post the code you're using to set up the parameters for sd_ble_enable(), that's where you have to initially configure the SD to have the connections you want.

  • Hi RK,

    Thank you for your reply. So, if you don't configure the stack to higher bandwidth the central wont be transmitting 6 packets..?

    Below is what is code stack configuration.

    uint32_t err_code;
    
    nrf_clock_lf_cfg_t clock_lf_cfg = NRF_CLOCK_LFCLKSRC;
    
    // Initialize the SoftDevice handler module.
    SOFTDEVICE_HANDLER_INIT(&clock_lf_cfg, NULL);
    
    ble_enable_params_t ble_enable_params;
    
    memset(&ble_enable_params, 0x00, sizeof(ble_enable_params));
    
    err_code = softdevice_enable_get_default_config(CENTRAL_LINK_COUNT,
                                                    PERIPHERAL_LINK_COUNT,
                                                    &ble_enable_params);
    APP_ERROR_CHECK(err_code);
    
    //Check the ram settings against the used number of links
    CHECK_RAM_START_ADDR(CENTRAL_LINK_COUNT,PERIPHERAL_LINK_COUNT);
    
    // Enable BLE stack.
    err_code = softdevice_enable(&ble_enable_params);
    APP_ERROR_CHECK(err_code);
    
    /* Configure bandwidth and connect as a peripheral */
    ble_opt_t ble_opt;
    ble_common_opt_conn_bw_t conn_bw;
    memset(&conn_bw, 0x00, sizeof(conn_bw));
    memset(&ble_opt, 0x00, sizeof(ble_opt));
    
    // if this set to mid this will work but setting it to high will not
    conn_bw.conn_bw.conn_bw_rx = BLE_CONN_BW_HIGH;
    conn_bw.conn_bw.conn_bw_tx = BLE_CONN_BW_HIGH;
    

    // conn_bw.conn_bw.conn_bw_rx = BLE_CONN_BW_MID; // conn_bw.conn_bw.conn_bw_tx = BLE_CONN_BW_MID;

    conn_bw.role = BLE_GAP_ROLE_CENTRAL;
    
    // gap option is missing?
    ble_opt.common_opt.conn_bw = conn_bw;
    
    err_code = sd_ble_opt_set(BLE_COMMON_OPT_CONN_BW, &ble_opt);
    APP_ERROR_CHECK(err_code);
    
    // Register with the SoftDevice handler module for BLE events.
    err_code = softdevice_ble_evt_handler_set(ble_evt_dispatch);
    APP_ERROR_CHECK(err_code);
    

    This configuration I have is this, from

    devzone.nordicsemi.com/.../:

    uint32_t err_code;

    nrf_clock_lf_cfg_t my_xtal_cfg = {
        .source = NRF_CLOCK_LF_SRC_XTAL,
        .xtal_accuracy = NRF_CLOCK_LF_XTAL_ACCURACY_20_PPM
    };
    
    err_code = sd_softdevice_enable(&my_xtal_cfg , fault_handler);
    APP_ERROR_CHECK(err_code);
    
    /* Example for one high-bandwidth RX and TX connection as a central */
    ble_conn_bw_counts_t conn_bw_counts = {
        .tx_counts = {.high_count = 1, .mid_count = 0, .low_count = 0},
        .rx_counts = {.high_count = 1, .mid_count = 0, .low_count = 0}
    };
    
    
    ble_enable_params_t params;
    uint32_t retv;
    uint32_t app_ram_base;
    
    memset(&params, 0x00, sizeof(params));
    
    /*Set bandwidth*/
    params.common_enable_params.p_conn_bw_counts = &conn_bw_counts;
    
    // may set to x uuid..adjust the RAM?
    params.common_enable_params.vs_uuid_count = 1;
    /* this application requires 1 connection as a peripheral */
    params.gap_enable_params.periph_conn_count = 0;
    /* this application requires 0 connections as a central */
    params.gap_enable_params.central_conn_count = 1;
    /* this application only needs to be able to pair in one central link at a time */
    params.gap_enable_params.central_sec_count = 0;
    /* we require the Service Changed characteristic */
    params.gatts_enable_params.service_changed = 0;
    /* the default Attribute Table size is appropriate for our application */
    params.gatts_enable_params.attr_tab_size = BLE_GATTS_ATTR_TAB_SIZE_DEFAULT;
    /* set app_ram_base to the starting memory address of the application RAM,
    obtained directly from the linker */
    
    
    app_ram_base = __LINKER_APP_RAM_BASE;
    /* enable the BLE Stack */
    retv = sd_ble_enable(&params, &app_ram_base);
    APP_ERROR_CHECK(retv);
    
    /* Configure bandwidth and connect as a peripheral */
    ble_opt_t ble_opt;
    ble_common_opt_conn_bw_t conn_bw;
    memset(&conn_bw, 0x00, sizeof(conn_bw));
    memset(&ble_opt, 0x00, sizeof(ble_opt));
    
    // if this set to mid this will work but setting it to high will not
    conn_bw.conn_bw.conn_bw_rx = BLE_CONN_BW_HIGH;
    conn_bw.conn_bw.conn_bw_tx = BLE_CONN_BW_HIGH;
    

    // conn_bw.conn_bw.conn_bw_rx = BLE_CONN_BW_MID; // conn_bw.conn_bw.conn_bw_tx = BLE_CONN_BW_MID;

    conn_bw.role = BLE_GAP_ROLE_CENTRAL;
    
    // gap option is missing?
    ble_opt.common_opt.conn_bw = conn_bw;
    
    err_code = sd_ble_opt_set(BLE_COMMON_OPT_CONN_BW, &ble_opt);
    APP_ERROR_CHECK(err_code);
    
    // Register with the SoftDevice handler module for BLE events.
    err_code = softdevice_ble_evt_handler_set(ble_evt_dispatch);
    APP_ERROR_CHECK(err_code);
    

    I use the ___LINKER_APP_RAM_BASE as APP_RAM_BASE_CENTRAL_LINKS_1_PERIPH_LINKS_0_SEC_COUNT_0_MID_BW and even

    I hope you can help me figure this out.

    Thank you very much. -Mc

  • softdevice_enable_get_default_config() is going to do exactly that - get you the default configuration which is medium speed central connections. You need to configure the ble_enable_params_t to have a number of high-speed central connections if you want to use them later.

    read the notes which came with the S130/S132 V2 releases, they give a number of examples of how to configure the connections you want.

  • Thank you RK,

    Such a great help!!!! The nrf51 S130 v2.0 softdevice and ble app uart central sample from nrf5_sdk11.0 can be configured to transmit the 6 packets per interval. My peripheral can be now receive 6 packets per interval.

    Regards, Marlon

  • Good to hear - I just pointed you to the docs and you sorted it out yourself. Nice to know it works!

Related