add all the features and rename existing non-roles to features

pull/9790/head
paul-szczepanek-arm 2019-02-06 12:13:25 +00:00 committed by Vincent Coubard
parent 8e36ed4b1e
commit aefab05e5a
22 changed files with 197 additions and 142 deletions

View File

@ -356,7 +356,7 @@ public:
*/ */
const Gap &gap() const; const Gap &gap() const;
#if BLE_ROLE_GATT_SERVER #if BLE_FEATURE_GATT_SERVER
/** /**
* Accessor to GattServer. All GattServer related functionality requires * Accessor to GattServer. All GattServer related functionality requires
* going through this accessor. * going through this accessor.
@ -372,9 +372,9 @@ public:
* instance. * instance.
*/ */
const GattServer &gattServer() const; const GattServer &gattServer() const;
#endif // BLE_ROLE_GATT_SERVER #endif // BLE_FEATURE_GATT_SERVER
#if BLE_ROLE_GATT_CLIENT #if BLE_FEATURE_GATT_CLIENT
/** /**
* Accessors to GattClient. All GattClient related functionality requires * Accessors to GattClient. All GattClient related functionality requires
* going through this accessor. * going through this accessor.
@ -390,9 +390,9 @@ public:
* instance. * instance.
*/ */
const GattClient &gattClient() const; const GattClient &gattClient() const;
#endif // BLE_ROLE_GATT_CLIENT #endif // BLE_FEATURE_GATT_CLIENT
#if BLE_ROLE_SECURITY #if BLE_FEATURE_SECURITY
/** /**
* Accessors to SecurityManager. All SecurityManager-related functionality * Accessors to SecurityManager. All SecurityManager-related functionality
* requires going through this accessor. * requires going through this accessor.
@ -409,7 +409,7 @@ public:
* BLE instance. * BLE instance.
*/ */
const SecurityManager &securityManager() const; const SecurityManager &securityManager() const;
#endif // BLE_ROLE_SECURITY #endif // BLE_FEATURE_SECURITY
/** /**
* Translate error code into a printable string. * Translate error code into a printable string.
@ -1318,7 +1318,7 @@ public:
MBED_DEPRECATED("Use ble.gap().getPermittedTxPowerValues(...)") MBED_DEPRECATED("Use ble.gap().getPermittedTxPowerValues(...)")
void getPermittedTxPowerValues(const int8_t **valueArrayPP, size_t *countP); void getPermittedTxPowerValues(const int8_t **valueArrayPP, size_t *countP);
#if BLE_ROLE_GATT_SERVER #if BLE_FEATURE_GATT_SERVER
/** /**
* Add a service declaration to the local server ATT table. Also add the * Add a service declaration to the local server ATT table. Also add the
* characteristics contained within. * characteristics contained within.
@ -1477,9 +1477,9 @@ public:
{ {
return gattServer().write(connectionHandle, attributeHandle, value, size, localOnly); return gattServer().write(connectionHandle, attributeHandle, value, size, localOnly);
} }
#endif // BLE_ROLE_GATT_SERVER #endif // BLE_FEATURE_GATT_SERVER
#if BLE_ROLE_SECURITY #if BLE_FEATURE_SECURITY
/** /**
* Enable the BLE stack's Security Manager. The Security Manager implements * Enable the BLE stack's Security Manager. The Security Manager implements
* the cryptographic algorithms and protocol exchanges that allow two * the cryptographic algorithms and protocol exchanges that allow two
@ -1548,7 +1548,7 @@ public:
{ {
return securityManager().purgeAllBondingState(); return securityManager().purgeAllBondingState();
} }
#endif // BLE_ROLE_SECURITY #endif // BLE_FEATURE_SECURITY
/** /**
* Set up a callback for timeout events. Refer to Gap::TimeoutSource_t for * Set up a callback for timeout events. Refer to Gap::TimeoutSource_t for
@ -1633,7 +1633,7 @@ public:
MBED_DEPRECATED("ble.gap().onRadioNotification(...)") MBED_DEPRECATED("ble.gap().onRadioNotification(...)")
void onRadioNotification(void (*callback)(bool)); void onRadioNotification(void (*callback)(bool));
#if BLE_ROLE_GATT_SERVER #if BLE_FEATURE_GATT_SERVER
/** /**
* Add a callback for the GATT event DATA_SENT (which is triggered when * Add a callback for the GATT event DATA_SENT (which is triggered when
* updates are sent out by GATT in the form of notifications). * updates are sent out by GATT in the form of notifications).
@ -1835,9 +1835,9 @@ public:
{ {
gattServer().onConfirmationReceived(callback); gattServer().onConfirmationReceived(callback);
} }
#endif // BLE_ROLE_GATT_SERVER #endif // BLE_FEATURE_GATT_SERVER
#if BLE_ROLE_SECURITY #if BLE_FEATURE_SECURITY
/** /**
* Set up a callback for when the security setup procedure (key generation * 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 * and exchange) for a link has started. This will be skipped for bonded
@ -1934,7 +1934,7 @@ public:
{ {
return securityManager().onPasskeyDisplay(callback); return securityManager().onPasskeyDisplay(callback);
} }
#endif // BLE_ROLE_SECURITY #endif // BLE_FEATURE_SECURITY
private: private:
friend class BLEInstanceBase; friend class BLEInstanceBase;

View File

@ -184,7 +184,7 @@ public:
virtual const Gap &getGap(void) const = 0; virtual const Gap &getGap(void) const = 0;
#if BLE_ROLE_GATT_SERVER #if BLE_FEATURE_GATT_SERVER
/** /**
* Accessor to the vendor implementation of the GattServer interface. * Accessor to the vendor implementation of the GattServer interface.
* *
@ -204,9 +204,9 @@ public:
* @see BLE::gattServer() GattServer * @see BLE::gattServer() GattServer
*/ */
virtual const GattServer &getGattServer(void) const = 0; virtual const GattServer &getGattServer(void) const = 0;
#endif // BLE_ROLE_GATT_SERVER #endif // BLE_FEATURE_GATT_SERVER
#if BLE_ROLE_GATT_CLIENT #if BLE_FEATURE_GATT_CLIENT
/** /**
* Accessor to the vendor implementation of the GattClient interface. * Accessor to the vendor implementation of the GattClient interface.
* *
@ -218,7 +218,7 @@ public:
virtual GattClient &getGattClient(void) = 0; virtual GattClient &getGattClient(void) = 0;
#endif #endif
#if BLE_ROLE_SECURITY #if BLE_FEATURE_SECURITY
/** /**
* Accessor to the vendor implementation of the SecurityManager interface. * Accessor to the vendor implementation of the SecurityManager interface.
* *
@ -238,7 +238,7 @@ public:
* @see BLE::securityManager() SecurityManager * @see BLE::securityManager() SecurityManager
*/ */
virtual const SecurityManager &getSecurityManager(void) const = 0; virtual const SecurityManager &getSecurityManager(void) const = 0;
#endif // BLE_ROLE_SECURITY #endif // BLE_FEATURE_SECURITY
/** /**
* Process pending events present in the vendor subsystem; then, put the MCU * Process pending events present in the vendor subsystem; then, put the MCU

View File

@ -2,43 +2,69 @@
#define MBED_BLE_ROLES_H__ #define MBED_BLE_ROLES_H__
#ifdef BLE_ROLE_PERIPHERAL #ifdef BLE_ROLE_PERIPHERAL
#ifndef BLE_ROLE_OBSERVER #if !defined(BLE_ROLE_OBSERVER)
#error "BLE role 'PERIPHERAL' depends on role 'OBSERVER'" #error "BLE role 'PERIPHERAL' depends on role 'OBSERVER'"
#endif // BLE_ROLE_OBSERVER #endif
#endif // BLE_ROLE_PERIPHERAL #endif // BLE_ROLE_PERIPHERAL
#ifdef BLE_ROLE_CENTRAL #ifdef BLE_ROLE_CENTRAL
#ifndef BLE_ROLE_BROADCASTER #if !defined(BLE_ROLE_BROADCASTER)
#error "BLE role 'CENTRAL' depends on role 'BROADCASTER'" #error "BLE role 'CENTRAL' depends on role 'BROADCASTER'"
#endif // BLE_ROLE_BROADCASTER #endif
#endif // BLE_ROLE_CENTRAL #endif // BLE_ROLE_CENTRAL
#ifdef BLE_ROLE_SECURITY #ifdef BLE_FEATURE_SECURITY
#ifndef BLE_ROLE_PERIPHERAL #if !defined(BLE_ROLE_PERIPHERAL) && !defined(BLE_ROLE_CENTRAL)
#error "BLE role 'SECURITY' depends on role 'PERIPHERAL'" #error "BLE feature 'SECURITY' requires 'PERIPHERAL' or 'CENTRAL' role"
#endif // BLE_ROLE_PERIPHERAL #endif
#endif // BLE_ROLE_SECURITY #endif // BLE_FEATURE_SECURITY
#ifdef BLE_ROLE_PRIVACY #ifdef BLE_FEATURE_SECURE_CONNECTIONS
#ifndef BLE_ROLE_SECURITY #if !defined(BLE_FEATURE_SECURITY)
#error "BLE role 'PRIVACY' depends on role 'SECURITY'" #error "BLE feature 'SECURE CONNECTIONS' requires the 'SECURITY' feature"
#endif // BLE_ROLE_SECURITY #endif
#endif // BLE_ROLE_PRIVACY #endif // BLE_FEATURE_SECURE_CONNECTIONS
#ifdef BLE_ROLE_GATT_CLIENT #ifdef BLE_FEATURE_SIGNING
#ifndef BLE_ROLE_PERIPHERAL #if !defined(BLE_FEATURE_SECURITY)
#error "BLE role 'GATT CLIENT' depends on role 'PERIPHERAL'" #error "BLE feature 'SIGNING' requires the 'SECURITY' feature"
#endif // BLE_ROLE_PERIPHERAL #endif
#endif // BLE_FEATURE_SIGNING
#ifndef BLE_ROLE_BROADCASTER #ifdef BLE_FEATURE_WHITELIST
#error "BLE role 'GATT CLIENT' depends on role 'BROADCASTER'" #if !defined(BLE_FEATURE_SECURITY)
#endif // BLE_ROLE_BROADCASTER #error "BLE feature 'WHITELIST' requires the 'SECURITY' feature"
#endif // BLE_ROLE_GATT_CLIENT #endif
#endif // BLE_FEATURE_WHITELIST
#ifdef BLE_ROLE_GATT_SERVER #ifdef BLE_FEATURE_PRIVACY
#ifndef BLE_ROLE_SECURITY #if !defined(BLE_FEATURE_SECURITY)
#error "BLE role 'GATT SERVER' depends on role 'SECURITY'" #error "BLE feature 'PRIVACY' requires the 'SECURITY' feature"
#endif // BLE_ROLE_SECURITY #endif
#endif // BLE_ROLE_GATT_SERVER #endif // BLE_FEATURE_PRIVACY
#ifdef BLE_FEATURE_EXTENDED_ADVERTISING
#if !defined(BLE_FEATURE_PHY_MANAGEMENT)
#error "BLE feature 'EXTENDED ADVERTISING' requires the 'PHY MANAGEMENT' feature"
#endif
#endif // BLE_FEATURE_EXTENDED_ADVERTISING
#ifdef BLE_FEATURE_PERIODIC_ADVERTISING
#if !defined(BLE_FEATURE_EXTENDED_ADVERTISING)
#error "BLE feature 'PERIODIC ADVERTISING' requires the 'EXTENDED ADVERTISING' feature"
#endif
#endif // BLE_FEATURE_PERIODIC_ADVERTISING
#ifdef BLE_FEATURE_GATT_CLIENT
#if !defined(BLE_ROLE_PERIPHERAL) && !defined(BLE_ROLE_CENTRAL)
#error "BLE feature 'GATT CLIENT' requires 'PERIPHERAL' or 'CENTRAL' role"
#endif
#endif // BLE_FEATURE_GATT_CLIENT
#ifdef BLE_FEATURE_GATT_SERVER
#if !defined(BLE_ROLE_PERIPHERAL) && !defined(BLE_ROLE_CENTRAL)
#error "BLE feature 'GATT SERVER' requires 'PERIPHERAL' or 'CENTRAL' role"
#endif
#endif // BLE_FEATURE_GATT_SERVER
#endif // MBED_BLE_ROLES_H__ #endif // MBED_BLE_ROLES_H__

View File

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

View File

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

View File

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

View File

@ -17,7 +17,7 @@
#ifndef MBED_BLE_GENERIC_GATT_CLIENT #ifndef MBED_BLE_GENERIC_GATT_CLIENT
#define MBED_BLE_GENERIC_GATT_CLIENT #define MBED_BLE_GENERIC_GATT_CLIENT
#if BLE_ROLE_GATT_CLIENT #if BLE_FEATURE_GATT_CLIENT
#include <algorithm> #include <algorithm>
#include "ble/GattClient.h" #include "ble/GattClient.h"
@ -179,6 +179,6 @@ private:
} // generic } // generic
} // ble } // ble
#endif // BLE_ROLE_GATT_CLIENT #endif // BLE_FEATURE_GATT_CLIENT
#endif /* MBED_BLE_GENERIC_GATT_CLIENT */ #endif /* MBED_BLE_GENERIC_GATT_CLIENT */

