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

NRF52840 & S140 & SDK14.1, Maximum number of connections in BLE Multi-link Example?

Hello,

I am working on the project through the BLE Multi-link Example.

In the description of the BLE Multi-link Example, "The central device can have a maximum of 8 concurrent connections to peripheral devices." I saw it written.


Could you connect more than eight?
I wonder if I can just increase the link count?

Thanks.

  • Hello,

    Yes, the SoftDevice supports up to 20 concurrent links, so you can increase the link count in the sdk_config header. However, the build will fail if you increase the link count to more than 15 because of a limitation in the SDK macros used for registering the services instances. Below are the necessary code changes to fix this limitation and support up to 20 links:

    diff --git a/components/libraries/util/app_util.h b/components/libraries/util/app_util.h
    index b5adb20..0018561 100644
    --- a/components/libraries/util/app_util.h
    +++ b/components/libraries/util/app_util.h
    @@ -739,7 +739,7 @@ typedef struct
      * @return All arguments processed by given macro
      */
     #define MACRO_MAP_FOR(...) MACRO_MAP_FOR_(__VA_ARGS__)
    -#define MACRO_MAP_FOR_N_LIST 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
    +#define MACRO_MAP_FOR_N_LIST 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20
     #define MACRO_MAP_FOR_(...) MACRO_MAP_FOR_N(NUM_VA_ARGS_LESS_1(__VA_ARGS__), __VA_ARGS__)
     
     /**
    @@ -882,6 +882,11 @@ typedef struct
     #define MACRO_REPEAT_FOR_13(n_list, macro, ...) macro(GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), __VA_ARGS__) MACRO_REPEAT_FOR_12((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__)
     #define MACRO_REPEAT_FOR_14(n_list, macro, ...) macro(GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), __VA_ARGS__) MACRO_REPEAT_FOR_13((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__)
     #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__)
     
     /**@brief Adding curly brace to the macro parameter.
      *
    diff --git a/examples/ble_central/ble_app_multilink_central/pca10040/s132/config/sdk_config.h b/examples/ble_central/ble_app_multilink_central/pca10040/s132/config/sdk_config.h
    index cdf4275..1dd77d7 100644
    --- a/examples/ble_central/ble_app_multilink_central/pca10040/s132/config/sdk_config.h
    +++ b/examples/ble_central/ble_app_multilink_central/pca10040/s132/config/sdk_config.h
    @@ -11418,14 +11418,14 @@
     
     // <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
    +#define NRF_SDH_BLE_CENTRAL_LINK_COUNT 20
     #endif
     
     // <o> NRF_SDH_BLE_TOTAL_LINK_COUNT - Total link count. 
     // <i> 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
    +#define NRF_SDH_BLE_TOTAL_LINK_COUNT 20
     #endif
     
     // <o> NRF_SDH_BLE_GAP_EVENT_LENGTH - GAP event length. 
    

    Also, remember to allocate more RAM to the softdevice if you increase the link count, each link will require additional RAM buffers internally in the stack. Appropriate linker settings will be printed out in the debug log.  

Related