Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BLE: fix missing define guards for feature selection #14919

Merged
merged 1 commit into from
Jul 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@
#include "source/pal/PalAttClient.h"
#include "source/pal/PalSecurityManager.h"
#include "source/pal/PalGap.h"
#if BLE_FEATURE_SIGNING
#include "source/pal/PalSigningMonitor.h"
#endif //BLE_FEATURE_SIGNING
#include "source/pal/PalAttClientToGattClient.h"

#include "source/BLEInstanceBaseImpl.h"
Expand Down Expand Up @@ -283,6 +285,7 @@ PalGattClient &BLEInstanceBase::getPalGattClient()
#if BLE_FEATURE_SECURITY
ble::impl::SecurityManager &BLEInstanceBase::getSecurityManagerImpl()
{
#if BLE_FEATURE_SIGNING
// Creation of a proxy monitor to let the security manager register to
// the gatt client and gatt server.
static struct : ble::PalSigningMonitor {
Expand All @@ -296,11 +299,14 @@ ble::impl::SecurityManager &BLEInstanceBase::getSecurityManagerImpl()
#endif // BLE_FEATURE_GATT_SERVER
}
} signing_event_monitor;
#endif //BLE_FEATURE_SIGNING

static ble::impl::SecurityManager m_instance(
ble::impl::PalSecurityManager::get_security_manager(),
getGapImpl(),
signing_event_monitor
getGapImpl()
#if BLE_FEATURE_SIGNING
, signing_event_monitor
#endif //BLE_FEATURE_SIGNING
#if BLE_FEATURE_PRIVACY
, getPrivateAddressRegistry()
#endif //BLE_FEATURE_PRIVACY
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@
#endif

namespace ble {

#if BLE_FEATURE_SIGNING
class PalSigningMonitor;
#endif //BLE_FEATURE_SIGNING

namespace impl {

Expand All @@ -70,8 +71,9 @@ class BLEInstanceBase final : public ble::BLEInstanceBase {
using Timeout = mbed::Timeout;
using Timer = mbed::Timer;
#endif

#if BLE_FEATURE_SIGNING
friend PalSigningMonitor;
#endif //BLE_FEATURE_SIGNING

/**
* Construction with an HCI driver.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1629,7 +1629,9 @@ GattServer::GattServer() :
updatesEnabledCallback(nullptr),
updatesDisabledCallback(nullptr),
confirmationReceivedCallback(nullptr),
#if BLE_FEATURE_SIGNING
_signing_event_handler(nullptr),
#endif //BLE_FEATURE_SIGNING
cccds(),
cccd_values(),
cccd_handles(),
Expand All @@ -1645,12 +1647,14 @@ GattServer::GattServer() :
{
}

#if BLE_FEATURE_SIGNING
void GattServer::set_signing_event_handler(
PalSigningMonitorEventHandler *signing_event_handler
)
{
_signing_event_handler = signing_event_handler;
}
#endif //BLE_FEATURE_SIGNING

void GattServer::onDataSent(const DataSentCallback_t &callback)
{
Expand Down
17 changes: 13 additions & 4 deletions connectivity/FEATURE_BLE/source/cordio/source/GattServerImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@

#include "source/BLEInstanceBase.h"
#include "source/generic/GattServerEvents.h"
#if BLE_FEATURE_SIGNING
#include "source/pal/PalSigningMonitor.h"
#endif //BLE_FEATURE_SIGNING

namespace ble {

Expand All @@ -49,10 +51,16 @@ class PalGenericAccessService;
class BLE;

namespace impl {
class GattServer : public PalSigningMonitor {
class GattServer
#if BLE_FEATURE_SIGNING
: public PalSigningMonitor
#endif //BLE_FEATURE_SIGNING
{
friend ble::BLE;
friend ble::PalAttClient;
#if BLE_FEATURE_SIGNING
friend PalSigningMonitor;
#endif //BLE_FEATURE_SIGNING
friend PalGenericAccessService;

using EventHandler = ble::GattServer::EventHandler;
Expand Down Expand Up @@ -214,11 +222,11 @@ class GattServer : public PalSigningMonitor {
void initialize();

static uint8_t atts_auth_cb(dmConnId_t connId, uint8_t permit, uint16_t handle);

#if BLE_FEATURE_SIGNING
void set_signing_event_handler(
PalSigningMonitorEventHandler *signing_event_handler
) override;

#endif //BLE_FEATURE_SIGNING
private:

GattServer();
Expand Down Expand Up @@ -361,8 +369,9 @@ class GattServer : public PalSigningMonitor {
* The registered callback handler for confirmation received events.
*/
EventCallback_t confirmationReceivedCallback;

#if BLE_FEATURE_SIGNING
PalSigningMonitorEventHandler *_signing_event_handler;
#endif //BLE_FEATURE_SIGNING

attsCccSet_t cccds[MBED_CONF_BLE_API_IMPLEMENTATION_MAX_CCCD_COUNT];
uint16_t cccd_values[MBED_CONF_BLE_API_IMPLEMENTATION_MAX_CCCD_COUNT];
Expand Down
11 changes: 10 additions & 1 deletion connectivity/FEATURE_BLE/source/generic/GattClientImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@
#include "ble/gatt/CharacteristicDescriptorDiscovery.h"
#include "ble/gatt/GattCallbackParamTypes.h"
#include "source/pal/PalGattClient.h"
#if BLE_FEATURE_SIGNING
#include "source/pal/PalSigningMonitor.h"
#endif //BLE_FEATURE_SIGNING
#include "ble/GattClient.h"

namespace ble {
Expand All @@ -40,9 +42,13 @@ class BLEInstanceBase;
namespace impl {

class GattClient :
#if BLE_FEATURE_SIGNING
public PalSigningMonitor,
#endif //BLE_FEATURE_SIGNING
public PalGattClientEventHandler {
#if BLE_FEATURE_SIGNING
friend PalSigningMonitor;
#endif //BLE_FEATURE_SIGNING
friend BLEInstanceBase;
public:
using EventHandler = ble::GattClient::EventHandler;
Expand Down Expand Up @@ -163,11 +169,12 @@ class GattClient :
/* private implementation follows */

private:
#if BLE_FEATURE_SIGNING
/**
* @see ble::PalSigningMonitor::set_signing_event_handler
*/
void set_signing_event_handler(PalSigningMonitorEventHandler *signing_event_handler) override;

#endif //BLE_FEATURE_SIGNING
/**
* @see PalGattClient::EventHandler::on_att_mtu_change
*/
Expand Down Expand Up @@ -244,7 +251,9 @@ class GattClient :

PalGattClient &_pal_client;
ServiceDiscovery::TerminationCallback_t _termination_callback;
#if BLE_FEATURE_SIGNING
PalSigningMonitorEventHandler *_signing_event_handler;
#endif // BLE_FEATURE_SIGNING
mutable ProcedureControlBlock *control_blocks;
bool _is_reseting;

Expand Down
12 changes: 10 additions & 2 deletions connectivity/FEATURE_BLE/source/generic/SecurityManagerImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@

#include "source/pal/GapTypes.h"
#include "source/pal/PalConnectionMonitor.h"
#if BLE_FEATURE_SIGNING
#include "source/pal/PalSigningMonitor.h"
#endif //BLE_FEATURE_SIGNING
#include "source/pal/PalSecurityManager.h"

#include "source/generic/SecurityDb.h"
Expand Down Expand Up @@ -479,15 +481,19 @@ class SecurityManager :
public:
SecurityManager(
ble::PalSecurityManager &palImpl,
ble::PalConnectionMonitor &connMonitorImpl,
ble::PalSigningMonitor &signingMonitorImpl
ble::PalConnectionMonitor &connMonitorImpl
#if BLE_FEATURE_SIGNING
, ble::PalSigningMonitor &signingMonitorImpl
#endif //BLE_FEATURE_SIGNING
#if BLE_FEATURE_PRIVACY
, PrivateAddressController &privateAddressController
#endif // BLE_FEATURE_PRIVACY
) : eventHandler(nullptr),
_pal(palImpl),
_connection_monitor(connMonitorImpl),
#if BLE_FEATURE_SIGNING
_signing_monitor(signingMonitorImpl),
#endif //BLE_FEATURE_SIGNING
_db(nullptr),
#if BLE_FEATURE_PRIVACY
_private_address_controller(privateAddressController),
Expand Down Expand Up @@ -681,7 +687,9 @@ class SecurityManager :

PalSecurityManager &_pal;
PalConnectionMonitor &_connection_monitor;
#if BLE_FEATURE_SIGNING
PalSigningMonitor &_signing_monitor;
#endif //BLE_FEATURE_SIGNING

SecurityDb *_db;
#if BLE_FEATURE_PRIVACY
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ ble_error_t PalAttClientToGattClient::write_without_response(
);
}


#if BLE_FEATURE_SIGNING
ble_error_t PalAttClientToGattClient::signed_write_without_response(
connection_handle_t connection_handle,
attribute_handle_t characteristic_value_handle,
Expand All @@ -197,7 +197,7 @@ ble_error_t PalAttClientToGattClient::signed_write_without_response(
value
);
}

#endif // BLE_FEATURE_SIGNING

ble_error_t PalAttClientToGattClient::write_attribute(
connection_handle_t connection_handle,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ class PalAttClientToGattClient : public PalGattClient {
attribute_handle_t characteristic_value_handle,
const Span<const uint8_t>& value
) override;

#if BLE_FEATURE_SIGNING
/**
* @see ble::PalGattClient::signed_write_without_response
*/
Expand All @@ -149,7 +149,7 @@ class PalAttClientToGattClient : public PalGattClient {
attribute_handle_t characteristic_value_handle,
const Span<const uint8_t>& value
) override;

#endif //BLE_FEATURE_SIGNING
/**
* @see ble::PalGattClient::write_attribute
*/
Expand Down
4 changes: 2 additions & 2 deletions connectivity/FEATURE_BLE/source/pal/PalGattClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ class PalGattClient {
attribute_handle_t characteristic_value_handle,
const Span<const uint8_t>& value
) = 0;

#if BLE_FEATURE_SIGNING
/**
* Send a Signed Write without Response command to the server.
*
Expand All @@ -494,7 +494,7 @@ class PalGattClient {
attribute_handle_t characteristic_value_handle,
const Span<const uint8_t>& value
) = 0;

#endif //BLE_FEATURE_SIGNING
/**
* Send a write request to the server.
*
Expand Down