Skip to content

Commit 029ed3a

Browse files
committed
BLE: Cleanup BLEInstanceBas implementation
1 parent 2af0f88 commit 029ed3a

File tree

10 files changed

+113
-103
lines changed

10 files changed

+113
-103
lines changed

connectivity/FEATURE_BLE/source/BLEInstanceBase.h

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,6 @@ namespace ble {
4949
*
5050
* @see BLE
5151
*/
52-
#if !defined(DOXYGEN_ONLY)
53-
namespace interface {
54-
#endif // !defined(DOXYGEN_ONLY)
55-
5652
class BLEInstanceBase {
5753
public:
5854
/**
@@ -116,7 +112,7 @@ class BLEInstanceBase {
116112
*
117113
* @see BLE::init() BLE::hasInitialized()
118114
*/
119-
virtual bool hasInitialized(void) const = 0;
115+
virtual bool hasInitialized() const = 0;
120116

121117
/**
122118
* Shutdown the vendor BLE subsystem.
@@ -139,7 +135,7 @@ class BLEInstanceBase {
139135
* @see BLE::shutdown() BLE::init() BLE::hasInitialized() Gap::reset()
140136
* GattClient::reset() GattServer::reset() SecurityManager::reset() .
141137
*/
142-
virtual ble_error_t shutdown(void) = 0;
138+
virtual ble_error_t shutdown() = 0;
143139

144140
/**
145141
* Fetches a NULL terminated string representation of the underlying BLE
@@ -150,7 +146,7 @@ class BLEInstanceBase {
150146
*
151147
* @see BLE::getVersion()
152148
*/
153-
virtual const char *getVersion(void) = 0;
149+
virtual const char *getVersion() = 0;
154150

155151
/**
156152
* Accessor to the vendor implementation of the Gap interface.
@@ -160,7 +156,7 @@ class BLEInstanceBase {
160156
*
161157
* @see BLE::gap() Gap
162158
*/
163-
virtual ble::Gap &getGap(void) = 0;
159+
virtual ble::Gap &getGap() = 0;
164160

165161
/**
166162
* Const alternative to getGap().
@@ -170,7 +166,7 @@ class BLEInstanceBase {
170166
*
171167
* @see BLE::gap() Gap
172168
*/
173-
virtual const ble::Gap &getGap(void) const = 0;
169+
virtual const ble::Gap &getGap() const = 0;
174170

175171

176172
#if BLE_FEATURE_GATT_SERVER
@@ -183,7 +179,7 @@ class BLEInstanceBase {
183179
*
184180
* @see BLE::gattServer() GattServer
185181
*/
186-
virtual ble::GattServer &getGattServer(void) = 0;
182+
virtual ble::GattServer &getGattServer() = 0;
187183

188184
/**
189185
* A const alternative to getGattServer().
@@ -193,7 +189,7 @@ class BLEInstanceBase {
193189
*
194190
* @see BLE::gattServer() GattServer
195191
*/
196-
virtual const ble::GattServer &getGattServer(void) const = 0;
192+
virtual const ble::GattServer &getGattServer() const = 0;
197193

198194
#endif // BLE_FEATURE_GATT_SERVER
199195

@@ -207,7 +203,7 @@ class BLEInstanceBase {
207203
*
208204
* @see BLE::gattClient() GattClient
209205
*/
210-
virtual ble::GattClient &getGattClient(void) = 0;
206+
virtual ble::GattClient &getGattClient() = 0;
211207

212208
#endif
213209

@@ -221,7 +217,7 @@ class BLEInstanceBase {
221217
*
222218
* @see BLE::securityManager() SecurityManager
223219
*/
224-
virtual ble::SecurityManager &getSecurityManager(void) = 0;
220+
virtual ble::SecurityManager &getSecurityManager() = 0;
225221

226222
/**
227223
* A const alternative to getSecurityManager().
@@ -231,16 +227,11 @@ class BLEInstanceBase {
231227
*
232228
* @see BLE::securityManager() SecurityManager
233229
*/
234-
virtual const ble::SecurityManager &getSecurityManager(void) const = 0;
230+
virtual const ble::SecurityManager &getSecurityManager() const = 0;
235231

236232
#endif // BLE_FEATURE_SECURITY
237233
};
238234

239-
#if !defined(DOXYGEN_ONLY)
240-
} // namespace interface
241-
#endif // !defined(DOXYGEN_ONLY)
242-
} // namespace ble
243-
244235
/**
245236
* Return the instance of the vendor implementation of BLEInstanceBase.
246237
*
@@ -250,15 +241,13 @@ class BLEInstanceBase {
250241
* @attention The vendor library must provide an implementation for this function
251242
* library. Otherwise, there will be a linker error.
252243
*/
253-
extern ble::BLEInstanceBase *createBLEInstance(void);
254-
255-
/* This includes the concrete class implementation, to provide a an alternative BLE PAL implementation
256-
* disable Cordio and place your header in a path with the same structure */
257-
#include "ble/internal/BLEInstanceBaseImpl.h"
244+
extern ble::BLEInstanceBase *createBLEInstance();
258245

259246
/**
260247
* @}
261248
* @}
262249
*/
263250

251+
} // namespace ble
252+
264253
#endif // ifndef MBED_BLE_DEVICE_INSTANCE_BASE__

connectivity/FEATURE_BLE/source/cordio/include/ble/internal/BLEInstanceBaseImpl.h

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,18 @@ namespace ble {
4646

4747
class PalSigningMonitor;
4848

49+
namespace impl {
50+
4951
/**
5052
* @see BLEInstanceBase
5153
*/
52-
class BLEInstanceBase : public interface::BLEInstanceBase {
54+
class BLEInstanceBase : public ble::BLEInstanceBase {
5355
friend PalSigningMonitor;
56+
5457
/**
5558
* Construction with an HCI driver.
5659
*/
57-
BLEInstanceBase(CordioHCIDriver& hci_driver);
60+
BLEInstanceBase(CordioHCIDriver &hci_driver);
5861

5962
/**
6063
* Destructor
@@ -67,13 +70,13 @@ class BLEInstanceBase : public interface::BLEInstanceBase {
6770
* Access to the singleton containing the implementation of BLEInstanceBase
6871
* for the Cordio stack.
6972
*/
70-
static BLEInstanceBase& deviceInstance();
73+
static BLEInstanceBase &deviceInstance();
7174

7275
/**
7376
* @see BLEInstanceBase::init
7477
*/
7578
virtual ble_error_t init(
76-
FunctionPointerWithContext< ::BLE::InitializationCompleteCallbackContext*> initCallback
79+
FunctionPointerWithContext<::BLE::InitializationCompleteCallbackContext *> initCallback
7780
);
7881

7982
/**
@@ -91,34 +94,37 @@ class BLEInstanceBase : public interface::BLEInstanceBase {
9194
*/
9295
virtual const char *getVersion();
9396

94-
ble::impl::Gap& getGapImpl();
97+
ble::impl::Gap &getGapImpl();
9598

9699
/**
97100
* @see BLEInstanceBase::getGap
98101
*/
99-
virtual ble::Gap& getGap();
102+
virtual ble::Gap &getGap();
100103

101104
/**
102105
* @see BLEInstanceBase::getGap
103106
*/
104-
virtual const ble::Gap& getGap() const;
107+
virtual const ble::Gap &getGap() const;
105108

106109
#if BLE_FEATURE_GATT_SERVER
107-
ble::impl::GattServer& getGattServerImpl();
110+
111+
ble::impl::GattServer &getGattServerImpl();
108112

109113
/**
110114
* @see BLEInstanceBase::getGattServer
111115
*/
112-
virtual GattServer &getGattServer();
116+
virtual ble::GattServer &getGattServer();
113117

114118
/**
115119
* @see BLEInstanceBase::getGattServer
116120
*/
117-
virtual const GattServer &getGattServer() const;
121+
virtual const ble::GattServer &getGattServer() const;
122+
118123
#endif // BLE_FEATURE_GATT_SERVER
119124

120125
#if BLE_FEATURE_GATT_CLIENT
121-
ble::impl::GattClient& getGattClientImpl();
126+
127+
ble::impl::GattClient &getGattClientImpl();
122128

123129
/**
124130
* @see BLEInstanceBase::getGattClient
@@ -131,10 +137,12 @@ class BLEInstanceBase : public interface::BLEInstanceBase {
131137
* @return PAL Gatt Client.
132138
*/
133139
PalGattClient &getPalGattClient();
140+
134141
#endif // BLE_FEATURE_GATT_CLIENT
135142

136143
#if BLE_FEATURE_SECURITY
137-
ble::impl::SecurityManager& getSecurityManagerImpl();
144+
145+
ble::impl::SecurityManager &getSecurityManagerImpl();
138146

139147
/**
140148
* @see BLEInstanceBase::getSecurityManager
@@ -159,17 +167,22 @@ class BLEInstanceBase : public interface::BLEInstanceBase {
159167
virtual void processEvents();
160168

161169
private:
162-
static void stack_handler(wsfEventMask_t event, wsfMsgHdr_t* msg);
163-
static void device_manager_cb(dmEvt_t* dm_event);
164-
static void connection_handler(dmEvt_t* dm_event);
170+
static void stack_handler(wsfEventMask_t event, wsfMsgHdr_t *msg);
171+
172+
static void device_manager_cb(dmEvt_t *dm_event);
173+
174+
static void connection_handler(dmEvt_t *dm_event);
175+
165176
static void timeoutCallback();
166177

167178
void stack_setup();
179+
168180
void start_stack_reset();
181+
169182
void callDispatcher();
170183

171-
static CordioHCIDriver* _hci_driver;
172-
static FunctionPointerWithContext< ::BLE::InitializationCompleteCallbackContext*> _init_callback;
184+
static CordioHCIDriver *_hci_driver;
185+
static FunctionPointerWithContext<::BLE::InitializationCompleteCallbackContext *> _init_callback;
173186

174187
enum {
175188
NOT_INITIALIZED,
@@ -182,6 +195,7 @@ class BLEInstanceBase : public interface::BLEInstanceBase {
182195
uint64_t _last_update_us;
183196
};
184197

198+
} // namespace impl
185199
} // namespace ble
186200

187201

connectivity/FEATURE_BLE/source/cordio/include/ble/internal/PalAttClientImpl.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@
2020
#define IMPL_PAL_ATT_CLIENT_
2121

2222
#include "source/pal/PalSimpleAttServerMessage.h"
23-
#include "att_api.h"
2423
#include "source/pal/PalAttClient.h"
2524

25+
#include "att_api.h"
26+
2627
namespace ble {
2728
namespace impl {
2829

0 commit comments

Comments
 (0)