Skip to content

Commit c99ff74

Browse files
authored
Merge pull request #13475 from pan-/ble-remove-user-facing-abstraction
Ble remove user facing abstraction
2 parents 6fb5e60 + ea47ee0 commit c99ff74

File tree

343 files changed

+3472
-1910
lines changed

Some content is hidden

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

343 files changed

+3472
-1910
lines changed

connectivity/FEATURE_BLE/include/ble/BLE.h

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,20 @@
1919
#ifndef MBED_BLE_H__
2020
#define MBED_BLE_H__
2121

22-
#include "FunctionPointerWithContext.h"
2322
#include "platform/mbed_error.h"
2423
#include "platform/mbed_assert.h"
2524
#include "platform/mbed_toolchain.h"
2625

27-
#include "ble/common/ble/BLERoles.h"
28-
#include "ble/common/ble/BLETypes.h"
29-
#include "ble/common/ble/blecommon.h"
30-
3126
#include "ble/Gap.h"
3227
#include "ble/GattClient.h"
3328
#include "ble/GattServer.h"
3429
#include "ble/SecurityManager.h"
3530

31+
#include "ble/common/BLERoles.h"
32+
#include "ble/common/BLETypes.h"
33+
#include "ble/common/blecommon.h"
34+
#include "ble/common/FunctionPointerWithContext.h"
35+
3636
/* Forward declaration for the implementation class */
3737

