Skip to content

Commit 72b7d97

Browse files
pull define out into json config
1 parent 98bb0f7 commit 72b7d97

File tree

3 files changed

+18
-16
lines changed

3 files changed

+18
-16
lines changed

connectivity/FEATURE_BLE/libraries/ble-api-implementation/include/ble/internal/GattServerImpl.h

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,9 @@
3333
#include "att_api.h"
3434
#include "SecurityManager.h"
3535

36-
#include "ble/BLE.h"
3736
#include "ble/types/GattCallbackParamTypes.h"
3837
#include "ble/internal/PalSigningMonitor.h"
3938

40-
/*! Maximum count of characteristics that can be stored for authorisation purposes */
41-
#define MAX_CHARACTERISTIC_AUTHORIZATION_CNT 20
42-
43-
/*! client characteristic configuration descriptors settings */
44-
#define MAX_CCCD_CNT 20
45-
4639
namespace ble {
4740

4841
// fwd declaration of PalAttClient and BLE
@@ -346,12 +339,12 @@ class GattServer :
346339

347340
PalSigningMonitorEventHandler *_signing_event_handler;
348341

349-
attsCccSet_t cccds[MAX_CCCD_CNT];
350-
uint16_t cccd_values[MAX_CCCD_CNT];
351-
uint16_t cccd_handles[MAX_CCCD_CNT];
342+
attsCccSet_t cccds[MBED_CONF_BLE_API_IMPLEMENTATION_MAX_CCCD_COUNT];
343+
uint16_t cccd_values[MBED_CONF_BLE_API_IMPLEMENTATION_MAX_CCCD_COUNT];
344+
uint16_t cccd_handles[MBED_CONF_BLE_API_IMPLEMENTATION_MAX_CCCD_COUNT];
352345
uint8_t cccd_cnt;
353346

354-
GattCharacteristic *_auth_char[MAX_CHARACTERISTIC_AUTHORIZATION_CNT];
347+
GattCharacteristic *_auth_char[MBED_CONF_BLE_API_IMPLEMENTATION_MAX_CHARACTERISTIC_AUTHORISATION_COUNT];
355348
uint8_t _auth_char_count;
356349

357350
struct {
Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
11
{
2-
"name": "ble-api-implementation"
2+
"name": "ble-api-implementation",
3+
"config": {
4+
"max-characteristic-authorisation-count": {
5+
"help": "Maximum count of characteristics that can be stored for authorisation purposes.",
6+
"value": 20
7+
},
8+
"max-cccd-count": {
9+
"help": "Client characteristic configuration descriptors settings.",
10+
"value": 20
11+
}
12+
}
313
}

connectivity/FEATURE_BLE/libraries/ble-api-implementation/source/GattServerImpl.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#include <algorithm>
2121
#include "ble/GattServer.h"
2222
#include "ble/internal/BLEInstanceBase.h"
23-
#include "mbed.h"
2423
#include "wsf_types.h"
2524
#include "att_api.h"
2625

@@ -407,7 +406,7 @@ ble_error_t GattServer::insert_characteristic_value_attribute(
407406
characteristic->isReadAuthorizationEnabled() ||
408407
characteristic->isWriteAuthorizationEnabled()
409408
) {
410-
if ( _auth_char_count >= MAX_CHARACTERISTIC_AUTHORIZATION_CNT) {
409+
if ( _auth_char_count >= MBED_CONF_BLE_API_IMPLEMENTATION_MAX_CHARACTERISTIC_AUTHORISATION_COUNT) {
411410
return BLE_ERROR_NO_MEM;
412411
}
413412
_auth_char[_auth_char_count] = characteristic;
@@ -447,7 +446,7 @@ ble_error_t GattServer::insert_descriptor(
447446

448447
// handle the special case of a CCCD
449448
if (descriptor->getUUID() == UUID(BLE_UUID_DESCRIPTOR_CLIENT_CHAR_CONFIG)) {
450-
if (cccd_cnt >= MAX_CCCD_CNT) {
449+
if (cccd_cnt >= MBED_CONF_BLE_API_IMPLEMENTATION_MAX_CCCD_COUNT) {
451450
return BLE_ERROR_NO_MEM;
452451
}
453452

@@ -553,7 +552,7 @@ ble_error_t GattServer::insert_cccd(
553552
GattCharacteristic *characteristic,
554553
attsAttr_t *&attribute_it
555554
) {
556-
if (cccd_cnt >= MAX_CCCD_CNT) {
555+
if (cccd_cnt >= MBED_CONF_BLE_API_IMPLEMENTATION_MAX_CCCD_COUNT) {
557556
return BLE_ERROR_NO_MEM;
558557
}
559558

0 commit comments

Comments
 (0)