mirror of https://github.com/ARMmbed/mbed-os.git
feat(ble): Guard out Observer code when role is disabled
parent
5d73a03a64
commit
72d28d920a
|
@ -842,6 +842,7 @@ public:
|
|||
MBED_DEPRECATED("Use ble.gap().stopAdvertising(...)")
|
||||
ble_error_t stopAdvertising(void);
|
||||
|
||||
#if BLE_ROLE_OBSERVER
|
||||
/**
|
||||
* Set up parameters for GAP scanning (observer mode).
|
||||
*
|
||||
|
@ -1039,6 +1040,7 @@ public:
|
|||
{
|
||||
return gap().stopScan();
|
||||
}
|
||||
#endif // BLE_ROLE_OBSERVER
|
||||
|
||||
/**
|
||||
* Create a connection (GAP Link Establishment).
|
||||
|
|
|
@ -66,7 +66,9 @@ 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.
|
||||
|
@ -1655,6 +1657,7 @@ public:
|
|||
)
|
||||
void clearScanResponse(void);
|
||||
|
||||
#if BLE_ROLE_OBSERVER
|
||||
/**
|
||||
* Set the parameters used during a scan procedure.
|
||||
*
|
||||
|
@ -1865,6 +1868,8 @@ public:
|
|||
void (T::*callbackMember)(const AdvertisementCallbackParams_t *params)
|
||||
);
|
||||
|
||||
#endif // BLE_ROLE_OBSERVER
|
||||
|
||||
/**
|
||||
* Enable radio-notification events.
|
||||
*
|
||||
|
@ -2619,6 +2624,8 @@ protected:
|
|||
#pragma diag_suppress 1361
|
||||
#endif
|
||||
|
||||
#if BLE_ROLE_OBSERVER
|
||||
|
||||
template<class Impl>
|
||||
template<typename T>
|
||||
ble_error_t LegacyGap<Impl>::startScan(
|
||||
|
@ -2637,6 +2644,8 @@ 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 *))
|
||||
|
|
|
@ -757,6 +757,7 @@ public:
|
|||
|
||||
/* scanning */
|
||||
|
||||
#if BLE_ROLE_OBSERVER
|
||||
/** Set new scan parameters.
|
||||
*
|
||||
* @param params Scan parameters, @see GapScanParameters for details.
|
||||
|
@ -795,6 +796,8 @@ public:
|
|||
*/
|
||||
ble_error_t stopScan();
|
||||
|
||||
#endif // BLE_ROLE_OBSERVER
|
||||
|
||||
/** Synchronize with periodic advertising from an advertiser and begin receiving periodic
|
||||
* advertising packets.
|
||||
*
|
||||
|
|
|
@ -234,6 +234,7 @@ public:
|
|||
*/
|
||||
bool isPeriodicAdvertisingActive_(advertising_handle_t handle);
|
||||
|
||||
#if BLE_ROLE_OBSERVER
|
||||
/** @copydoc Gap::setScanParameters
|
||||
*/
|
||||
ble_error_t setScanParameters_(const ScanParameters ¶ms);
|
||||
|
@ -245,6 +246,7 @@ public:
|
|||
duplicates_filter_t filtering,
|
||||
scan_period_t period
|
||||
);
|
||||
#endif // BLE_ROLE_OBSERVER
|
||||
|
||||
/** @copydoc Gap::createSync
|
||||
*/
|
||||
|
@ -331,10 +333,12 @@ public:
|
|||
*/
|
||||
ble_error_t stopAdvertising_();
|
||||
|
||||
#if BLE_ROLE_OBSERVER
|
||||
/**
|
||||
* @see Gap::stopScan
|
||||
*/
|
||||
ble_error_t stopScan_();
|
||||
#endif // BLE_ROLE_OBSERVER
|
||||
|
||||
/**
|
||||
* @see Gap::connect
|
||||
|
|
|
@ -454,6 +454,8 @@ 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,
|
||||
|
@ -481,6 +483,8 @@ 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);
|
||||
}
|
||||
|
|
|
@ -426,6 +426,8 @@ ble_error_t LegacyGap<Impl>::accumulateScanResponse(
|
|||
return rc;
|
||||
}
|
||||
|
||||
#if BLE_ROLE_OBSERVER
|
||||
|
||||
template<class Impl>
|
||||
void LegacyGap<Impl>::clearScanResponse(void)
|
||||
{
|
||||
|
@ -527,6 +529,8 @@ ble_error_t LegacyGap<Impl>::startScan(
|
|||
return err;
|
||||
}
|
||||
|
||||
#endif // BLE_ROLE_OBSERVER
|
||||
|
||||
template<class Impl>
|
||||
GapAdvertisingParams &LegacyGap<Impl>::getAdvertisingParams(void)
|
||||
{
|
||||
|
|
|
@ -156,6 +156,8 @@ 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 ¶ms)
|
||||
{
|
||||
|
@ -178,6 +180,8 @@ 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,
|
||||
|
|
|
@ -574,6 +574,8 @@ 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_()
|
||||
{
|
||||
|
@ -604,6 +606,8 @@ 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,
|
||||
|
@ -629,8 +633,10 @@ 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(),
|
||||
|
@ -3029,6 +3035,8 @@ 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 ¶ms)
|
||||
{
|
||||
|
@ -3128,6 +3136,8 @@ 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,
|
||||
|
|
Loading…
Reference in New Issue