fix toggling off ble feature signing

pull/14919/head
Paul Szczepanek 2021-07-14 15:13:13 +01:00
parent d147abc3e5
commit 7ba7f3e667
9 changed files with 55 additions and 17 deletions

View File

@ -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"
@ -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 {
@ -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

View File

@ -54,8 +54,9 @@
#endif
namespace ble {
#if BLE_FEATURE_SIGNING
class PalSigningMonitor;
#endif //BLE_FEATURE_SIGNING
namespace impl {
@ -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.

View File

@ -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(),
@ -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)
{

View File

@ -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 {
@ -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;
@ -214,11 +222,11 @@ public:
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();
@ -361,8 +369,9 @@ private:
* 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];

View File

@ -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 {
@ -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;
@ -163,11 +169,12 @@ private:
/* 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
*/
@ -244,7 +251,9 @@ private:
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;

View File

@ -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"
@ -479,15 +481,19 @@ private:
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),
@ -681,7 +687,9 @@ private:
PalSecurityManager &_pal;
PalConnectionMonitor &_connection_monitor;
#if BLE_FEATURE_SIGNING
PalSigningMonitor &_signing_monitor;
#endif //BLE_FEATURE_SIGNING
SecurityDb *_db;
#if BLE_FEATURE_PRIVACY

View File

@ -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,
@ -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,

View File

@ -140,7 +140,7 @@ public:
attribute_handle_t characteristic_value_handle,
const Span<const uint8_t>& value
) override;
#if BLE_FEATURE_SIGNING
/**
* @see ble::PalGattClient::signed_write_without_response
*/
@ -149,7 +149,7 @@ public:
attribute_handle_t characteristic_value_handle,
const Span<const uint8_t>& value
) override;
#endif //BLE_FEATURE_SIGNING
/**
* @see ble::PalGattClient::write_attribute
*/

View File

@ -472,7 +472,7 @@ public:
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.
*
@ -494,7 +494,7 @@ public:
attribute_handle_t characteristic_value_handle,
const Span<const uint8_t>& value
) = 0;
#endif //BLE_FEATURE_SIGNING
/**
* Send a write request to the server.
*