Skip to content

Commit 5f1b716

Browse files
authored
Merge pull request #13760 from paul-szczepanek-arm/privacy-fix-ifdef
Fix conditional compilation for ble
2 parents 665e453 + 119d459 commit 5f1b716

16 files changed

+299
-152
lines changed

connectivity/FEATURE_BLE/include/ble/SecurityManager.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -835,6 +835,7 @@ class SecurityManager
835835
// Privacy
836836
//
837837

838+
#if BLE_FEATURE_PRIVACY
838839
/**
839840
* Sets how often the address is rotated when privacy is enabled.
840841
*
@@ -845,6 +846,7 @@ class SecurityManager
845846
ble_error_t setPrivateAddressTimeout(
846847
uint16_t timeout_in_seconds
847848
);
849+
#endif // BLE_FEATURE_PRIVACY
848850

849851
/* Event callback handlers. */
850852
public:

connectivity/FEATURE_BLE/source/SecurityManager.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* mbed Microcontroller Library
22
* Copyright (c) 2020 ARM Limited
33
* SPDX-License-Identifier: Apache-2.0
4-
*
4+
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.
77
* You may obtain a copy of the License at
@@ -192,12 +192,14 @@ ble_error_t SecurityManager::getSigningKey(ble::connection_handle_t connectionHa
192192
return impl->getSigningKey(connectionHandle, authenticated);
193193
}
194194

195+
#if BLE_FEATURE_PRIVACY
195196
ble_error_t SecurityManager::setPrivateAddressTimeout(
196197
uint16_t timeout_in_seconds
197198
)
198199
{
199200
return impl->setPrivateAddressTimeout(timeout_in_seconds);
200201
}
202+
#endif // BLE_FEATURE_PRIVACY
201203

202204
void SecurityManager::onShutdown(const SecurityManagerShutdownCallback_t& callback)
203205
{

connectivity/FEATURE_BLE/source/cordio/source/BLEInstanceBaseImpl.cpp

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -200,9 +200,10 @@ ble::impl::Gap &BLEInstanceBase::getGapImpl()
200200
static ble::impl::Gap gap(
201201
_event_queue,
202202
ble::impl::PalGap::get_gap(),
203-
cordio_gap_service,
204-
ble::impl::PalSecurityManager::get_security_manager(),
205-
getPrivateAddressRegistry()
203+
cordio_gap_service
204+
#if BLE_FEATURE_PRIVACY
205+
, getPrivateAddressRegistry()
206+
#endif // BLE_FEATURE_PRIVACY
206207
);
207208
return gap;
208209
}
@@ -221,7 +222,6 @@ const ble::Gap &BLEInstanceBase::getGap() const
221222
};
222223

223224
#if BLE_FEATURE_GATT_SERVER
224-
225225
ble::impl::GattServer &BLEInstanceBase::getGattServerImpl()
226226
{
227227
return ble::impl::GattServer::getInstance();
@@ -239,11 +239,9 @@ const ble::GattServer &BLEInstanceBase::getGattServer() const
239239
auto &self = const_cast<BLEInstanceBase &>(*this);
240240
return const_cast<const ble::GattServer &>(self.getGattServer());
241241
}
242-
243242
#endif // BLE_FEATURE_GATT_SERVER
244243

245244
#if BLE_FEATURE_GATT_CLIENT
246-
247245
ble::impl::GattClient &BLEInstanceBase::getGattClientImpl()
248246
{
249247
static ble::impl::GattClient gatt_client(getPalGattClient());
@@ -262,11 +260,9 @@ PalGattClient &BLEInstanceBase::getPalGattClient()
262260
static PalAttClientToGattClient pal_gatt_client(impl::PalAttClient::get_client());
263261
return pal_gatt_client;
264262
}
265-
266263
#endif // BLE_FEATURE_GATT_CLIENT
267264

268265
#if BLE_FEATURE_SECURITY
269-
270266
ble::impl::SecurityManager &BLEInstanceBase::getSecurityManagerImpl()
271267
{
272268
// Creation of a proxy monitor to let the security manager register to
@@ -286,13 +282,16 @@ ble::impl::SecurityManager &BLEInstanceBase::getSecurityManagerImpl()
286282
static ble::impl::SecurityManager m_instance(
287283
ble::impl::PalSecurityManager::get_security_manager(),
288284
getGapImpl(),
289-
signing_event_monitor,
290-
getPrivateAddressRegistry()
285+
signing_event_monitor
286+
#if BLE_FEATURE_PRIVACY
287+
, getPrivateAddressRegistry()
288+
#endif //BLE_FEATURE_PRIVACY
291289
);
292290

293291
return m_instance;
294292
}
295293