View File

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

View File

@ -17,7 +17,7 @@
#ifndef SERVICES_URIBEACONCONFIGSERVICE_H_ #ifndef SERVICES_URIBEACONCONFIGSERVICE_H_
#define SERVICES_URIBEACONCONFIGSERVICE_H_ #define SERVICES_URIBEACONCONFIGSERVICE_H_
#if BLE_ROLE_GATT_SERVER #if BLE_FEATURE_GATT_SERVER
#include "ble/BLE.h" #include "ble/BLE.h"
@ -482,6 +482,6 @@ public:
} }
}; };
#endif // BLE_ROLE_GATT_SERVER #endif // BLE_FEATURE_GATT_SERVER
#endif // SERVICES_URIBEACONCONFIGSERVICE_H_ #endif // SERVICES_URIBEACONCONFIGSERVICE_H_

View File

@ -215,7 +215,7 @@ Gap &BLE::gap()
return transport->getGap(); return transport->getGap();
} }
#if BLE_ROLE_GATT_SERVER #if BLE_FEATURE_GATT_SERVER
const GattServer& BLE::gattServer() const const GattServer& BLE::gattServer() const
{ {
@ -235,9 +235,9 @@ GattServer& BLE::gattServer()
return transport->getGattServer(); return transport->getGattServer();
} }
#endif // BLE_ROLE_GATT_SERVER #endif // BLE_FEATURE_GATT_SERVER
#if BLE_ROLE_GATT_CLIENT #if BLE_FEATURE_GATT_CLIENT
const GattClient& BLE::gattClient() const const GattClient& BLE::gattClient() const
{ {
@ -257,9 +257,9 @@ GattClient& BLE::gattClient()
return transport->getGattClient(); return transport->getGattClient();
} }
#endif // BLE_ROLE_GATT_CLIENT #endif // BLE_FEATURE_GATT_CLIENT
#if BLE_ROLE_SECURITY #if BLE_FEATURE_SECURITY
const SecurityManager& BLE::securityManager() const const SecurityManager& BLE::securityManager() const
{ {
@ -279,7 +279,7 @@ SecurityManager& BLE::securityManager()
return transport->getSecurityManager(); return transport->getSecurityManager();
} }
#endif // BLE_ROLE_SECURITY #endif // BLE_FEATURE_SECURITY
void BLE::waitForEvent(void) void BLE::waitForEvent(void)
{ {

View File

@ -17,7 +17,7 @@
#include "ble/DiscoveredCharacteristic.h" #include "ble/DiscoveredCharacteristic.h"
#include "ble/GattClient.h" #include "ble/GattClient.h"
#if BLE_ROLE_GATT_CLIENT #if BLE_FEATURE_GATT_CLIENT
ble_error_t ble_error_t
DiscoveredCharacteristic::read(uint16_t offset) const DiscoveredCharacteristic::read(uint16_t offset) const
@ -168,4 +168,4 @@ ble_error_t DiscoveredCharacteristic::discoverDescriptors(
return err; return err;
} }
#endif // BLE_ROLE_GATT_CLIENT #endif // BLE_FEATURE_GATT_CLIENT

View File

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

View File

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
#if BLE_ROLE_GATT_CLIENT #if BLE_FEATURE_GATT_CLIENT
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@ -1491,4 +1491,4 @@ uint16_t GenericGattClient<TPalGattClient, SigningMonitorEventHandler>::get_mtu(
} // namespace pal } // namespace pal
} // namespace ble } // namespace ble
#endif // BLE_ROLE_GATT_CLIENT #endif // BLE_FEATURE_GATT_CLIENT

