Skip to content

Commit 909676d

Browse files
committed
PIMPL for ble::Gap
1 parent a32168c commit 909676d

File tree

4 files changed

+590
-37
lines changed

4 files changed

+590
-37
lines changed

connectivity/FEATURE_BLE/include/ble/Gap.h

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,9 @@ class PalGenericAccessService;
281281
* controller or by the peer.
282282
*/
283283
#if !defined(DOXYGEN_ONLY)
284-
namespace interface {
284+
namespace impl {
285+
class Gap;
286+
}
285287
#endif // !defined(DOXYGEN_ONLY)
286288
class Gap {
287289
public:
@@ -1421,7 +1423,9 @@ class Gap {
14211423
* @param[in] memberPtr Shutdown event handler to register.
14221424
*/
14231425
template<typename T>
1424-
void onShutdown(T *objPtr, void (T::*memberPtr)(const Gap *));
1426+
void onShutdown(T *objPtr, void (T::*memberPtr)(const Gap *)) {
1427+
onShutdown(GapShutdownCallback_t(objPtr, memberPtr));
1428+
}
14251429

14261430
/**
14271431
* Access the callchain of shutdown event handler.
@@ -1442,21 +1446,21 @@ class Gap {
14421446
*/
14431447
ble_error_t setRandomStaticAddress(const ble::address_t& address);
14441448
#endif // !defined(DOXYGEN_ONLY)
1449+
1450+
private:
1451+
impl::Gap* impl;
14451452
};
14461453

14471454
/**
14481455
* @}
14491456
* @}
14501457
*/
14511458

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

14571461
/* This includes the concrete class implementation, to provide a an alternative API implementation
14581462
* disable ble-api-implementation and place your header in a path with the same structure */
1459-
#include "ble/internal/GapImpl.h"
1463+
//#include "ble/internal/GapImpl.h"
14601464

14611465
/** @deprecated Use the namespaced ble::Gap instead of the global Gap. */
14621466
using ble::Gap;

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

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,20 +48,29 @@
4848
namespace ble {
4949

5050
class PalGenericAccessService;
51+
5152
class PalSecurityManager;
53+
5254
class PalGap;
55+
5356
class BLEInstanceBase;
5457

58+
namespace impl {
59+
5560
class Gap :
56-
public ble::interface::Gap,
5761
public PalConnectionMonitor,
58-
public PalGapEventHandler
59-
{
62+
public PalGapEventHandler {
6063
friend PalConnectionMonitor;
6164
friend PalGapEventHandler;
6265
friend PalGap;
6366
friend BLEInstanceBase;
67+
68+
using EventHandler = ::ble::Gap::EventHandler;
69+
using GapShutdownCallback_t = ::ble::Gap::GapShutdownCallback_t;
70+
using GapShutdownCallbackChain_t = ::ble::Gap::GapShutdownCallbackChain_t ;
6471
public:
72+
using PreferredConnectionParams_t = ::ble::Gap::PreferredConnectionParams_t ;
73+
6574
/**
6675
* Default peripheral privacy configuration.
6776
*/
@@ -98,6 +107,7 @@ class Gap :
98107
);
99108

100109
ble_error_t destroyAdvertisingSet(advertising_handle_t handle);
110+
101111
#endif // BLE_FEATURE_EXTENDED_ADVERTISING
102112

103113
ble_error_t setAdvertisingParameters(
@@ -124,6 +134,7 @@ class Gap :
124134
ble_error_t stopAdvertising(advertising_handle_t handle);
125135

126136
bool isAdvertisingActive(advertising_handle_t handle);
137+
127138
#endif // BLE_ROLE_BROADCASTER
128139

129140
#if BLE_ROLE_BROADCASTER
@@ -146,6 +157,7 @@ class Gap :
146157
ble_error_t stopPeriodicAdvertising(advertising_handle_t handle);
147158

148159
bool isPeriodicAdvertisingActive(advertising_handle_t handle);
160+
149161
#endif // BLE_ROLE_BROADCASTER
150162
#endif // BLE_FEATURE_PERIODIC_ADVERTISING
151163

@@ -161,6 +173,7 @@ class Gap :
161173
);
162174

163175
ble_error_t stopScan();
176+
164177
#endif // BLE_ROLE_OBSERVER
165178

166179
#if BLE_ROLE_OBSERVER
@@ -198,6 +211,7 @@ class Gap :
198211
ble_error_t clearPeriodicAdvertiserList();
199212

200213
uint8_t getMaxPeriodicAdvertiserListSize();
214+
201215
#endif // BLE_ROLE_OBSERVER
202216
#endif // BLE_FEATURE_PERIODIC_ADVERTISING
203217

@@ -210,6 +224,7 @@ class Gap :
210224
);
211225

212226
ble_error_t cancelConnect();
227+
213228
#endif // BLE_ROLE_CENTRAL
214229

215230
#if BLE_FEATURE_CONNECTABLE
@@ -246,6 +261,7 @@ class Gap :
246261
connection_handle_t connectionHandle,
247262
local_disconnection_reason_t reason
248263
);
264+
249265
#endif // BLE_FEATURE_CONNECTABLE
250266
#if BLE_FEATURE_PHY_MANAGEMENT
251267

@@ -262,6 +278,7 @@ class Gap :
262278
const phy_set_t *rxPhys,
263279
coded_symbol_per_bit_t codedSymbol
264280
);
281+
265282
#endif // BLE_FEATURE_PHY_MANAGEMENT
266283

267284
#if BLE_FEATURE_PRIVACY
@@ -277,6 +294,7 @@ class Gap :
277294
ble_error_t getPeripheralPrivacyConfiguration(
278295
peripheral_privacy_configuration_t *configuration
279296
);
297+
280298
#endif // BLE_ROLE_BROADCASTER
281299

282300
#if BLE_ROLE_OBSERVER
@@ -288,6 +306,7 @@ class Gap :
288306
ble_error_t getCentralPrivacyConfiguration(
289307
central_privacy_configuration_t *configuration
290308
);
309+
291310
#endif // BLE_ROLE_OBSERVER
292311
#endif // BLE_FEATURE_PRIVACY
293312

@@ -321,12 +340,14 @@ class Gap :
321340
GapShutdownCallbackChain_t &onShutdown();
322341

323342
#if !defined(DOXYGEN_ONLY)
343+
324344
/*
325345
* API reserved for the controller driver to set the random static address.
326346
* Setting a new random static address while the controller is operating is
327347
* forbidden by the Bluetooth specification.
328348
*/
329-
ble_error_t setRandomStaticAddress(const ble::address_t& address);
349+
ble_error_t setRandomStaticAddress(const ble::address_t &address);
350+
330351
#endif // !defined(DOXYGEN_ONLY)
331352

332353
/* ===================================================================== */
@@ -335,7 +356,8 @@ class Gap :
335356
private:
336357
/* Disallow copy and assignment. */
337358
Gap(const Gap &);
338-
Gap& operator=(const Gap &);
359+
360+
Gap &operator=(const Gap &);
339361

340362
Gap(
341363
PalEventQueue &event_queue,
@@ -507,6 +529,7 @@ class Gap :
507529
);
508530

509531
void on_scan_timeout();
532+
510533
void process_legacy_scan_timeout();
511534

512535
private:
@@ -598,6 +621,7 @@ class Gap :
598621
bool _user_manage_connection_parameter_requests : 1;
599622
};
600623

624+
} // namespace impl
601625
} // namespace ble
602626

603627
#endif //IMPL_GAP_GAP_H

0 commit comments

Comments
 (0)