BLE - Cleanup conditional directives in Gap.

- Remove conditional directives for member variables.
- Remove conditional directive for processXXX functions that are exclusively used by implementation.
-  Remove conditional directives on types exported by the class.
pull/9790/head
Vincent Coubard 2019-02-28 11:28:55 +00:00
parent 126a7a966e
commit c9d719a8ca
2 changed files with 15 additions and 58 deletions

View File

@ -409,7 +409,6 @@ public:
CENTRAL = 0x2, CENTRAL = 0x2,
}; };
#if BLE_ROLE_OBSERVER
/** /**
* Representation of a scanned advertising packet. * Representation of a scanned advertising packet.
* *
@ -484,9 +483,7 @@ public:
*/ */
typedef FunctionPointerWithContext<const AdvertisementCallbackParams_t *> typedef FunctionPointerWithContext<const AdvertisementCallbackParams_t *>
AdvertisementReportCallback_t; AdvertisementReportCallback_t;
#endif // BLE_ROLE_OBSERVER
#if BLE_FEATURE_CONNECTABLE
/** /**
* Connection events. * Connection events.
* *
@ -678,21 +675,15 @@ public:
} }
}; };
#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.
@ -728,7 +719,7 @@ public:
*/ */
typedef CallChainOfFunctionPointersWithContext<TimeoutSource_t> typedef CallChainOfFunctionPointersWithContext<TimeoutSource_t>
TimeoutEventCallbackChain_t; TimeoutEventCallbackChain_t;
#if BLE_FEATURE_CONNECTABLE
/** /**
* Connection event handler. * Connection event handler.
* *
@ -760,7 +751,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.
* *
@ -2267,7 +2258,6 @@ protected:
/* Entry points for the underlying stack to report events back to the user. */ /* Entry points for the underlying stack to report events back to the user. */
public: public:
#if BLE_FEATURE_CONNECTABLE
/** /**
* Notify all registered connection event handlers of a connection event. * Notify all registered connection event handlers of a connection event.
* *
@ -2362,8 +2352,7 @@ public:
"Use EventHandler::onDisconnectionComplete() instead" "Use EventHandler::onDisconnectionComplete() instead"
) )
void processDisconnectionEvent(Handle_t handle, DisconnectionReason_t reason); void processDisconnectionEvent(Handle_t handle, DisconnectionReason_t reason);
#endif // BLE_FEATURE_CONNECTABLE
#if BLE_ROLE_OBSERVER
/** /**
* Forward a received advertising packet to all registered event handlers * Forward a received advertising packet to all registered event handlers
* listening for scanned packet events. * listening for scanned packet events.
@ -2433,7 +2422,7 @@ public:
const uint8_t *advertisingData, const uint8_t *advertisingData,
BLEProtocol::AddressType_t addressType = BLEProtocol::AddressType::RANDOM_STATIC BLEProtocol::AddressType_t addressType = BLEProtocol::AddressType::RANDOM_STATIC
); );
#endif // BLE_ROLE_OBSERVER
/** /**
* Notify the occurrence of a timeout event to all registered timeout events * Notify the occurrence of a timeout event to all registered timeout events
* handler. * handler.
@ -2454,7 +2443,6 @@ public:
void processTimeoutEvent(TimeoutSource_t source); void processTimeoutEvent(TimeoutSource_t source);
protected: protected:
#if BLE_ROLE_BROADCASTER
/** /**
* Current advertising parameters. * Current advertising parameters.
*/ */
@ -2464,36 +2452,31 @@ protected:
* Current advertising data. * Current advertising data.
*/ */
GapAdvertisingData _advPayload; GapAdvertisingData _advPayload;
#endif // BLE_ROLE_BROADCASTER
#if BLE_ROLE_OBSERVER
/** /**
* Current scanning parameters. * Current scanning parameters.
*/ */
GapScanningParams _scanningParams; GapScanningParams _scanningParams;
#endif // BLE_ROLE_OBSERVER
#if BLE_ROLE_BROADCASTER
/** /**
* Current scan response. * Current scan response.
*/ */
GapAdvertisingData _scanResponse; GapAdvertisingData _scanResponse;
#endif // BLE_ROLE_BROADCASTER
#if BLE_FEATURE_CONNECTABLE
/** /**
* Number of open connections. * Number of open connections.
*/ */
uint8_t connectionCount; uint8_t connectionCount;
#endif // BLE_FEATURE_CONNECTABLE
/** /**
* Current GAP state. * Current GAP state.
*/ */
GapState_t state; GapState_t state;
#if BLE_ROLE_OBSERVER
/** /**
* Active scanning flag. * Active scanning flag.
*/ */
bool scanningActive; bool scanningActive;
#endif // BLE_ROLE_OBSERVER
protected: protected:
/** /**
@ -2507,14 +2490,12 @@ protected:
*/ */
RadioNotificationEventCallback_t radioNotificationCallback; RadioNotificationEventCallback_t radioNotificationCallback;
#if BLE_ROLE_OBSERVER
/** /**
* The registered callback handler for scanned advertisement packet * The registered callback handler for scanned advertisement packet
* notifications. * notifications.
*/ */
AdvertisementReportCallback_t onAdvertisementReport; AdvertisementReportCallback_t onAdvertisementReport;
#endif // BLE_ROLE_OBSERVER
#if BLE_FEATURE_CONNECTABLE
/** /**
* Callchain containing all registered callback handlers for connection * Callchain containing all registered callback handlers for connection
* events. * events.
@ -2526,7 +2507,7 @@ protected:
* events. * events.
*/ */
DisconnectionEventCallbackChain_t disconnectionCallChain; DisconnectionEventCallbackChain_t disconnectionCallChain;
#endif // BLE_FEATURE_CONNECTABLE
private: private:
/** /**
* Callchain containing all registered callback handlers for shutdown * Callchain containing all registered callback handlers for shutdown

View File

@ -91,7 +91,6 @@ ble_error_t LegacyGap<Impl>::setWhitelist(const Whitelist_t &whitelist) {
} }
#endif // BLE_FEATURE_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,
@ -123,7 +122,6 @@ 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(
@ -626,7 +624,6 @@ 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(),
@ -639,7 +636,6 @@ 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(
@ -663,7 +659,6 @@ 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,
@ -753,7 +748,6 @@ 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 #if BLE_ROLE_CENTRAL
template<class Impl> template<class Impl>
@ -772,7 +766,6 @@ ble_error_t LegacyGap<Impl>::connect(
} }
#endif // BLE_ROLE_CENTRAL #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,
@ -804,9 +797,7 @@ 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,
@ -858,7 +849,6 @@ 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
@ -943,32 +933,18 @@ ble_error_t LegacyGap<Impl>::reset(void)
template<class Impl> template<class Impl>
LegacyGap<Impl>::LegacyGap() : LegacyGap<Impl>::LegacyGap() :
#if BLE_ROLE_BROADCASTER
_advParams(), _advParams(),
_advPayload(), _advPayload(),
#endif // BLE_ROLE_BROADCASTER
#if BLE_ROLE_OBSERVER
_scanningParams(), _scanningParams(),
#endif
#if BLE_ROLE_BROADCASTER
_scanResponse(), _scanResponse(),
#endif
#if BLE_FEATURE_CONNECTABLE
connectionCount(0), connectionCount(0),
#endif
state(), state(),
#if BLE_ROLE_OBSERVER
scanningActive(false), scanningActive(false),
#endif
timeoutCallbackChain(), timeoutCallbackChain(),
radioNotificationCallback() radioNotificationCallback(),
#if BLE_ROLE_OBSERVER onAdvertisementReport(),
, onAdvertisementReport() connectionCallChain(),
#endif disconnectionCallChain()
#if BLE_FEATURE_CONNECTABLE
, connectionCallChain()
, disconnectionCallChain()
#endif // BLE_FEATURE_CONNECTABLE
{ {
#if BLE_ROLE_BROADCASTER #if BLE_ROLE_BROADCASTER
_advPayload.clear(); _advPayload.clear();