View File

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

View File

@ -16,7 +16,7 @@
#include "ble/services/URIBeaconConfigService.h" #include "ble/services/URIBeaconConfigService.h"
#if BLE_ROLE_GATT_SERVER #if BLE_FEATURE_GATT_SERVER
#define UUID_URI_BEACON(FIRST, SECOND) { \ #define UUID_URI_BEACON(FIRST, SECOND) { \
0xee, 0x0c, FIRST, SECOND, 0x87, 0x86, 0x40, 0xba, \ 0xee, 0x0c, FIRST, SECOND, 0x87, 0x86, 0x40, 0xba, \
@ -36,4 +36,4 @@ const uint8_t UUID_RESET_CHAR[UUID::LENGTH_OF_LONG_UUID] = UUID_URI_B
const uint8_t BEACON_UUID[sizeof(UUID::ShortUUIDBytes_t)] = {0xD8, 0xFE}; const uint8_t BEACON_UUID[sizeof(UUID::ShortUUIDBytes_t)] = {0xD8, 0xFE};
#endif // BLE_ROLE_GATT_SERVER #endif // BLE_FEATURE_GATT_SERVER

View File

@ -95,7 +95,7 @@ public:
*/ */
virtual const impl::GenericGapImpl& getGap() const; virtual const impl::GenericGapImpl& getGap() const;
#if BLE_ROLE_GATT_SERVER #if BLE_FEATURE_GATT_SERVER
/** /**
* @see BLEInstanceBase::getGattServer * @see BLEInstanceBase::getGattServer
*/ */
@ -105,16 +105,16 @@ public:
* @see BLEInstanceBase::getGattServer * @see BLEInstanceBase::getGattServer
*/ */
virtual const GattServer &getGattServer() const; virtual const GattServer &getGattServer() const;
#endif // BLE_ROLE_GATT_SERVER #endif // BLE_FEATURE_GATT_SERVER
#if BLE_ROLE_GATT_CLIENT #if BLE_FEATURE_GATT_CLIENT
/** /**
* @see BLEInstanceBase::getGattClient * @see BLEInstanceBase::getGattClient
*/ */
virtual impl::GenericGattClientImpl &getGattClient(); virtual impl::GenericGattClientImpl &getGattClient();
#endif // BLE_ROLE_GATT_CLIENT #endif // BLE_FEATURE_GATT_CLIENT
#if BLE_ROLE_SECURITY #if BLE_FEATURE_SECURITY
/** /**
* Get the PAL Gatt Client. * Get the PAL Gatt Client.
@ -133,7 +133,7 @@ public:
*/ */
virtual const SecurityManager &getSecurityManager() const; virtual const SecurityManager &getSecurityManager() const;
#endif // BLE_ROLE_SECURITY #endif // BLE_FEATURE_SECURITY
/** /**
* @see BLEInstanceBase::waitForEvent * @see BLEInstanceBase::waitForEvent

View File

@ -17,7 +17,7 @@
#ifndef CORDIO_GATT_SERVER_H_ #ifndef CORDIO_GATT_SERVER_H_
#define CORDIO_GATT_SERVER_H_ #define CORDIO_GATT_SERVER_H_
#if BLE_ROLE_GATT_SERVER #if BLE_FEATURE_GATT_SERVER
#include <stddef.h> #include <stddef.h>
#include "ble/blecommon.h" #include "ble/blecommon.h"
@ -293,6 +293,6 @@ private:
} // namespace vendor } // namespace vendor
} // namespace ble } // namespace ble
#endif // BLE_ROLE_GATT_SERVER #endif // BLE_FEATURE_GATT_SERVER
#endif /* CORDIO_GATT_SERVER_H_ */ #endif /* CORDIO_GATT_SERVER_H_ */

