Skip to content

Commit bacf6a9

Browse files
author
Cruz Monrreal
authored
Merge pull request #6860 from andrewleech/nordic_ble_config
Nordic BLE: Allow configuration of softdevice parameters
2 parents 7dc4848 + bf313aa commit bacf6a9

File tree

6 files changed

+81
-34
lines changed

6 files changed

+81
-34
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.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"name": "nordic-ble",
3+
"config": {
4+
"central_link_count": {
5+
"help": "When acting as BLE central, how many peripherals can connect",
6+
"value": "3",
7+
"macro_name": "NRF_SDH_BLE_CENTRAL_LINK_COUNT"
8+
},
9+
"peripheral_link_count": {
10+
"help": "When acting as BLE peripheral, how many centrals can we conenct to",
11+
"value": "1",
12+
"macro_name": "NRF_SDH_BLE_PERIPHERAL_LINK_COUNT"
13+
},
14+
"gatt_attr_tab_size": {
15+
"help": "The size of the table used to hold gatts. Can be adjusted by trial and error",
16+
"value": "0x600",
17+
"macro_name": "NRF_SDH_BLE_GATTS_ATTR_TAB_SIZE"
18+
},
19+
"uuid_table_max_entries": {
20+
"help": "maximum number of 128-bit UUIDs with distinct bases that we expect to be in use",
21+
"value": "4",
22+
"macro_name": "NRF_SDH_BLE_VS_UUID_COUNT"
23+
},
24+
"is_srvc_changed_charact_present": {
25+
"help": "select whether to include the Service Changed characteristic in the GATT Server",
26+
"value": "1",
27+
"macro_name": "NRF_SDH_BLE_SERVICE_CHANGED"
28+
}
29+
}
30+
}

targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_SDK_14_2/TARGET_SOFTDEVICE_S132_FULL/mbed_lib.json

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,7 @@
1212
"NRF_SDH_ENABLED=1",
1313
"NRF_SDH_BLE_ENABLED=1",
1414
"PEER_MANAGER_ENABLED=1",
15-
"NRF_SDH_BLE_PERIPHERAL_LINK_COUNT=1",
16-
"NRF_SDH_BLE_CENTRAL_LINK_COUNT=3",
17-
"NRF_SDH_BLE_TOTAL_LINK_COUNT=4",
18-
"NRF_SDH_BLE_SERVICE_CHANGED=1",
1915
"NRF_SDH_BLE_GATT_MAX_MTU_SIZE=23",
20-
"NRF_SDH_BLE_GATTS_ATTR_TAB_SIZE=0x600",
21-
"NRF_SDH_BLE_VS_UUID_COUNT=4",
2216
"NRF_SDH_BLE_OBSERVER_PRIO_LEVELS=4",
2317
"NRF_SDH_BLE_GAP_EVENT_LENGTH=3",
2418
"BLE_ADV_BLE_OBSERVER_PRIO=1",

targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_SDK_14_2/TARGET_SOFTDEVICE_S140_FULL/mbed_lib.json

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,7 @@
1212
"NRF_SDH_ENABLED=1",
1313
"NRF_SDH_BLE_ENABLED=1",
1414
"PEER_MANAGER_ENABLED=1",
15-
"NRF_SDH_BLE_PERIPHERAL_LINK_COUNT=1",
16-
"NRF_SDH_BLE_CENTRAL_LINK_COUNT=3",
17-
"NRF_SDH_BLE_TOTAL_LINK_COUNT=4",
18-
"NRF_SDH_BLE_SERVICE_CHANGED=1",
1915
"NRF_SDH_BLE_GATT_MAX_MTU_SIZE=23",
20-
"NRF_SDH_BLE_GATTS_ATTR_TAB_SIZE=0x600",
21-
"NRF_SDH_BLE_VS_UUID_COUNT=4",
2216
"NRF_SDH_BLE_OBSERVER_PRIO_LEVELS=4",
2317
"NRF_SDH_BLE_GAP_EVENT_LENGTH=3",
2418
"BLE_ADV_BLE_OBSERVER_PRIO=1",

0 commit comments

Comments
 (0)