added #if guards to cordio ble

pull/9790/head
paul-szczepanek-arm 2019-02-07 15:50:36 +00:00 committed by Vincent Coubard
parent bed567825f
commit 5a97706aab
26 changed files with 93 additions and 99 deletions

View File

@ -17,7 +17,7 @@
#ifndef MBED_BLE_H__
#define MBED_BLE_H__
#include "BLERoles.h
#include "BLERoles.h"
#include "blecommon.h"
#include "ble/Gap.h"
@ -844,7 +844,6 @@ public:
MBED_DEPRECATED("Use ble.gap().stopAdvertising(...)")
ble_error_t stopAdvertising(void);
#if BLE_ROLE_OBSERVER
/**
* Set up parameters for GAP scanning (observer mode).
*
@ -1042,7 +1041,6 @@ public:
{
return gap().stopScan();
}
#endif // BLE_ROLE_OBSERVER
/**
* Create a connection (GAP Link Establishment).

View File

@ -17,8 +17,6 @@
#ifndef MBED_DISCOVERED_CHARACTERISTIC_H__
#define MBED_DISCOVERED_CHARACTERISTIC_H__
#if BLE_FEATURE_GATT_CLIENT
#include "UUID.h"
#include "ble/Gap.h"
#include "GattAttribute.h"
@ -636,6 +634,4 @@ protected:
* @}
*/
#endif // BLE_FEATURE_GATT_CLIENT
#endif /*MBED_DISCOVERED_CHARACTERISTIC_H__*/

View File

@ -17,8 +17,6 @@
#ifndef MBED_DISCOVERED_CHARACTERISTIC_DESCRIPTOR_H__
#define MBED_DISCOVERED_CHARACTERISTIC_DESCRIPTOR_H__
#if BLE_FEATURE_GATT_CLIENT
#include "UUID.h"
#include "ble/Gap.h"
#include "GattAttribute.h"
@ -152,6 +150,4 @@ private:
* @}
*/
#endif // BLE_FEATURE_GATT_CLIENT
#endif /* MBED_DISCOVERED_CHARACTERISTIC_DESCRIPTOR_H__ */

View File

@ -66,9 +66,7 @@ public:
using ble::interface::Gap<Impl>::stopAdvertising;
using ble::interface::Gap<Impl>::connect;
using ble::interface::Gap<Impl>::disconnect;
#if BLE_ROLE_OBSERVER
using ble::interface::Gap<Impl>::startScan;
#endif // BLE_ROLE_OBSERVER
/**
* Address-type for BLEProtocol addresses.
@ -1657,7 +1655,6 @@ public:
)
void clearScanResponse(void);
#if BLE_ROLE_OBSERVER
/**
* Set the parameters used during a scan procedure.
*
@ -1868,8 +1865,6 @@ public:
void (T::*callbackMember)(const AdvertisementCallbackParams_t *params)
);
#endif // BLE_ROLE_OBSERVER
/**
* Enable radio-notification events.
*
@ -2624,8 +2619,6 @@ protected:
#pragma diag_suppress 1361
#endif
#if BLE_ROLE_OBSERVER
template<class Impl>
template<typename T>
ble_error_t LegacyGap<Impl>::startScan(
@ -2644,8 +2637,6 @@ ble_error_t LegacyGap<Impl>::startScan(
return err;
}
#endif // BLE_ROLE_OBSERVER
template<class Impl>
template<typename T>
void LegacyGap<Impl>::onConnection(T *tptr, void (T::*mptr)(const ConnectionCallbackParams_t *))

View File

@ -17,8 +17,6 @@
#ifndef MBED_GATT_CLIENT_H__
#define MBED_GATT_CLIENT_H__
#if BLE_FEATURE_GATT_CLIENT
#include "ble/common/StaticInterface.h"
#include "ble/GattAttribute.h"
#include "ble/ServiceDiscovery.h"
@ -880,6 +878,4 @@ private:
using ble::impl::GattClient;
#endif
#endif // BLE_FEATURE_GATT_CLIENT
#endif /* ifndef MBED_GATT_CLIENT_H__ */