View File

@ -356,10 +356,10 @@ public:
} }
} }
#if BLE_ROLE_GATT_SERVER #if BLE_FEATURE_GATT_SERVER
// pass events not handled to the server side // pass events not handled to the server side
ble::vendor::cordio::GattServer::getInstance().att_cb(event); ble::vendor::cordio::GattServer::getInstance().att_cb(event);
#endif // BLE_ROLE_GATT_SERVER #endif // BLE_FEATURE_GATT_SERVER
} }
private: private:

View File

@ -20,7 +20,7 @@ public:
virtual ~GenericAccessService() { } virtual ~GenericAccessService() { }
virtual ble_error_t get_device_name_length(uint8_t& length) { virtual ble_error_t get_device_name_length(uint8_t& length) {
#if BLE_ROLE_GATT_SERVER #if BLE_FEATURE_GATT_SERVER
const uint8_t* name = NULL; const uint8_t* name = NULL;
uint16_t actual_length = 0; uint16_t actual_length = 0;
@ -28,13 +28,13 @@ public:
length = actual_length; length = actual_length;
return BLE_ERROR_NONE; return BLE_ERROR_NONE;
#endif // BLE_ROLE_GATT_SERVER #endif // BLE_FEATURE_GATT_SERVER
return BLE_ERROR_NOT_IMPLEMENTED; return BLE_ERROR_NOT_IMPLEMENTED;
} }
virtual ble_error_t get_device_name(ArrayView<uint8_t>& array) { virtual ble_error_t get_device_name(ArrayView<uint8_t>& array) {
#if BLE_ROLE_GATT_SERVER #if BLE_FEATURE_GATT_SERVER
const uint8_t* name = NULL; const uint8_t* name = NULL;
uint16_t length = 0; uint16_t length = 0;
@ -49,67 +49,67 @@ public:
return BLE_ERROR_NONE; return BLE_ERROR_NONE;
#else #else
return BLE_ERROR_NOT_IMPLEMENTED; return BLE_ERROR_NOT_IMPLEMENTED;
#endif // BLE_ROLE_GATT_SERVER #endif // BLE_FEATURE_GATT_SERVER
} }
virtual ble_error_t set_device_name(const uint8_t* device_name) { virtual ble_error_t set_device_name(const uint8_t* device_name) {
#if BLE_ROLE_GATT_SERVER #if BLE_FEATURE_GATT_SERVER
return gatt_server().setDeviceName(device_name); return gatt_server().setDeviceName(device_name);
#else #else
return BLE_ERROR_NOT_IMPLEMENTED; return BLE_ERROR_NOT_IMPLEMENTED;
#endif // BLE_ROLE_GATT_SERVER #endif // BLE_FEATURE_GATT_SERVER
} }
virtual ble_error_t get_appearance( virtual ble_error_t get_appearance(
GapAdvertisingData::Appearance& appearance GapAdvertisingData::Appearance& appearance
) { ) {
#if BLE_ROLE_GATT_SERVER #if BLE_FEATURE_GATT_SERVER
appearance = gatt_server().getAppearance(); appearance = gatt_server().getAppearance();
return BLE_ERROR_NONE; return BLE_ERROR_NONE;
#else #else
return BLE_ERROR_NOT_IMPLEMENTED; return BLE_ERROR_NOT_IMPLEMENTED;
#endif // BLE_ROLE_GATT_SERVER #endif // BLE_FEATURE_GATT_SERVER
} }
virtual ble_error_t set_appearance( virtual ble_error_t set_appearance(
GapAdvertisingData::Appearance appearance GapAdvertisingData::Appearance appearance
) { ) {
#if BLE_ROLE_GATT_SERVER #if BLE_FEATURE_GATT_SERVER
gatt_server().setAppearance(appearance); gatt_server().setAppearance(appearance);
return BLE_ERROR_NONE; return BLE_ERROR_NONE;
#else #else
return BLE_ERROR_NOT_IMPLEMENTED; return BLE_ERROR_NOT_IMPLEMENTED;
#endif // BLE_ROLE_GATT_SERVER #endif // BLE_FEATURE_GATT_SERVER
} }
virtual ble_error_t get_peripheral_prefered_connection_parameters( virtual ble_error_t get_peripheral_prefered_connection_parameters(
::Gap::ConnectionParams_t& parameters ::Gap::ConnectionParams_t& parameters
) { ) {
#if BLE_ROLE_GATT_SERVER #if BLE_FEATURE_GATT_SERVER
parameters = gatt_server().getPreferredConnectionParams(); parameters = gatt_server().getPreferredConnectionParams();
return BLE_ERROR_NONE; return BLE_ERROR_NONE;
#else #else
return BLE_ERROR_NOT_IMPLEMENTED; return BLE_ERROR_NOT_IMPLEMENTED;
#endif // BLE_ROLE_GATT_SERVER #endif // BLE_FEATURE_GATT_SERVER
} }
virtual ble_error_t set_peripheral_prefered_connection_parameters( virtual ble_error_t set_peripheral_prefered_connection_parameters(
const ::Gap::ConnectionParams_t& parameters const ::Gap::ConnectionParams_t& parameters
) { ) {
#if BLE_ROLE_GATT_SERVER #if BLE_FEATURE_GATT_SERVER
gatt_server().setPreferredConnectionParams(parameters); gatt_server().setPreferredConnectionParams(parameters);
return BLE_ERROR_NONE; return BLE_ERROR_NONE;
#else #else
return BLE_ERROR_NOT_IMPLEMENTED; return BLE_ERROR_NOT_IMPLEMENTED;
#endif // BLE_ROLE_GATT_SERVER #endif // BLE_FEATURE_GATT_SERVER
} }
private: private:
#if BLE_ROLE_GATT_SERVER #if BLE_FEATURE_GATT_SERVER
ble::vendor::cordio::GattServer& gatt_server() { ble::vendor::cordio::GattServer& gatt_server() {
return ble::vendor::cordio::GattServer::getInstance(); return ble::vendor::cordio::GattServer::getInstance();
} }
#endif // BLE_ROLE_GATT_SERVER #endif // BLE_FEATURE_GATT_SERVER
}; };
} // cordio } // cordio

