broadcaster role cordio pass

pull/9790/head
paul-szczepanek-arm 2019-02-22 16:09:01 +00:00 committed by Vincent Coubard
parent c198603c63
commit eb16fb6053
14 changed files with 203 additions and 111 deletions

View File

@ -676,17 +676,22 @@ public:
{ {
} }
}; };
#endif // BLE_FEATURE_CONNECTABLE
#endif // BLE_FEATURE_CONNECTABLE
#if BLE_FEATURE_PRIVACY
#if BLE_ROLE_PERIPHERAL
/** /**
* @copydoc ble::peripheral_privacy_configuration_t * @copydoc ble::peripheral_privacy_configuration_t
*/ */
typedef ble::peripheral_privacy_configuration_t PeripheralPrivacyConfiguration_t; typedef ble::peripheral_privacy_configuration_t PeripheralPrivacyConfiguration_t;
#endif // BLE_ROLE_PERIPHERAL
#if BLE_ROLE_CENTRAL
/** /**
* @copydoc ble::central_privay_configuration_t * @copydoc ble::central_privay_configuration_t
*/ */
typedef ble::central_privay_configuration_t CentralPrivacyConfiguration_t; typedef ble::central_privay_configuration_t CentralPrivacyConfiguration_t;
#endif // BLE_ROLE_CENTRAL
#endif // BLE_FEATURE_PRIVACY
/** /**
* Number of microseconds in 1.25 milliseconds. * Number of microseconds in 1.25 milliseconds.
@ -722,7 +727,7 @@ public:
*/ */
typedef CallChainOfFunctionPointersWithContext<TimeoutSource_t> typedef CallChainOfFunctionPointersWithContext<TimeoutSource_t>
TimeoutEventCallbackChain_t; TimeoutEventCallbackChain_t;
#if BLE_FEATURE_CONNECTABLE
/** /**
* Connection event handler. * Connection event handler.
* *
@ -754,7 +759,7 @@ public:
*/ */
typedef CallChainOfFunctionPointersWithContext<const DisconnectionCallbackParams_t *> typedef CallChainOfFunctionPointersWithContext<const DisconnectionCallbackParams_t *>
DisconnectionEventCallbackChain_t; DisconnectionEventCallbackChain_t;
#endif // BLE_FEATURE_CONNECTABLE
/** /**
* Radio notification event handler. * Radio notification event handler.
* *

View File

@ -511,6 +511,7 @@ public:
) )
{ {
} }
#endif // BLE_FEATURE_PHY_MANAGEMENT
/** /**
* Function invoked when the connections changes the maximum number of octets * Function invoked when the connections changes the maximum number of octets
@ -531,7 +532,6 @@ public:
) )
{ {
} }
#endif // BLE_FEATURE_PHY_MANAGEMENT
protected: protected:
/** /**
* Prevent polymorphic deletion and avoid unnecessary virtual destructor * Prevent polymorphic deletion and avoid unnecessary virtual destructor

View File

@ -126,8 +126,10 @@ public:
*/ */
GenericGap( GenericGap(
pal::EventQueue &event_queue, pal::EventQueue &event_queue,
PalGap &pal_gap, PalGap &pal_gap
pal::GenericAccessService &generic_access_service #if BLE_FEATURE_GATT_SERVER
, pal::GenericAccessService &generic_access_service
#endif
#if BLE_FEATURE_SECURITY #if BLE_FEATURE_SECURITY
PalSecurityManager &pal_sm PalSecurityManager &pal_sm
#endif #endif
@ -553,6 +555,8 @@ public:
*/ */
ble_error_t enablePrivacy_(bool enable); ble_error_t enablePrivacy_(bool enable);
#if BLE_FEATURE_PRIVACY
#if BLE_ROLE_BROADCASTER
/** /**
* @see Gap::setPeripheralPrivacyConfiguration * @see Gap::setPeripheralPrivacyConfiguration
*/ */
@ -566,7 +570,8 @@ public:
ble_error_t getPeripheralPrivacyConfiguration_( ble_error_t getPeripheralPrivacyConfiguration_(
PeripheralPrivacyConfiguration_t *configuration PeripheralPrivacyConfiguration_t *configuration
); );
#endif // BLE_ROLE_BROADCASTER
#if BLE_ROLE_OBSERVER
/** /**
* @see Gap::setCentralPrivacyConfiguration * @see Gap::setCentralPrivacyConfiguration
*/ */
@ -580,6 +585,8 @@ public:
ble_error_t getCentralPrivacyConfiguration_( ble_error_t getCentralPrivacyConfiguration_(
CentralPrivacyConfiguration_t *configuration CentralPrivacyConfiguration_t *configuration
); );
#endif // BLE_ROLE_OBSERVER
#endif // BLE_FEATURE_PRIVACY
/** /**
* @see Gap::setAdvertisingData * @see Gap::setAdvertisingData

View File

@ -1,75 +1,75 @@
{ {
"name": "ble", "name": "ble",
"config": { "config": {
"ble-role-observer": { "ble-feature-observer": {
"help": "Include observer BLE role support (scanning for and processing advertising packets).", "help": "Include observer BLE role support, allows listening for and processing advertising packets.",
"value": true, "value": false,
"macro_name": "BLE_ROLE_OBSERVER" "macro_name": "BLE_ROLE_OBSERVER"
}, },
"ble-role-broadcaster": { "ble-role-broadcaster": {
"help": "Include broadcaster BLE role support (sending advertising packets).", "help": "Include broadcaster BLE role support, allows sending advertising packets.",
"value": true, "value": true,
"macro_name": "BLE_ROLE_BROADCASTER" "macro_name": "BLE_ROLE_BROADCASTER"
}, },
"ble-role-central": { "ble-role-peripheral": {
"help": "Include central BLE role support (initiates connections), depends on observer role.", "help": "Include peripheral BLE role support, depends on observer role.",
"value": true, "value": false,
"macro_name": "BLE_ROLE_CENTRAL" "macro_name": "BLE_ROLE_PERIPHERAL"
}, },
"ble-role-peripheral": { "ble-role-central": {
"help": "Include peripheral BLE role support (accepts connections), depends on broadcaster role.", "help": "Include central BLE role support, depends on broadcaster role.",
"value": true, "value": false,
"macro_name": "BLE_ROLE_PERIPHERAL" "macro_name": "BLE_ROLE_CENTRAL"
}, },
"ble-feature-gatt-client": { "ble-feature-security": {
"help": "Include Gatt Client BLE role support (requests remote operations on attributes), depends on peripheral and central role.", "help": "Include security BLE role support, depends on peripheral or central role.",
"value": true, "value": false,
"macro_name": "BLE_FEATURE_GATT_CLIENT" "macro_name": "BLE_FEATURE_SECURITY"
}, },
"ble-feature-gatt-server": { "ble-feature-secure-connections": {
"help": "Include Gatt Server BLE role support (executes operations on stored attributes), depends on peripheral or central role.", "help": "Include secure connections support, depends on the security feature.",
"value": true, "value": false,
"macro_name": "BLE_FEATURE_GATT_SERVER" "macro_name": "BLE_FEATURE_SECURE_CONNECTIONS"
}, },
"ble-feature-security": { "ble-feature-signing": {
"help": "Include security support (key management), depends on peripheral or central role.", "help": "Include signing support, depends on the security feature.",
"value": true, "value": false,
"macro_name": "BLE_FEATURE_SECURITY" "macro_name": "BLE_FEATURE_SIGNING"
}, },
"ble-feature-secure-connections": { "ble-feature-whitelist": {
"help": "Include secure connections support, depends on the security feature.", "help": "Include whitelist support, depends on the security feature.",
"value": true, "value": false,
"macro_name": "BLE_FEATURE_SECURE_CONNECTIONS" "macro_name": "BLE_FEATURE_WHITELIST"
}, },
"ble-feature-signing": { "ble-feature-privacy": {
"help": "Include signing support (signed attribute writes), depends on the security feature.", "help": "Include privacy support, depends on the security feature.",
"value": true, "value": false,
"macro_name": "BLE_FEATURE_SIGNING" "macro_name": "BLE_FEATURE_PRIVACY"
}, },
"ble-feature-whitelist": { "ble-feature-phy-management": {
"help": "Include whitelist support (peer filtering), depends on the security feature.", "help": "Include additional PHY support.",
"value": true, "value": false,
"macro_name": "BLE_FEATURE_WHITELIST" "macro_name": "BLE_FEATURE_PHY_MANAGEMENT"
}, },
"ble-feature-privacy": { "ble-feature-extended-advertising": {
"help": "Include privacy support (random resolvable addresses), depends on the security feature.", "help": "Include extended advertising support, depends on the phy management feature.",
"value": true, "value": false,
"macro_name": "BLE_FEATURE_PRIVACY" "macro_name": "BLE_FEATURE_EXTENDED_ADVERTISING"
}, },
"ble-feature-phy-management": { "ble-feature-periodic-advertising": {
"help": "Additional PHY support (2M and Coded)", "help": "Include periodic advertising support, depends on the extended advertising feature.",
"value": true, "value": false,
"macro_name": "BLE_FEATURE_PHY_MANAGEMENT" "macro_name": "BLE_FEATURE_PERIODIC_ADVERTISING"
}, },
"ble-feature-extended-advertising": { "ble-feature-gatt-client": {
"help": "Include extended advertising support (advertising sets, secondary channels), depends on the phy management feature.", "help": "Include Gatt Client BLE role support, depends on peripheral and central role.",
"value": true, "value": false,
"macro_name": "BLE_FEATURE_EXTENDED_ADVERTISING" "macro_name": "BLE_FEATURE_GATT_CLIENT"
}, },
"ble-feature-periodic-advertising": { "ble-feature-gatt-server": {
"help": "Include periodic advertising support, depends on the extended advertising feature.", "help": "Include Gatt Server BLE role support, depends on peripheral or central role.",
"value": true, "value": false,
"macro_name": "BLE_FEATURE_PERIODIC_ADVERTISING" "macro_name": "BLE_FEATURE_GATT_SERVER"
} }
} }
} }

View File

@ -369,6 +369,7 @@ ble_error_t BLE::setAddress(
return gap().setAddress(type, address); return gap().setAddress(type, address);
} }
#if BLE_ROLE_CENTRAL
ble_error_t BLE::connect( ble_error_t BLE::connect(
const BLEProtocol::AddressBytes_t peerAddr, const BLEProtocol::AddressBytes_t peerAddr,
BLEProtocol::AddressType_t peerAddrType, BLEProtocol::AddressType_t peerAddrType,
@ -377,15 +378,19 @@ ble_error_t BLE::connect(
) { ) {
return gap().connect(peerAddr, peerAddrType, connectionParams, scanParams); return gap().connect(peerAddr, peerAddrType, connectionParams, scanParams);
} }
#endif // BLE_ROLE_CENTRAL
#if BLE_FEATURE_CONNECTABLE
ble_error_t BLE::disconnect(Gap::DisconnectionReason_t reason) { ble_error_t BLE::disconnect(Gap::DisconnectionReason_t reason) {
return gap().disconnect(reason); return gap().disconnect(reason);
} }
#endif // BLE_FEATURE_CONNECTABLE
Gap::GapState_t BLE::getGapState(void) const { Gap::GapState_t BLE::getGapState(void) const {
return gap().getState(); return gap().getState();
} }
#if BLE_ROLE_BROADCASTER
void BLE::setAdvertisingType(GapAdvertisingParams::AdvertisingType advType) { void BLE::setAdvertisingType(GapAdvertisingParams::AdvertisingType advType) {
gap().setAdvertisingType(advType); gap().setAdvertisingType(advType);
} }
@ -453,7 +458,9 @@ ble_error_t BLE::startAdvertising(void) {
ble_error_t BLE::stopAdvertising(void) { ble_error_t BLE::stopAdvertising(void) {
return gap().stopAdvertising(); return gap().stopAdvertising();
} }
#endif // BLE_ROLE_BROADCASTER
#if BLE_ROLE_OBSERVER
ble_error_t BLE::setScanParams(uint16_t interval, ble_error_t BLE::setScanParams(uint16_t interval,
uint16_t window, uint16_t window,
uint16_t timeout, uint16_t timeout,
@ -480,7 +487,9 @@ void BLE::setActiveScan(bool activeScanning) {
ble_error_t BLE::startScan(void (*callback)(const Gap::AdvertisementCallbackParams_t *params)) { ble_error_t BLE::startScan(void (*callback)(const Gap::AdvertisementCallbackParams_t *params)) {
return gap().startScan(callback); return gap().startScan(callback);
} }
#endif // BLE_ROLE_OBSERVER
#if BLE_FEATURE_CONNECTABLE
ble_error_t BLE::disconnect(Gap::Handle_t connectionHandle, Gap::DisconnectionReason_t reason) { ble_error_t BLE::disconnect(Gap::Handle_t connectionHandle, Gap::DisconnectionReason_t reason) {
return gap().disconnect(connectionHandle, reason); return gap().disconnect(connectionHandle, reason);
} }
@ -488,6 +497,7 @@ ble_error_t BLE::disconnect(Gap::Handle_t connectionHandle, Gap::DisconnectionRe
ble_error_t BLE::updateConnectionParams(Gap::Handle_t handle, const Gap::ConnectionParams_t *params) { ble_error_t BLE::updateConnectionParams(Gap::Handle_t handle, const Gap::ConnectionParams_t *params) {
return gap().updateConnectionParams(handle, params); return gap().updateConnectionParams(handle, params);
} }
#endif // BLE_FEATURE_CONNECTABLE
ble_error_t BLE::setTxPower(int8_t txPower) { ble_error_t BLE::setTxPower(int8_t txPower) {
return gap().setTxPower(txPower); return gap().setTxPower(txPower);
@ -501,9 +511,11 @@ void BLE::onTimeout(Gap::TimeoutEventCallback_t timeoutCallback) {
gap().onTimeout(timeoutCallback); gap().onTimeout(timeoutCallback);
} }
#if BLE_FEATURE_CONNECTABLE
void BLE::onDisconnection(Gap::DisconnectionEventCallback_t disconnectionCallback) { void BLE::onDisconnection(Gap::DisconnectionEventCallback_t disconnectionCallback) {
gap().onDisconnection(disconnectionCallback); gap().onDisconnection(disconnectionCallback);
} }
#endif // BLE_FEATURE_CONNECTABLE
void BLE::onRadioNotification(void (*callback)(bool)) { void BLE::onRadioNotification(void (*callback)(bool)) {
gap().onRadioNotification(callback); gap().onRadioNotification(callback);

View File

@ -14,6 +14,10 @@
* limitations under the License. * limitations under the License.
*/ */
#include "BLERoles.h"
#if BLE_ROLE_OBSERVER
#include "ble/Gap.h" #include "ble/Gap.h"
#include "ble/GapScanningParams.h" #include "ble/GapScanningParams.h"
@ -73,3 +77,5 @@ GapScanningParams::setActiveScanning(bool activeScanning)
{ {
_activeScanning = activeScanning; _activeScanning = activeScanning;
} }
#endif

View File

@ -74,6 +74,7 @@ ble::peer_address_type_t convert_legacy_address_type(
namespace ble { namespace ble {
namespace interface { namespace interface {
#if BLE_FEATURE_WHITELIST
template<class Impl> template<class Impl>
uint8_t LegacyGap<Impl>::getMaxWhitelistSize(void) const { uint8_t LegacyGap<Impl>::getMaxWhitelistSize(void) const {
return impl()->getMaxWhitelistSize_(); return impl()->getMaxWhitelistSize_();
@ -88,7 +89,9 @@ template<class Impl>
ble_error_t LegacyGap<Impl>::setWhitelist(const Whitelist_t &whitelist) { ble_error_t LegacyGap<Impl>::setWhitelist(const Whitelist_t &whitelist) {
return impl()->setWhitelist_(whitelist); return impl()->setWhitelist_(whitelist);
} }
#endif // BLE_FEATURE_WHITELIST
#if BLE_FEATURE_CONNECTABLE
template<class Impl> template<class Impl>
void LegacyGap<Impl>::processConnectionEvent( void LegacyGap<Impl>::processConnectionEvent(
Handle_t handle, Handle_t handle,
@ -120,6 +123,7 @@ void LegacyGap<Impl>::processConnectionEvent(
connectionCallChain.call(&callbackParams); connectionCallChain.call(&callbackParams);
} }
#endif // BLE_FEATURE_CONNECTABLE
template<class Impl> template<class Impl>
ble_error_t LegacyGap<Impl>::setAddress( ble_error_t LegacyGap<Impl>::setAddress(
@ -137,11 +141,14 @@ ble_error_t LegacyGap<Impl>::getAddress(
return impl()->getAddress_(typeP, address); return impl()->getAddress_(typeP, address);
} }
#if BLE_ROLE_BROADCASTER
template<class Impl> template<class Impl>
ble_error_t LegacyGap<Impl>::stopAdvertising(void) { ble_error_t LegacyGap<Impl>::stopAdvertising(void) {
return impl()->stopAdvertising_(); return impl()->stopAdvertising_();
} }
#endif // BLE_ROLE_BROADCASTER
#if BLE_ROLE_CENTRAL
template<class Impl> template<class Impl>
ble_error_t LegacyGap<Impl>::connect( ble_error_t LegacyGap<Impl>::connect(
const BLEProtocol::AddressBytes_t peerAddr, const BLEProtocol::AddressBytes_t peerAddr,
@ -171,7 +178,9 @@ ble_error_t LegacyGap<Impl>::connect(
scanParams scanParams
); );
} }
#endif // BLE_ROLE_CENTRAL
#if BLE_FEATURE_CONNECTABLE
template<class Impl> template<class Impl>
ble_error_t LegacyGap<Impl>::disconnect( ble_error_t LegacyGap<Impl>::disconnect(
Handle_t connectionHandle, DisconnectionReason_t reason Handle_t connectionHandle, DisconnectionReason_t reason
@ -191,7 +200,7 @@ ble_error_t LegacyGap<Impl>::updateConnectionParams(
) { ) {
return impl()->updateConnectionParams_(handle, params); return impl()->updateConnectionParams_(handle, params);
} }
#endif // BLE_FEATURE_CONNECTABLE
template<class Impl> template<class Impl>
ble_error_t LegacyGap<Impl>::setTxPower(int8_t txPower) { ble_error_t LegacyGap<Impl>::setTxPower(int8_t txPower) {
@ -205,43 +214,53 @@ void LegacyGap<Impl>::getPermittedTxPowerValues(
return impl()->getPermittedTxPowerValues_(valueArrayPP, countP); return impl()->getPermittedTxPowerValues_(valueArrayPP, countP);
} }
#if BLE_FEATEURE_WHITELIST
#if BLE_ROLE_BROADCASTER
template<class Impl> template<class Impl>
ble_error_t LegacyGap<Impl>::setAdvertisingPolicyMode(AdvertisingPolicyMode_t mode) { ble_error_t LegacyGap<Impl>::setAdvertisingPolicyMode(AdvertisingPolicyMode_t mode) {
return impl()->setAdvertisingPolicyMode_(mode); return impl()->setAdvertisingPolicyMode_(mode);
} }
template<class Impl>
ble_error_t LegacyGap<Impl>::setScanningPolicyMode(ScanningPolicyMode_t mode) {
return impl()->setScanningPolicyMode_(mode);
}
template<class Impl>
ble_error_t LegacyGap<Impl>::setInitiatorPolicyMode(InitiatorPolicyMode_t mode) {
return impl()->setInitiatorPolicyMode_(mode);
}
template<class Impl> template<class Impl>
typename LegacyGap<Impl>::AdvertisingPolicyMode_t typename LegacyGap<Impl>::AdvertisingPolicyMode_t
LegacyGap<Impl>::getAdvertisingPolicyMode(void) const { LegacyGap<Impl>::getAdvertisingPolicyMode(void) const {
return impl()->getAdvertisingPolicyMode_(); return impl()->getAdvertisingPolicyMode_();
} }
#endif // BLE_ROLE_BROADCASTER
#if BLE_ROLE_OBSERVER
template<class Impl>
ble_error_t LegacyGap<Impl>::setScanningPolicyMode(ScanningPolicyMode_t mode) {
return impl()->setScanningPolicyMode_(mode);
}
template<class Impl> template<class Impl>
typename LegacyGap<Impl>::ScanningPolicyMode_t typename LegacyGap<Impl>::ScanningPolicyMode_t
LegacyGap<Impl>::getScanningPolicyMode(void) const { LegacyGap<Impl>::getScanningPolicyMode(void) const {
return impl()->getScanningPolicyMode_(); return impl()->getScanningPolicyMode_();
} }
#endif // BLE_ROLE_OBSERVER
#if BLE_ROLE_CENTRAL
template<class Impl>
ble_error_t LegacyGap<Impl>::setInitiatorPolicyMode(InitiatorPolicyMode_t mode) {
return impl()->setInitiatorPolicyMode_(mode);
}
template<class Impl> template<class Impl>
typename LegacyGap<Impl>::InitiatorPolicyMode_t typename LegacyGap<Impl>::InitiatorPolicyMode_t
LegacyGap<Impl>::getInitiatorPolicyMode(void) const { LegacyGap<Impl>::getInitiatorPolicyMode(void) const {
return impl()->getInitiatorPolicyMode_(); return impl()->getInitiatorPolicyMode_();
} }
#endif // BLE_ROLE_CENTRAL
#endif // BLE_FEATEURE_WHITELIST
#if BLE_ROLE_OBSERVER
template<class Impl> template<class Impl>
ble_error_t LegacyGap<Impl>::startRadioScan(const GapScanningParams &scanningParams) { ble_error_t LegacyGap<Impl>::startRadioScan(const GapScanningParams &scanningParams) {
return impl()->startRadioScan_(scanningParams); return impl()->startRadioScan_(scanningParams);
} }
#endif // BLE_ROLE_OBSERVER
template<class Impl> template<class Impl>
ble_error_t LegacyGap<Impl>::initRadioNotification(void) { ble_error_t LegacyGap<Impl>::initRadioNotification(void) {
@ -264,6 +283,7 @@ typename LegacyGap<Impl>::GapState_t LegacyGap<Impl>::getState(void) const
return state; return state;
} }
#if BLE_ROLE_BROADCASTER
template<class Impl> template<class Impl>
void LegacyGap<Impl>::setAdvertisingType(GapAdvertisingParams::AdvertisingType_t advType) void LegacyGap<Impl>::setAdvertisingType(GapAdvertisingParams::AdvertisingType_t advType)
{ {
@ -432,7 +452,9 @@ void LegacyGap<Impl>::clearScanResponse(void)
_scanResponse.clear(); _scanResponse.clear();
setAdvertisingData(_advPayload, _scanResponse); setAdvertisingData(_advPayload, _scanResponse);
} }
#endif // BLE_ROLE_BROADCASTER
#if BLE_ROLE_OBSERVER
template<class Impl> template<class Impl>
ble_error_t LegacyGap<Impl>::setScanParams( ble_error_t LegacyGap<Impl>::setScanParams(
uint16_t interval, uint16_t interval,
@ -526,7 +548,9 @@ ble_error_t LegacyGap<Impl>::startScan(
return err; return err;
} }
#endif // BLE_ROLE_OBSERVER
#if BLE_ROLE_BROADCASTER
template<class Impl> template<class Impl>
GapAdvertisingParams &LegacyGap<Impl>::getAdvertisingParams(void) GapAdvertisingParams &LegacyGap<Impl>::getAdvertisingParams(void)
{ {
@ -544,6 +568,7 @@ void LegacyGap<Impl>::setAdvertisingParams(const GapAdvertisingParams &newParams
{ {
_advParams = newParams; _advParams = newParams;
} }
#endif // BLE_ROLE_BROADCASTER
template<class Impl> template<class Impl>
void LegacyGap<Impl>::onTimeout(TimeoutEventCallback_t callback) void LegacyGap<Impl>::onTimeout(TimeoutEventCallback_t callback)
@ -557,6 +582,7 @@ typename LegacyGap<Impl>::TimeoutEventCallbackChain_t& LegacyGap<Impl>::onTimeou
return timeoutCallbackChain; return timeoutCallbackChain;
} }
#if BLE_FEATURE_CONNECTION
template<class Impl> template<class Impl>
void LegacyGap<Impl>::onConnection(ConnectionEventCallback_t callback) void LegacyGap<Impl>::onConnection(ConnectionEventCallback_t callback)
{ {
@ -574,6 +600,7 @@ void LegacyGap<Impl>::onDisconnection(DisconnectionEventCallback_t callback)
{ {
disconnectionCallChain.add(callback); disconnectionCallChain.add(callback);
} }
#endif // BLE_FEATURE_CONNECTION
template<class Impl> template<class Impl>
typename LegacyGap<Impl>::DisconnectionEventCallbackChain_t& LegacyGap<Impl>::onDisconnection() typename LegacyGap<Impl>::DisconnectionEventCallbackChain_t& LegacyGap<Impl>::onDisconnection()
@ -599,6 +626,7 @@ typename LegacyGap<Impl>::GapShutdownCallbackChain_t& LegacyGap<Impl>::onShutdow
return shutdownCallChain; return shutdownCallChain;
} }
#if BLE_ROLE_OBSERVER
template<class Impl> template<class Impl>
LegacyGap<Impl>::AdvertisementCallbackParams_t::AdvertisementCallbackParams_t() : LegacyGap<Impl>::AdvertisementCallbackParams_t::AdvertisementCallbackParams_t() :
peerAddr(), peerAddr(),
@ -611,6 +639,7 @@ LegacyGap<Impl>::AdvertisementCallbackParams_t::AdvertisementCallbackParams_t()
peerAddrType(PeerAddressType_t::PUBLIC) peerAddrType(PeerAddressType_t::PUBLIC)
{ {
} }
#endif // BLE_ROLE_OBSERVER
template<class Impl> template<class Impl>
ble_error_t LegacyGap<Impl>::getRandomAddressType( ble_error_t LegacyGap<Impl>::getRandomAddressType(
@ -634,6 +663,7 @@ ble_error_t LegacyGap<Impl>::getRandomAddressType(
} }
} }
#if BLE_FEATURE_CONNECTABLE
template<class Impl> template<class Impl>
LegacyGap<Impl>::ConnectionCallbackParams_t::ConnectionCallbackParams_t( LegacyGap<Impl>::ConnectionCallbackParams_t::ConnectionCallbackParams_t(
Handle_t handleIn, Handle_t handleIn,
@ -723,7 +753,9 @@ void LegacyGap<Impl>::ConnectionCallbackParams_t::constructor_helper(
memset(ownAddr, 0, ADDR_LEN); memset(ownAddr, 0, ADDR_LEN);
} }
} }
#endif // BLE_FEATURE_CONNECTABLE
#if BLE_ROLE_CENTRAL
template<class Impl> template<class Impl>
ble_error_t LegacyGap<Impl>::connect( ble_error_t LegacyGap<Impl>::connect(
const BLEProtocol::AddressBytes_t peerAddr, const BLEProtocol::AddressBytes_t peerAddr,
@ -738,7 +770,9 @@ ble_error_t LegacyGap<Impl>::connect(
scanParams scanParams
); );
} }
#endif // BLE_ROLE_CENTRAL
#if BLE_FEATURE_CONNECTABLE
template<class Impl> template<class Impl>
void LegacyGap<Impl>::processConnectionEvent( void LegacyGap<Impl>::processConnectionEvent(
Handle_t handle, Handle_t handle,
@ -770,7 +804,9 @@ void LegacyGap<Impl>::processConnectionEvent(
connectionCallChain.call(&callbackParams); connectionCallChain.call(&callbackParams);
} }
#endif // BLE_FEATURE_CONNECTABLE
#if BLE_ROLE_OBSERVER
template<class Impl> template<class Impl>
void LegacyGap<Impl>::processAdvertisementReport( void LegacyGap<Impl>::processAdvertisementReport(
const BLEProtocol::AddressBytes_t peerAddr, const BLEProtocol::AddressBytes_t peerAddr,
@ -822,6 +858,7 @@ void LegacyGap<Impl>::processAdvertisementReport(
onAdvertisementReport.call(&params); onAdvertisementReport.call(&params);
} }
#endif // BLE_ROLE_OBSERVER
#if defined(__GNUC__) && !defined(__CC_ARM) #if defined(__GNUC__) && !defined(__CC_ARM)
#pragma GCC diagnostic pop #pragma GCC diagnostic pop
@ -995,7 +1032,6 @@ ble_error_t LegacyGap<Impl>::reset_(void)
connectionCount = 0; connectionCount = 0;
#endif #endif
/* Clear scanning state */ /* Clear scanning state */
#if BLE_ROLE_OBSERVER #if BLE_ROLE_OBSERVER
scanningActive = false; scanningActive = false;
@ -1014,8 +1050,10 @@ ble_error_t LegacyGap<Impl>::reset_(void)
disconnectionCallChain.clear(); disconnectionCallChain.clear();
#endif // BLE_FEATURE_CONNECTABLE #endif // BLE_FEATURE_CONNECTABLE
radioNotificationCallback = NULL; radioNotificationCallback = NULL;
#if BLE_ROLE_OBSERVER
onAdvertisementReport = NULL; onAdvertisementReport = NULL;
ble::interface::Gap<Impl>::_eventHandler = NULL; #endif
_eventHandler = NULL;
return BLE_ERROR_NONE; return BLE_ERROR_NONE;
} }

View File

@ -49,6 +49,7 @@ uint16_t Gap<Impl>::getMaxActiveSetAdvertisingDataLength()
return impl()->getMaxActiveSetAdvertisingDataLength_(); return impl()->getMaxActiveSetAdvertisingDataLength_();
} }
#if BLE_FEATURE_EXTENDED_ADVERTISING
template<class Impl> template<class Impl>
ble_error_t Gap<Impl>::createAdvertisingSet( ble_error_t Gap<Impl>::createAdvertisingSet(
advertising_handle_t *handle, advertising_handle_t *handle,
@ -63,6 +64,7 @@ ble_error_t Gap<Impl>::destroyAdvertisingSet(advertising_handle_t handle)
{ {
return impl()->destroyAdvertisingSet_(handle); return impl()->destroyAdvertisingSet_(handle);
} }
#endif // BLE_FEATURE_EXTENDED_ADVERTISING
template<class Impl> template<class Impl>
ble_error_t Gap<Impl>::setAdvertisingParameters( ble_error_t Gap<Impl>::setAdvertisingParameters(
@ -406,6 +408,7 @@ Gap<Impl>::Gap() : _eventHandler(NULL)
/* -------------------- Future deprecation ------------------------- */ /* -------------------- Future deprecation ------------------------- */
#if BLE_FEATURE_PRIVACY
template<class Impl> template<class Impl>
const peripheral_privacy_configuration_t Gap<Impl>::default_peripheral_privacy_configuration = { const peripheral_privacy_configuration_t Gap<Impl>::default_peripheral_privacy_configuration = {
/* use_non_resolvable_random_address */ false, /* use_non_resolvable_random_address */ false,
@ -417,6 +420,7 @@ const central_privay_configuration_t Gap<Impl>::default_central_privacy_configur
/* use_non_resolvable_random_address */ false, /* use_non_resolvable_random_address */ false,
/* resolution_strategy */ central_privay_configuration_t::RESOLVE_AND_FORWARD /* resolution_strategy */ central_privay_configuration_t::RESOLVE_AND_FORWARD
}; };
#endif // BLE_FEATURE_PRIVACY
#if BLE_FEATURE_PRIVACY #if BLE_FEATURE_PRIVACY
template<class Impl> template<class Impl>

View File

@ -482,9 +482,8 @@ GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::
); );
} }
#endif // BLE_FEATURE_EXTENDED_ADVERTISING
_existing_sets.set(LEGACY_ADVERTISING_HANDLE); _existing_sets.set(LEGACY_ADVERTISING_HANDLE);
#endif // BLE_FEATURE_EXTENDED_ADVERTISING
} }
template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler> template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>
@ -1204,7 +1203,6 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
return BLE_ERROR_NONE; return BLE_ERROR_NONE;
} }
#endif // BLE_FEATURE_WHITELIST
#if BLE_ROLE_BROADCASTER #if BLE_ROLE_BROADCASTER
template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler> template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>
@ -1271,6 +1269,7 @@ typename GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventH
return (InitiatorPolicyMode_t) _initiator_policy_mode.value(); return (InitiatorPolicyMode_t) _initiator_policy_mode.value();
} }
#endif // BLE_ROLE_CENTRAL #endif // BLE_ROLE_CENTRAL
#endif // BLE_FEATURE_WHITELIST
#if BLE_ROLE_OBSERVER #if BLE_ROLE_OBSERVER
template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler> template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>
@ -1548,9 +1547,9 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
AdvertisingParameters() AdvertisingParameters()
); );
} }
#endif // BLE_FEATURE_EXTENDED_ADVERTISING
_existing_sets.set(LEGACY_ADVERTISING_HANDLE); _existing_sets.set(LEGACY_ADVERTISING_HANDLE);
#endif // BLE_FEATURE_EXTENDED_ADVERTISING
return BLE_ERROR_NONE; return BLE_ERROR_NONE;
} }
@ -2600,7 +2599,7 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
) )
{ {
useVersionTwoAPI(); useVersionTwoAPI();
#if BLE_FEATURE_EXTENDED_ADVERTISING
ble_error_t error = BLE_ERROR_NONE; ble_error_t error = BLE_ERROR_NONE;
if (handle >= getMaxAdvertisingSetNumber()) { if (handle >= getMaxAdvertisingSetNumber()) {
@ -2616,7 +2615,6 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
return BLE_ERROR_INVALID_STATE; return BLE_ERROR_INVALID_STATE;
} }
#if BLE_FEATURE_EXTENDED_ADVERTISING
if (is_extended_advertising_available()) { if (is_extended_advertising_available()) {
error = _pal_gap.extended_advertising_enable( error = _pal_gap.extended_advertising_enable(
/* enable */ true, /* enable */ true,
@ -2660,6 +2658,9 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
{ {
useVersionTwoAPI(); useVersionTwoAPI();
ble_error_t status;
#if BLE_FEATURE_EXTENDED_ADVERTISING
if (handle >= getMaxAdvertisingSetNumber()) { if (handle >= getMaxAdvertisingSetNumber()) {
return BLE_ERROR_INVALID_PARAM; return BLE_ERROR_INVALID_PARAM;
} }
@ -2672,9 +2673,6 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
return BLE_ERROR_INVALID_STATE; return BLE_ERROR_INVALID_STATE;
} }
ble_error_t status;
#if BLE_FEATURE_EXTENDED_ADVERTISING
if (is_extended_advertising_available()) { if (is_extended_advertising_available()) {
status = _pal_gap.extended_advertising_enable( status = _pal_gap.extended_advertising_enable(
/*enable ? */ false, /*enable ? */ false,
@ -2936,7 +2934,7 @@ void GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandl
} }
#endif // BLE_FEATURE_CONNECTABLE #endif // BLE_FEATURE_CONNECTABLE
#if BLE_ROLE_BROADCASTER #if BLE_ROLE_OBSERVER
template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler> template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>
void GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::on_extended_advertising_report_( void GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::on_extended_advertising_report_(
advertising_event_t event_type, advertising_event_t event_type,
@ -2977,7 +2975,7 @@ void GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandl
) )
); );
} }
#endif // BLE_ROLE_BROADCASTER #endif // BLE_ROLE_OBSERVER
#if BLE_FEATURE_PERIODIC_ADVERTISING #if BLE_FEATURE_PERIODIC_ADVERTISING
#if BLE_ROLE_OBSERVER #if BLE_ROLE_OBSERVER

View File

@ -14,6 +14,10 @@
* limitations under the License. * limitations under the License.
*/ */
#include "BLERoles.h"
#if BLE_FEATURE_GATT_SERVER
#ifdef TARGET_NRF51822 /* DFU only supported on nrf51 platforms */ #ifdef TARGET_NRF51822 /* DFU only supported on nrf51 platforms */
#include "ble/services/DFUService.h" #include "ble/services/DFUService.h"
@ -42,3 +46,5 @@ const uint8_t DFUServicePacketCharacteristicUUID[] = {
DFUService::ResetPrepare_t DFUService::handoverCallback = NULL; DFUService::ResetPrepare_t DFUService::handoverCallback = NULL;
#endif /* #ifdef TARGET_NRF51822 */ #endif /* #ifdef TARGET_NRF51822 */
#endif // BLE_FEATURE_GATT_SERVER

View File

@ -14,6 +14,10 @@
* limitations under the License. * limitations under the License.
*/ */
#include "BLERoles.h"
#if BLE_FEATURE_GATT_SERVER
#include "ble/services/UARTService.h" #include "ble/services/UARTService.h"
const uint8_t UARTServiceBaseUUID[UUID::LENGTH_OF_LONG_UUID] = { const uint8_t UARTServiceBaseUUID[UUID::LENGTH_OF_LONG_UUID] = {
@ -40,3 +44,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_FEATURE_GATT_SERVER

View File

@ -14,6 +14,10 @@
* limitations under the License. * limitations under the License.
*/ */
#include "BLERoles.h"
#if BLE_FEATURE_GATT_SERVER
#include "ble/services/URIBeaconConfigService.h" #include "ble/services/URIBeaconConfigService.h"
#define UUID_URI_BEACON(FIRST, SECOND) { \ #define UUID_URI_BEACON(FIRST, SECOND) { \
@ -33,3 +37,5 @@ 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 UUID_RESET_CHAR[UUID::LENGTH_OF_LONG_UUID] = UUID_URI_BEACON(0x20, 0x89);
const uint8_t BEACON_UUID[sizeof(UUID::ShortUUIDBytes_t)] = {0xD8, 0xFE}; const uint8_t BEACON_UUID[sizeof(UUID::ShortUUIDBytes_t)] = {0xD8, 0xFE};
#endif // BLE_FEATURE_GATT_SERVER

View File

@ -182,8 +182,10 @@ impl::GenericGapImpl& BLE::getGap()
static pal::vendor::cordio::GenericAccessService cordio_gap_service; static pal::vendor::cordio::GenericAccessService cordio_gap_service;
static impl::GenericGapImpl gap( static impl::GenericGapImpl gap(
_event_queue, _event_queue,
impl::PalGapImpl::get_gap(), impl::PalGapImpl::get_gap()
cordio_gap_service #if BLE_FEATURE_GATT_SERVER
, cordio_gap_service
#endif
#if BLE_FEATURE_SECURITY #if BLE_FEATURE_SECURITY
, impl::PalSecurityManagerImpl::get_security_manager() , impl::PalSecurityManagerImpl::get_security_manager()
#endif #endif
@ -509,10 +511,11 @@ void BLE::stack_setup()
#if BLE_FEATURE_ATT #if BLE_FEATURE_ATT
AttConnRegister(BLE::connection_handler); AttConnRegister(BLE::connection_handler);
#if BLE_FEATURE_GATT_CLIENT
AttRegister((attCback_t) ble::pal::vendor::cordio::CordioAttClient::att_client_handler); AttRegister((attCback_t) ble::pal::vendor::cordio::CordioAttClient::att_client_handler);
#if !(BLE_FEATURE_GATT_CLIENT) #else
AttRegister((attCback_t) ble::vendor::cordio::GattServer::att_cb); AttRegister((attCback_t) ble::vendor::cordio::GattServer::att_cb);
#endif // !(BLE_FEATURE_GATT_CLIENT) #endif // BLE_FEATURE_GATT_CLIENT
#endif #endif
} }

View File

@ -14,6 +14,10 @@
* limitations under the License. * limitations under the License.
*/ */
#include "BLERoles.h"
#if BLE_FEATURE_SECURITY
#include <string.h> #include <string.h>
#include "CordioPalSecurityManager.h" #include "CordioPalSecurityManager.h"
@ -40,9 +44,6 @@ CordioSecurityManager<EventHandler>::CordioSecurityManager() :
, _peer_csrks() , _peer_csrks()
#endif #endif
{ {
#if !(BLE_FEATURE_SECURITY)
#error "Security Manager feature disabledin the config file"
#endif
} }
template <class EventHandler> template <class EventHandler>
@ -1026,3 +1027,4 @@ void CordioSecurityManager<EventHandler>::cleanup_peer_csrks() {
} // pal } // pal
} // ble } // ble
#endif // BLE_FEATURE_SECURITY