View File

@ -757,7 +757,6 @@ public:
/* scanning */
#if BLE_ROLE_OBSERVER
/** Set new scan parameters.
*
* @param params Scan parameters, @see GapScanParameters for details.
@ -796,8 +795,6 @@ public:
*/
ble_error_t stopScan();
#endif // BLE_ROLE_OBSERVER
/** Synchronize with periodic advertising from an advertiser and begin receiving periodic
* advertising packets.
*

View File

@ -127,8 +127,10 @@ public:
GenericGap(
pal::EventQueue &event_queue,
PalGap &pal_gap,
pal::GenericAccessService &generic_access_service,
pal::GenericAccessService &generic_access_service
#if BLE_FEATURE_SECURITY
PalSecurityManager &pal_sm
#endif
);
/**
@ -234,7 +236,6 @@ public:
*/
bool isPeriodicAdvertisingActive_(advertising_handle_t handle);
#if BLE_ROLE_OBSERVER
/** @copydoc Gap::setScanParameters
*/
ble_error_t setScanParameters_(const ScanParameters &params);
@ -246,7 +247,6 @@ public:
duplicates_filter_t filtering,
scan_period_t period
);
#endif // BLE_ROLE_OBSERVER
/** @copydoc Gap::createSync
*/
@ -333,12 +333,10 @@ public:
*/
ble_error_t stopAdvertising_();
#if BLE_ROLE_OBSERVER
/**
* @see Gap::stopScan
*/
ble_error_t stopScan_();
#endif // BLE_ROLE_OBSERVER
/**
* @see Gap::connect
@ -789,7 +787,9 @@ private:
pal::EventQueue &_event_queue;
PalGap &_pal_gap;
pal::GenericAccessService &_gap_service;
#if BLE_FEATURE_SECURITY
PalSecurityManager &_pal_sm;
#endif
BLEProtocol::AddressType_t _address_type;
ble::address_t _address;
pal::initiator_policy_t _initiator_policy_mode;

View File

@ -17,8 +17,6 @@
#ifndef MBED_BLE_GENERIC_GATT_CLIENT
#define MBED_BLE_GENERIC_GATT_CLIENT
#if BLE_FEATURE_GATT_CLIENT
#include <algorithm>
#include "ble/GattClient.h"
#include "ble/pal/PalGattClient.h"
@ -37,7 +35,9 @@ namespace generic {
template<template<class> class TPalGattClient, class SigningMonitorEventHandler>
class GenericGattClient :
public interface::GattClient<GenericGattClient<TPalGattClient, SigningMonitorEventHandler> >,
#if BLE_FEATURE_SIGNING
public pal::SigningEventMonitor<GenericGattClient<TPalGattClient, SigningMonitorEventHandler>, SigningMonitorEventHandler>,
#endif // BLE_FEATURE_SIGNING
public pal::GattClientEventHandler<GenericGattClient<TPalGattClient, SigningMonitorEventHandler> > {
using interface::GattClient<GenericGattClient<TPalGattClient, SigningMonitorEventHandler> >::eventHandler;
@ -136,10 +136,12 @@ public:
*/
ble_error_t reset_(void);
#if BLE_FEATURE_SIGNING
/**
* @see ble::pal::SigningEventMonitor::set_signing_event_handler
*/
void set_signing_event_handler_(SigningMonitorEventHandler *signing_event_handler);
#endif // BLE_FEATURE_SIGNING
/**
* @see pal::GattClient::EventHandler::on_att_mtu_change
@ -171,7 +173,9 @@ private:
PalGattClient* const _pal_client;
ServiceDiscovery::TerminationCallback_t _termination_callback;
#if BLE_FEATURE_SIGNING
SigningMonitorEventHandler* _signing_event_handler;
#endif
mutable ProcedureControlBlock* control_blocks;
bool _is_reseting;
};
@ -179,6 +183,4 @@ private:
} // generic
} // ble
#endif // BLE_FEATURE_GATT_CLIENT
#endif /* MBED_BLE_GENERIC_GATT_CLIENT */

