mirror of https://github.com/ARMmbed/mbed-os.git
feat(ble): Guard out GattClient code when role is disabled
parent
9806f91ecf
commit
6e301ce148
|
@ -21,6 +21,7 @@
|
|||
#include "ble/Gap.h"
|
||||
#include "ble/GattServer.h"
|
||||
#include "ble/GattClient.h"
|
||||
|
||||
#include "ble/SecurityManager.h"
|
||||
|
||||
#include "ble/FunctionPointerWithContext.h"
|
||||
|
@ -371,6 +372,7 @@ public:
|
|||
*/
|
||||
const GattServer &gattServer() const;
|
||||
|
||||
#if BLE_ROLE_GATT_CLIENT
|
||||
/**
|
||||
* Accessors to GattClient. All GattClient related functionality requires
|
||||
* going through this accessor.
|
||||
|
@ -386,6 +388,7 @@ public:
|
|||
* instance.
|
||||
*/
|
||||
const GattClient &gattClient() const;
|
||||
#endif // BLE_ROLE_GATT_CLIENT
|
||||
|
||||
/**
|
||||
* Accessors to SecurityManager. All SecurityManager-related functionality
|
||||
|
|
|
@ -203,6 +203,7 @@ public:
|
|||
*/
|
||||
virtual const GattServer &getGattServer(void) const = 0;
|
||||
|
||||
#if BLE_ROLE_GATT_CLIENT
|
||||
/**
|
||||
* Accessor to the vendor implementation of the GattClient interface.
|
||||
*
|
||||
|
@ -212,6 +213,7 @@ public:
|
|||
* @see BLE::gattClient() GattClient
|
||||
*/
|
||||
virtual GattClient &getGattClient(void) = 0;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Accessor to the vendor implementation of the SecurityManager interface.
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
#ifndef MBED_DISCOVERED_CHARACTERISTIC_H__
|
||||
#define MBED_DISCOVERED_CHARACTERISTIC_H__
|
||||
|
||||
#if BLE_ROLE_GATT_CLIENT
|
||||
|
||||
#include "UUID.h"
|
||||
#include "ble/Gap.h"
|
||||
#include "GattAttribute.h"
|
||||
|
@ -634,4 +636,6 @@ protected:
|
|||
* @}
|
||||
*/
|
||||
|
||||
#endif // BLE_ROLE_GATT_CLIENT
|
||||
|
||||
#endif /*MBED_DISCOVERED_CHARACTERISTIC_H__*/
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
#ifndef MBED_DISCOVERED_CHARACTERISTIC_DESCRIPTOR_H__
|
||||
#define MBED_DISCOVERED_CHARACTERISTIC_DESCRIPTOR_H__
|
||||
|
||||
#if BLE_ROLE_GATT_CLIENT
|
||||
|
||||
#include "UUID.h"
|
||||
#include "ble/Gap.h"
|
||||
#include "GattAttribute.h"
|
||||
|
@ -150,4 +152,6 @@ private:
|
|||
* @}
|
||||
*/
|
||||
|
||||
#endif // BLE_ROLE_GATT_CLIENT
|
||||
|
||||
#endif /* MBED_DISCOVERED_CHARACTERISTIC_DESCRIPTOR_H__ */
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
#ifndef MBED_GATT_CLIENT_H__
|
||||
#define MBED_GATT_CLIENT_H__
|
||||
|
||||
#if BLE_ROLE_GATT_CLIENT
|
||||
|
||||
#include "ble/common/StaticInterface.h"
|
||||
#include "ble/GattAttribute.h"
|
||||
#include "ble/ServiceDiscovery.h"
|
||||
|
@ -878,5 +880,6 @@ private:
|
|||
using ble::impl::GattClient;
|
||||
#endif
|
||||
|
||||
#endif // BLE_ROLE_GATT_CLIENT
|
||||
|
||||
#endif /* ifndef MBED_GATT_CLIENT_H__ */
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
#ifndef MBED_BLE_GENERIC_GATT_CLIENT
|
||||
#define MBED_BLE_GENERIC_GATT_CLIENT
|
||||
|
||||
#if BLE_ROLE_GATT_CLIENT
|
||||
|
||||
#include <algorithm>
|
||||
#include "ble/GattClient.h"
|
||||
#include "ble/pal/PalGattClient.h"
|
||||
|
@ -177,4 +179,6 @@ private:
|
|||
} // generic
|
||||
} // ble
|
||||
|
||||
#endif // BLE_ROLE_GATT_CLIENT
|
||||
|
||||
#endif /* MBED_BLE_GENERIC_GATT_CLIENT */
|
||||
|
|
|
@ -233,6 +233,8 @@ GattServer& BLE::gattServer()
|
|||
return transport->getGattServer();
|
||||
}
|
||||
|
||||
#if BLE_ROLE_GATT_CLIENT
|
||||
|
||||
const GattClient& BLE::gattClient() const
|
||||
{
|
||||
if (!transport) {
|
||||
|
@ -251,6 +253,8 @@ GattClient& BLE::gattClient()
|
|||
return transport->getGattClient();
|
||||
}
|
||||
|
||||
#endif // BLE_ROLE_GATT_CLIENT
|
||||
|
||||
const SecurityManager& BLE::securityManager() const
|
||||
{
|
||||
if (!transport) {
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
#include "ble/DiscoveredCharacteristic.h"
|
||||
#include "ble/GattClient.h"
|
||||
|
||||
#if BLE_ROLE_GATT_CLIENT
|
||||
|
||||
ble_error_t
|
||||
DiscoveredCharacteristic::read(uint16_t offset) const
|
||||
{
|
||||
|
@ -165,3 +167,5 @@ ble_error_t DiscoveredCharacteristic::discoverDescriptors(
|
|||
|
||||
return err;
|
||||
}
|
||||
|
||||
#endif // BLE_ROLE_GATT_CLIENT
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#if BLE_ROLE_GATT_CLIENT
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
@ -1487,4 +1489,6 @@ uint16_t GenericGattClient<TPalGattClient, SigningMonitorEventHandler>::get_mtu(
|
|||
}
|
||||
|
||||
} // namespace pal
|
||||
} // namespace ble
|
||||
} // namespace ble
|
||||
|
||||
#endif // BLE_ROLE_GATT_CLIENT
|
||||
|
|
|
@ -105,10 +105,12 @@ public:
|
|||
*/
|
||||
virtual const GattServer &getGattServer() const;
|
||||
|
||||
#if BLE_ROLE_GATT_CLIENT
|
||||
/**
|
||||
* @see BLEInstanceBase::getGattClient
|
||||
*/
|
||||
virtual impl::GenericGattClientImpl &getGattClient();
|
||||
#endif // BLE_ROLE_GATT_CLIENT
|
||||
|
||||
/**
|
||||
* Get the PAL Gatt Client.
|
||||
|
|
|
@ -156,7 +156,11 @@ ble_error_t BLE::shutdown()
|
|||
_hci_driver->terminate();
|
||||
|
||||
getGattServer().reset();
|
||||
|
||||
#if BLE_ROLE_GATT_CLIENT
|
||||
getGattClient().reset();
|
||||
#endif // BLE_ROLE_GATT_CLIENT
|
||||
|
||||
getGap().reset();
|
||||
_event_queue.clear();
|
||||
|
||||
|
@ -198,6 +202,7 @@ const GattServer& BLE::getGattServer() const
|
|||
return cordio::GattServer::getInstance();
|
||||
}
|
||||
|
||||
#if BLE_ROLE_GATT_CLIENT
|
||||
impl::GenericGattClientImpl& BLE::getGattClient()
|
||||
{
|
||||
static impl::GenericGattClientImpl gatt_client(&getPalGattClient());
|
||||
|
@ -213,6 +218,7 @@ impl::PalGattClientImpl& BLE::getPalGattClient()
|
|||
|
||||
return pal_client;
|
||||
}
|
||||
#endif // BLE_ROLE_GATT_CLIENT
|
||||
|
||||
SecurityManager& BLE::getSecurityManager()
|
||||
{
|
||||
|
@ -462,7 +468,9 @@ FunctionPointerWithContext< ::BLE::InitializationCompleteCallbackContext*> BLE::
|
|||
|
||||
template<>
|
||||
void SigningEventMonitor<impl::GenericSecurityManagerImpl>::set_signing_event_handler_(impl::GenericSecurityManagerImpl *handler) {
|
||||
#if BLE_ROLE_GATT_CLIENT
|
||||
BLE::deviceInstance().getGattClient().set_signing_event_handler(handler);
|
||||
#endif // BLE_ROLE_GATT_CLIENT
|
||||
BLE::deviceInstance().getGattServer().set_signing_event_handler(handler);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue