feat(ble): Guard out SecurityManager code when role is disabled

pull/9790/head
Steve Cartmell 2019-01-11 16:36:37 -08:00 committed by Vincent Coubard
parent 73f7ffb124
commit 5d73a03a64
6 changed files with 22 additions and 0 deletions

View File

@ -392,6 +392,7 @@ public:
const GattClient &gattClient() const;
#endif // BLE_ROLE_GATT_CLIENT
#if BLE_ROLE_SECURITY
/**
* Accessors to SecurityManager. All SecurityManager-related functionality
* requires going through this accessor.
@ -408,6 +409,7 @@ public:
* BLE instance.
*/
const SecurityManager &securityManager() const;
#endif // BLE_ROLE_SECURITY
/**
* Translate error code into a printable string.
@ -1475,6 +1477,7 @@ public:
}
#endif // BLE_ROLE_GATT_SERVER
#if BLE_ROLE_SECURITY
/**
* Enable the BLE stack's Security Manager. The Security Manager implements
* the cryptographic algorithms and protocol exchanges that allow two
@ -1543,6 +1546,7 @@ public:
{
return securityManager().purgeAllBondingState();
}
#endif // BLE_ROLE_SECURITY
/**
* Set up a callback for timeout events. Refer to Gap::TimeoutSource_t for
@ -1831,6 +1835,7 @@ public:
}
#endif // BLE_ROLE_GATT_SERVER
#if BLE_ROLE_SECURITY
/**
* Set up a callback for when the security setup procedure (key generation
* and exchange) for a link has started. This will be skipped for bonded
@ -1927,6 +1932,7 @@ public:
{
return securityManager().onPasskeyDisplay(callback);
}
#endif // BLE_ROLE_SECURITY
private:
friend class BLEInstanceBase;

View File

@ -218,6 +218,7 @@ public:
virtual GattClient &getGattClient(void) = 0;
#endif
#if BLE_ROLE_SECURITY
/**
* Accessor to the vendor implementation of the SecurityManager interface.
*
@ -237,6 +238,7 @@ public:
* @see BLE::securityManager() SecurityManager
*/
virtual const SecurityManager &getSecurityManager(void) const = 0;
#endif // BLE_ROLE_SECURITY
/**
* Process pending events present in the vendor subsystem; then, put the MCU

View File

@ -259,6 +259,8 @@ GattClient& BLE::gattClient()
#endif // BLE_ROLE_GATT_CLIENT
#if BLE_ROLE_SECURITY
const SecurityManager& BLE::securityManager() const
{
if (!transport) {
@ -277,6 +279,8 @@ SecurityManager& BLE::securityManager()
return transport->getSecurityManager();
}
#endif // BLE_ROLE_SECURITY
void BLE::waitForEvent(void)
{
if (!transport) {

View File

@ -1844,6 +1844,7 @@ void GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandl
e.peer_resolvable_private_address.data()
);
#if BLE_ROLE_SECURITY
// Now starts pairing or authentication procedures if required
if (needs_pairing) {
SecurityManager &sm = createBLEInstance()->getSecurityManager();
@ -1853,6 +1854,7 @@ void GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandl
// TODO: GAP Authentication != Security Manager authentication
// Needs to be implemented
}
#endif // BLE_ROLE_SECURITY
}
template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>

View File

@ -114,6 +114,8 @@ public:
virtual impl::GenericGattClientImpl &getGattClient();
#endif // BLE_ROLE_GATT_CLIENT
#if BLE_ROLE_SECURITY
/**
* Get the PAL Gatt Client.
*
@ -131,6 +133,8 @@ public:
*/
virtual const SecurityManager &getSecurityManager() const;
#endif // BLE_ROLE_SECURITY
/**
* @see BLEInstanceBase::waitForEvent
*/

View File

@ -224,6 +224,8 @@ impl::PalGattClientImpl& BLE::getPalGattClient()
}
#endif // BLE_ROLE_GATT_CLIENT
#if BLE_ROLE_SECURITY
SecurityManager& BLE::getSecurityManager()
{
static vendor::cordio::SigningEventMonitor<impl::GenericSecurityManagerImpl> signing_event_monitor;
@ -242,6 +244,8 @@ const SecurityManager& BLE::getSecurityManager() const
return const_cast<const SecurityManager&>(self.getSecurityManager());
}
#endif // BLE_ROLE_SECURITY
void BLE::waitForEvent()
{
static Timeout nextTimeout;