View File

@ -155,13 +155,13 @@ ble_error_t BLE::shutdown()
initialization_status = NOT_INITIALIZED; initialization_status = NOT_INITIALIZED;
_hci_driver->terminate(); _hci_driver->terminate();
#if BLE_ROLE_GATT_SERVER #if BLE_FEATURE_GATT_SERVER
getGattServer().reset(); getGattServer().reset();
#endif #endif
#if BLE_ROLE_GATT_CLIENT #if BLE_FEATURE_GATT_CLIENT
getGattClient().reset(); getGattClient().reset();
#endif // BLE_ROLE_GATT_CLIENT #endif // BLE_FEATURE_GATT_CLIENT
getGap().reset(); getGap().reset();
_event_queue.clear(); _event_queue.clear();
@ -194,7 +194,7 @@ const impl::GenericGapImpl& BLE::getGap() const
return const_cast<const impl::GenericGapImpl&>(self.getGap()); return const_cast<const impl::GenericGapImpl&>(self.getGap());
}; };
#if BLE_ROLE_GATT_SERVER #if BLE_FEATURE_GATT_SERVER
GattServer& BLE::getGattServer() GattServer& BLE::getGattServer()
{ {
return cordio::GattServer::getInstance(); return cordio::GattServer::getInstance();
@ -204,9 +204,9 @@ const GattServer& BLE::getGattServer() const
{ {
return cordio::GattServer::getInstance(); return cordio::GattServer::getInstance();
} }
#endif // BLE_ROLE_GATT_SERVER #endif // BLE_FEATURE_GATT_SERVER
#if BLE_ROLE_GATT_CLIENT #if BLE_FEATURE_GATT_CLIENT
impl::GenericGattClientImpl& BLE::getGattClient() impl::GenericGattClientImpl& BLE::getGattClient()
{ {
static impl::GenericGattClientImpl gatt_client(&getPalGattClient()); static impl::GenericGattClientImpl gatt_client(&getPalGattClient());
@ -222,9 +222,9 @@ impl::PalGattClientImpl& BLE::getPalGattClient()
return pal_client; return pal_client;
} }
#endif // BLE_ROLE_GATT_CLIENT #endif // BLE_FEATURE_GATT_CLIENT
#if BLE_ROLE_SECURITY #if BLE_FEATURE_SECURITY
SecurityManager& BLE::getSecurityManager() SecurityManager& BLE::getSecurityManager()
{ {
@ -244,7 +244,7 @@ const SecurityManager& BLE::getSecurityManager() const
return const_cast<const SecurityManager&>(self.getSecurityManager()); return const_cast<const SecurityManager&>(self.getSecurityManager());
} }
#endif // BLE_ROLE_SECURITY #endif // BLE_FEATURE_SECURITY
void BLE::waitForEvent() void BLE::waitForEvent()
{ {
@ -293,10 +293,10 @@ void BLE::processEvents()
DmExtConnSlaveInit(); DmExtConnSlaveInit();
} }
#if BLE_ROLE_GATT_SERVER #if BLE_FEATURE_GATT_SERVER
deviceInstance().getGattServer().initialize(); deviceInstance().getGattServer().initialize();
deviceInstance().initialization_status = INITIALIZED; deviceInstance().initialization_status = INITIALIZED;
#endif // BLE_ROLE_GATT_SERVER #endif // BLE_FEATURE_GATT_SERVER
_init_callback.call(&context); _init_callback.call(&context);
} break; } break;
@ -378,7 +378,7 @@ void BLE::stack_setup()
WsfTimerInit(); WsfTimerInit();
#if BLE_ROLE_SECURITY #if BLE_FEATURE_SECURITY
SecInit(); SecInit();
// Note: enable once security is supported // Note: enable once security is supported
@ -386,7 +386,7 @@ void BLE::stack_setup()
SecAesInit(); SecAesInit();
SecCmacInit(); SecCmacInit();
SecEccInit(); SecEccInit();
#endif // BLE_ROLE_SECURITY #endif // BLE_FEATURE_SECURITY
handlerId = WsfOsSetNextHandler(HciHandler); handlerId = WsfOsSetNextHandler(HciHandler);
HciHandlerInit(handlerId); HciHandlerInit(handlerId);
@ -413,21 +413,21 @@ void BLE::stack_setup()
DmConnSlaveInit(); DmConnSlaveInit();
#endif // BLE_ROLE_PERIPHERAL #endif // BLE_ROLE_PERIPHERAL
#if BLE_ROLE_SECURITY #if BLE_FEATURE_SECURITY
DmSecInit(); DmSecInit();
#endif // BLE_ROLE_SECURITY #endif // BLE_FEATURE_SECURITY
DmPhyInit(); DmPhyInit();
// Note: enable once security is supported // Note: enable once security is supported
#if BLE_ROLE_SECURITY #if BLE_FEATURE_SECURITY
DmSecLescInit(); DmSecLescInit();
#endif // BLE_ROLE_SECURITY #endif // BLE_FEATURE_SECURITY
#if BLE_ROLE_PRIVACY #if BLE_FEATURE_PRIVACY
DmPrivInit(); DmPrivInit();
#endif // BLE_ROLE_PRIVACY #endif // BLE_FEATURE_PRIVACY
DmHandlerInit(handlerId); DmHandlerInit(handlerId);
@ -437,7 +437,7 @@ void BLE::stack_setup()
L2cSlaveInit(); L2cSlaveInit();
L2cMasterInit(); L2cMasterInit();
#if BLE_ROLE_GATT_SERVER #if BLE_FEATURE_GATT_SERVER
handlerId = WsfOsSetNextHandler(AttHandler); handlerId = WsfOsSetNextHandler(AttHandler);
AttHandlerInit(handlerId); AttHandlerInit(handlerId);
AttsInit(); AttsInit();
@ -446,7 +446,7 @@ void BLE::stack_setup()
AttsAuthorRegister(GattServer::atts_auth_cb); AttsAuthorRegister(GattServer::atts_auth_cb);
AttcInit(); AttcInit();
AttcSignInit(); AttcSignInit();
#endif // BLE_ROLE_GATT_SERVER #endif // BLE_FEATURE_GATT_SERVER
handlerId = WsfOsSetNextHandler(SmpHandler); handlerId = WsfOsSetNextHandler(SmpHandler);
SmpHandlerInit(handlerId); SmpHandlerInit(handlerId);
@ -509,12 +509,12 @@ FunctionPointerWithContext< ::BLE::InitializationCompleteCallbackContext*> BLE::
template<> template<>
void SigningEventMonitor<impl::GenericSecurityManagerImpl>::set_signing_event_handler_(impl::GenericSecurityManagerImpl *handler) { void SigningEventMonitor<impl::GenericSecurityManagerImpl>::set_signing_event_handler_(impl::GenericSecurityManagerImpl *handler) {
#if BLE_ROLE_GATT_CLIENT #if BLE_FEATURE_GATT_CLIENT
BLE::deviceInstance().getGattClient().set_signing_event_handler(handler); BLE::deviceInstance().getGattClient().set_signing_event_handler(handler);
#endif // BLE_ROLE_GATT_CLIENT #endif // BLE_FEATURE_GATT_CLIENT
#if BLE_ROLE_GATT_SERVER #if BLE_FEATURE_GATT_SERVER
BLE::deviceInstance().getGattServer().set_signing_event_handler(handler); BLE::deviceInstance().getGattServer().set_signing_event_handler(handler);
#endif // BLE_ROLE_GATT_SERVER #endif // BLE_FEATURE_GATT_SERVER
} }
} // namespace cordio } // namespace cordio

