Skip to content

Commit f8d254f

Browse files
author
Cruz Monrreal
authored
Merge pull request #9790 from paul-szczepanek-arm/ble-conf
Ble conf
2 parents 3d1b55d + 54a866c commit f8d254f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1004
-127
lines changed

features/FEATURE_BLE/ble/BLE.h

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
#ifndef MBED_BLE_H__
1818
#define MBED_BLE_H__
1919

20+
#include "BLERoles.h"
21+
2022
#include "blecommon.h"
2123
#include "ble/Gap.h"
2224
#include "ble/GattServer.h"
@@ -355,6 +357,7 @@ class BLE {
355357
*/
356358
const Gap &gap() const;
357359

360+
#if BLE_FEATURE_GATT_SERVER
358361
/**
359362
* Accessor to GattServer. All GattServer related functionality requires
360363
* going through this accessor.
@@ -370,7 +373,9 @@ class BLE {
370373
* instance.
371374
*/
372375
const GattServer &gattServer() const;
376+
#endif // BLE_FEATURE_GATT_SERVER
373377

378+
#if BLE_FEATURE_GATT_CLIENT
374379
/**
375380
* Accessors to GattClient. All GattClient related functionality requires
376381
* going through this accessor.
@@ -386,7 +391,9 @@ class BLE {
386391
* instance.
387392
*/
388393
const GattClient &gattClient() const;
394+
#endif // BLE_FEATURE_GATT_CLIENT
389395

396+
#if BLE_FEATURE_SECURITY
390397
/**
391398
* Accessors to SecurityManager. All SecurityManager-related functionality
392399
* requires going through this accessor.
@@ -403,6 +410,7 @@ class BLE {
403410
* BLE instance.
404411
*/
405412
const SecurityManager &securityManager() const;
413+
#endif // BLE_FEATURE_SECURITY
406414

407415
/**
408416
* Translate error code into a printable string.
@@ -489,6 +497,7 @@ class BLE {
489497
return gap().getAddress(typeP, address);
490498
}
491499

500+
#if BLE_ROLE_BROADCASTER
492501
/**
493502
* Set the GAP advertising mode to use for this device.
494503
*
@@ -834,7 +843,9 @@ class BLE {
834843
*/
835844
MBED_DEPRECATED("Use ble.gap().stopAdvertising(...)")
836845
ble_error_t stopAdvertising(void);
846+
#endif // BLE_ROLE_BROADCASTER
837847

848+
#if BLE_ROLE_OBSERVER
838849
/**
839850
* Set up parameters for GAP scanning (observer mode).
840851
*
@@ -1032,7 +1043,9 @@ class BLE {
10321043
{
10331044
return gap().stopScan();
10341045
}
1046+
#endif // BLE_ROLE_OBSERVER
10351047

1048+
#if BLE_ROLE_CENTRAL
10361049
/**
10371050
* Create a connection (GAP Link Establishment).
10381051
*
@@ -1061,7 +1074,9 @@ class BLE {
10611074
const Gap::ConnectionParams_t *connectionParams = NULL,
10621075
const GapScanningParams *scanParams = NULL
10631076
);
1077+
#endif // BLE_ROLE_CENTRAL
10641078

1079+
#if BLE_FEATURE_CONNECTABLE
10651080
/**
10661081
* This call initiates the disconnection procedure, and its completion is
10671082
* communicated to the application with an invocation of the
@@ -1104,6 +1119,7 @@ class BLE {
11041119
*/
11051120
MBED_DEPRECATED("Use ble.gap().disconnect(...)")
11061121
ble_error_t disconnect(Gap::DisconnectionReason_t reason);
1122+
#endif // BLE_FEATURE_CONNECTABLE
11071123

11081124
/**
11091125
* Returns the current Gap state of the device using a bitmask that
@@ -1119,6 +1135,8 @@ class BLE {
11191135
MBED_DEPRECATED("Use ble.gap().getState()")
11201136
Gap::GapState_t getGapState(void) const;
11211137

1138+
#if BLE_FEATURE_CONNECTABLE
1139+
#if BLE_FEATURE_GATT_SERVER
11221140
/**
11231141
* Get the GAP peripheral's preferred connection parameters. These are the
11241142
* defaults that the peripheral would like to have in a connection. The
@@ -1163,6 +1181,7 @@ class BLE {
11631181
{
11641182
return gap().setPreferredConnectionParams(params);
11651183
}
1184+
#endif // BLE_FEATURE_GATT_SERVER
11661185

11671186
/**
11681187
* Update connection parameters while in the peripheral role.
@@ -1185,7 +1204,9 @@ class BLE {
11851204
*/
11861205
MBED_DEPRECATED("Use ble.gap().updateConnectionParams(...)")
11871206
ble_error_t updateConnectionParams(Gap::Handle_t handle, const Gap::ConnectionParams_t *params);
1207+
#endif // BLE_FEATURE_CONNECTABLE
11881208

1209+
#if BLE_FEATURE_GATT_SERVER
11891210
/**
11901211
* Set the device name characteristic in the Gap service.
11911212
*
@@ -1276,6 +1297,7 @@ class BLE {
12761297
{
12771298
return gap().getAppearance(appearanceP);
12781299
}
1300+
#endif // BLE_FEATURE_GATT_SERVER
12791301

12801302
/**
12811303
* Set the radio's transmit power.
@@ -1309,6 +1331,7 @@ class BLE {
13091331
MBED_DEPRECATED("Use ble.gap().getPermittedTxPowerValues(...)")
13101332
void getPermittedTxPowerValues(const int8_t **valueArrayPP, size_t *countP);
13111333

1334+
#if BLE_FEATURE_GATT_SERVER
13121335
/**
13131336
* Add a service declaration to the local server ATT table. Also add the
13141337
* characteristics contained within.
@@ -1467,7 +1490,9 @@ class BLE {
14671490
{
14681491
return gattServer().write(connectionHandle, attributeHandle, value, size, localOnly);
14691492
}
1493+
#endif // BLE_FEATURE_GATT_SERVER
14701494

1495+
#if BLE_FEATURE_SECURITY
14711496
/**
14721497
* Enable the BLE stack's Security Manager. The Security Manager implements
14731498
* the cryptographic algorithms and protocol exchanges that allow two
@@ -1536,6 +1561,7 @@ class BLE {
15361561
{
15371562
return securityManager().purgeAllBondingState();
15381563
}
1564+
#endif // BLE_FEATURE_SECURITY
15391565

15401566
/**
15411567
* Set up a callback for timeout events. Refer to Gap::TimeoutSource_t for
@@ -1551,6 +1577,7 @@ class BLE {
15511577
MBED_DEPRECATED("ble.gap().onTimeout(callback)")
15521578
void onTimeout(Gap::TimeoutEventCallback_t timeoutCallback);
15531579

1580+
#if BLE_FEATURE_CONNECTABLE
15541581
/**
15551582
* Set up a callback for connection events. Refer to Gap::ConnectionEventCallback_t.
15561583
*
@@ -1595,6 +1622,7 @@ class BLE {
15951622
{
15961623
gap().onDisconnection(tptr, mptr);
15971624
}
1625+
#endif // BLE_FEATURE_CONNECTABLE
15981626

15991627
/**
16001628
* Radio Notification is a feature that enables ACTIVE and INACTIVE
@@ -1620,6 +1648,7 @@ class BLE {
16201648
MBED_DEPRECATED("ble.gap().onRadioNotification(...)")
16211649
void onRadioNotification(void (*callback)(bool));
16221650

1651+
#if BLE_FEATURE_GATT_SERVER
16231652
/**
16241653
* Add a callback for the GATT event DATA_SENT (which is triggered when
16251654
* updates are sent out by GATT in the form of notifications).
@@ -1821,7 +1850,9 @@ class BLE {
18211850
{
18221851
gattServer().onConfirmationReceived(callback);
18231852
}
1853+
#endif // BLE_FEATURE_GATT_SERVER
18241854

1855+
#if BLE_FEATURE_SECURITY
18251856
/**
18261857
* Set up a callback for when the security setup procedure (key generation
18271858
* and exchange) for a link has started. This will be skipped for bonded
@@ -1918,6 +1949,7 @@ class BLE {
19181949
{
19191950
return securityManager().onPasskeyDisplay(callback);
19201951
}
1952+
#endif // BLE_FEATURE_SECURITY
19211953

19221954
private:
19231955
friend class BLEInstanceBase;

features/FEATURE_BLE/ble/BLEInstanceBase.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,8 @@ class BLEInstanceBase
183183
*/
184184
virtual const Gap &getGap(void) const = 0;
185185

186+
187+
#if BLE_FEATURE_GATT_SERVER
186188
/**
187189
* Accessor to the vendor implementation of the GattServer interface.
188190
*
@@ -202,7 +204,9 @@ class BLEInstanceBase
202204
* @see BLE::gattServer() GattServer
203205
*/
204206
virtual const GattServer &getGattServer(void) const = 0;
207+
#endif // BLE_FEATURE_GATT_SERVER
205208

209+
#if BLE_FEATURE_GATT_CLIENT
206210
/**
207211
* Accessor to the vendor implementation of the GattClient interface.
208212
*
@@ -212,7 +216,9 @@ class BLEInstanceBase
212216
* @see BLE::gattClient() GattClient
213217
*/
214218
virtual GattClient &getGattClient(void) = 0;
219+
#endif
215220

221+
#if BLE_FEATURE_SECURITY
216222
/**
217223
* Accessor to the vendor implementation of the SecurityManager interface.
218224
*
@@ -232,6 +238,7 @@ class BLEInstanceBase
232238
* @see BLE::securityManager() SecurityManager
233239
*/
234240
virtual const SecurityManager &getSecurityManager(void) const = 0;
241+
#endif // BLE_FEATURE_SECURITY
235242

236243
/**
237244
* Process pending events present in the vendor subsystem; then, put the MCU

features/FEATURE_BLE/ble/BLERoles.h

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
#ifndef MBED_BLE_ROLES_H__
2+
#define MBED_BLE_ROLES_H__
3+
4+
#if !(BLE_ROLE_OBSERVER) && !(BLE_ROLE_BROADCASTER)
5+
#error "BLE requires at least one role 'BROADCASTER' or 'OBSERVER' to be enabled"
6+
#endif
7+
8+
#if (BLE_ROLE_PERIPHERAL) || (BLE_ROLE_CENTRAL)
9+
#define BLE_FEATURE_CONNECTABLE 1
10+
#endif
11+
12+
#if (BLE_FEATURE_GATT_CLIENT) || (BLE_FEATURE_GATT_SERVER)
13+
#define BLE_FEATURE_ATT 1
14+
#endif
15+
16+
#if BLE_ROLE_PERIPHERAL
17+
#if !(BLE_ROLE_BROADCASTER)
18+
#error "BLE role 'PERIPHERAL' depends on role 'BROADCASTER'"
19+
#endif
20+
#endif // BLE_ROLE_PERIPHERAL
21+
22+
#if BLE_ROLE_CENTRAL
23+
#if !(BLE_ROLE_OBSERVER)
24+
#error "BLE role 'CENTRAL' depends on role 'OBSERVER'"
25+
#endif
26+
#endif // BLE_ROLE_CENTRAL
27+
28+
#if BLE_FEATURE_SECURITY
29+
#if !(BLE_ROLE_PERIPHERAL) && !(BLE_ROLE_CENTRAL)
30+
#error "BLE feature 'SECURITY' requires 'PERIPHERAL' or 'CENTRAL' role"
31+
#endif
32+
#endif // BLE_FEATURE_SECURITY
33+
34+
#if BLE_FEATURE_SECURE_CONNECTIONS
35+
#if !(BLE_FEATURE_SECURITY)
36+
#error "BLE feature 'SECURE CONNECTIONS' requires the 'SECURITY' feature"
37+
#endif
38+
#endif // BLE_FEATURE_SECURE_CONNECTIONS
39+
40+
#if BLE_FEATURE_SIGNING
41+
#if !(BLE_FEATURE_SECURITY)
42+
#error "BLE feature 'SIGNING' requires the 'SECURITY' feature"
43+
#endif
44+
#endif // BLE_FEATURE_SIGNING
45+
46+
#if BLE_FEATURE_WHITELIST
47+
#if !(BLE_FEATURE_SECURITY)
48+
#error "BLE feature 'WHITELIST' requires the 'SECURITY' feature"
49+
#endif
50+
#endif // BLE_FEATURE_WHITELIST
51+
52+
#if BLE_FEATURE_PRIVACY
53+
#if !(BLE_FEATURE_SECURITY)
54+
#error "BLE feature 'PRIVACY' requires the 'SECURITY' feature"
55+
#endif
56+
#endif // BLE_FEATURE_PRIVACY
57+
58+
#if BLE_FEATURE_PERIODIC_ADVERTISING
59+
#if !(BLE_FEATURE_EXTENDED_ADVERTISING)
60+
#error "BLE feature 'PERIODIC ADVERTISING' requires the 'EXTENDED ADVERTISING' feature"
61+
#endif
62+
#endif // BLE_FEATURE_PERIODIC_ADVERTISING
63+
64+
#if BLE_FEATURE_GATT_CLIENT
65+
#if !(BLE_FEATURE_CONNECTABLE)
66+
#error "BLE feature 'GATT CLIENT' requires 'PERIPHERAL' or 'CENTRAL' role"
67+
#endif
68+
#endif // BLE_FEATURE_GATT_CLIENT
69+
70+
#if BLE_FEATURE_GATT_SERVER
71+
#if !(BLE_FEATURE_CONNECTABLE)
72+
#error "BLE feature 'GATT SERVER' requires 'PERIPHERAL' or 'CENTRAL' role"
73+
#endif
74+
#endif // BLE_FEATURE_GATT_SERVER
75+
76+
#endif // MBED_BLE_ROLES_H__

0 commit comments

Comments
 (0)