diff --git a/features/FEATURE_BLE/ble/Gap.h b/features/FEATURE_BLE/ble/Gap.h index b3019d8a9c..4d7350551b 100644 --- a/features/FEATURE_BLE/ble/Gap.h +++ b/features/FEATURE_BLE/ble/Gap.h @@ -17,6 +17,7 @@ #ifndef MBED_BLE_GAP_H__ #define MBED_BLE_GAP_H__ +#include "ble/common/StaticInterface.h" #include "BLETypes.h" #include "BLEProtocol.h" #include "ble/GapAdvertisingData.h" @@ -29,6 +30,7 @@ #include "platform/mbed_toolchain.h" #include "ble/gap/Gap.h" +#include "BleImplementationForward.h" /** * @addtogroup ble @@ -37,19 +39,34 @@ * @{ */ +#if !defined(DOXYGEN_ONLY) +namespace ble { +namespace interface { +#endif + /** * @copydoc ble::Gap */ +#if defined(DOXYGEN_ONLY) class Gap : public ble::Gap { +#else +template +class LegacyGap : + public ble::StaticInterface, + public ble::interface::Gap +{ +#endif + using ble::StaticInterface::impl; + public: - using ble::Gap::setAdvertisingParameters; - using ble::Gap::setAdvertisingPayload; - using ble::Gap::setAdvertisingScanResponse; - using ble::Gap::startAdvertising; - using ble::Gap::stopAdvertising; - using ble::Gap::connect; - using ble::Gap::disconnect; - using ble::Gap::startScan; + using ble::interface::Gap::setAdvertisingParameters; + using ble::interface::Gap::setAdvertisingPayload; + using ble::interface::Gap::setAdvertisingScanResponse; + using ble::interface::Gap::startAdvertising; + using ble::interface::Gap::stopAdvertising; + using ble::interface::Gap::connect; + using ble::interface::Gap::disconnect; + using ble::interface::Gap::startScan; /** * Address-type for BLEProtocol addresses. @@ -738,14 +755,14 @@ public: * * @see Gap::onShutdown(). */ - typedef FunctionPointerWithContext GapShutdownCallback_t; + typedef FunctionPointerWithContext GapShutdownCallback_t; /** * Callchain of gap shutdown event handler. * * @see Gap::onShutdown(). */ - typedef CallChainOfFunctionPointersWithContext + typedef CallChainOfFunctionPointersWithContext GapShutdownCallbackChain_t; /* @@ -790,7 +807,7 @@ public: "mbed-os-5.9.0", "Non portable API, use enablePrivacy to enable use of private addresses" ) - virtual ble_error_t setAddress( + ble_error_t setAddress( BLEProtocol::AddressType_t type, const BLEProtocol::AddressBytes_t address ); @@ -806,7 +823,7 @@ public: * * @return BLE_ERROR_NONE on success. */ - virtual ble_error_t getAddress( + ble_error_t getAddress( BLEProtocol::AddressType_t *typeP, BLEProtocol::AddressBytes_t address ); @@ -834,12 +851,7 @@ public: * @return Minimum Advertising interval in milliseconds for connectable * undirected and connectable directed advertising types. */ - virtual uint16_t getMinAdvertisingInterval(void) const - { - /* Requesting action from porter(s): override this API if this capability - is supported. */ - return 0; - } + uint16_t getMinAdvertisingInterval(void) const; /** * Get the minimum advertising interval in milliseconds, which can be @@ -848,24 +860,14 @@ public: * @return Minimum Advertising interval in milliseconds for scannable * undirected and nonconnectable undirected event types. */ - virtual uint16_t getMinNonConnectableAdvertisingInterval(void) const - { - /* Requesting action from porter(s): override this API if this capability - is supported. */ - return 0; - } + uint16_t getMinNonConnectableAdvertisingInterval(void) const; /** * Get the maximum advertising interval in milliseconds. * * @return Maximum Advertising interval in milliseconds. */ - virtual uint16_t getMaxAdvertisingInterval(void) const - { - /* Requesting action from porter(s): override this API if this capability - is supported. */ - return 0xFFFF; - } + uint16_t getMaxAdvertisingInterval(void) const; /** * Stop the ongoing advertising procedure. @@ -883,7 +885,7 @@ public: "Deprecated since addition of extended advertising support." "Use stopAdvertising(advertising_handle_t) instead." ) - virtual ble_error_t stopAdvertising(void); + ble_error_t stopAdvertising(void); /** * Initiate a connection to a peer. @@ -909,7 +911,7 @@ public: "Deprecated since addition of extended advertising support." "Use connect(target_peer_address_type_t, address_t, ConnectionParameters) instead." ) - virtual ble_error_t connect( + ble_error_t connect( const BLEProtocol::AddressBytes_t peerAddr, PeerAddressType_t peerAddrType, const ConnectionParams_t *connectionParams, @@ -940,7 +942,7 @@ public: "This function won't work if privacy is enabled; You must use the overload " "accepting PeerAddressType_t." ) - virtual ble_error_t connect( + ble_error_t connect( const BLEProtocol::AddressBytes_t peerAddr, BLEProtocol::AddressType_t peerAddrType, const ConnectionParams_t *connectionParams, @@ -990,7 +992,7 @@ public: "Deprecated since addition of extended advertising support." "Use disconnect(connection_handle_t, local_disconnection_reason_t) instead." ) - virtual ble_error_t disconnect( + ble_error_t disconnect( Handle_t connectionHandle, DisconnectionReason_t reason ); @@ -1007,7 +1009,7 @@ public: * @return BLE_ERROR_NONE if disconnection was successful. */ MBED_DEPRECATED("Use disconnect(Handle_t, DisconnectionReason_t) instead.") - virtual ble_error_t disconnect(DisconnectionReason_t reason); + ble_error_t disconnect(DisconnectionReason_t reason); public: @@ -1020,15 +1022,7 @@ public: * @return BLE_ERROR_NONE if the parameters were successfully filled into * @p params. */ - virtual ble_error_t getPreferredConnectionParams(ConnectionParams_t *params) - { - /* Avoid compiler warnings about unused variables. */ - (void) params; - - /* Requesting action from porter(s): override this API if this capability - is supported. */ - return BLE_ERROR_NOT_IMPLEMENTED; - } + ble_error_t getPreferredConnectionParams(ConnectionParams_t *params); /** * Set the value of the preferred connection parameters exposed in the GATT @@ -1043,17 +1037,9 @@ public: * @return BLE_ERROR_NONE if the preferred connection params were set * correctly. */ - virtual ble_error_t setPreferredConnectionParams( + ble_error_t setPreferredConnectionParams( const ConnectionParams_t *params - ) - { - /* Avoid compiler warnings about unused variables. */ - (void) params; - - /* Requesting action from porter(s): override this API if this capability - is supported. */ - return BLE_ERROR_NOT_IMPLEMENTED; - } + ); /** * Update connection parameters of an existing connection. @@ -1079,7 +1065,7 @@ public: "conn_interval_t, slave_latency_t, supervision_timeout_t, " "conn_event_length_t, conn_event_length_t) instead." ) - virtual ble_error_t updateConnectionParams( + ble_error_t updateConnectionParams( Handle_t handle, const ConnectionParams_t *params ); @@ -1093,15 +1079,7 @@ public: * * @return BLE_ERROR_NONE if the device name was set correctly. */ - virtual ble_error_t setDeviceName(const uint8_t *deviceName) - { - /* Avoid compiler warnings about unused variables. */ - (void) deviceName; - - /* Requesting action from porter(s): override this API if this capability - is supported. */ - return BLE_ERROR_NOT_IMPLEMENTED; - } + ble_error_t setDeviceName(const uint8_t *deviceName); /** * Get the value of the device name characteristic in the Generic Access @@ -1125,16 +1103,7 @@ public: * bytes actually returned in deviceName. The application may use this * information to retry with a suitable buffer size. */ - virtual ble_error_t getDeviceName(uint8_t *deviceName, unsigned *lengthP) - { - /* avoid compiler warnings about unused variables */ - (void) deviceName; - (void) lengthP; - - /* Requesting action from porter(s): override this API if this capability - is supported. */ - return BLE_ERROR_NOT_IMPLEMENTED; - } + ble_error_t getDeviceName(uint8_t *deviceName, unsigned *lengthP); /** * Set the value of the appearance characteristic in the GAP service. @@ -1143,15 +1112,7 @@ public: * * @return BLE_ERROR_NONE if the new appearance was set correctly. */ - virtual ble_error_t setAppearance(GapAdvertisingData::Appearance appearance) - { - /* Avoid compiler warnings about unused variables. */ - (void) appearance; - - /* Requesting action from porter(s): override this API if this capability - is supported. */ - return BLE_ERROR_NOT_IMPLEMENTED; - } + ble_error_t setAppearance(GapAdvertisingData::Appearance appearance); /** * Get the value of the appearance characteristic in the GAP service. @@ -1161,15 +1122,7 @@ public: * @return BLE_ERROR_NONE if the device-appearance was fetched correctly * from the underlying BLE stack. */ - virtual ble_error_t getAppearance(GapAdvertisingData::Appearance *appearanceP) - { - /* Avoid compiler warnings about unused variables. */ - (void) appearanceP; - - /* Requesting action from porter(s): override this API if this capability - is supported. */ - return BLE_ERROR_NOT_IMPLEMENTED; - } + ble_error_t getAppearance(GapAdvertisingData::Appearance *appearanceP); /** * Set the radio's transmit power. @@ -1187,7 +1140,7 @@ public: "Deprecated since addition of extended advertising support." "See ble::AdvertisingParameters and setAdvertisingParameters." ) - virtual ble_error_t setTxPower(int8_t txPower); + ble_error_t setTxPower(int8_t txPower); /** * Query the underlying stack for allowed Tx power values. @@ -1201,7 +1154,7 @@ public: "mbed-os-5.11.0", "Deprecated since addition of extended advertising support." ) - virtual void getPermittedTxPowerValues( + void getPermittedTxPowerValues( const int8_t **valueArrayPP, size_t *countP ); @@ -1213,7 +1166,7 @@ public: * @note If using Mbed OS, you can configure the size of the whitelist by * setting the YOTTA_CFG_WHITELIST_MAX_SIZE macro in your yotta config file. */ - virtual uint8_t getMaxWhitelistSize(void) const; + uint8_t getMaxWhitelistSize(void) const; /** * Get the Link Layer to use the internal whitelist when scanning, @@ -1225,7 +1178,7 @@ public: * @return BLE_ERROR_NONE if the implementation's whitelist was successfully * copied into the supplied reference. */ - virtual ble_error_t getWhitelist(Whitelist_t &whitelist) const; + ble_error_t getWhitelist(Whitelist_t &whitelist) const; /** * Set the value of the whitelist to be used during GAP procedures. @@ -1245,7 +1198,7 @@ public: * @note If the input whitelist is larger than @ref getMaxWhitelistSize(), * then @ref BLE_ERROR_PARAM_OUT_OF_RANGE is returned. */ - virtual ble_error_t setWhitelist(const Whitelist_t &whitelist); + ble_error_t setWhitelist(const Whitelist_t &whitelist); /** * Set the advertising policy filter mode to be used during the next @@ -1264,7 +1217,7 @@ public: "Deprecated since addition of extended advertising support." "This setting is now part of ble::AdvertisingParameters." ) - virtual ble_error_t setAdvertisingPolicyMode(AdvertisingPolicyMode_t mode); + ble_error_t setAdvertisingPolicyMode(AdvertisingPolicyMode_t mode); /** * Set the scan policy filter mode to be used during the next scan procedure. @@ -1282,7 +1235,7 @@ public: "Deprecated since addition of extended advertising support." "This setting is now part of ble::ScanParameters." ) - virtual ble_error_t setScanningPolicyMode(ScanningPolicyMode_t mode); + ble_error_t setScanningPolicyMode(ScanningPolicyMode_t mode); /** * Set the initiator policy filter mode to be used during the next connection @@ -1301,7 +1254,7 @@ public: "Deprecated since addition of extended advertising support." "This setting is now part of ble::ConnectionParameters." ) - virtual ble_error_t setInitiatorPolicyMode(InitiatorPolicyMode_t mode); + ble_error_t setInitiatorPolicyMode(InitiatorPolicyMode_t mode); /** * Get the current advertising policy filter mode. @@ -1314,7 +1267,7 @@ public: "mbed-os-5.11.0", "Deprecated since addition of extended advertising support." ) - virtual AdvertisingPolicyMode_t getAdvertisingPolicyMode(void) const; + AdvertisingPolicyMode_t getAdvertisingPolicyMode(void) const; /** * Get the current scan policy filter mode. @@ -1327,7 +1280,7 @@ public: "mbed-os-5.11.0", "Deprecated since addition of extended advertising support." ) - virtual ScanningPolicyMode_t getScanningPolicyMode(void) const; + ScanningPolicyMode_t getScanningPolicyMode(void) const; /** * Get the current initiator policy filter mode. @@ -1340,7 +1293,7 @@ public: "mbed-os-5.11.0", "Deprecated since addition of extended advertising support." ) - virtual InitiatorPolicyMode_t getInitiatorPolicyMode(void) const; + InitiatorPolicyMode_t getInitiatorPolicyMode(void) const; protected: /* Override the following in the underlying adaptation layer to provide the @@ -1363,7 +1316,7 @@ protected: "Vendors should use the cordio hci interface or the ble::pal or " "implement startScan(duplicates_filter_t, scan_duration_t, period)" ) - virtual ble_error_t startRadioScan(const GapScanningParams &scanningParams); + ble_error_t startRadioScan(const GapScanningParams &scanningParams); /* * APIs with nonvirtual implementations. @@ -1933,7 +1886,7 @@ public: "mbed-os-5.11.0", "Deprecated since addition of extended advertising support. " ) - virtual ble_error_t initRadioNotification(void); + ble_error_t initRadioNotification(void); private: /** @@ -1954,10 +1907,10 @@ private: "Deprecated since addition of extended advertising support. " "Implement setAdvertisingPayload() and setAdvertisingScanResponse() instead." ) - virtual ble_error_t setAdvertisingData( + ble_error_t setAdvertisingData( const GapAdvertisingData &advData, const GapAdvertisingData &scanResponse - ) = 0; + ); /** * Start the advertising procedure. @@ -1979,7 +1932,7 @@ private: "Implement startAdvertising(advertising_handle_t, adv_duration_t, uint8_t)" "instead." ) - virtual ble_error_t startAdvertising(const GapAdvertisingParams ¶ms) = 0; + ble_error_t startAdvertising(const GapAdvertisingParams ¶ms); public: /** @@ -2237,7 +2190,7 @@ public: * @param[in] memberPtr Shutdown event handler to register. */ template - void onShutdown(T *objPtr, void (T::*memberPtr)(const Gap *)) + void onShutdown(T *objPtr, void (T::*memberPtr)(const LegacyGap *)) { shutdownCallChain.add(objPtr, memberPtr); } @@ -2272,56 +2225,13 @@ public: * @note Currently, a call to reset() does not reset the advertising and * scan parameters to default values. */ - virtual ble_error_t reset(void) - { - /* Notify that the instance is about to shut down */ - shutdownCallChain.call(this); - shutdownCallChain.clear(); - - /* Clear Gap state */ - state.advertising = 0; - state.connected = 0; - connectionCount = 0; - - /* Clear scanning state */ - scanningActive = false; - - /* Clear advertising and scanning data */ - _advPayload.clear(); - _scanResponse.clear(); - - /* Clear callbacks */ - timeoutCallbackChain.clear(); - connectionCallChain.clear(); - disconnectionCallChain.clear(); - radioNotificationCallback = NULL; - onAdvertisementReport = NULL; - _eventHandler = NULL; - - return BLE_ERROR_NONE; - } + ble_error_t reset(void); protected: /** * Construct a Gap instance. */ - Gap() : - _advParams(), - _advPayload(), - _scanningParams(), - _scanResponse(), - connectionCount(0), - state(), - scanningActive(false), - timeoutCallbackChain(), - radioNotificationCallback(), - onAdvertisementReport(), - connectionCallChain(), - disconnectionCallChain() - { - _advPayload.clear(); - _scanResponse.clear(); - } + LegacyGap(); /* Entry points for the underlying stack to report events back to the user. */ public: @@ -2418,17 +2328,7 @@ public: "Deprecated since addition of extended advertising support. " "Use EventHandler::onDisconnectionComplete() instead" ) - void processDisconnectionEvent(Handle_t handle, DisconnectionReason_t reason) - { - /* Update Gap state */ - --connectionCount; - if (!connectionCount) { - state.connected = 0; - } - - DisconnectionCallbackParams_t callbackParams(handle, reason); - disconnectionCallChain.call(&callbackParams); - } + void processDisconnectionEvent(Handle_t handle, DisconnectionReason_t reason); /** * Forward a received advertising packet to all registered event handlers @@ -2517,16 +2417,7 @@ public: "Deprecated since addition of extended advertising support. " "Use EventHandler instead" ) - void processTimeoutEvent(TimeoutSource_t source) - { - if (source == TIMEOUT_SRC_ADVERTISING) { - /* Update gap state if the source is an advertising timeout */ - state.advertising = 0; - } - if (timeoutCallbackChain) { - timeoutCallbackChain(source); - } - } + void processTimeoutEvent(TimeoutSource_t source); protected: /** @@ -2603,9 +2494,114 @@ private: private: /* Disallow copy and assignment. */ - Gap(const Gap &); + LegacyGap(const LegacyGap &); - Gap &operator=(const Gap &); + LegacyGap &operator=(const LegacyGap &); + + +protected: + using ble::interface::Gap::startAdvertising_; + using ble::interface::Gap::stopAdvertising_; + using ble::interface::Gap::connect_; + using ble::interface::Gap::disconnect_; + + /* --- Abstract calls with default implementation --- */ + uint16_t getMinAdvertisingInterval_(void) const; + + uint16_t getMinNonConnectableAdvertisingInterval_(void) const; + + uint16_t getMaxAdvertisingInterval_(void) const; + + /* Note: Implementation must call the base class reset_ */ + ble_error_t reset_(void); + + /* --- Abstract calls to override --- */ + + uint8_t getMaxWhitelistSize_(void) const; + + ble_error_t getWhitelist_(Whitelist_t &whitelist) const; + + ble_error_t setWhitelist_(const Whitelist_t &whitelist); + + ble_error_t setAddress_( + BLEProtocol::AddressType_t type, + const BLEProtocol::AddressBytes_t address + ); + + ble_error_t getAddress_( + BLEProtocol::AddressType_t *typeP, + BLEProtocol::AddressBytes_t address + ); + + ble_error_t stopAdvertising_(void); + + ble_error_t connect_( + const BLEProtocol::AddressBytes_t peerAddr, + PeerAddressType_t peerAddrType, + const ConnectionParams_t *connectionParams, + const GapScanningParams *scanParams + ); + + ble_error_t connect_( + const BLEProtocol::AddressBytes_t peerAddr, + BLEProtocol::AddressType_t peerAddrType, + const ConnectionParams_t *connectionParams, + const GapScanningParams *scanParams + ); + + ble_error_t disconnect_( + Handle_t connectionHandle, DisconnectionReason_t reason + ); + + ble_error_t disconnect_(DisconnectionReason_t reason); + + ble_error_t updateConnectionParams_( + Handle_t handle, + const ConnectionParams_t *params + ); + + ble_error_t setTxPower_(int8_t txPower); + + void getPermittedTxPowerValues_( + const int8_t **valueArrayPP, size_t *countP + ); + + ble_error_t setAdvertisingPolicyMode_(AdvertisingPolicyMode_t mode); + + ble_error_t setScanningPolicyMode_(ScanningPolicyMode_t mode); + + ble_error_t setInitiatorPolicyMode_(InitiatorPolicyMode_t mode); + + AdvertisingPolicyMode_t getAdvertisingPolicyMode_(void) const; + + ScanningPolicyMode_t getScanningPolicyMode_(void) const; + + InitiatorPolicyMode_t getInitiatorPolicyMode_(void) const; + + ble_error_t startRadioScan_(const GapScanningParams &scanningParams); + + ble_error_t initRadioNotification_(void); + + ble_error_t getPreferredConnectionParams_(ConnectionParams_t *params); + + ble_error_t setPreferredConnectionParams_( + const ConnectionParams_t *params + ); + + ble_error_t setDeviceName_(const uint8_t *deviceName); + + ble_error_t getDeviceName_(uint8_t *deviceName, unsigned *lengthP); + + ble_error_t setAppearance_(GapAdvertisingData::Appearance appearance); + + ble_error_t getAppearance_(GapAdvertisingData::Appearance *appearanceP); + + ble_error_t setAdvertisingData_( + const GapAdvertisingData &advData, + const GapAdvertisingData &scanResponse + ); + + ble_error_t startAdvertising_(const GapAdvertisingParams ¶ms); }; /** @@ -2623,8 +2619,9 @@ private: #pragma diag_suppress 1361 #endif +template template -ble_error_t Gap::startScan( +ble_error_t LegacyGap::startScan( T *object, void (T::*callbackMember)(const AdvertisementCallbackParams_t *params) ) @@ -2640,21 +2637,23 @@ ble_error_t Gap::startScan( return err; } - +template template -void Gap::onConnection(T *tptr, void (T::*mptr)(const ConnectionCallbackParams_t *)) +void LegacyGap::onConnection(T *tptr, void (T::*mptr)(const ConnectionCallbackParams_t *)) { connectionCallChain.add(tptr, mptr); } +template template -void Gap::onDisconnection(T *tptr, void (T::*mptr)(const DisconnectionCallbackParams_t *)) +void LegacyGap::onDisconnection(T *tptr, void (T::*mptr)(const DisconnectionCallbackParams_t *)) { disconnectionCallChain.add(tptr, mptr); } +template template -void Gap::onRadioNotification(T *tptr, void (T::*mptr)(bool)) +void LegacyGap::onRadioNotification(T *tptr, void (T::*mptr)(bool)) { radioNotificationCallback.attach(tptr, mptr); } @@ -2665,4 +2664,16 @@ void Gap::onRadioNotification(T *tptr, void (T::*mptr)(bool)) #pragma pop #endif +} // interface +} // ble + +// import LegacyGap implementation into global namespace +typedef ble::impl::LegacyGap Gap; + +// import Gap implementation into ble namespace +namespace ble { +typedef impl::Gap Gap; +} + + #endif // ifndef MBED_BLE_GAP_H__ diff --git a/features/FEATURE_BLE/source/LegacyGap.cpp b/features/FEATURE_BLE/source/LegacyGap.tpp similarity index 50% rename from features/FEATURE_BLE/source/LegacyGap.cpp rename to features/FEATURE_BLE/source/LegacyGap.tpp index 5ce1f0fbcd..772eb03d62 100644 --- a/features/FEATURE_BLE/source/LegacyGap.cpp +++ b/features/FEATURE_BLE/source/LegacyGap.tpp @@ -17,14 +17,13 @@ #include "ble/Gap.h" namespace { - ble_error_t convert_address_type( - Gap::PeerAddressType_t input_type, + ble::peer_address_type_t input_type, const BLEProtocol::AddressBytes_t address, BLEProtocol::AddressType_t& output_type ) { - typedef Gap::RandomAddressType_t RandomAddressType_t; - typedef Gap::PeerAddressType_t PeerAddressType_t; + typedef ble::random_address_type_t RandomAddressType_t; + typedef ble::peer_address_type_t PeerAddressType_t; typedef BLEProtocol::AddressType LegacyAddressType_t; // best effort; peerAddrTypeIn should not be used when privacy is on. @@ -60,34 +59,38 @@ ble_error_t convert_address_type( return BLE_ERROR_NONE; } -Gap::PeerAddressType_t convert_legacy_address_type( +ble::peer_address_type_t convert_legacy_address_type( BLEProtocol::AddressType_t legacy_address ) { if (legacy_address == BLEProtocol::AddressType::PUBLIC) { - return Gap::PeerAddressType_t::PUBLIC; + return ble::peer_address_type_t::PUBLIC; } else { - return Gap::PeerAddressType_t::RANDOM; + return ble::peer_address_type_t::RANDOM; } } } // end of anonymous namespace -uint8_t Gap::getMaxWhitelistSize(void) const -{ - return 0; +namespace ble { +namespace interface { + +template +uint8_t LegacyGap::getMaxWhitelistSize(void) const { + return impl()->getMaxWhitelistSize_(); } -ble_error_t Gap::getWhitelist(Whitelist_t &whitelist) const -{ - return BLE_ERROR_NOT_IMPLEMENTED; +template +ble_error_t LegacyGap::getWhitelist(Whitelist_t &whitelist) const { + return impl()->getWhitelist_(whitelist); } -ble_error_t Gap::setWhitelist(const Whitelist_t &whitelist) -{ - return BLE_ERROR_NOT_IMPLEMENTED; +template +ble_error_t LegacyGap::setWhitelist(const Whitelist_t &whitelist) { + return impl()->setWhitelist_(whitelist); } -void Gap::processConnectionEvent( +template +void LegacyGap::processConnectionEvent( Handle_t handle, Role_t role, PeerAddressType_t peerAddrType, @@ -118,176 +121,134 @@ void Gap::processConnectionEvent( connectionCallChain.call(&callbackParams); } -ble_error_t Gap::setAddress( +template +ble_error_t LegacyGap::setAddress( BLEProtocol::AddressType_t type, const BLEProtocol::AddressBytes_t address ) { - /* avoid compiler warnings about unused variables */ - (void)type; - (void)address; - - /* Requesting action from porter(s): override this API if this capability - is supported. */ - return BLE_ERROR_NOT_IMPLEMENTED; + return impl()->setAddress_(type, address); } -ble_error_t Gap::getAddress( +template +ble_error_t LegacyGap::getAddress( BLEProtocol::AddressType_t *typeP, BLEProtocol::AddressBytes_t address ) { - /* Avoid compiler warnings about unused variables. */ - (void)typeP; - (void)address; - - /* Requesting action from porter(s): override this API if this capability - is supported. */ - return BLE_ERROR_NOT_IMPLEMENTED; + return impl()->getAddress_(typeP, address); } -ble_error_t Gap::stopAdvertising(void) -{ - /* Requesting action from porter(s): override this API if this capability - is supported. */ - return BLE_ERROR_NOT_IMPLEMENTED; +template +ble_error_t LegacyGap::stopAdvertising(void) { + return impl()->stopAdvertising_(); } -ble_error_t Gap::connect( +template +ble_error_t LegacyGap::connect( const BLEProtocol::AddressBytes_t peerAddr, PeerAddressType_t peerAddrType, const ConnectionParams_t *connectionParams, const GapScanningParams *scanParams ) { - /* Avoid compiler warnings about unused variables. */ - (void)peerAddr; - (void)peerAddrType; - (void)connectionParams; - (void)scanParams; - - /* Requesting action from porter(s): override this API if this capability - is supported. */ - return BLE_ERROR_NOT_IMPLEMENTED; + return impl()->connect_( + peerAddr, + peerAddrType, + connectionParams, + scanParams + ); } -ble_error_t Gap::connect( +template +ble_error_t LegacyGap::connect( const BLEProtocol::AddressBytes_t peerAddr, BLEProtocol::AddressType_t peerAddrType, const ConnectionParams_t *connectionParams, const GapScanningParams *scanParams ) { - /* Avoid compiler warnings about unused variables. */ - (void)peerAddr; - (void)peerAddrType; - (void)connectionParams; - (void)scanParams; - - /* Requesting action from porter(s): override this API if this capability - is supported. */ - return BLE_ERROR_NOT_IMPLEMENTED; + return impl()->connect_( + peerAddr, + peerAddrType, + connectionParams, + scanParams + ); } -ble_error_t Gap::disconnect( +template +ble_error_t LegacyGap::disconnect( Handle_t connectionHandle, DisconnectionReason_t reason ) { - /* avoid compiler warnings about unused variables */ - (void)connectionHandle; - (void)reason; - - /* Requesting action from porter(s): override this API if this capability - is supported. */ - return BLE_ERROR_NOT_IMPLEMENTED; + return impl()->disconnect_(connectionHandle, reason); } -ble_error_t Gap::disconnect(DisconnectionReason_t reason) { - /* Avoid compiler warnings about unused variables. */ - (void)reason; - - /* Requesting action from porter(s): override this API if this capability - is supported. */ - return BLE_ERROR_NOT_IMPLEMENTED; +template +ble_error_t LegacyGap::disconnect(DisconnectionReason_t reason) { + return impl()->disconnect_(reason); } -ble_error_t Gap::updateConnectionParams( +template +ble_error_t LegacyGap::updateConnectionParams( Handle_t handle, const ConnectionParams_t *params ) { - /* avoid compiler warnings about unused variables */ - (void)handle; - (void)params; - - /* Requesting action from porter(s): override this API if this capability - is supported. */ - return BLE_ERROR_NOT_IMPLEMENTED; + return impl()->updateConnectionParams_(handle, params); } -ble_error_t Gap::setTxPower(int8_t txPower) -{ - /* Avoid compiler warnings about unused variables. */ - (void)txPower; - /* Requesting action from porter(s): override this API if this capability - is supported. */ - return BLE_ERROR_NOT_IMPLEMENTED; +template +ble_error_t LegacyGap::setTxPower(int8_t txPower) { + return impl()->setTxPower_(txPower); } -void Gap::getPermittedTxPowerValues( +template +void LegacyGap::getPermittedTxPowerValues( const int8_t **valueArrayPP, size_t *countP -) { - /* Avoid compiler warnings about unused variables. */ - (void)valueArrayPP; - - /* Requesting action from porter(s): override this API if this capability - is supported. */ - *countP = 0; +) { + return impl()->getPermittedTxPowerValues_(valueArrayPP, countP); } -ble_error_t Gap::setAdvertisingPolicyMode(AdvertisingPolicyMode_t mode) -{ - (void) mode; - return BLE_ERROR_NOT_IMPLEMENTED; +template +ble_error_t LegacyGap::setAdvertisingPolicyMode(AdvertisingPolicyMode_t mode) { + return impl()->setAdvertisingPolicyMode_(mode); } -ble_error_t Gap::setScanningPolicyMode(ScanningPolicyMode_t mode) -{ - (void) mode; - return BLE_ERROR_NOT_IMPLEMENTED; +template +ble_error_t LegacyGap::setScanningPolicyMode(ScanningPolicyMode_t mode) { + return impl()->setScanningPolicyMode_(mode); } -ble_error_t Gap::setInitiatorPolicyMode(InitiatorPolicyMode_t mode) -{ - (void) mode; - return BLE_ERROR_NOT_IMPLEMENTED; +template +ble_error_t LegacyGap::setInitiatorPolicyMode(InitiatorPolicyMode_t mode) { + return impl()->setInitiatorPolicyMode_(mode); } -Gap::AdvertisingPolicyMode_t Gap::getAdvertisingPolicyMode(void) const -{ - return ADV_POLICY_IGNORE_WHITELIST; +template +typename LegacyGap::AdvertisingPolicyMode_t +LegacyGap::getAdvertisingPolicyMode(void) const { + return impl()->getAdvertisingPolicyMode_(); } -Gap::ScanningPolicyMode_t Gap::getScanningPolicyMode(void) const -{ - return SCAN_POLICY_IGNORE_WHITELIST; +template +typename LegacyGap::ScanningPolicyMode_t +LegacyGap::getScanningPolicyMode(void) const { + return impl()->getScanningPolicyMode_(); } -Gap::InitiatorPolicyMode_t Gap::getInitiatorPolicyMode(void) const -{ - return INIT_POLICY_IGNORE_WHITELIST; +template +typename LegacyGap::InitiatorPolicyMode_t +LegacyGap::getInitiatorPolicyMode(void) const { + return impl()->getInitiatorPolicyMode_(); } -ble_error_t Gap::startRadioScan(const GapScanningParams &scanningParams) -{ - (void)scanningParams; - /* Requesting action from porter(s): override this API if this capability - is supported. */ - return BLE_ERROR_NOT_IMPLEMENTED; +template +ble_error_t LegacyGap::startRadioScan(const GapScanningParams &scanningParams) { + return impl()->startRadioScan_(scanningParams); } -ble_error_t Gap::initRadioNotification(void) -{ - /* Requesting action from porter(s): override this API if this capability - is supported. */ - return BLE_ERROR_NOT_IMPLEMENTED; +template +ble_error_t LegacyGap::initRadioNotification(void) { + return impl()->initRadioNotification_(); } +/* -------- deprecated template implementation -------- */ #if defined(__GNUC__) && !defined(__CC_ARM) #pragma GCC diagnostic push @@ -297,17 +258,20 @@ ble_error_t Gap::initRadioNotification(void) #pragma diag_suppress 1361 #endif -Gap::GapState_t Gap::getState(void) const +template +typename LegacyGap::GapState_t LegacyGap::getState(void) const { return state; } -void Gap::setAdvertisingType(GapAdvertisingParams::AdvertisingType_t advType) +template +void LegacyGap::setAdvertisingType(GapAdvertisingParams::AdvertisingType_t advType) { _advParams.setAdvertisingType(advType); } -void Gap::setAdvertisingInterval(uint16_t interval) +template +void LegacyGap::setAdvertisingInterval(uint16_t interval) { if (interval == 0) { stopAdvertising(); @@ -317,12 +281,14 @@ void Gap::setAdvertisingInterval(uint16_t interval) _advParams.setInterval(interval); } -void Gap::setAdvertisingTimeout(uint16_t timeout) +template +void LegacyGap::setAdvertisingTimeout(uint16_t timeout) { _advParams.setTimeout(timeout); } -ble_error_t Gap::startAdvertising(void) +template +ble_error_t LegacyGap::startAdvertising(void) { ble_error_t rc; if ((rc = startAdvertising(_advParams)) == BLE_ERROR_NONE) { @@ -331,13 +297,15 @@ ble_error_t Gap::startAdvertising(void) return rc; } -void Gap::clearAdvertisingPayload(void) +template +void LegacyGap::clearAdvertisingPayload(void) { _advPayload.clear(); setAdvertisingData(_advPayload, _scanResponse); } -ble_error_t Gap::accumulateAdvertisingPayload(uint8_t flags) +template +ble_error_t LegacyGap::accumulateAdvertisingPayload(uint8_t flags) { GapAdvertisingData advPayloadCopy = _advPayload; ble_error_t rc; @@ -353,7 +321,8 @@ ble_error_t Gap::accumulateAdvertisingPayload(uint8_t flags) return rc; } -ble_error_t Gap::accumulateAdvertisingPayload(GapAdvertisingData::Appearance app) +template +ble_error_t LegacyGap::accumulateAdvertisingPayload(GapAdvertisingData::Appearance app) { GapAdvertisingData advPayloadCopy = _advPayload; ble_error_t rc; @@ -369,7 +338,8 @@ ble_error_t Gap::accumulateAdvertisingPayload(GapAdvertisingData::Appearance app return rc; } -ble_error_t Gap::accumulateAdvertisingPayloadTxPower(int8_t power) +template +ble_error_t LegacyGap::accumulateAdvertisingPayloadTxPower(int8_t power) { GapAdvertisingData advPayloadCopy = _advPayload; ble_error_t rc; @@ -385,7 +355,8 @@ ble_error_t Gap::accumulateAdvertisingPayloadTxPower(int8_t power) return rc; } -ble_error_t Gap::accumulateAdvertisingPayload( +template +ble_error_t LegacyGap::accumulateAdvertisingPayload( GapAdvertisingData::DataType type, const uint8_t *data, uint8_t len ) { GapAdvertisingData advPayloadCopy = _advPayload; @@ -402,7 +373,8 @@ ble_error_t Gap::accumulateAdvertisingPayload( return rc; } -ble_error_t Gap::updateAdvertisingPayload( +template +ble_error_t LegacyGap::updateAdvertisingPayload( GapAdvertisingData::DataType type, const uint8_t *data, uint8_t len ) { GapAdvertisingData advPayloadCopy = _advPayload; @@ -419,7 +391,8 @@ ble_error_t Gap::updateAdvertisingPayload( return rc; } -ble_error_t Gap::setAdvertisingPayload(const GapAdvertisingData &payload) +template +ble_error_t LegacyGap::setAdvertisingPayload(const GapAdvertisingData &payload) { ble_error_t rc = setAdvertisingData(payload, _scanResponse); if (rc == BLE_ERROR_NONE) { @@ -429,12 +402,14 @@ ble_error_t Gap::setAdvertisingPayload(const GapAdvertisingData &payload) return rc; } -const GapAdvertisingData &Gap::getAdvertisingPayload(void) const +template +const GapAdvertisingData &LegacyGap::getAdvertisingPayload(void) const { return _advPayload; } -ble_error_t Gap::accumulateScanResponse( +template +ble_error_t LegacyGap::accumulateScanResponse( GapAdvertisingData::DataType type, const uint8_t *data, uint8_t len ) { GapAdvertisingData scanResponseCopy = _scanResponse; @@ -451,13 +426,15 @@ ble_error_t Gap::accumulateScanResponse( return rc; } -void Gap::clearScanResponse(void) +template +void LegacyGap::clearScanResponse(void) { _scanResponse.clear(); setAdvertisingData(_advPayload, _scanResponse); } -ble_error_t Gap::setScanParams( +template +ble_error_t LegacyGap::setScanParams( uint16_t interval, uint16_t window, uint16_t timeout, @@ -474,7 +451,8 @@ ble_error_t Gap::setScanParams( return rc; } -ble_error_t Gap::setScanParams(const GapScanningParams& scanningParams) { +template +ble_error_t LegacyGap::setScanParams(const GapScanningParams& scanningParams) { return setScanParams( scanningParams.getInterval(), scanningParams.getWindow(), @@ -483,12 +461,14 @@ ble_error_t Gap::setScanParams(const GapScanningParams& scanningParams) { ); } -ble_error_t Gap::setScanInterval(uint16_t interval) +template +ble_error_t LegacyGap::setScanInterval(uint16_t interval) { return _scanningParams.setInterval(interval); } -ble_error_t Gap::setScanWindow(uint16_t window) +template +ble_error_t LegacyGap::setScanWindow(uint16_t window) { ble_error_t rc; if ((rc = _scanningParams.setWindow(window)) != BLE_ERROR_NONE) { @@ -503,7 +483,8 @@ ble_error_t Gap::setScanWindow(uint16_t window) return BLE_ERROR_NONE; } -ble_error_t Gap::setScanTimeout(uint16_t timeout) +template +ble_error_t LegacyGap::setScanTimeout(uint16_t timeout) { ble_error_t rc; if ((rc = _scanningParams.setTimeout(timeout)) != BLE_ERROR_NONE) { @@ -518,7 +499,8 @@ ble_error_t Gap::setScanTimeout(uint16_t timeout) return BLE_ERROR_NONE; } -ble_error_t Gap::setActiveScanning(bool activeScanning) +template +ble_error_t LegacyGap::setActiveScanning(bool activeScanning) { _scanningParams.setActiveScanning(activeScanning); @@ -530,7 +512,8 @@ ble_error_t Gap::setActiveScanning(bool activeScanning) return BLE_ERROR_NONE; } -ble_error_t Gap::startScan( +template +ble_error_t LegacyGap::startScan( void (*callback)(const AdvertisementCallbackParams_t *params) ) { ble_error_t err = BLE_ERROR_NONE; @@ -544,68 +527,80 @@ ble_error_t Gap::startScan( return err; } -GapAdvertisingParams &Gap::getAdvertisingParams(void) +template +GapAdvertisingParams &LegacyGap::getAdvertisingParams(void) { return _advParams; } -const GapAdvertisingParams &Gap::getAdvertisingParams(void) const +template +const GapAdvertisingParams &LegacyGap::getAdvertisingParams(void) const { return _advParams; } -void Gap::setAdvertisingParams(const GapAdvertisingParams &newParams) +template +void LegacyGap::setAdvertisingParams(const GapAdvertisingParams &newParams) { _advParams = newParams; } -void Gap::onTimeout(TimeoutEventCallback_t callback) +template +void LegacyGap::onTimeout(TimeoutEventCallback_t callback) { timeoutCallbackChain.add(callback); } -Gap::TimeoutEventCallbackChain_t& Gap::onTimeout() +template +typename LegacyGap::TimeoutEventCallbackChain_t& LegacyGap::onTimeout() { return timeoutCallbackChain; } -void Gap::onConnection(ConnectionEventCallback_t callback) +template +void LegacyGap::onConnection(ConnectionEventCallback_t callback) { connectionCallChain.add(callback); } -Gap::ConnectionEventCallbackChain_t& Gap::onConnection() +template +typename LegacyGap::ConnectionEventCallbackChain_t& LegacyGap::onConnection() { return connectionCallChain; } -void Gap::onDisconnection(DisconnectionEventCallback_t callback) +template +void LegacyGap::onDisconnection(DisconnectionEventCallback_t callback) { disconnectionCallChain.add(callback); } -Gap::DisconnectionEventCallbackChain_t& Gap::onDisconnection() +template +typename LegacyGap::DisconnectionEventCallbackChain_t& LegacyGap::onDisconnection() { return disconnectionCallChain; } -void Gap::onRadioNotification(void (*callback)(bool param)) +template +void LegacyGap::onRadioNotification(void (*callback)(bool param)) { radioNotificationCallback.attach(callback); } -void Gap::onShutdown(const GapShutdownCallback_t& callback) +template +void LegacyGap::onShutdown(const GapShutdownCallback_t& callback) { shutdownCallChain.add(callback); } -Gap::GapShutdownCallbackChain_t& Gap::onShutdown() +template +typename LegacyGap::GapShutdownCallbackChain_t& LegacyGap::onShutdown() { return shutdownCallChain; } - -Gap::AdvertisementCallbackParams_t::AdvertisementCallbackParams_t() : +template +LegacyGap::AdvertisementCallbackParams_t::AdvertisementCallbackParams_t() : peerAddr(), rssi(), isScanResponse(), @@ -617,7 +612,8 @@ Gap::AdvertisementCallbackParams_t::AdvertisementCallbackParams_t() : { } -ble_error_t Gap::getRandomAddressType( +template +ble_error_t LegacyGap::getRandomAddressType( const BLEProtocol::AddressBytes_t address, RandomAddressType_t* type ) { @@ -638,7 +634,8 @@ ble_error_t Gap::getRandomAddressType( } } -Gap::ConnectionCallbackParams_t::ConnectionCallbackParams_t( +template +LegacyGap::ConnectionCallbackParams_t::ConnectionCallbackParams_t( Handle_t handleIn, Role_t roleIn, BLEProtocol::AddressType_t peerAddrTypeIn, @@ -667,7 +664,8 @@ Gap::ConnectionCallbackParams_t::ConnectionCallbackParams_t( ); } -Gap::ConnectionCallbackParams_t::ConnectionCallbackParams_t( +template +LegacyGap::ConnectionCallbackParams_t::ConnectionCallbackParams_t( Handle_t handleIn, Role_t roleIn, PeerAddressType_t peerAddrTypeIn, @@ -698,7 +696,8 @@ Gap::ConnectionCallbackParams_t::ConnectionCallbackParams_t( convert_address_type(peerAddrTypeIn, peerAddrIn, peerAddrType); } -void Gap::ConnectionCallbackParams_t::constructor_helper( +template +void LegacyGap::ConnectionCallbackParams_t::constructor_helper( const uint8_t *peerAddrIn, const uint8_t *ownAddrIn, const uint8_t *peerResolvableAddrIn, @@ -725,7 +724,8 @@ void Gap::ConnectionCallbackParams_t::constructor_helper( } } -ble_error_t Gap::connect( +template +ble_error_t LegacyGap::connect( const BLEProtocol::AddressBytes_t peerAddr, DeprecatedAddressType_t peerAddrType, const ConnectionParams_t *connectionParams, @@ -739,7 +739,8 @@ ble_error_t Gap::connect( ); } -void Gap::processConnectionEvent( +template +void LegacyGap::processConnectionEvent( Handle_t handle, Role_t role, BLEProtocol::AddressType_t peerAddrType, @@ -770,7 +771,8 @@ void Gap::processConnectionEvent( connectionCallChain.call(&callbackParams); } -void Gap::processAdvertisementReport( +template +void LegacyGap::processAdvertisementReport( const BLEProtocol::AddressBytes_t peerAddr, int8_t rssi, bool isScanResponse, @@ -792,7 +794,8 @@ void Gap::processAdvertisementReport( onAdvertisementReport.call(¶ms); } -void Gap::processAdvertisementReport( +template +void LegacyGap::processAdvertisementReport( const BLEProtocol::AddressBytes_t peerAddr, int8_t rssi, bool isScanResponse, @@ -825,3 +828,361 @@ void Gap::processAdvertisementReport( #elif defined(__CC_ARM) #pragma pop #endif + +template +uint16_t LegacyGap::getMinAdvertisingInterval(void) const +{ + return impl()->getMinAdvertisingInterval_(); +} + +template +uint16_t LegacyGap::getMinNonConnectableAdvertisingInterval(void) const +{ + return impl()->getMinNonConnectableAdvertisingInterval_(); +} + +template +uint16_t LegacyGap::getMaxAdvertisingInterval(void) const +{ + return impl()->getMaxAdvertisingInterval_(); +} + +template +ble_error_t LegacyGap::getPreferredConnectionParams(ConnectionParams_t *params) +{ + return impl()->getPreferredConnectionParams_(params); +} + +template +ble_error_t LegacyGap::setPreferredConnectionParams( + const ConnectionParams_t *params +) +{ + return impl()->setPreferredConnectionParams_(params); +} + +template +ble_error_t LegacyGap::setDeviceName(const uint8_t *deviceName) +{ + return impl()->setDeviceName_(deviceName); +} + +template +ble_error_t LegacyGap::getDeviceName(uint8_t *deviceName, unsigned *lengthP) +{ + return impl()->getDeviceName_(deviceName, lengthP); +} + +template +ble_error_t LegacyGap::setAppearance(GapAdvertisingData::Appearance appearance) +{ + return impl()->setAppearance_(appearance); +} + +template +ble_error_t LegacyGap::getAppearance(GapAdvertisingData::Appearance *appearanceP) +{ + return impl()->getAppearance_(appearanceP); +} + +template +ble_error_t LegacyGap::setAdvertisingData( + const GapAdvertisingData &advData, + const GapAdvertisingData &scanResponse +) { + return impl()->setAdvertisingData_(advData, scanResponse); +} + +template +ble_error_t LegacyGap::startAdvertising(const GapAdvertisingParams ¶ms) { + return impl()->startAdvertising_(params); +} + +template +ble_error_t LegacyGap::reset(void) +{ + return impl()->reset_(); +} + +template +LegacyGap::LegacyGap() : + _advParams(), + _advPayload(), + _scanningParams(), + _scanResponse(), + connectionCount(0), + state(), + scanningActive(false), + timeoutCallbackChain(), + radioNotificationCallback(), + onAdvertisementReport(), + connectionCallChain(), + disconnectionCallChain() +{ + _advPayload.clear(); + _scanResponse.clear(); +} + +template +void LegacyGap::processDisconnectionEvent(Handle_t handle, DisconnectionReason_t reason) +{ + /* Update Gap state */ + --connectionCount; + if (!connectionCount) { + state.connected = 0; + } + + DisconnectionCallbackParams_t callbackParams(handle, reason); + disconnectionCallChain.call(&callbackParams); +} + +template +void LegacyGap::processTimeoutEvent(TimeoutSource_t source) +{ + if (source == TIMEOUT_SRC_ADVERTISING) { + /* Update gap state if the source is an advertising timeout */ + state.advertising = 0; + } + if (timeoutCallbackChain) { + timeoutCallbackChain(source); + } +} + + +template +uint16_t LegacyGap::getMinAdvertisingInterval_(void) const +{ + return 0; +} + +template +uint16_t LegacyGap::getMinNonConnectableAdvertisingInterval_(void) const +{ + return 0; +} + +template +uint16_t LegacyGap::getMaxAdvertisingInterval_(void) const +{ + return 0xFFFF; +} + +template +ble_error_t LegacyGap::reset_(void) +{ + /* Notify that the instance is about to shut down */ + shutdownCallChain.call(this); + shutdownCallChain.clear(); + + /* Clear Gap state */ + state.advertising = 0; + state.connected = 0; + connectionCount = 0; + + /* Clear scanning state */ + scanningActive = false; + + /* Clear advertising and scanning data */ + _advPayload.clear(); + _scanResponse.clear(); + + /* Clear callbacks */ + timeoutCallbackChain.clear(); + connectionCallChain.clear(); + disconnectionCallChain.clear(); + radioNotificationCallback = NULL; + onAdvertisementReport = NULL; + ble::interface::Gap::_eventHandler = NULL; + + return BLE_ERROR_NONE; +} + +// ----------------------------------------------------------------------------- +/* ------------------------- Default implementations ------------------------ */ +// ----------------------------------------------------------------------------- + +template +uint8_t LegacyGap::getMaxWhitelistSize_(void) const { + return 0; +} + +template +ble_error_t LegacyGap::getWhitelist_(Whitelist_t &whitelist) const { + return BLE_ERROR_NOT_IMPLEMENTED; +} + +template +ble_error_t LegacyGap::setWhitelist_(const Whitelist_t &whitelist) { + return BLE_ERROR_NOT_IMPLEMENTED; +} + +template +ble_error_t LegacyGap::setAddress_( + BLEProtocol::AddressType_t type, + const BLEProtocol::AddressBytes_t address +) { + return BLE_ERROR_NOT_IMPLEMENTED; +} + +template +ble_error_t LegacyGap::getAddress_( + BLEProtocol::AddressType_t *typeP, + BLEProtocol::AddressBytes_t address +) { + return BLE_ERROR_NOT_IMPLEMENTED; +} + +template +ble_error_t LegacyGap::stopAdvertising_(void) { + return BLE_ERROR_NOT_IMPLEMENTED; +} + +template +ble_error_t LegacyGap::connect_( + const BLEProtocol::AddressBytes_t peerAddr, + PeerAddressType_t peerAddrType, + const ConnectionParams_t *connectionParams, + const GapScanningParams *scanParams +) { + return BLE_ERROR_NOT_IMPLEMENTED; +} + +template +ble_error_t LegacyGap::connect_( + const BLEProtocol::AddressBytes_t peerAddr, + BLEProtocol::AddressType_t peerAddrType, + const ConnectionParams_t *connectionParams, + const GapScanningParams *scanParams +) { + return BLE_ERROR_NOT_IMPLEMENTED; +} + +template +ble_error_t LegacyGap::disconnect_( + Handle_t connectionHandle, DisconnectionReason_t reason +) { + return BLE_ERROR_NOT_IMPLEMENTED; +} + +template +ble_error_t LegacyGap::disconnect_(DisconnectionReason_t reason) { + return BLE_ERROR_NOT_IMPLEMENTED; +} + +template +ble_error_t LegacyGap::updateConnectionParams_( + Handle_t handle, + const ConnectionParams_t *params +) { + return BLE_ERROR_NOT_IMPLEMENTED; +} + + +template +ble_error_t LegacyGap::setTxPower_(int8_t txPower) { + return BLE_ERROR_NOT_IMPLEMENTED; +} + +template +void LegacyGap::getPermittedTxPowerValues_( + const int8_t **valueArrayPP, size_t *countP +) { + *countP = 0; +} + +template +ble_error_t LegacyGap::setAdvertisingPolicyMode_(AdvertisingPolicyMode_t mode) { + return BLE_ERROR_NOT_IMPLEMENTED; +} + +template +ble_error_t LegacyGap::setScanningPolicyMode_(ScanningPolicyMode_t mode) { + return BLE_ERROR_NOT_IMPLEMENTED; +} + +template +ble_error_t LegacyGap::setInitiatorPolicyMode_(InitiatorPolicyMode_t mode) { + return BLE_ERROR_NOT_IMPLEMENTED; +} + +template +typename LegacyGap::AdvertisingPolicyMode_t +LegacyGap::getAdvertisingPolicyMode_(void) const { + return LegacyGap::ADV_POLICY_IGNORE_WHITELIST; +} + +template +typename LegacyGap::ScanningPolicyMode_t +LegacyGap::getScanningPolicyMode_(void) const { + return LegacyGap::SCAN_POLICY_IGNORE_WHITELIST; +} + +template +typename LegacyGap::InitiatorPolicyMode_t +LegacyGap::getInitiatorPolicyMode_(void) const { + return LegacyGap::INIT_POLICY_IGNORE_WHITELIST; +} + +template +ble_error_t LegacyGap::startRadioScan_(const GapScanningParams &scanningParams) { + return BLE_ERROR_NOT_IMPLEMENTED; +} + +template +ble_error_t LegacyGap::initRadioNotification_(void) { + return BLE_ERROR_NOT_IMPLEMENTED; +} + +template +ble_error_t LegacyGap::getPreferredConnectionParams_(ConnectionParams_t *params) +{ + return BLE_ERROR_NOT_IMPLEMENTED; +} + +template +ble_error_t LegacyGap::setPreferredConnectionParams_( + const ConnectionParams_t *params +) +{ + return BLE_ERROR_NOT_IMPLEMENTED; +} + +template +ble_error_t LegacyGap::setDeviceName_(const uint8_t *deviceName) +{ + return BLE_ERROR_NOT_IMPLEMENTED; +} + +template +ble_error_t LegacyGap::getDeviceName_(uint8_t *deviceName, unsigned *lengthP) +{ + return BLE_ERROR_NOT_IMPLEMENTED; +} + +template +ble_error_t LegacyGap::setAppearance_(GapAdvertisingData::Appearance appearance) +{ + return BLE_ERROR_NOT_IMPLEMENTED; +} + +template +ble_error_t LegacyGap::getAppearance_(GapAdvertisingData::Appearance *appearanceP) +{ + return BLE_ERROR_NOT_IMPLEMENTED; +} + +template +ble_error_t LegacyGap::setAdvertisingData_( + const GapAdvertisingData &advData, + const GapAdvertisingData &scanResponse +) { + return BLE_ERROR_NOT_IMPLEMENTED; +} + +template +ble_error_t LegacyGap::startAdvertising_(const GapAdvertisingParams ¶ms) { + return BLE_ERROR_NOT_IMPLEMENTED; +} + +} // namespace interface +} // namespace ble