294+
#if BLE_FEATURE_SECURITY
296295
ble::SecurityManager &BLEInstanceBase::getSecurityManager()
297296
{
298297
static ble::SecurityManager m_instance(&getSecurityManagerImpl());
@@ -304,6 +303,7 @@ const ble::SecurityManager &BLEInstanceBase::getSecurityManager() const
304303
const BLEInstanceBase &self = const_cast<BLEInstanceBase &>(*this);
305304
return const_cast<const ble::SecurityManager &>(self.getSecurityManager());
306305
}
306+
#endif // BLE_FEATURE_SECURITY
307307

308308
#if BLE_FEATURE_PRIVACY
309309
ble::PrivateAddressController &BLEInstanceBase::getPrivateAddressRegistry()
@@ -315,8 +315,7 @@ ble::PrivateAddressController &BLEInstanceBase::getPrivateAddressRegistry()
315315
);
316316
return registry;
317317
}
318-
#endif
319-
318+
#endif // BLE_FEATURE_PRIVACY
320319
#endif // BLE_FEATURE_SECURITY
321320

322321
void BLEInstanceBase::waitForEvent()

connectivity/FEATURE_BLE/source/cordio/source/PalGapImpl.cpp

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
* limitations under the License.
1717
*/
1818
#include "source/PalGapImpl.h"
19+
#include "ble/common/BLERoles.h"
1920
#include "hci_api.h"
2021
#include "dm_api.h"
2122
#include "dm_main.h"
@@ -571,7 +572,9 @@ void PalGap::gap_handler(const wsfMsgHdr_t *msg)
571572
}
572573
break;
573574
#endif // BLE_FEATURE_PHY_MANAGEMENT
575+
574576
#if BLE_FEATURE_PERIODIC_ADVERTISING
577+
#if BLE_ROLE_OBSERVER
575578
case DM_PER_ADV_SYNC_EST_IND: {
576579
if (!handler) {
577580
break;
@@ -619,8 +622,10 @@ void PalGap::gap_handler(const wsfMsgHdr_t *msg)
619622
handler->on_periodic_advertising_sync_loss(evt->syncHandle);
620623
}
621624
break;
625+
#endif // BLE_ROLE_OBSERVER
622626
#endif // BLE_FEATURE_PERIODIC_ADVERTISING
623627

628+
#if BLE_ROLE_BROADCASTER
624629
case DM_ADV_START_IND:
625630
if (!handler) {
626631
break;
@@ -634,6 +639,7 @@ void PalGap::gap_handler(const wsfMsgHdr_t *msg)
634639
}
635640
handler->on_legacy_advertising_stopped();
636641
break;
642+
#endif // BLE_ROLE_BROADCASTER
637643

638644
#if BLE_FEATURE_EXTENDED_ADVERTISING && BLE_ROLE_BROADCASTER
639645
case DM_SCAN_REQ_RCVD_IND: {
@@ -743,7 +749,7 @@ void PalGap::gap_handler(const wsfMsgHdr_t *msg)
743749
#endif // BLE_FEATURE_EXTENDED_ADVERTISING
744750
#endif // BLE_ROLE_OBSERVER
745751

746-
#if BLE_ROLE_CENTRAL || BLE_ROLE_PERIPHERAL
752+
#if BLE_FEATURE_CONNECTABLE
747753
case DM_REM_CONN_PARAM_REQ_IND: {
748754
if (!handler) {
749755
break;
@@ -769,7 +775,7 @@ void PalGap::gap_handler(const wsfMsgHdr_t *msg)
769775
get_gap().get_running_conn_direct_adv_cb(evt->hdr.param);
770776
if (adv_cb) {
771777
adv_cb->state = direct_adv_cb_t::free;
772-
778+
#if BLE_ROLE_BROADCASTER
773779
if (handler) {
774780
handler->on_advertising_set_terminated(
775781
hci_error_code_t(evt->status),
@@ -778,6 +784,7 @@ void PalGap::gap_handler(const wsfMsgHdr_t *msg)
778784
0
779785
);
780786
}
787+
#endif // BLE_ROLE_BROADCASTER
781788
}
782789
}
783790
}
@@ -794,20 +801,20 @@ void PalGap::gap_handler(const wsfMsgHdr_t *msg)
794801
}
795802
}
796803
break;
797-
#endif // BLE_ROLE_CENTRAL || BLE_ROLE_PERIPHERAL
804+
#endif // BLE_FEATURE_CONNECTABLE
798805
}
799806

