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

NRF52832 Maximum number of central links

HI, I found that the maximum number of connections 52832 can only be 15 connections, like this

// <o> NRF_SDH_BLE_CENTRAL_LINK_COUNT - Maximum number of central links. 
#ifndef NRF_SDH_BLE_CENTRAL_LINK_COUNT
#define NRF_SDH_BLE_CENTRAL_LINK_COUNT 15
#endif

When I set up more than 15 when the compiler will be wrong, I would like to know what method can set the maximum number of links to 20

I am using the example is :

nRF5_SDK_14.1.0_1dda907\examples\ble_central\ble_app_multilink_central\pca10040\s132\arm5_no_packs
  • Firstly maximum number of links and GAP/GATT roles doesn't depend on HW you use (nRF2832 in this case) but BLE stack you use! Then latest Nordic S140 and S132 stacks for nRF52 chips support up to 20 concurrent connection links so no, 15 is not the limit. Secondly if you are not fine with this limit you have two obvious choices: go with other stacks (e.g. Zephyr should support at least 32 links today) or develop your own!

    If you are fine with 20 and you just want to modify nRF5_SDK_14.1.0_1dda907.zip\examples\ble_central\ble_app_multilink_central example to handle more links then it has 8 central links configured in nRF5 SDK v14.1.0 and you can easily modify that in examples\ble_central\ble_app_multilink_central\pca10040\s132\config\sdk_config.h file by modifying following lines:

    // <h> nRF_SoftDevice 
    
    //==========================================================
    // <e> NRF_SDH_BLE_ENABLED - nrf_sdh_ble - SoftDevice BLE event handler
    //==========================================================
    #ifndef NRF_SDH_BLE_ENABLED
    #define NRF_SDH_BLE_ENABLED 1
    #endif
    // <h> BLE Stack configuration - Stack configuration parameters
    
    // <i> These values are not used directly by the SoftDevice handler but the application or other libraries might depend on them.
    // <i> Keep them up-to-date with the desired configuration.
    //==========================================================
    // <o> NRF_SDH_BLE_PERIPHERAL_LINK_COUNT - Maximum number of peripheral links. 
    #ifndef NRF_SDH_BLE_PERIPHERAL_LINK_COUNT
    #define NRF_SDH_BLE_PERIPHERAL_LINK_COUNT 0
    #endif
    
    // <o> NRF_SDH_BLE_CENTRAL_LINK_COUNT - Maximum number of central links. 
    #ifndef NRF_SDH_BLE_CENTRAL_LINK_COUNT
    #define NRF_SDH_BLE_CENTRAL_LINK_COUNT 8
    #endif
    
    // <o> NRF_SDH_BLE_TOTAL_LINK_COUNT - Maximum number of total concurrent connections using the default configuration. 
    #ifndef NRF_SDH_BLE_TOTAL_LINK_COUNT
    #define NRF_SDH_BLE_TOTAL_LINK_COUNT 8
    #endif
    
  • And if you encounter some error while going above certain limit (like 15) then please debug the error and show us which SD API call throws what error status. It should be easy to fix that (typically some memory allocation problem which can be solved by giving more RAM to SD during init or you might need to correct some timings - if you want to operate many concurrent links then of course you cannot have very low connection interval and high bandwidth).

  • .

    BLE_LBS_C_ARRAY_DEF(m_lbs_c, NRF_SDH_BLE_CENTRAL_LINK_COUNT);           /**< LED Button client instances. */
    
    BLE_DB_DISCOVERY_ARRAY_DEF(m_db_disc, NRF_SDH_BLE_CENTRAL_LINK_COUNT);  /**< Database discovery module instances. */
    
    ..\..\..\main.c(94): error:  #20: identifier "MACRO_REPEAT_FOR_20" is undefined
    ..\..\..\main.c(94): error:  #59: function call is not allowed in a constant expression
    

    The compiler prompts these errors

  • Well this is just "bug" (or limitation if you want) in nRF5 SDK, these macros are defined only up to 15. See components\libraries\util\app_util.h. You can probably fix it by finding all MACRO_REPEAT_FOR defines in different SDK header files and patching them inside your project folder (they will be loaded by compiler prior to SDK header files of the same name). Alternatively report it here on forum to list of SDK bugs/limitations and wait for patch release from Nordic (which typically comes in 4-12 weeks).

  • Thank you for the quick reply to the instructions, as you described the way I added the macro definition now that can be compiled through like this

    #define MACRO_REPEAT_FOR_15(n_list, macro, ...) macro(GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), __VA_ARGS__) MACRO_REPEAT_FOR_14((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__)
    #define MACRO_REPEAT_FOR_16(n_list, macro, ...) macro(GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), __VA_ARGS__) MACRO_REPEAT_FOR_15((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__)
    #define MACRO_REPEAT_FOR_17(n_list, macro, ...) macro(GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), __VA_ARGS__) MACRO_REPEAT_FOR_16((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__)
    #define MACRO_REPEAT_FOR_18(n_list, macro, ...) macro(GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), __VA_ARGS__) MACRO_REPEAT_FOR_17((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__)
    #define MACRO_REPEAT_FOR_19(n_list, macro, ...) macro(GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), __VA_ARGS__) MACRO_REPEAT_FOR_18((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__)
    #define MACRO_REPEAT_FOR_20(n_list, macro, ...) macro(GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), __VA_ARGS__) MACRO_REPEAT_FOR_19((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__)
    
Related