View File

@ -35,8 +35,10 @@ template <template<class> class TPalSecurityManager, template<class> class Signi
class GenericSecurityManager :
public interface::SecurityManager<GenericSecurityManager<TPalSecurityManager, SigningMonitor > >, // SecurityManager
public pal::SecurityManagerEventHandler<GenericSecurityManager<TPalSecurityManager, SigningMonitor> >, // PalSmEventHandler
public pal::ConnectionEventMonitorEventHandler<GenericSecurityManager<TPalSecurityManager, SigningMonitor> >, // ConnectionObserver
public pal::SigningMonitorEventHandler<GenericSecurityManager<TPalSecurityManager, SigningMonitor> > //SigningObserver
public pal::ConnectionEventMonitorEventHandler<GenericSecurityManager<TPalSecurityManager, SigningMonitor> > // ConnectionObserver
#if BLE_FEATURE_SIGNING
, public pal::SigningMonitorEventHandler<GenericSecurityManager<TPalSecurityManager, SigningMonitor> > //SigningObserver
#endif // BLE_FEATURE_SIGNING
{
// typedefs
typedef interface::SecurityManager<GenericSecurityManager> SecurityManager;
@ -594,6 +596,7 @@ public:
connection_handle_t connection
);
#if BLE_FEATURE_SIGNING
/** @copydoc ble::pal::SecurityManager::on_signed_write_received
*/
void on_signed_write_received_(
@ -610,6 +613,7 @@ public:
/** @copydoc ble::pal::SecurityManager::on_signed_write
*/
void on_signed_write_();
#endif // BLE_FEATURE_SIGNING
/** @copydoc ble::pal::SecurityManager::on_slave_security_request
*/

View File

@ -17,8 +17,6 @@
#ifndef __BLE_UART_SERVICE_H__
#define __BLE_UART_SERVICE_H__
#if BLE_FEATURE_GATT_SERVER
#ifdef YOTTA_CFG_MBED_OS
#include "mbed-drivers/mbed.h"
#include "mbed-drivers/Stream.h"
@ -217,6 +215,4 @@ protected:
* application. */
};
#endif // BLE_FEATURE_GATT_SERVER
#endif /* #ifndef __BLE_UART_SERVICE_H__*/

View File

@ -17,8 +17,6 @@
#ifndef SERVICES_URIBEACONCONFIGSERVICE_H_
#define SERVICES_URIBEACONCONFIGSERVICE_H_
#if BLE_FEATURE_GATT_SERVER
#include "ble/BLE.h"
#ifdef YOTTA_CFG_MBED_OS
@ -482,6 +480,4 @@ public:
}
};
#endif // BLE_FEATURE_GATT_SERVER
#endif // SERVICES_URIBEACONCONFIGSERVICE_H_

View File

