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 numberOriginal file lineDiff line numberDiff line change
@@ -17,6 +17,8 @@
17
#ifndef MBED_BLE_H__
17
#ifndef MBED_BLE_H__
18
#define MBED_BLE_H__
18
#define MBED_BLE_H__
19

19

20+
#include "BLERoles.h"
21+
20
#include "blecommon.h"
22
#include "blecommon.h"
21
#include "ble/Gap.h"
23
#include "ble/Gap.h"
22
#include "ble/GattServer.h"
24
#include "ble/GattServer.h"
@@ -355,6 +357,7 @@ class BLE {
355
*/
357
*/
356
const Gap &gap() const;
358
const Gap &gap() const;
357

359

360+
#if BLE_FEATURE_GATT_SERVER
358
/**
361
/**
359
* Accessor to GattServer. All GattServer related functionality requires
362
* Accessor to GattServer. All GattServer related functionality requires
360
* going through this accessor.
363
* going through this accessor.
@@ -370,7 +373,9 @@ class BLE {
370
* instance.
373
* instance.
371
*/
374
*/
372
const GattServer &gattServer() const;
375
const GattServer &gattServer() const;
376+
#endif // BLE_FEATURE_GATT_SERVER
373

377

378+
#if BLE_FEATURE_GATT_CLIENT
374
/**
379
/**
375
* Accessors to GattClient. All GattClient related functionality requires
380
* Accessors to GattClient. All GattClient related functionality requires
376
* going through this accessor.
381
* going through this accessor.
@@ -386,7 +391,9 @@ class BLE {
386
* instance.
391
* instance.
387
*/
392
*/
388
const GattClient &gattClient() const;
393
const GattClient &gattClient() const;
394+
#endif // BLE_FEATURE_GATT_CLIENT
389

395

396+
#if BLE_FEATURE_SECURITY
390
/**
397
/**
391
* Accessors to SecurityManager. All SecurityManager-related functionality
398
* Accessors to SecurityManager. All SecurityManager-related functionality
392
* requires going through this accessor.
399
* requires going through this accessor.
@@ -403,6 +410,7 @@ class BLE {
403
* BLE instance.
410
* BLE instance.
404
*/
411
*/
405
const SecurityManager &securityManager() const;
412
const SecurityManager &securityManager() const;
413+
#endif // BLE_FEATURE_SECURITY
406

414

407
/**
415
/**
408
* Translate error code into a printable string.
416
* Translate error code into a printable string.
@@ -489,6 +497,7 @@ class BLE {
489
return gap().getAddress(typeP, address);
497
return gap().getAddress(typeP, address);
490
}
498
}
491

499

500+
#if BLE_ROLE_BROADCASTER
492
/**
501
/**
493
* Set the GAP advertising mode to use for this device.
502
* Set the GAP advertising mode to use for this device.
494
*
503
*
@@ -834,7 +843,9 @@ class BLE {
834
*/
843
*/
835
MBED_DEPRECATED("Use ble.gap().stopAdvertising(...)")
844
MBED_DEPRECATED("Use ble.gap().stopAdvertising(...)")
836
ble_error_t stopAdvertising(void);
845
ble_error_t stopAdvertising(void);
846+
#endif // BLE_ROLE_BROADCASTER
837

847

848+
#if BLE_ROLE_OBSERVER
838
/**
849
/**
839
* Set up parameters for GAP scanning (observer mode).
850
* Set up parameters for GAP scanning (observer mode).
840
*
851
*
@@ -1032,7 +1043,9 @@ class BLE {
1032
{
1043
{
1033
return gap().stopScan();
1044
return gap().stopScan();
1034
}
1045
}
1046+
#endif // BLE_ROLE_OBSERVER
1035

1047

1048+
#if BLE_ROLE_CENTRAL
1036
/**
1049
/**
1037
* Create a connection (GAP Link Establishment).
1050
* Create a connection (GAP Link Establishment).
1038
*
1051
*
@@ -1061,7 +1074,9 @@ class BLE {
1061
const Gap::ConnectionParams_t *connectionParams = NULL,
1074
const Gap::ConnectionParams_t *connectionParams = NULL,
1062
const GapScanningParams *scanParams = NULL
1075
const GapScanningParams *scanParams = NULL
1063
);
1076
);
1077+
#endif // BLE_ROLE_CENTRAL
1064

1078

1079+
#if BLE_FEATURE_CONNECTABLE
1065
/**
1080
/**
1066
* This call initiates the disconnection procedure, and its completion is
1081
* This call initiates the disconnection procedure, and its completion is
1067
* communicated to the application with an invocation of the
1082
* communicated to the application with an invocation of the
@@ -1104,6 +1119,7 @@ class BLE {
1104
*/
1119
*/
1105
MBED_DEPRECATED("Use ble.gap().disconnect(...)")
1120
MBED_DEPRECATED("Use ble.gap().disconnect(...)")
1106
ble_error_t disconnect(Gap::DisconnectionReason_t reason);
1121
ble_error_t disconnect(Gap::DisconnectionReason_t reason);
1122+
#endif // BLE_FEATURE_CONNECTABLE
1107

1123

1108
/**
1124
/**
1109
* Returns the current Gap state of the device using a bitmask that
1125
* Returns the current Gap state of the device using a bitmask that
@@ -1119,6 +1135,8 @@ class BLE {
1119
MBED_DEPRECATED("Use ble.gap().getState()")
1135
MBED_DEPRECATED("Use ble.gap().getState()")
1120
Gap::GapState_t getGapState(void) const;
1136
Gap::GapState_t getGapState(void) const;
1121

1137

1138+
#if BLE_FEATURE_CONNECTABLE
1139+
#if BLE_FEATURE_GATT_SERVER
1122
/**
1140
/**
1123
* Get the GAP peripheral's preferred connection parameters. These are the
1141
* Get the GAP peripheral's preferred connection parameters. These are the
1124
* defaults that the peripheral would like to have in a connection. The
1142
* defaults that the peripheral would like to have in a connection. The
@@ -1163,6 +1181,7 @@ class BLE {
1163
{
1181
{
1164
return gap().setPreferredConnectionParams(params);
1182
return gap().setPreferredConnectionParams(params);
1165
}
1183
}
1184+
#endif // BLE_FEATURE_GATT_SERVER
1166

1185

1167
/**
1186
/**
1168
* Update connection parameters while in the peripheral role.
1187
* Update connection parameters while in the peripheral role.
@@ -1185,7 +1204,9 @@ class BLE {
1185
*/
1204
*/
1186
MBED_DEPRECATED("Use ble.gap().updateConnectionParams(...)")
1205
MBED_DEPRECATED("Use ble.gap().updateConnectionParams(...)")
1187
ble_error_t updateConnectionParams(Gap::Handle_t handle, const Gap::ConnectionParams_t *params);
1206
ble_error_t updateConnectionParams(Gap::Handle_t handle, const Gap::ConnectionParams_t *params);
1207+
#endif // BLE_FEATURE_CONNECTABLE
1188

1208

1209+
#if BLE_FEATURE_GATT_SERVER
1189
/**
1210
/**
1190
* Set the device name characteristic in the Gap service.
1211
* Set the device name characteristic in the Gap service.
1191
*
1212
*
@@ -1276,6 +1297,7 @@ class BLE {
1276
{
1297
{
1277
return gap().getAppearance(appearanceP);
1298
return gap().getAppearance(appearanceP);
1278
}
1299
}
1300+
#endif // BLE_FEATURE_GATT_SERVER
1279

1301

1280
/**
1302
/**
1281
* Set the radio's transmit power.
1303
* Set the radio's transmit power.
@@ -1309,6 +1331,7 @@ class BLE {
1309
MBED_DEPRECATED("Use ble.gap().getPermittedTxPowerValues(...)")
1331
MBED_DEPRECATED("Use ble.gap().getPermittedTxPowerValues(...)")
1310
void getPermittedTxPowerValues(const int8_t **valueArrayPP, size_t *countP);
1332
void getPermittedTxPowerValues(const int8_t **valueArrayPP, size_t *countP);
1311

1333

1334+
#if BLE_FEATURE_GATT_SERVER
1312
/**
1335
/**
1313
* Add a service declaration to the local server ATT table. Also add the
1336
* Add a service declaration to the local server ATT table. Also add the
1314
* characteristics contained within.
1337
* characteristics contained within.
@@ -1467,7 +1490,9 @@ class BLE {
1467
{
1490
{
1468
return gattServer().write(connectionHandle, attributeHandle, value, size, localOnly);
1491
return gattServer().write(connectionHandle, attributeHandle, value, size, localOnly);
1469
}
1492
}
1493+
#endif // BLE_FEATURE_GATT_SERVER
1470

1494

1495+
#if BLE_FEATURE_SECURITY
1471
/**
1496
/**
1472
* Enable the BLE stack's Security Manager. The Security Manager implements
1497
* Enable the BLE stack's Security Manager. The Security Manager implements
1473
* the cryptographic algorithms and protocol exchanges that allow two
1498
* the cryptographic algorithms and protocol exchanges that allow two
@@ -1536,6 +1561,7 @@ class BLE {
1536
{
1561
{
1537
return securityManager().purgeAllBondingState();
1562
return securityManager().purgeAllBondingState();
1538
}
1563
}
1564+
#endif // BLE_FEATURE_SECURITY
1539

1565

1540
/**
1566
/**
1541
* Set up a callback for timeout events. Refer to Gap::TimeoutSource_t for
1567
* Set up a callback for timeout events. Refer to Gap::TimeoutSource_t for
@@ -1551,6 +1577,7 @@ class BLE {
1551
MBED_DEPRECATED("ble.gap().onTimeout(callback)")
1577
MBED_DEPRECATED("ble.gap().onTimeout(callback)")
1552
void onTimeout(Gap::TimeoutEventCallback_t timeoutCallback);
1578
void onTimeout(Gap::TimeoutEventCallback_t timeoutCallback);
1553

1579

1580+
#if BLE_FEATURE_CONNECTABLE
1554
/**
1581
/**
1555
* Set up a callback for connection events. Refer to Gap::ConnectionEventCallback_t.
1582
* Set up a callback for connection events. Refer to Gap::ConnectionEventCallback_t.
1556
*
1583
*
@@ -1595,6 +1622,7 @@ class BLE {
1595
{
1622
{
1596
gap().onDisconnection(tptr, mptr);
1623
gap().onDisconnection(tptr, mptr);
1597
}
1624
}
1625+
#endif // BLE_FEATURE_CONNECTABLE
1598

1626

1599
/**
1627
/**
1600
* Radio Notification is a feature that enables ACTIVE and INACTIVE
1628
* Radio Notification is a feature that enables ACTIVE and INACTIVE
@@ -1620,6 +1648,7 @@ class BLE {
1620
MBED_DEPRECATED("ble.gap().onRadioNotification(...)")
1648
MBED_DEPRECATED("ble.gap().onRadioNotification(...)")
1621
void onRadioNotification(void (*callback)(bool));
1649
void onRadioNotification(void (*callback)(bool));
1622

1650

1651+
#if BLE_FEATURE_GATT_SERVER
1623
/**
1652
/**
1624
* Add a callback for the GATT event DATA_SENT (which is triggered when
1653
* Add a callback for the GATT event DATA_SENT (which is triggered when
1625
* updates are sent out by GATT in the form of notifications).
1654
* updates are sent out by GATT in the form of notifications).
@@ -1821,7 +1850,9 @@ class BLE {
1821
{
1850
{
1822
gattServer().onConfirmationReceived(callback);
1851
gattServer().onConfirmationReceived(callback);
1823
}
1852
}
1853+
#endif // BLE_FEATURE_GATT_SERVER
1824

1854

1855+
#if BLE_FEATURE_SECURITY
1825
/**
1856
/**
1826
* Set up a callback for when the security setup procedure (key generation
1857
* Set up a callback for when the security setup procedure (key generation
1827
* and exchange) for a link has started. This will be skipped for bonded
1858
* and exchange) for a link has started. This will be skipped for bonded
@@ -1918,6 +1949,7 @@ class BLE {
1918
{
1949
{
1919
return securityManager().onPasskeyDisplay(callback);
1950
return securityManager().onPasskeyDisplay(callback);
1920
}
1951
}
1952+
#endif // BLE_FEATURE_SECURITY
1921

1953

1922
private:
1954
private:
1923
friend class BLEInstanceBase;
1955
friend class BLEInstanceBase;

features/FEATURE_BLE/ble/BLEInstanceBase.h

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

185

186+
187+
#if BLE_FEATURE_GATT_SERVER
186
/**
188
/**
187
* Accessor to the vendor implementation of the GattServer interface.
189
* Accessor to the vendor implementation of the GattServer interface.
188
*
190
*
@@ -202,7 +204,9 @@ class BLEInstanceBase
202
* @see BLE::gattServer() GattServer
204
* @see BLE::gattServer() GattServer
203
*/
205
*/
204
virtual const GattServer &getGattServer(void) const = 0;
206
virtual const GattServer &getGattServer(void) const = 0;
207+
#endif // BLE_FEATURE_GATT_SERVER
205

208

209+
#if BLE_FEATURE_GATT_CLIENT
206
/**
210
/**
207
* Accessor to the vendor implementation of the GattClient interface.
211
* Accessor to the vendor implementation of the GattClient interface.
208
*
212
*
@@ -212,7 +216,9 @@ class BLEInstanceBase
212
* @see BLE::gattClient() GattClient
216
* @see BLE::gattClient() GattClient
213
*/
217
*/
214
virtual GattClient &getGattClient(void) = 0;
218
virtual GattClient &getGattClient(void) = 0;
219+
#endif
215

220

221+
#if BLE_FEATURE_SECURITY
216
/**
222
/**
217
* Accessor to the vendor implementation of the SecurityManager interface.
223
* Accessor to the vendor implementation of the SecurityManager interface.
218
*
224
*
@@ -232,6 +238,7 @@ class BLEInstanceBase
232
* @see BLE::securityManager() SecurityManager
238
* @see BLE::securityManager() SecurityManager
233
*/
239
*/
234
virtual const SecurityManager &getSecurityManager(void) const = 0;
240
virtual const SecurityManager &getSecurityManager(void) const = 0;
241+
#endif // BLE_FEATURE_SECURITY
235

242

236
/**
243
/**
237
* Process pending events present in the vendor subsystem; then, put the MCU
244
* 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 numberOriginal file lineDiff 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)