3838
namespace ble {
@@ -154,6 +154,10 @@ class BLE {
154154
*/
155155
static const InstanceID_t NUM_INSTANCES = 1;
156156

157+
// Prevent copy construction and copy assignment of BLE.
158+
BLE(const BLE &) = delete;
159+
BLE &operator=(const BLE &) = delete;
160+
157161
/**
158162
* Get a reference to the BLE singleton.
159163
*
@@ -164,16 +168,6 @@ class BLE {
164168
*/
165169
static BLE &Instance();
166170

167-
/**
168-
* Constructor for a handle to a BLE instance (the BLE stack). BLE handles
169-
* are thin wrappers around a transport object (that is, ptr. to
170-
* ble::BLEInstanceBase).
171-
*
172-
* @param[in] transport Ble transport used for the BLE instance.
173-
* @note Cordio supports only one instance.
174-
*/
175-
BLE(ble::BLEInstanceBase &transport);
176-
177171
/**
178172
* Get a reference to the BLE singleton corresponding to a given interface.
179173
*
@@ -203,7 +197,7 @@ class BLE {
203197
*/
204198
MBED_DEPRECATED_SINCE("mbed-os-6.3.0", "BLE singleton supports one instance. You may create multiple"
205199
"instances by using the constructor.")
206-
InstanceID_t getInstanceID(void) const
200+
InstanceID_t getInstanceID() const
207201
{
208202
return DEFAULT_INSTANCE;
209203
}
@@ -309,7 +303,7 @@ class BLE {
309303
* @attention This should be called before using anything else in the BLE
310304
* API.
311305
*/
312-
ble_error_t init(InitializationCompleteCallback_t completion_cb = NULL)
306+
ble_error_t init(InitializationCompleteCallback_t completion_cb = nullptr)
313307
{
314308
FunctionPointerWithContext<InitializationCompleteCallbackContext *> callback(completion_cb);
315309
return initImplementation(callback);
@@ -341,7 +335,7 @@ class BLE {
341335
* @note The application should set up a callback to signal completion of
342336
* initialization when using init().
343337
*/
344-
bool hasInitialized(void) const;
338+
bool hasInitialized() const;
345339

346340
/**
347341
* Shut down the underlying stack, and reset state of this BLE instance.
@@ -353,7 +347,7 @@ class BLE {
353347
* GAP state. This API offers a way to repopulate the GATT database with new
354348
* services and characteristics.
355349
*/
356-
ble_error_t shutdown(void);
350+
ble_error_t shutdown();
357351

358352
/**
359353
* This call allows the application to get the BLE stack version information.
@@ -362,7 +356,7 @@ class BLE {
362356
*
363357
* @note The BLE API owns the string returned.
364358
*/
365-
const char *getVersion(void);
359+
const char *getVersion();
366360

367361
/**
368362
* Accessor to Gap. All Gap-related functionality requires going through
@@ -455,6 +449,16 @@ class BLE {
455449
private:
456450
friend class ble::BLEInstanceBase;
457451

452+
/**
453+
* Constructor for a handle to a BLE instance (the BLE stack). BLE handles
454+
* are thin wrappers around a transport object (that is, ptr. to
455+
* ble::BLEInstanceBase).
456+
*
457+
* @param[in] transport Ble transport used for the BLE instance.
458+
* @note Cordio supports only one instance.
459+
*/
460+
BLE(ble::BLEInstanceBase &transport);
461+
458462
/**
459463
* Implementation of init() [internal to BLE_API].
460464
*
@@ -465,11 +469,6 @@ class BLE {
465469
FunctionPointerWithContext<InitializationCompleteCallbackContext *> callback
466470
);
467471

468-
private:
469-
// Prevent copy construction and copy assignment of BLE.
470-
BLE(const BLE &);
471-
BLE &operator=(const BLE &);
472-
473472
private:
474473
ble::BLEInstanceBase &transport; /* The device-specific backend */
475474
OnEventsToProcessCallback_t whenEventsToProcess;
@@ -480,7 +479,7 @@ class BLE {
480479

481480
using ble::BLE;
482481
/**
483-
* @namespace ble Entry namespace for all %BLE API definitions.
482+
* @namespace ble Entry namespace for all BLE API definitions.
484483
*/
485484

486485
/**

connectivity/FEATURE_BLE/include/ble/Gap.h

Lines changed: 40 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -19,28 +19,27 @@
1919
#ifndef BLE_GAP_GAP_H
2020
#define BLE_GAP_GAP_H
2121

22-
#include "CallChainOfFunctionPointersWithContext.h"
23-
24-
#include <algorithm>
25-
26-
#include "drivers/LowPowerTimeout.h"
27-
#include "drivers/LowPowerTicker.h"
28-
#include "platform/mbed_error.h"
29-
30-
#include "ble/common/ble/BLERoles.h"
31-
#include "ble/common/ble/BLETypes.h"
32-
#include "ble/common/ble/gap/AdvertisingDataBuilder.h"
33-
#include "ble/common/ble/gap/AdvertisingDataParser.h"
34-
#include "ble/common/ble/gap/AdvertisingDataSimpleBuilder.h"
35-
#include "ble/common/ble/gap/AdvertisingDataTypes.h"
36-
#include "ble/common/ble/gap/AdvertisingParameters.h"
37-
#include "ble/common/ble/gap/ConnectionParameters.h"
38-
#include "ble/common/ble/gap/Events.h"
39-
#include "ble/common/ble/gap/ScanParameters.h"
40-
#include "ble/common/ble/gap/Types.h"
22+
#include "ble/common/CallChainOfFunctionPointersWithContext.h"
23+
24+
#include "ble/common/BLERoles.h"
25+
#include "ble/common/BLETypes.h"
26+
#include "ble/gap/AdvertisingDataBuilder.h"
27+
#include "ble/gap/AdvertisingDataParser.h"
28+
#include "ble/gap/AdvertisingDataSimpleBuilder.h"
29+
#include "ble/gap/AdvertisingDataTypes.h"
30+
#include "ble/gap/AdvertisingParameters.h"
31+
#include "ble/gap/ConnectionParameters.h"
32+
#include "ble/gap/ScanParameters.h"
33+
#include "ble/gap/Events.h"
34+
#include "ble/gap/Types.h"
4135

4236
namespace ble {
43-
class PalGenericAccessService;
37+
38+
#if !defined(DOXYGEN_ONLY)
39+
namespace impl {
40+
class Gap;
41+
}
42+
#endif // !defined(DOXYGEN_ONLY)
4443

4544
/**
4645
* @addtogroup ble
@@ -280,9 +279,6 @@ class PalGenericAccessService;
280279
* PHY and of any changes to PHYs which may be triggered autonomously by the
281280
* controller or by the peer.
282281
*/
283-
#if !defined(DOXYGEN_ONLY)
284-
namespace interface {
285-
#endif // !defined(DOXYGEN_ONLY)
286282
class Gap {
287283
public:
288284
/**
@@ -547,9 +543,7 @@ class Gap {
547543
* Prevent polymorphic deletion and avoid unnecessary virtual destructor
548544
* as the Gap class will never delete the instance it contains.
549545
*/
550-
~EventHandler()
551-
{
552-
}
546+
~EventHandler() = default;
553547
};
554548

555549
/**
@@ -1314,7 +1308,7 @@ class Gap {
13141308
*
13151309
* @return Maximum size of the whitelist.
13161310
*/
1317-
uint8_t getMaxWhitelistSize(void) const;
1311+
uint8_t getMaxWhitelistSize() const;
13181312

13191313
/**
13201314
* Get the Link Layer to use the internal whitelist when scanning,
@@ -1377,7 +1371,7 @@ class Gap {
13771371
* the address in input was not identifiable as a random address.
13781372
*/
13791373
static ble_error_t getRandomAddressType(
1380-
const ble::address_t address,
1374+
ble::address_t address,
13811375
ble::random_address_type_t *addressType
13821376
);
13831377

@@ -1399,7 +1393,7 @@ class Gap {
13991393
* @note Currently, a call to reset() does not reset the advertising and
14001394
* scan parameters to default values.
14011395
*/
1402-
ble_error_t reset(void);
1396+
ble_error_t reset();
14031397

14041398
/**
14051399
* Register a Gap shutdown event handler.
@@ -1421,7 +1415,9 @@ class Gap {
14211415
* @param[in] memberPtr Shutdown event handler to register.
14221416
*/
14231417
template<typename T>
1424-
void onShutdown(T *objPtr, void (T::*memberPtr)(const Gap *));
1418+
void onShutdown(T *objPtr, void (T::*memberPtr)(const Gap *)) {
1419+
onShutdown(GapShutdownCallback_t(objPtr, memberPtr));
1420+
}
14251421

14261422
/**
14271423
* Access the callchain of shutdown event handler.
@@ -1435,29 +1431,36 @@ class Gap {
14351431
GapShutdownCallbackChain_t &onShutdown();
14361432

14371433
#if !defined(DOXYGEN_ONLY)
1434+
/*
1435+
* Constructor from the private implementation.
1436+
*/
1437+
Gap(impl::Gap* impl) : impl(impl) {}
1438+
1439+
/*
1440+
* Restrict copy and move.
1441+
*/
1442+
Gap(const Gap&) = delete;
1443+
Gap& operator=(const Gap&) = delete;
1444+
14381445
/*
14391446
* API reserved for the controller driver to set the random static address.
14401447
* Setting a new random static address while the controller is operating is
14411448
* forbidden by the Bluetooth specification.
14421449
*/
14431450
ble_error_t setRandomStaticAddress(const ble::address_t& address);
14441451
#endif // !defined(DOXYGEN_ONLY)
1452+
1453+
private:
1454+
impl::Gap* impl;
14451455
};
14461456

14471457
/**
14481458
* @}
14491459
* @}
14501460
*/
14511461

1452-
#if !defined(DOXYGEN_ONLY)
1453-
} // namespace interface
1454-
#endif // !defined(DOXYGEN_ONLY)
14551462
} // namespace ble
14561463

1457-
/* This includes the concrete class implementation, to provide a an alternative API implementation
1458-
* disable ble-api-implementation and place your header in a path with the same structure */
1459-
#include "ble/internal/GapImpl.h"
1460-
14611464
/** @deprecated Use the namespaced ble::Gap instead of the global Gap. */
14621465
using ble::Gap;
14631466

0 commit comments

Comments
 (0)