17
17
#ifndef MBED_BLE_H__
18
18
#define MBED_BLE_H__
19
19
20
+ #include " BLERoles.h"
21
+
20
22
#include " blecommon.h"
21
23
#include " ble/Gap.h"
22
24
#include " ble/GattServer.h"
@@ -355,6 +357,7 @@ class BLE {
355
357
*/
356
358
const Gap &gap () const ;
357
359
360
+ #if BLE_FEATURE_GATT_SERVER
358
361
/* *
359
362
* Accessor to GattServer. All GattServer related functionality requires
360
363
* going through this accessor.
@@ -370,7 +373,9 @@ class BLE {
370
373
* instance.
371
374
*/
372
375
const GattServer &gattServer () const ;
376
+ #endif // BLE_FEATURE_GATT_SERVER
373
377
378
+ #if BLE_FEATURE_GATT_CLIENT
374
379
/* *
375
380
* Accessors to GattClient. All GattClient related functionality requires
376
381
* going through this accessor.
@@ -386,7 +391,9 @@ class BLE {
386
391
* instance.
387
392
*/
388
393
const GattClient &gattClient () const ;
394
+ #endif // BLE_FEATURE_GATT_CLIENT
389
395
396
+ #if BLE_FEATURE_SECURITY
390
397
/* *
391
398
* Accessors to SecurityManager. All SecurityManager-related functionality
392
399
* requires going through this accessor.
@@ -403,6 +410,7 @@ class BLE {
403
410
* BLE instance.
404
411
*/
405
412
const SecurityManager &securityManager () const ;
413
+ #endif // BLE_FEATURE_SECURITY
406
414
407
415
/* *
408
416
* Translate error code into a printable string.
@@ -489,6 +497,7 @@ class BLE {
489
497
return gap ().getAddress (typeP, address);
490
498
}
491
499
500
+ #if BLE_ROLE_BROADCASTER
492
501
/* *
493
502
* Set the GAP advertising mode to use for this device.
494
503
*
@@ -834,7 +843,9 @@ class BLE {
834
843
*/
835
844
MBED_DEPRECATED (" Use ble.gap().stopAdvertising(...)" )
836
845
ble_error_t stopAdvertising(void );
846
+ #endif // BLE_ROLE_BROADCASTER
837
847
848
+ #if BLE_ROLE_OBSERVER
838
849
/* *
839
850
* Set up parameters for GAP scanning (observer mode).
840
851
*
@@ -1032,7 +1043,9 @@ class BLE {
1032
1043
{
1033
1044
return gap ().stopScan ();
1034
1045
}
1046
+ #endif // BLE_ROLE_OBSERVER
1035
1047
1048
+ #if BLE_ROLE_CENTRAL
1036
1049
/* *
1037
1050
* Create a connection (GAP Link Establishment).
1038
1051
*
@@ -1061,7 +1074,9 @@ class BLE {
1061
1074
const Gap::ConnectionParams_t *connectionParams = NULL ,
1062
1075
const GapScanningParams *scanParams = NULL
1063
1076
);
1077
+ #endif // BLE_ROLE_CENTRAL
1064
1078
1079
+ #if BLE_FEATURE_CONNECTABLE
1065
1080
/* *
1066
1081
* This call initiates the disconnection procedure, and its completion is
1067
1082
* communicated to the application with an invocation of the
@@ -1104,6 +1119,7 @@ class BLE {
1104
1119
*/
1105
1120
MBED_DEPRECATED (" Use ble.gap().disconnect(...)" )
1106
1121
ble_error_t disconnect(Gap::DisconnectionReason_t reason);
1122
+ #endif // BLE_FEATURE_CONNECTABLE
1107
1123
1108
1124
/* *
1109
1125
* Returns the current Gap state of the device using a bitmask that
@@ -1119,6 +1135,8 @@ class BLE {
1119
1135
MBED_DEPRECATED (" Use ble.gap().getState()" )
1120
1136
Gap::GapState_t getGapState (void ) const ;
1121
1137
1138
+ #if BLE_FEATURE_CONNECTABLE
1139
+ #if BLE_FEATURE_GATT_SERVER
1122
1140
/* *
1123
1141
* Get the GAP peripheral's preferred connection parameters. These are the
1124
1142
* defaults that the peripheral would like to have in a connection. The
@@ -1163,6 +1181,7 @@ class BLE {
1163
1181
{
1164
1182
return gap ().setPreferredConnectionParams (params);
1165
1183
}
1184
+ #endif // BLE_FEATURE_GATT_SERVER
1166
1185
1167
1186
/* *
1168
1187
* Update connection parameters while in the peripheral role.
@@ -1185,7 +1204,9 @@ class BLE {
1185
1204
*/
1186
1205
MBED_DEPRECATED (" Use ble.gap().updateConnectionParams(...)" )
1187
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
1211
* Set the device name characteristic in the Gap service.
1191
1212
*
@@ -1276,6 +1297,7 @@ class BLE {
1276
1297
{
1277
1298
return gap ().getAppearance (appearanceP);
1278
1299
}
1300
+ #endif // BLE_FEATURE_GATT_SERVER
1279
1301
1280
1302
/* *
1281
1303
* Set the radio's transmit power.
@@ -1309,6 +1331,7 @@ class BLE {
1309
1331
MBED_DEPRECATED (" Use ble.gap().getPermittedTxPowerValues(...)" )
1310
1332
void getPermittedTxPowerValues (const int8_t **valueArrayPP, size_t *countP);
1311
1333
1334
+ #if BLE_FEATURE_GATT_SERVER
1312
1335
/* *
1313
1336
* Add a service declaration to the local server ATT table. Also add the
1314
1337
* characteristics contained within.
@@ -1467,7 +1490,9 @@ class BLE {
1467
1490
{
1468
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
1497
* Enable the BLE stack's Security Manager. The Security Manager implements
1473
1498
* the cryptographic algorithms and protocol exchanges that allow two
@@ -1536,6 +1561,7 @@ class BLE {
1536
1561
{
1537
1562
return securityManager ().purgeAllBondingState ();
1538
1563
}
1564
+ #endif // BLE_FEATURE_SECURITY
1539
1565
1540
1566
/* *
1541
1567
* Set up a callback for timeout events. Refer to Gap::TimeoutSource_t for
@@ -1551,6 +1577,7 @@ class BLE {
1551
1577
MBED_DEPRECATED (" ble.gap().onTimeout(callback)" )
1552
1578
void onTimeout (Gap::TimeoutEventCallback_t timeoutCallback);
1553
1579
1580
+ #if BLE_FEATURE_CONNECTABLE
1554
1581
/* *
1555
1582
* Set up a callback for connection events. Refer to Gap::ConnectionEventCallback_t.
1556
1583
*
@@ -1595,6 +1622,7 @@ class BLE {
1595
1622
{
1596
1623
gap ().onDisconnection (tptr, mptr);
1597
1624
}
1625
+ #endif // BLE_FEATURE_CONNECTABLE
1598
1626
1599
1627
/* *
1600
1628
* Radio Notification is a feature that enables ACTIVE and INACTIVE
@@ -1620,6 +1648,7 @@ class BLE {
1620
1648
MBED_DEPRECATED (" ble.gap().onRadioNotification(...)" )
1621
1649
void onRadioNotification (void (*callback)(bool ));
1622
1650
1651
+ #if BLE_FEATURE_GATT_SERVER
1623
1652
/* *
1624
1653
* Add a callback for the GATT event DATA_SENT (which is triggered when
1625
1654
* updates are sent out by GATT in the form of notifications).
@@ -1821,7 +1850,9 @@ class BLE {
1821
1850
{
1822
1851
gattServer ().onConfirmationReceived (callback);
1823
1852
}
1853
+ #endif // BLE_FEATURE_GATT_SERVER
1824
1854
1855
+ #if BLE_FEATURE_SECURITY
1825
1856
/* *
1826
1857
* Set up a callback for when the security setup procedure (key generation
1827
1858
* and exchange) for a link has started. This will be skipped for bonded
@@ -1918,6 +1949,7 @@ class BLE {
1918
1949
{
1919
1950
return securityManager ().onPasskeyDisplay (callback);
1920
1951
}
1952
+ #endif // BLE_FEATURE_SECURITY
1921
1953
1922
1954
private:
1923
1955
friend class BLEInstanceBase ;
0 commit comments