Skip to content

Commit ff5ca11

Browse files
committed
Allow configuration (via defines) of some of the key settings for the NRF51 softdevice.
* CENTRAL_LINK_COUNT * PERIPHERAL_LINK_COUNT * gatts_enable_params.attr_tab_size * gatts_enable_params.service_changed * common_enable_params.vs_uuid_count These settings control the range of functionality enabled in the softdevice as well as ram consumption. In particular reducing these values is critical to enable usage of 16K nrf51 devices.
1 parent 52cb119 commit ff5ca11

File tree

3 files changed

+51
-22
lines changed

3 files changed

+51
-22
lines changed

features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_NRF51/source/btle/btle.cpp

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -111,20 +111,6 @@ error_t btle_init(void)
111111
SOFTDEVICE_HANDLER_INIT(&clockConfiguration, signalEvent);
112112

113113
// Enable BLE stack
114-
/**
115-
* Using this call, the application can select whether to include the
116-
* Service Changed characteristic in the GATT Server. The default in all
117-
* previous releases has been to include the Service Changed characteristic,
118-
* but this affects how GATT clients behave. Specifically, it requires
119-
* clients to subscribe to this attribute and not to cache attribute handles
120-
* between connections unless the devices are bonded. If the application
121-
* does not need to change the structure of the GATT server attributes at
122-
* runtime this adds unnecessary complexity to the interaction with peer
123-
* clients. If the SoftDevice is enabled with the Service Changed
124-
* Characteristics turned off, then clients are allowed to cache attribute
125-
* handles making applications simpler on both sides.
126-
*/
127-
static const bool IS_SRVC_CHANGED_CHARACT_PRESENT = true;
128114

129115
ble_enable_params_t ble_enable_params;
130116
uint32_t err_code = softdevice_enable_get_default_config(CENTRAL_LINK_COUNT,

features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_NRF51/source/btle/btle.h

Lines changed: 44 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,50 @@ extern "C" {
2626
#include "ble_srv_common.h"
2727
#include "headers/nrf_ble.h"
2828

29-
#define CENTRAL_LINK_COUNT 3 /**<number of central links used by the application. When changing this number remember to adjust the RAM settings */
30-
/** If value for YOTTA_CFG_NORDIC_BLE_PERIPHERAL_LINKS was used, ram settings are adjusted by the yotta target module. */
31-
#define PERIPHERAL_LINK_COUNT 1 /**<number of peripheral links used by the application. When changing this number remember to adjust the RAM settings*/
32-
/** If value for YOTTA_CFG_NORDIC_BLE_CENTRAL_LINKS was used, ram settings are adjusted by the yotta target module. */
33-
#define GATTS_ATTR_TAB_SIZE 0x600 /**< GATTS attribite table size. */
34-
/** If value for YOTTA_CFG_NORDIC_BLE_GATTS_ATTR_TAB_SIZE was used, ram settings are adjusted by the yotta target module. */
29+
/* number of central links used by the application.
30+
* When changing this number remember to adjust the RAM settings */
31+
#ifndef NRF_SDH_BLE_CENTRAL_LINK_COUNT
32+
#define CENTRAL_LINK_COUNT 3
33+
#else
34+
#define CENTRAL_LINK_COUNT NRF_SDH_BLE_CENTRAL_LINK_COUNT
35+
#endif
36+
37+
/* number of peripheral links used by the application.
38+
* When changing this number remember to adjust the RAM settings */
39+
#ifndef NRF_SDH_BLE_PERIPHERAL_LINK_COUNT
40+
#define PERIPHERAL_LINK_COUNT 1
41+
#else
42+
#define PERIPHERAL_LINK_COUNT NRF_SDH_BLE_PERIPHERAL_LINK_COUNT
43+
#endif
44+
45+
46+
/* GATTS attribite table size.
47+
* When changing this number remember to adjust the RAM settings */
48+
#ifndef NRF_SDH_BLE_GATTS_ATTR_TAB_SIZE
49+
#define GATTS_ATTR_TAB_SIZE 0x600
50+
#else
51+
#define GATTS_ATTR_TAB_SIZE NRF_SDH_BLE_GATTS_ATTR_TAB_SIZE
52+
#endif
53+
54+
55+
/**
56+
* Using this call, the application can select whether to include the
57+
* Service Changed characteristic in the GATT Server. The default in all
58+
* previous releases has been to include the Service Changed characteristic,
59+
* but this affects how GATT clients behave. Specifically, it requires
60+
* clients to subscribe to this attribute and not to cache attribute handles
61+
* between connections unless the devices are bonded. If the application
62+
* does not need to change the structure of the GATT server attributes at
63+
* runtime this adds unnecessary complexity to the interaction with peer
64+
* clients. If the SoftDevice is enabled with the Service Changed
65+
* Characteristics turned off, then clients are allowed to cache attribute
66+
* handles making applications simpler on both sides.
67+
*/
68+
#ifndef NRF_SDH_BLE_SERVICE_CHANGED
69+
#define IS_SRVC_CHANGED_CHARACT_PRESENT 1
70+
#else
71+
#define IS_SRVC_CHANGED_CHARACT_PRESENT NRF_SDH_BLE_SERVICE_CHANGED
72+
#endif
3573

3674
error_t btle_init(void);
3775

features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_NRF51/source/btle/custom/custom_helper.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,13 @@
2626
extern "C" {
2727
#endif
2828

29-
#define UUID_TABLE_MAX_ENTRIES (4) /* This is the maximum number of 128-bit UUIDs with distinct bases that
30-
* we expect to be in use; increase this limit if needed. */
29+
/* This is the maximum number of 128-bit UUIDs with distinct bases that *
30+
* we expect to be in use; increase this limit if needed. */
31+
#ifdef NRF_SDH_BLE_VS_UUID_COUNT
32+
#define UUID_TABLE_MAX_ENTRIES NRF_SDH_BLE_VS_UUID_COUNT
33+
#else
34+
#define UUID_TABLE_MAX_ENTRIES (4)
35+
#endif
3136

3237
/**
3338
* Reset the table of 128bits uuids.

0 commit comments

Comments
 (0)