@ -454,8 +454,6 @@ ble_error_t BLE::stopAdvertising(void) {
return gap().stopAdvertising();
}
#if BLE_ROLE_OBSERVER
ble_error_t BLE::setScanParams(uint16_t interval,
uint16_t window,
uint16_t timeout,
@ -483,8 +481,6 @@ ble_error_t BLE::startScan(void (*callback)(const Gap::AdvertisementCallbackPara
return gap().startScan(callback);
}
#endif // BLE_ROLE_OBSERVER
ble_error_t BLE::disconnect(Gap::Handle_t connectionHandle, Gap::DisconnectionReason_t reason) {
return gap().disconnect(connectionHandle, reason);
}

View File

@ -17,8 +17,6 @@
#include "ble/DiscoveredCharacteristic.h"
#include "ble/GattClient.h"
#if BLE_FEATURE_GATT_CLIENT
ble_error_t
DiscoveredCharacteristic::read(uint16_t offset) const
{
@ -167,5 +165,3 @@ ble_error_t DiscoveredCharacteristic::discoverDescriptors(
return err;
}
#endif // BLE_FEATURE_GATT_CLIENT

View File

@ -426,8 +426,6 @@ ble_error_t LegacyGap<Impl>::accumulateScanResponse(
return rc;
}
#if BLE_ROLE_OBSERVER
template<class Impl>
void LegacyGap<Impl>::clearScanResponse(void)
{
@ -529,8 +527,6 @@ ble_error_t LegacyGap<Impl>::startScan(
return err;
}
#endif // BLE_ROLE_OBSERVER
template<class Impl>
GapAdvertisingParams &LegacyGap<Impl>::getAdvertisingParams(void)
{

View File

@ -156,8 +156,6 @@ bool Gap<Impl>::isPeriodicAdvertisingActive(advertising_handle_t handle)
return impl()->isPeriodicAdvertisingActive_(handle);
}
#if BLE_ROLE_OBSERVER
template<class Impl>
ble_error_t Gap<Impl>::setScanParameters(const ScanParameters &params)
{
@ -180,8 +178,6 @@ ble_error_t Gap<Impl>::stopScan()
return impl()->stopScan_();
}
#endif // BLE_ROLE_OBSERVER
template<class Impl>
ble_error_t Gap<Impl>::createSync(
peer_address_type_t peerAddressType,

View File

@ -425,12 +425,16 @@ template <template<class> class PalGapImpl, class PalSecurityManager, class Conn
GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::GenericGap(
pal::EventQueue &event_queue,
PalGapImpl<GenericGap> &pal_gap,
pal::GenericAccessService &generic_access_service,
PalSecurityManager &pal_sm
pal::GenericAccessService &generic_access_service
#if BLE_FEATURE_SECURITY
, PalSecurityManager &pal_sm
#endif
) : _event_queue(event_queue),
_pal_gap(pal_gap),
_gap_service(generic_access_service),
#if BLE_FEATURE_SECURITY
_pal_sm(pal_sm),
#endif
_address_type(LegacyAddressType::PUBLIC),
_initiator_policy_mode(pal::initiator_policy_t::NO_FILTER),
_scanning_filter_policy(pal::scanning_filter_policy_t::NO_FILTER),
@ -574,8 +578,6 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
return BLE_ERROR_NONE;
}
#if BLE_ROLE_OBSERVER
template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>
ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::stopScan_()
{
@ -606,8 +608,6 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
return BLE_ERROR_NONE;
}
#endif // BLE_ROLE_OBSERVER
template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>
ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::connect_(
const BLEProtocol::AddressBytes_t peerAddr,
@ -633,10 +633,8 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
return BLE_ERROR_PARAM_OUT_OF_RANGE;
}
#if BLE_ROLE_OBSERVER
// Force scan stop before initiating the scan used for connection
LegacyGap::stopScan();
#endif // BLE_ROLE_OBSERVER
return _pal_gap.create_connection(
scanParams->getInterval(),
@ -2082,8 +2080,11 @@ bool GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandl
{
do {
byte_array_t<8> random_data;
#if BLE_FEATURE_SECURITY
ble_error_t ret = _pal_sm.get_random_data(random_data);
#else
ble_error_t ret = BLE_ERROR_NOT_IMPLEMENTED;
#endif // BLE_FEATURE_SECURITY
if (ret != BLE_ERROR_NONE) {
// Abort
return false;
@ -3035,8 +3036,6 @@ void GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandl
}
}
#if BLE_ROLE_OBSERVER
template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>
ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::setScanParameters_(const ScanParameters &params)
{
@ -3136,8 +3135,6 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
return BLE_ERROR_NONE;
}
#endif // BLE_ROLE_OBSERVER
template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>
ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::createSync_(
peer_address_type_t peerAddressType,

View File

@ -14,8 +14,6 @@
* limitations under the License.
*/
#if BLE_FEATURE_GATT_CLIENT
#include <stdio.h>
#include <stdlib.h>
@ -953,7 +951,9 @@ template<template<class> class TPalGattClient, class SigningMonitorEventHandler>
GenericGattClient<TPalGattClient, SigningMonitorEventHandler>::GenericGattClient(PalGattClient* pal_client) :
_pal_client(pal_client),
_termination_callback(),
#if BLE_FEATURE_SIGNING
_signing_event_handler(NULL),
#endif
control_blocks(NULL),
_is_reseting(false) {
_pal_client->when_server_message_received(
@ -1106,6 +1106,7 @@ ble_error_t GenericGattClient<TPalGattClient, SigningMonitorEventHandler>::write
uint16_t mtu = get_mtu(connection_handle);
#if BLE_FEATURE_SIGNING
/* if link is encrypted signed writes should be normal writes */
if (cmd == Base::GATT_OP_SIGNED_WRITE_CMD) {
ble::link_encryption_t encryption(ble::link_encryption_t::NOT_ENCRYPTED);
@ -1120,6 +1121,7 @@ ble_error_t GenericGattClient<TPalGattClient, SigningMonitorEventHandler>::write
cmd = Base::GATT_OP_WRITE_CMD;
}
}
#endif // BLE_FEATURE_SIGNING
if (cmd == Base::GATT_OP_WRITE_CMD) {
if (length > (uint16_t) (mtu - WRITE_HEADER_LENGTH)) {
@ -1131,6 +1133,7 @@ ble_error_t GenericGattClient<TPalGattClient, SigningMonitorEventHandler>::write
make_const_ArrayView(value, length)
);
} else if (cmd == Base::GATT_OP_SIGNED_WRITE_CMD) {
#if BLE_FEATURE_SIGNING
if (length > (uint16_t) (mtu - WRITE_HEADER_LENGTH - CMAC_LENGTH - MAC_COUNTER_LENGTH)) {
return BLE_ERROR_PARAM_OUT_OF_RANGE;
}
@ -1139,10 +1142,12 @@ ble_error_t GenericGattClient<TPalGattClient, SigningMonitorEventHandler>::write
attribute_handle,
make_const_ArrayView(value, length)
);
if (_signing_event_handler && (status == BLE_ERROR_NONE)) {
_signing_event_handler->on_signed_write();
}
return status;
#endif // BLE_FEATURE_SIGNING
} else {
uint8_t* data = NULL;
@ -1309,12 +1314,14 @@ ble_error_t GenericGattClient<TPalGattClient, SigningMonitorEventHandler>::reset
return BLE_ERROR_NONE;
}
#if BLE_FEATURE_SIGNING
template<template<class> class TPalGattClient, class SigningMonitorEventHandler>
void GenericGattClient<TPalGattClient, SigningMonitorEventHandler>::set_signing_event_handler_(
SigningMonitorEventHandler *signing_event_handler
) {
_signing_event_handler = signing_event_handler;
}
#endif // BLE_FEATURE_SIGNING
template<template<class> class TPalGattClient, class SigningMonitorEventHandler>
void GenericGattClient<TPalGattClient, SigningMonitorEventHandler>::on_att_mtu_change_(
@ -1491,4 +1498,3 @@ uint16_t GenericGattClient<TPalGattClient, SigningMonitorEventHandler>::get_mtu(
} // namespace pal
} // namespace ble
#endif // BLE_FEATURE_GATT_CLIENT

View File

@ -1280,6 +1280,7 @@ void GenericSecurityManager<TPalSecurityManager, SigningMonitor>::on_valid_mic_t
(void)connection;
}
#if BLE_FEATURE_SIGNING
template<template<class> class TPalSecurityManager, template<class> class SigningMonitor>
void GenericSecurityManager<TPalSecurityManager, SigningMonitor>::on_signed_write_received_(
connection_handle_t connection,
@ -1324,6 +1325,7 @@ void GenericSecurityManager<TPalSecurityManager, SigningMonitor>::on_signed_writ
MBED_ASSERT(_db);
_db->set_local_sign_counter(_db->get_local_sign_counter() + 1);
}
#endif // BLE_FEATURE_SIGNING
template<template<class> class TPalSecurityManager, template<class> class SigningMonitor>
void GenericSecurityManager<TPalSecurityManager, SigningMonitor>::on_slave_security_request_(

View File

@ -16,8 +16,6 @@
#include "ble/services/UARTService.h"
#if BLE_FEATURE_GATT_SERVER
const uint8_t UARTServiceBaseUUID[UUID::LENGTH_OF_LONG_UUID] = {
0x6E, 0x40, 0x00, 0x00, 0xB5, 0xA3, 0xF3, 0x93,
0xE0, 0xA9, 0xE5, 0x0E, 0x24, 0xDC, 0xCA, 0x9E,
@ -42,4 +40,3 @@ const uint8_t UARTServiceRXCharacteristicUUID[UUID::LENGTH_OF_LONG_UUID] = {
0xE0, 0xA9, 0xE5, 0x0E, 0x24, 0xDC, 0xCA, 0x9E,
};
#endif // BLE_FEATURE_GATT_SERVER

View File

@ -16,8 +16,6 @@
#include "ble/services/URIBeaconConfigService.h"
#if BLE_FEATURE_GATT_SERVER
#define UUID_URI_BEACON(FIRST, SECOND) { \
0xee, 0x0c, FIRST, SECOND, 0x87, 0x86, 0x40, 0xba, \
0xab, 0x96, 0x99, 0xb9, 0x1a, 0xc9, 0x81, 0xd8, \
@ -35,5 +33,3 @@ const uint8_t UUID_BEACON_PERIOD_CHAR[UUID::LENGTH_OF_LONG_UUID] = UUID_URI_B
const uint8_t UUID_RESET_CHAR[UUID::LENGTH_OF_LONG_UUID] = UUID_URI_BEACON(0x20, 0x89);
const uint8_t BEACON_UUID[sizeof(UUID::ShortUUIDBytes_t)] = {0xD8, 0xFE};
#endif // BLE_FEATURE_GATT_SERVER

View File

@ -53,8 +53,10 @@ class BLE;
/**
* Cordio implementation of ::GattServer
*/
class GattServer : public ::ble::interface::GattServer<GattServer>,
public pal::SigningEventMonitor<GattServer, impl::SigningEventHandler>
class GattServer : public ::ble::interface::GattServer<GattServer>
#if BLE_FEATURE_SIGNING
, public pal::SigningEventMonitor<GattServer, impl::SigningEventHandler>
#endif
{
friend ble::vendor::cordio::BLE;
friend ble::pal::vendor::cordio::CordioAttClient;
@ -176,6 +178,7 @@ public:
*/
ble_error_t reset_(void);
#if BLE_FEATURE_SIGNING
/**
* @see pal::SigningEventMonitor::set_signing_event_handler
*/
@ -184,6 +187,7 @@ public:
) {
_signing_event_handler = signing_event_handler;
}
#endif // BLE_FEATURE_SIGNING
private:
@ -246,7 +250,9 @@ private:
internal_service_t *next;
};
#if BLE_FEATURE_SIGNING
impl::SigningEventHandler *_signing_event_handler;
#endif
attsCccSet_t cccds[MAX_CCCD_CNT];
uint16_t cccd_values[MAX_CCCD_CNT];

View File

@ -36,7 +36,11 @@ namespace cordio {
class CordioAttClient : public ::ble::pal::AttClient<CordioAttClient> {
public:
CordioAttClient() : ::ble::pal::AttClient<CordioAttClient>(), _local_sign_counter(0) { }
CordioAttClient() : ::ble::pal::AttClient<CordioAttClient>(), _local_sign_counter(0) {
#if !(BLE_FEATURE_ATT)
#error "Both GattClient and GattSever disabled in config file."
#endif
}
~CordioAttClient() { }

View File

@ -238,6 +238,7 @@ public:
*/
ble_error_t set_irk_(const irk_t &irk);
#if BLE_FEATURE_SIGNING
/**
* @see ::ble::pal::SecurityManager::set_csrk
*/
@ -257,6 +258,7 @@ public:
);
ble_error_t remove_peer_csrk_(connection_handle_t connection);
#endif // BLE_FEATURE_SIGNING
////////////////////////////////////////////////////////////////////////////
// Authentication
@ -362,7 +364,9 @@ private:
// cb_completed is set when the previous block has completed
void process_privacy_control_blocks(bool cb_completed);
#if BLE_FEATURE_SIGNING
void cleanup_peer_csrks();
#endif
bool _use_default_passkey;
passkey_num_t _default_passkey;
@ -372,8 +376,11 @@ private:
PrivacyControlBlock* _pending_privacy_control_blocks;
bool _processing_privacy_control_block;
irk_t _irk;
#if BLE_FEATURE_SIGNING
csrk_t _csrk;
csrk_t* _peer_csrks[DM_CONN_MAX];
#endif // BLE_FEATURE_SIGNING
};
} // cordio

View File

@ -36,7 +36,9 @@
#include "mbed_assert.h"
#include "CordioPalAttClient.h"
#if BLE_FEATURE_SECURITY
#include "CordioPalSecurityManager.h"
#endif BLE_FEATURE_SECURITY
/*! WSF handler ID */
wsfHandlerId_t stack_handler_id;
@ -181,8 +183,10 @@ impl::GenericGapImpl& BLE::getGap()
static impl::GenericGapImpl gap(
_event_queue,
impl::PalGapImpl::get_gap(),
cordio_gap_service,
impl::PalSecurityManagerImpl::get_security_manager()
cordio_gap_service
#if BLE_FEATURE_SECURITY
, impl::PalSecurityManagerImpl::get_security_manager()
#endif
);
return gap;
@ -225,7 +229,6 @@ impl::PalGattClientImpl& BLE::getPalGattClient()
#endif // BLE_FEATURE_GATT_CLIENT
#if BLE_FEATURE_SECURITY
SecurityManager& BLE::getSecurityManager()
{
static vendor::cordio::SigningEventMonitor<impl::GenericSecurityManagerImpl> signing_event_monitor;
@ -243,7 +246,6 @@ const SecurityManager& BLE::getSecurityManager() const
const BLE &self = const_cast<BLE&>(*this);
return const_cast<const SecurityManager&>(self.getSecurityManager());
}
#endif // BLE_FEATURE_SECURITY
void BLE::waitForEvent()
@ -274,9 +276,11 @@ void BLE::processEvents()
return;
}
#if BLE_FEATURE_SECURITY
if (impl::PalSecurityManagerImpl::get_security_manager().sm_handler(msg)) {
return;
}
#endif // BLE_FEATURE_SECURITY
switch(msg->event) {
case DM_RESET_CMPL_IND: {

View File

@ -14,8 +14,6 @@
* limitations under the License.
*/
#if BLE_FEATURE_GATT_SERVER
#include <algorithm>
#include "CordioBLE.h"
#include "CordioGattServer.h"
@ -928,6 +926,7 @@ uint8_t GattServer::atts_write_cb(
case ATT_PDU_WRITE_CMD:
writeOp = GattWriteCallbackParams::OP_WRITE_CMD;
break;
#if BLE_FEATURE_SIGNING
case ATT_PDU_SIGNED_WRITE_CMD:
if (getInstance()._signing_event_handler) {
getInstance()._signing_event_handler->on_signed_write_received(
@ -937,6 +936,7 @@ uint8_t GattServer::atts_write_cb(
}
writeOp = GattWriteCallbackParams::OP_SIGN_WRITE_CMD;
break;
#endif // BLE_FEATURE_SIGNING
case ATT_PDU_PREP_WRITE_REQ:
writeOp = GattWriteCallbackParams::OP_PREP_WRITE_REQ;
break;
@ -1276,7 +1276,9 @@ bool GattServer::is_update_authorized(
}
GattServer::GattServer() :
#if BLE_FEATURE_SIGNING
_signing_event_handler(NULL),
#endif
cccds(),
cccd_values(),
cccd_handles(),
@ -1289,10 +1291,12 @@ GattServer::GattServer() :
allocated_blocks(NULL),
currentHandle(0)
{
#if !(BLE_FEATURE_GATT_SERVER)
#error "GattSever disabled in config file."
#endif
}
} // namespace cordio
} // namespace vendor
} // namespace ble
#endif // BLE_FEATURE_GATT_SERVER

View File

@ -35,10 +35,14 @@ CordioSecurityManager<EventHandler>::CordioSecurityManager() :
_lesc_keys_generated(false),
_public_key_x(),
_pending_privacy_control_blocks(NULL),
_processing_privacy_control_block(false),
_peer_csrks()
_processing_privacy_control_block(false)
#if BLE_FEATURE_SIGNING
, _peer_csrks()
#endif
{
#if !(BLE_FEATURE_SECURITY)
#error "Security Manager feature disabledin the config file"
#endif
}
template <class EventHandler>
@ -58,7 +62,9 @@ ble_error_t CordioSecurityManager<EventHandler>::initialize_()
_use_default_passkey = false;
_default_passkey = 0;
_lesc_keys_generated = false;
#if BLE_FEATURE_SIGNING
memset(_peer_csrks, 0, sizeof(_peer_csrks));
#endif
#if 0
// FIXME: need help from the stack or local calculation
@ -72,14 +78,18 @@ ble_error_t CordioSecurityManager<EventHandler>::initialize_()
template <class EventHandler>
ble_error_t CordioSecurityManager<EventHandler>::terminate_()
{
#if BLE_FEATURE_SIGNING
cleanup_peer_csrks();
#endif // BLE_FEATURE_SIGNING
return BLE_ERROR_NONE;
}
template <class EventHandler>
ble_error_t CordioSecurityManager<EventHandler>::reset_()
{
#if BLE_FEATURE_SIGNING
cleanup_peer_csrks();
#endif // BLE_FEATURE_SIGNING
initialize();
return BLE_ERROR_NONE;
}
@ -321,6 +331,7 @@ ble_error_t CordioSecurityManager<EventHandler>::set_irk_(const irk_t& irk)
return BLE_ERROR_NONE;
}
#if BLE_FEATURE_SIGNING
template <class EventHandler>
ble_error_t CordioSecurityManager<EventHandler>::set_csrk_(
const csrk_t& csrk,
@ -378,6 +389,7 @@ ble_error_t CordioSecurityManager<EventHandler>::remove_peer_csrk_(connection_ha
AttsSetCsrk(connection, NULL, false);
return BLE_ERROR_NONE;
}
#endif // BLE_FEATURE_SIGNING
////////////////////////////////////////////////////////////////////////////
// Global parameters
@ -704,12 +716,13 @@ bool CordioSecurityManager<EventHandler>::sm_handler(const wsfMsgHdr_t* msg) {
irk_t(reinterpret_cast<uint8_t*>(evt->keyData.irk.key))
);
break;
#if BLE_FEATURE_SIGNING
case DM_KEY_CSRK:
handler->on_keys_distributed_csrk(
connection, evt->keyData.csrk.key
);
break;
#endif // BLE_FEATURE_SIGNING
}
return true;
@ -996,6 +1009,7 @@ void CordioSecurityManager<EventHandler>::process_privacy_control_blocks(bool cb
_pending_privacy_control_blocks = next;
}
#if BLE_FEATURE_SIGNING
template <class EventHandler>
void CordioSecurityManager<EventHandler>::cleanup_peer_csrks() {
for (size_t i = 0; i < DM_CONN_MAX; ++i) {
@ -1005,6 +1019,7 @@ void CordioSecurityManager<EventHandler>::cleanup_peer_csrks() {
}
}
}
#endif // BLE_FEATURE_SIGNING
} // cordio
} // vendor