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

Packet Length Extension

Using the nRF52832 device with the S132-v3.0 soft-device (s132_nrf52_3.0.0_softdevice) and SDK version 12 (SDK120200F12) (Customized for our application, which includes use of the non-blocking SAADC )
1.  Please provide actual functioning code that will extend the packet size from 20 bytes to greater that 32 bytes for use for the UART BLE service
2.  Explain where this code is to be placed in the chain of blue-tooth initialization events...
Parents
  • Hi,

    To set the DLE to e.g. 50 you can use this code:

    static void ble_stack_init(void)
    {
        uint32_t err_code;
    
        nrf_clock_lf_cfg_t clock_lf_cfg = NRF_CLOCK_LFCLKSRC;
    
        // Initialize SoftDevice.
        SOFTDEVICE_HANDLER_INIT(&clock_lf_cfg, NULL);
    
        ble_enable_params_t 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.
    #if (NRF_SD_BLE_API_VERSION == 3)
        ble_enable_params.gatt_enable_params.att_mtu = NRF_BLE_MAX_MTU_SIZE;
    #endif
        err_code = softdevice_enable(&ble_enable_params);
        APP_ERROR_CHECK(err_code);
    
        // Subscribe for BLE events.
        err_code = softdevice_ble_evt_handler_set(ble_evt_dispatch);
        APP_ERROR_CHECK(err_code);
        
        
        ble_opt_t gap_opt;
        gap_opt.gap_opt.ext_len.rxtx_max_pdu_payload_size = 54; //Example: set max length to 54bytes
        err_code = sd_ble_opt_set(BLE_GAP_OPT_EXT_LEN, &gap_opt);
        APP_ERROR_CHECK(err_code);
    }

    make sure to call sd_ble_opt_set() after you have enabled the Softdevice with softdevice_enable(). Otherwise you will get error 0x3001.

    Also remember to increase the MTU size accordingly. In the BLE UART example you can do this by setting GATT_MTU_SIZE_DEFAULT in ble_gatt.h to the value you want. 

Reply
  • Hi,

    To set the DLE to e.g. 50 you can use this code:

    static void ble_stack_init(void)
    {
        uint32_t err_code;
    
        nrf_clock_lf_cfg_t clock_lf_cfg = NRF_CLOCK_LFCLKSRC;
    
        // Initialize SoftDevice.
        SOFTDEVICE_HANDLER_INIT(&clock_lf_cfg, NULL);
    
        ble_enable_params_t 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.
    #if (NRF_SD_BLE_API_VERSION == 3)
        ble_enable_params.gatt_enable_params.att_mtu = NRF_BLE_MAX_MTU_SIZE;
    #endif
        err_code = softdevice_enable(&ble_enable_params);
        APP_ERROR_CHECK(err_code);
    
        // Subscribe for BLE events.
        err_code = softdevice_ble_evt_handler_set(ble_evt_dispatch);
        APP_ERROR_CHECK(err_code);
        
        
        ble_opt_t gap_opt;
        gap_opt.gap_opt.ext_len.rxtx_max_pdu_payload_size = 54; //Example: set max length to 54bytes
        err_code = sd_ble_opt_set(BLE_GAP_OPT_EXT_LEN, &gap_opt);
        APP_ERROR_CHECK(err_code);
    }

    make sure to call sd_ble_opt_set() after you have enabled the Softdevice with softdevice_enable(). Otherwise you will get error 0x3001.

    Also remember to increase the MTU size accordingly. In the BLE UART example you can do this by setting GATT_MTU_SIZE_DEFAULT in ble_gatt.h to the value you want. 

Children
No Data
Related