View File

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
#if BLE_ROLE_GATT_SERVER #if BLE_FEATURE_GATT_SERVER
#include <algorithm> #include <algorithm>
#include "CordioBLE.h" #include "CordioBLE.h"
@ -1295,4 +1295,4 @@ GattServer::GattServer() :
} // namespace vendor } // namespace vendor
} // namespace ble } // namespace ble
#endif // BLE_ROLE_GATT_SERVER #endif // BLE_FEATURE_GATT_SERVER

View File

@ -51,35 +51,64 @@
"macro_name": "BLE_ROLE_BROADCASTER" "macro_name": "BLE_ROLE_BROADCASTER"
}, },
"ble-role-peripheral": { "ble-role-peripheral": {
"help": "Include peripheral BLE role support, depends on observer role, allows...", "help": "Include peripheral BLE role support, depends on observer role.",
"value": true, "value": true,
"macro_name": "BLE_ROLE_PERIPHERAL" "macro_name": "BLE_ROLE_PERIPHERAL"
}, },
"ble-role-central": { "ble-role-central": {
"help": "Include central BLE role support, depends on broadcaster role, allows...", "help": "Include central BLE role support, depends on broadcaster role.",
"value": true, "value": true,
"macro_name": "BLE_ROLE_CENTRAL" "macro_name": "BLE_ROLE_CENTRAL"
}, },
"ble-role-security": { "ble-feature-security": {
"help": "Include security BLE role support, depends on peripheral role, allows...", "help": "Include security BLE role support, depends on peripheral or central role.",
"value": true, "value": true,
"macro_name": "BLE_ROLE_SECURITY" "macro_name": "BLE_FEATURE_SECURITY"
}, },
"ble-role-privacy": { "ble-feature-secure-connections": {
"help": "Include security BLE role support, depends on security role, allows...", "help": "Include secure connections support, depends on the security feature.",
"value": true, "value": true,
"macro_name": "BLE_ROLE_PRIVACY" "macro_name": "BLE_FEATURE_SECURE_CONNECTIONS"
}, },
"ble-role-gatt-client": { "ble-feature-signing": {
"help": "Include Gatt Client BLE role support, depends on peripheral and central role, allows...", "help": "Include signing support, depends on the security feature.",
"value": true, "value": true,
"macro_name": "BLE_ROLE_GATT_CLIENT" "macro_name": "BLE_FEATURE_SIGNING"
}, },
"ble-role-gatt-server": { "ble-feature-whitelist": {
"help": "Include Gatt Server BLE role support, depends on security role, allows...", "help": "Include whitelist support, depends on the security feature.",
"value": true, "value": true,
"macro_name": "BLE_ROLE_GATT_SERVER" "macro_name": "BLE_FEATURE_WHITELIST"
>>>>>>> feat(ble): Add configuration options for enabling/disabling BLE roles },
"ble-feature-privacy": {
"help": "Include privacy support, depends on the security feature.",
"value": true,
"macro_name": "BLE_FEATURE_PRIVACY"
},
"ble-feature-phy-management": {
"help": "Include additional PHY support.",
"value": true,
"macro_name": "BLE_FEATURE_PHY_MANAGEMENT"
},
"ble-feature-extended-advertising": {
"help": "Include extended advertising support, depends on the phy management feature.",
"value": true,
"macro_name": "BLE_FEATURE_EXTENDED_ADVERTISING"
},
"ble-feature-periodic-advertising": {
"help": "Include periodic advertising support, depends on the extended advertising feature.",
"value": true,
"macro_name": "BLE_FEATURE_PERIODIC_ADVERTISING"
},
"ble-feature-gatt-client": {
"help": "Include Gatt Client BLE role support, depends on peripheral and central role.",
"value": true,
"macro_name": "BLE_FEATURE_GATT_CLIENT"
},
"ble-feature-gatt-server": {
"help": "Include Gatt Server BLE role support, depends on peripheral or central role.",
"value": true,
"macro_name": "BLE_FEATURE_GATT_SERVER"
} }
} }
}, },