Skip to content

Commit 2630091

Browse files
committed
BLE: Prevent code generation from GattClient when not used.
1 parent 8ef0a43 commit 2630091

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

connectivity/FEATURE_BLE/source/cordio/source/PalAttClientImpl.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,12 +304,14 @@ ble_error_t PalAttClient::terminate()
304304
return BLE_ERROR_NONE;
305305
}
306306

307+
#if BLE_FEATURE_GATT_CLIENT
307308
// singleton of the ARM Cordio client
308309
PalAttClient &PalAttClient::get_client()
309310
{
310311
static PalAttClient _client;
311312
return _client;
312313
}
314+
#endif
313315

314316
void PalAttClient::when_server_message_received(
315317
mbed::Callback<void(connection_handle_t, const AttServerMessage &)> cb
@@ -345,12 +347,17 @@ bool PalAttClient::event_handler(const attEvt_t *event)
345347

346348
bool PalAttClient::timeout_event_handler(const attEvt_t *event)
347349
{
350+
#if BLE_FEATURE_GATT_CLIENT
351+
348352
if (event->hdr.status != ATT_ERR_TIMEOUT) {
349353
return false;
350354
}
351355

352356
get_client().on_transaction_timeout(event->hdr.param);
353357
return true;
358+
#else
359+
return false;
360+
#endif
354361
}
355362

356363

@@ -359,10 +366,12 @@ void PalAttClient::generated_handler(
359366
const attEvt_t *event, ResultType (*convert)(const attEvt_t *)
360367
)
361368
{
369+
#if BLE_FEATURE_GATT_CLIENT
362370
get_client().on_server_event(
363371
event->hdr.param,
364372
convert(event)
365373
);
374+
#endif
366375
}
367376

368377
void PalAttClient::on_server_event(
@@ -392,9 +401,9 @@ void PalAttClient::on_transaction_timeout(
392401
}
393402
}
394403

404+
#if BLE_FEATURE_GATT_CLIENT
395405
void PalAttClient::att_client_handler(const attEvt_t *event)
396406
{
397-
#if BLE_FEATURE_GATT_CLIENT
398407
if (event->hdr.status == ATT_SUCCESS && event->hdr.event == ATT_MTU_UPDATE_IND) {
399408
ble::impl::BLEInstanceBase &ble = BLEInstanceBase::deviceInstance();
400409
PalGattClientEventHandler *handler = ble.getPalGattClient().get_event_handler();
@@ -444,13 +453,13 @@ void PalAttClient::att_client_handler(const attEvt_t *event)
444453
}
445454
}
446455
}
447-
#endif // BLE_FEATURE_GATT_CLIENT
448456

449457
#if BLE_FEATURE_GATT_SERVER
450458
// pass events not handled to the server side
451459
ble::impl::GattServer::att_cb(event);
452460
#endif // BLE_FEATURE_GATT_SERVER
453461
}
462+
#endif // BLE_FEATURE_GATT_CLIENT
454463

455464
} // namespace impl
456465
} // ble

connectivity/FEATURE_BLE/source/cordio/source/PalAttClientImpl.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,10 @@ class PalAttClient final : public ble::PalAttClient {
173173
*/
174174
ble_error_t terminate() final;
175175

176+
#if BLE_FEATURE_GATT_CLIENT
176177
// singleton of the ARM Cordio client
177178
static PalAttClient &get_client();
179+
#endif
178180

179181
void when_server_message_received(
180182
mbed::Callback<void(connection_handle_t, const AttServerMessage &)> cb
@@ -199,7 +201,9 @@ class PalAttClient final : public ble::PalAttClient {
199201
/**
200202
* Callback which handle attEvt_t and forward them to on_server_event.
201203
*/
204+
#if BLE_FEATURE_GATT_CLIENT
202205
static void att_client_handler(const attEvt_t *event);
206+
#endif
203207

204208
private:
205209
/**

connectivity/FEATURE_BLE/source/cordio/source/PalSecurityManagerImpl.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,8 +282,10 @@ ble_error_t PalSecurityManager::set_csrk(
282282
{
283283
_csrk = csrk;
284284
DmSecSetLocalCsrk(_csrk.data());
285+
#if BLE_FEATURE_GATT_CLIENT
285286
// extra set the sign counter used by the client
286287
impl::PalAttClient::get_client().set_sign_counter(sign_counter);
288+
#endif
287289

288290
return BLE_ERROR_NONE;
289291
}

0 commit comments

Comments
 (0)