800807
// all handlers are stored in a static array
801808
static const event_handler_t handlers[] = {
802809
#if BLE_ROLE_OBSERVER
803810
&event_handler<GapAdvertisingReportMessageConverter>,
804811
#endif // BLE_ROLE_OBSERVER
805-
#if BLE_ROLE_CENTRAL || BLE_ROLE_PERIPHERAL
812+
#if BLE_FEATURE_CONNECTABLE
806813
&event_handler<ConnectionCompleteMessageConverter>,
807814
&event_handler<DisconnectionMessageConverter>,
808815
&event_handler<ConnectionUpdateMessageConverter>,
809816
&event_handler<RemoteConnectionParameterRequestMessageConverter>,
810-
#endif // BLE_ROLE_CENTRAL || BLE_ROLE_PERIPHERAL
817+
#endif // BLE_FEATURE_CONNECTABLE
811818
&dummy_gap_event_handler
812819
};
813820

@@ -846,7 +853,7 @@ ble_error_t PalGap::set_advertising_set_random_address(
846853
return BLE_ERROR_NONE;
847854
}
848855

849-
856+
#if BLE_FEATURE_EXTENDED_ADVERTISING
850857
ble_error_t PalGap::set_extended_advertising_parameters(
851858
advertising_handle_t advertising_handle,
852859
advertising_event_properties_t event_properties,
@@ -986,7 +993,7 @@ ble_error_t PalGap::set_extended_advertising_parameters(
986993
peer_address_type
987994
);
988995
}
989-
996+
#endif // BLE_FEATURE_EXTENDED_ADVERTISING
990997

991998
ble_error_t PalGap::set_periodic_advertising_parameters(
992999
advertising_handle_t advertising_handle,

connectivity/FEATURE_BLE/source/cordio/source/PalGapImpl.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ class PalGap final : public ble::PalGap {
174174
const address_t &address
175175
) final;
176176

177+
#if BLE_FEATURE_EXTENDED_ADVERTISING
177178
ble_error_t set_extended_advertising_parameters(
178179
advertising_handle_t advertising_handle,
179180
advertising_event_properties_t event_properties,
@@ -191,6 +192,7 @@ class PalGap final : public ble::PalGap {
191192
uint8_t advertising_sid,
192193
bool scan_request_notification
193194
) final;
195+
#endif // BLE_FEATURE_EXTENDED_ADVERTISING
194196

195197
ble_error_t set_periodic_advertising_parameters(
196198
advertising_handle_t advertising_handle,

connectivity/FEATURE_BLE/source/cordio/source/PalPrivateAddressControllerImpl.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
* limitations under the License.
1616
*/
1717

18+
#if BLE_FEATURE_PRIVACY
19+
1820
#include "PalPrivateAddressControllerImpl.h"
1921
#include "dm_api.h"
2022

@@ -232,3 +234,4 @@ bool PalPrivateAddressController::cordio_handler(const wsfMsgHdr_t *msg)
232234
} // namespace impl
233235
} // namespace ble
234236

237+
#endif // BLE_FEATURE_PRIVACY

connectivity/FEATURE_BLE/source/cordio/source/PalPrivateAddressControllerImpl.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* mbed Microcontroller Library
22
* Copyright (c) 2020 ARM Limited
33
* SPDX-License-Identifier: Apache-2.0
4-
*
4+
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.
77
* You may obtain a copy of the License at
@@ -18,6 +18,8 @@
1818
#ifndef BLE_CORDIO_PAL_PRIVATE_ADDRESS_CONTROLLER_IMPL_H
1919
#define BLE_CORDIO_PAL_PRIVATE_ADDRESS_CONTROLLER_IMPL_H
2020

21+
#if BLE_FEATURE_PRIVACY
22+
2123
#include "source/pal/PalPrivateAddressController.h"
2224
#include "dm_api.h"
2325

@@ -91,4 +93,6 @@ struct PalPrivateAddressController final : public ble::PalPrivateAddressControll
9193
} // namespace impl
9294
} // namespace ble
9395

96+
#endif // BLE_FEATURE_PRIVACY
97+
9498
#endif //BLE_CORDIO_PAL_PRIVATE_ADDRESS_CONTROLLER_IMPL_H

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
* limitations under the License.
1717
*/
1818

19+
#if BLE_FEATURE_SECURITY
20+
1921
#include <cstring>
2022

2123
#include "ble/common/BLERoles.h"
@@ -789,3 +791,5 @@ PalSecurityManagerEventHandler *PalSecurityManager::get_event_handler()
789791

790792
} // namespace impl
791793
} // namespace ble
794+
795+
#endif // BLE_FEATURE_SECURITY

0 commit comments

Comments
 (0)