diff --git a/connectivity/FEATURE_BLE/include/ble/BLE.h b/connectivity/FEATURE_BLE/include/ble/BLE.h index 03dfe282b96..e1966b9b51d 100644 --- a/connectivity/FEATURE_BLE/include/ble/BLE.h +++ b/connectivity/FEATURE_BLE/include/ble/BLE.h @@ -19,20 +19,20 @@ #ifndef MBED_BLE_H__ #define MBED_BLE_H__ -#include "FunctionPointerWithContext.h" #include "platform/mbed_error.h" #include "platform/mbed_assert.h" #include "platform/mbed_toolchain.h" -#include "ble/common/ble/BLERoles.h" -#include "ble/common/ble/BLETypes.h" -#include "ble/common/ble/blecommon.h" - #include "ble/Gap.h" #include "ble/GattClient.h" #include "ble/GattServer.h" #include "ble/SecurityManager.h" +#include "ble/common/BLERoles.h" +#include "ble/common/BLETypes.h" +#include "ble/common/blecommon.h" +#include "ble/common/FunctionPointerWithContext.h" + /* Forward declaration for the implementation class */ namespace ble { @@ -154,6 +154,10 @@ class BLE { */ static const InstanceID_t NUM_INSTANCES = 1; + // Prevent copy construction and copy assignment of BLE. + BLE(const BLE &) = delete; + BLE &operator=(const BLE &) = delete; + /** * Get a reference to the BLE singleton. * @@ -164,16 +168,6 @@ class BLE { */ static BLE &Instance(); - /** - * Constructor for a handle to a BLE instance (the BLE stack). BLE handles - * are thin wrappers around a transport object (that is, ptr. to - * ble::BLEInstanceBase). - * - * @param[in] transport Ble transport used for the BLE instance. - * @note Cordio supports only one instance. - */ - BLE(ble::BLEInstanceBase &transport); - /** * Get a reference to the BLE singleton corresponding to a given interface. * @@ -203,7 +197,7 @@ class BLE { */ MBED_DEPRECATED_SINCE("mbed-os-6.3.0", "BLE singleton supports one instance. You may create multiple" "instances by using the constructor.") - InstanceID_t getInstanceID(void) const + InstanceID_t getInstanceID() const { return DEFAULT_INSTANCE; } @@ -309,7 +303,7 @@ class BLE { * @attention This should be called before using anything else in the BLE * API. */ - ble_error_t init(InitializationCompleteCallback_t completion_cb = NULL) + ble_error_t init(InitializationCompleteCallback_t completion_cb = nullptr) { FunctionPointerWithContext callback(completion_cb); return initImplementation(callback); @@ -341,7 +335,7 @@ class BLE { * @note The application should set up a callback to signal completion of * initialization when using init(). */ - bool hasInitialized(void) const; + bool hasInitialized() const; /** * Shut down the underlying stack, and reset state of this BLE instance. @@ -353,7 +347,7 @@ class BLE { * GAP state. This API offers a way to repopulate the GATT database with new * services and characteristics. */ - ble_error_t shutdown(void); + ble_error_t shutdown(); /** * This call allows the application to get the BLE stack version information. @@ -362,7 +356,7 @@ class BLE { * * @note The BLE API owns the string returned. */ - const char *getVersion(void); + const char *getVersion(); /** * Accessor to Gap. All Gap-related functionality requires going through @@ -455,6 +449,16 @@ class BLE { private: friend class ble::BLEInstanceBase; + /** + * Constructor for a handle to a BLE instance (the BLE stack). BLE handles + * are thin wrappers around a transport object (that is, ptr. to + * ble::BLEInstanceBase). + * + * @param[in] transport Ble transport used for the BLE instance. + * @note Cordio supports only one instance. + */ + BLE(ble::BLEInstanceBase &transport); + /** * Implementation of init() [internal to BLE_API]. * @@ -465,11 +469,6 @@ class BLE { FunctionPointerWithContext callback ); -private: - // Prevent copy construction and copy assignment of BLE. - BLE(const BLE &); - BLE &operator=(const BLE &); - private: ble::BLEInstanceBase &transport; /* The device-specific backend */ OnEventsToProcessCallback_t whenEventsToProcess; @@ -480,7 +479,7 @@ class BLE { using ble::BLE; /** - * @namespace ble Entry namespace for all %BLE API definitions. + * @namespace ble Entry namespace for all BLE API definitions. */ /** diff --git a/connectivity/FEATURE_BLE/include/ble/Gap.h b/connectivity/FEATURE_BLE/include/ble/Gap.h index 6caf0df0b16..ed8cfe2c723 100644 --- a/connectivity/FEATURE_BLE/include/ble/Gap.h +++ b/connectivity/FEATURE_BLE/include/ble/Gap.h @@ -19,28 +19,27 @@ #ifndef BLE_GAP_GAP_H #define BLE_GAP_GAP_H -#include "CallChainOfFunctionPointersWithContext.h" - -#include - -#include "drivers/LowPowerTimeout.h" -#include "drivers/LowPowerTicker.h" -#include "platform/mbed_error.h" - -#include "ble/common/ble/BLERoles.h" -#include "ble/common/ble/BLETypes.h" -#include "ble/common/ble/gap/AdvertisingDataBuilder.h" -#include "ble/common/ble/gap/AdvertisingDataParser.h" -#include "ble/common/ble/gap/AdvertisingDataSimpleBuilder.h" -#include "ble/common/ble/gap/AdvertisingDataTypes.h" -#include "ble/common/ble/gap/AdvertisingParameters.h" -#include "ble/common/ble/gap/ConnectionParameters.h" -#include "ble/common/ble/gap/Events.h" -#include "ble/common/ble/gap/ScanParameters.h" -#include "ble/common/ble/gap/Types.h" +#include "ble/common/CallChainOfFunctionPointersWithContext.h" + +#include "ble/common/BLERoles.h" +#include "ble/common/BLETypes.h" +#include "ble/gap/AdvertisingDataBuilder.h" +#include "ble/gap/AdvertisingDataParser.h" +#include "ble/gap/AdvertisingDataSimpleBuilder.h" +#include "ble/gap/AdvertisingDataTypes.h" +#include "ble/gap/AdvertisingParameters.h" +#include "ble/gap/ConnectionParameters.h" +#include "ble/gap/ScanParameters.h" +#include "ble/gap/Events.h" +#include "ble/gap/Types.h" namespace ble { -class PalGenericAccessService; + +#if !defined(DOXYGEN_ONLY) +namespace impl { +class Gap; +} +#endif // !defined(DOXYGEN_ONLY) /** * @addtogroup ble @@ -280,9 +279,6 @@ class PalGenericAccessService; * PHY and of any changes to PHYs which may be triggered autonomously by the * controller or by the peer. */ -#if !defined(DOXYGEN_ONLY) -namespace interface { -#endif // !defined(DOXYGEN_ONLY) class Gap { public: /** @@ -547,9 +543,7 @@ class Gap { * Prevent polymorphic deletion and avoid unnecessary virtual destructor * as the Gap class will never delete the instance it contains. */ - ~EventHandler() - { - } + ~EventHandler() = default; }; /** @@ -1314,7 +1308,7 @@ class Gap { * * @return Maximum size of the whitelist. */ - uint8_t getMaxWhitelistSize(void) const; + uint8_t getMaxWhitelistSize() const; /** * Get the Link Layer to use the internal whitelist when scanning, @@ -1377,7 +1371,7 @@ class Gap { * the address in input was not identifiable as a random address. */ static ble_error_t getRandomAddressType( - const ble::address_t address, + ble::address_t address, ble::random_address_type_t *addressType ); @@ -1399,7 +1393,7 @@ class Gap { * @note Currently, a call to reset() does not reset the advertising and * scan parameters to default values. */ - ble_error_t reset(void); + ble_error_t reset(); /** * Register a Gap shutdown event handler. @@ -1421,7 +1415,9 @@ class Gap { * @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 Gap *)) { + onShutdown(GapShutdownCallback_t(objPtr, memberPtr)); + } /** * Access the callchain of shutdown event handler. @@ -1435,6 +1431,17 @@ class Gap { GapShutdownCallbackChain_t &onShutdown(); #if !defined(DOXYGEN_ONLY) + /* + * Constructor from the private implementation. + */ + Gap(impl::Gap* impl) : impl(impl) {} + + /* + * Restrict copy and move. + */ + Gap(const Gap&) = delete; + Gap& operator=(const Gap&) = delete; + /* * API reserved for the controller driver to set the random static address. * Setting a new random static address while the controller is operating is @@ -1442,6 +1449,9 @@ class Gap { */ ble_error_t setRandomStaticAddress(const ble::address_t& address); #endif // !defined(DOXYGEN_ONLY) + +private: + impl::Gap* impl; }; /** @@ -1449,15 +1459,8 @@ class Gap { * @} */ -#if !defined(DOXYGEN_ONLY) -} // namespace interface -#endif // !defined(DOXYGEN_ONLY) } // namespace ble -/* This includes the concrete class implementation, to provide a an alternative API implementation - * disable ble-api-implementation and place your header in a path with the same structure */ -#include "ble/internal/GapImpl.h" - /** @deprecated Use the namespaced ble::Gap instead of the global Gap. */ using ble::Gap; diff --git a/connectivity/FEATURE_BLE/include/ble/GattClient.h b/connectivity/FEATURE_BLE/include/ble/GattClient.h index 37d7f1e88ed..216a085861a 100644 --- a/connectivity/FEATURE_BLE/include/ble/GattClient.h +++ b/connectivity/FEATURE_BLE/include/ble/GattClient.h @@ -21,19 +21,24 @@ #define MBED_GATT_CLIENT_H__ -#include "CallChainOfFunctionPointersWithContext.h" -#include +#include "ble/common/CallChainOfFunctionPointersWithContext.h" +#include "ble/common/blecommon.h" -#include "ble/common/ble/blecommon.h" -#include "ble/common/ble/GattAttribute.h" -#include "ble/common/ble/ServiceDiscovery.h" -#include "ble/common/ble/CharacteristicDescriptorDiscovery.h" -#include "ble/common/ble/GattCallbackParamTypes.h" -#include "ble/common/ble/DiscoveredService.h" -#include "ble/common/ble/DiscoveredCharacteristic.h" +#include "ble/gatt/GattAttribute.h" +#include "ble/gatt/ServiceDiscovery.h" +#include "ble/gatt/CharacteristicDescriptorDiscovery.h" +#include "ble/gatt/GattCallbackParamTypes.h" +#include "ble/gatt/DiscoveredService.h" +#include "ble/gatt/DiscoveredCharacteristic.h" namespace ble { +#if !defined(DOXYGEN_ONLY) +namespace impl { +class GattClient; +} +#endif // !defined(DOXYGEN_ONLY) + /** * @addtogroup ble * @{ @@ -89,9 +94,6 @@ namespace ble { * indicate properties are set. The client discovers that descriptor * if it intends to register to server initiated events. */ -#if !defined(DOXYGEN_ONLY) -namespace interface { -#endif // !defined(DOXYGEN_ONLY) class GattClient { public: /** @@ -118,9 +120,7 @@ class GattClient { * Prevent polymorphic deletion and avoid unnecessary virtual destructor * as the GattClient class will never delete the instance it contains. */ - ~EventHandler() - { - } + ~EventHandler() = default; }; /** @@ -233,7 +233,7 @@ class GattClient { * specific subclass. */ - ~GattClient() { } + ~GattClient() = default; /** * Launch the service and characteristic discovery procedure of a GATT server @@ -287,8 +287,8 @@ class GattClient { */ ble_error_t launchServiceDiscovery( ble::connection_handle_t connectionHandle, - ServiceDiscovery::ServiceCallback_t sc = NULL, - ServiceDiscovery::CharacteristicCallback_t cc = NULL, + ServiceDiscovery::ServiceCallback_t sc = nullptr, + ServiceDiscovery::CharacteristicCallback_t cc = nullptr, const UUID &matchingServiceUUID = UUID::ShortUUIDBytes_t(BLE_UUID_UNKNOWN), const UUID &matchingCharacteristicUUIDIn = UUID::ShortUUIDBytes_t(BLE_UUID_UNKNOWN) ); @@ -366,7 +366,7 @@ class GattClient { * * @return true if service discovery procedure is active and false otherwise. */ - bool isServiceDiscoveryActive(void) const; + bool isServiceDiscoveryActive() const; /** * Terminate all ongoing service discovery procedures. @@ -374,7 +374,7 @@ class GattClient { * It results in an invocation of the service discovery termination handler * registered with onServiceDiscoveryTermination(). */ - void terminateServiceDiscovery(void); + void terminateServiceDiscovery(); /** * Initiate the read procedure of an attribute handle. @@ -625,7 +625,10 @@ class GattClient { * available. */ template - void onShutdown(T *objPtr, void (T::*memberPtr)(const GattClient *)); + void onShutdown(T *objPtr, void (T::*memberPtr)(const GattClient *)) + { + onShutdown({objPtr, memberPtr}); + } /** * Get the callchain of shutdown event handlers. @@ -649,7 +652,6 @@ class GattClient { */ HVXCallbackChain_t& onHVX(); - /** * Reset the state of the GattClient instance. * @@ -667,7 +669,7 @@ class GattClient { * * @return BLE_ERROR_NONE on success. */ - ble_error_t reset(void); + ble_error_t reset(); /* Entry points for the underlying stack to report events back to the user. */ @@ -703,6 +705,15 @@ class GattClient { * registered handlers. */ void processHVXEvent(const GattHVXCallbackParams *params); + +#if !defined(DOXYGEN_ONLY) + GattClient(impl::GattClient* impl) : impl(impl) { } + GattClient(const GattClient&) = delete; + GattClient& operator=(const GattClient&) = delete; +#endif // !defined(DOXYGEN_ONLY) + +private: + impl::GattClient *impl; }; /** @@ -711,15 +722,8 @@ class GattClient { * @} */ -#if !defined(DOXYGEN_ONLY) -} // namespace interface -#endif // !defined(DOXYGEN_ONLY) } // namespace ble -/* This includes the concrete class implementation, to provide a an alternative API implementation - * disable ble-api-implementation and place your header in a path with the same structure */ -#include "ble/internal/GattClientImpl.h" - /** @deprecated Use the namespaced ble::GattClient instead of the global GattClient. */ using ble::GattClient; diff --git a/connectivity/FEATURE_BLE/include/ble/GattServer.h b/connectivity/FEATURE_BLE/include/ble/GattServer.h index e89d29412c1..6b1261f1f51 100644 --- a/connectivity/FEATURE_BLE/include/ble/GattServer.h +++ b/connectivity/FEATURE_BLE/include/ble/GattServer.h @@ -20,19 +20,22 @@ #ifndef MBED_GATT_SERVER_H__ #define MBED_GATT_SERVER_H__ -#include "CallChainOfFunctionPointersWithContext.h" +#include "ble/common/CallChainOfFunctionPointersWithContext.h" +#include "ble/common/blecommon.h" -#include "ble/common/ble/GattService.h" -#include "ble/common/ble/GattAttribute.h" -#include "ble/common/ble/GattServerEvents.h" -#include "ble/common/ble/GattCallbackParamTypes.h" - -#include "ble/common/ble/blecommon.h" -#include "ble/Gap.h" -#include "SecurityManager.h" +#include "ble/gatt/GattService.h" +#include "ble/gatt/GattAttribute.h" +#include "ble/gatt/GattCallbackParamTypes.h" namespace ble { +#if !defined(DOXYGEN_ONLY) +namespace impl { +class GattServer; +} +#endif // !defined(DOXYGEN_ONLY) + + /** * @addtogroup ble * @{ @@ -94,9 +97,6 @@ namespace ble { * Characteristic Value Notification and Characteristic Value Indication when * the nature of the server initiated is not relevant. */ -#if !defined(DOXYGEN_ONLY) -namespace interface { -#endif // !defined(DOXYGEN_ONLY) class GattServer { public: /** @@ -123,9 +123,7 @@ class GattServer { * Prevent polymorphic deletion and avoid unnecessary virtual destructor * as the GattServer class will never delete the instance it contains. */ - ~EventHandler() - { - } + ~EventHandler() = default; }; /** @@ -221,7 +219,7 @@ class GattServer { * * @return BLE_ERROR_NONE on success. */ - ble_error_t reset(void); + ble_error_t reset(); /** * Add a service declaration to the local attribute server table. @@ -415,7 +413,10 @@ class GattServer { * function. */ template - void onDataSent(T *objPtr, void (T::*memberPtr)(unsigned count)); + void onDataSent(T *objPtr, void (T::*memberPtr)(unsigned count)) + { + onDataSent({objPtr, memberPtr}); + } /** * Access the callchain of data sent event handlers. @@ -448,7 +449,10 @@ class GattServer { void onDataWritten( T *objPtr, void (T::*memberPtr)(const GattWriteCallbackParams *context) - ); + ) + { + onDataWritten({objPtr, memberPtr}); + } /** * Access the callchain of data written event handlers. @@ -495,7 +499,10 @@ class GattServer { ble_error_t onDataRead( T *objPtr, void (T::*memberPtr)(const GattReadCallbackParams *context) - ); + ) + { + return onDataRead({objPtr, memberPtr}); + } /** * Access the callchain of data read event handlers. @@ -537,7 +544,10 @@ class GattServer { * function. */ template - void onShutdown(T *objPtr, void (T::*memberPtr)(const GattServer *)); + void onShutdown(T *objPtr, void (T::*memberPtr)(const GattServer *)) + { + onShutdown({objPtr, memberPtr}); + } /** * Access the callchain of shutdown event handlers. @@ -578,72 +588,14 @@ class GattServer { */ void onConfirmationReceived(EventCallback_t callback); - /* Entry points for the underlying stack to report events back to the user. */ -protected: - /** - * Helper function that notifies all registered handlers of an occurrence - * of a data written event. - * - * @attention Vendor implementation must invoke this function after one of - * the GattServer attributes has been written. - * - * @param[in] params The data written parameters passed to the registered - * handlers. - */ - void handleDataWrittenEvent(const GattWriteCallbackParams *params); - - /** - * Helper function that notifies all registered handlers of an occurrence - * of a data read event. - * - * @attention Vendor implementation must invoke this function after one of - * the GattServer attributes has been read. - * - * @param[in] params The data read parameters passed to the registered - * handlers. - */ - void handleDataReadEvent(const GattReadCallbackParams *params); - - /** - * Helper function that notifies the registered handler of an occurrence - * of updates enabled, updates disabled or confirmation received events. - * - * @attention Vendor implementation must invoke this function when a client - * subscribes to characteristic updates, unsubscribes from characteristic - * updates or a notification confirmation has been received. - * - * @param[in] type The type of event that occurred. - * @param[in] attributeHandle The handle of the attribute concerned by the - * event. - */ - void handleEvent( - GattServerEvents::gattEvent_e type, - GattAttribute::Handle_t attributeHandle - ); - - /** - * Helper function that notifies all registered handlers of an occurrence - * of a data sent event. - * - * @attention Vendor implementation must invoke this function after the - * emission of a notification or an indication. - * - * @param[in] count Number of packets sent. - */ - void handleDataSentEvent(unsigned count); - - /** - * Get preferred connection paramters. - * - */ - Gap::PreferredConnectionParams_t getPreferredConnectionParams(); +#if !defined(DOXYGEN_ONLY) + GattServer(impl::GattServer* impl) : impl(impl) {} + GattServer(const GattServer&) = delete; + GattServer& operator=(const GattServer&) = delete; +#endif // !defined(DOXYGEN_ONLY) - /** - * Set preferred connection parameters. - * - * @param[in] params Preferred connection parameter values to set. - */ - void setPreferredConnectionParams(const Gap::PreferredConnectionParams_t& params); +private: + impl::GattServer *impl; }; /** @@ -652,15 +604,8 @@ class GattServer { * @} */ -#if !defined(DOXYGEN_ONLY) -} // namespace interface -#endif // !defined(DOXYGEN_ONLY) } // ble -/* This includes the concrete class implementation, to provide a an alternative API implementation - * disable ble-api-implementation and place your header in a path with the same structure */ -#include "ble/internal/GattServerImpl.h" - /** @deprecated Use the namespaced ble::GattServer instead of the global GattServer. */ using ble::GattServer; diff --git a/connectivity/FEATURE_BLE/include/ble/SecurityManager.h b/connectivity/FEATURE_BLE/include/ble/SecurityManager.h index b0e81e4d6ee..4f6bb67cc96 100644 --- a/connectivity/FEATURE_BLE/include/ble/SecurityManager.h +++ b/connectivity/FEATURE_BLE/include/ble/SecurityManager.h @@ -19,20 +19,20 @@ #ifndef BLE_SECURITY_MANAGER_H_ #define BLE_SECURITY_MANAGER_H_ -#include -#include "CallChainOfFunctionPointersWithContext.h" -#include "platform/Callback.h" +#include -#include "ble/common/ble/BLETypes.h" -#include "ble/common/ble/blecommon.h" - -#include "ble/common/ble/BLETypes.h" -#include "ble/internal/SecurityDb.h" -#include "ble/internal/PalConnectionMonitor.h" -#include "ble/internal/PalSecurityManager.h" +#include "ble/common/BLETypes.h" +#include "ble/common/blecommon.h" +#include "ble/common/CallChainOfFunctionPointersWithContext.h" namespace ble { +#if !defined(DOXYGEN_ONLY) +namespace impl { +class SecurityManager; +} +#endif // !defined(DOXYGEN_ONLY) + /** * Overview * @@ -186,9 +186,6 @@ namespace ble { * @endverbatim * */ -#if !defined(DOXYGEN_ONLY) -namespace interface { -#endif // !defined(DOXYGEN_ONLY) class SecurityManager { public: @@ -421,9 +418,7 @@ class SecurityManager * Prevent polymorphic deletion and avoid unnecessary virtual destructor * as the SecurityManager class will never delete the instance it contains. */ - ~EventHandler() - { - } + ~EventHandler() = default; }; /* @@ -457,9 +452,9 @@ class SecurityManager bool enableBonding = true, bool requireMITM = true, SecurityIOCapabilities_t iocaps = IO_CAPS_NONE, - const Passkey_t passkey = NULL, + const Passkey_t passkey = nullptr, bool signing = true, - const char *dbFilepath = NULL + const char *dbFilepath = nullptr ); /** @@ -473,7 +468,7 @@ class SecurityManager * * @return BLE_ERROR_NONE on success. */ - ble_error_t setDatabaseFilepath(const char *dbFilepath = NULL); + ble_error_t setDatabaseFilepath(const char *dbFilepath = nullptr); /** * Notify all registered onShutdown callbacks that the SecurityManager is @@ -488,7 +483,7 @@ class SecurityManager * * @return BLE_ERROR_NONE on success. */ - ble_error_t reset(void); + ble_error_t reset(); /** * Normally all bonding information is lost when device is reset, this requests that the stack @@ -511,7 +506,7 @@ class SecurityManager * @retval BLE_ERROR_INVALID_STATE If the API is called without module initialization or * application registration. */ - ble_error_t purgeAllBondingState(void); + ble_error_t purgeAllBondingState(); /** * Create a list of addresses from all peers in the bond table and generate @@ -870,7 +865,10 @@ class SecurityManager void onShutdown(const SecurityManagerShutdownCallback_t& callback); template - void onShutdown(T *objPtr, void (T::*memberPtr)(const SecurityManager *)); + void onShutdown(T *objPtr, void (T::*memberPtr)(const SecurityManager *)) + { + onShutdown({objPtr, memberPtr}); + } /** * Provide access to the callchain of shutdown event callbacks. @@ -894,18 +892,18 @@ class SecurityManager /** For backwards compatibility. This enum is now in BLETypes.h * @deprecated use the enum in ble namespace */ typedef ble::Keypress_t Keypress_t; + + SecurityManager(impl::SecurityManager* impl) : impl(impl) {} + SecurityManager(const SecurityManager&) = delete; + SecurityManager& operator=(const SecurityManager&) = delete; #endif // !defined(DOXYGEN_ONLY) + +private: + impl::SecurityManager *impl; }; -#if !defined(DOXYGEN_ONLY) -} // namespace interface -#endif // !defined(DOXYGEN_ONLY) } // ble -/* This includes the concrete class implementation, to provide a an alternative API implementation - * disable ble-api-implementation and place your header in a path with the same structure */ -#include "ble/internal/SecurityManagerImpl.h" - /** @deprecated Use the namespaced ble::SecurityManager instead of the global SecurityManager. */ using ble::SecurityManager; diff --git a/connectivity/FEATURE_BLE/include/ble/common/ble/BLERoles.h b/connectivity/FEATURE_BLE/include/ble/common/BLERoles.h similarity index 100% rename from connectivity/FEATURE_BLE/include/ble/common/ble/BLERoles.h rename to connectivity/FEATURE_BLE/include/ble/common/BLERoles.h diff --git a/connectivity/FEATURE_BLE/include/ble/common/ble/BLETypes.h b/connectivity/FEATURE_BLE/include/ble/common/BLETypes.h similarity index 99% rename from connectivity/FEATURE_BLE/include/ble/common/ble/BLETypes.h rename to connectivity/FEATURE_BLE/include/ble/common/BLETypes.h index 87105725d24..6771084df64 100644 --- a/connectivity/FEATURE_BLE/include/ble/common/ble/BLETypes.h +++ b/connectivity/FEATURE_BLE/include/ble/common/BLETypes.h @@ -19,13 +19,14 @@ #ifndef BLE_TYPES_H_ #define BLE_TYPES_H_ -#include -#include -#include -#include "SafeEnum.h" +#include +#include +#include + #include "platform/Span.h" -#include "ble/common/ble/gap/Types.h" +#include "ble/common/SafeEnum.h" +#include "ble/gap/Types.h" /** * @addtogroup ble @@ -872,7 +873,7 @@ struct whitelist_t { * @post type is equal to PUBLIC and the address value is equal to * 00:00:00:00:00:00 */ - entry_t(void) : type(), address() { } + entry_t() : type(), address() { } /** * Type of the peer address. diff --git a/connectivity/FEATURE_BLE/include/ble/common/ble/Bounded.h b/connectivity/FEATURE_BLE/include/ble/common/Bounded.h similarity index 97% rename from connectivity/FEATURE_BLE/include/ble/common/ble/Bounded.h rename to connectivity/FEATURE_BLE/include/ble/common/Bounded.h index a124fd5aac6..fa4c154a5ef 100644 --- a/connectivity/FEATURE_BLE/include/ble/common/ble/Bounded.h +++ b/connectivity/FEATURE_BLE/include/ble/common/Bounded.h @@ -19,7 +19,7 @@ #ifndef BLE_COMMON_BOUNDED_H_ #define BLE_COMMON_BOUNDED_H_ -#include +#include namespace ble { @@ -47,9 +47,9 @@ struct Bounded { Bounded(Rep v) : _value(v) { if (v < Min) { - _value = v; + _value = Min; } else if (v > Max) { - _value = v; + _value = Max; } } diff --git a/connectivity/FEATURE_BLE/include/ble/common/ble/CallChainOfFunctionPointersWithContext.h b/connectivity/FEATURE_BLE/include/ble/common/CallChainOfFunctionPointersWithContext.h similarity index 97% rename from connectivity/FEATURE_BLE/include/ble/common/ble/CallChainOfFunctionPointersWithContext.h rename to connectivity/FEATURE_BLE/include/ble/common/CallChainOfFunctionPointersWithContext.h index ac2431e012b..6348f53d68e 100644 --- a/connectivity/FEATURE_BLE/include/ble/common/ble/CallChainOfFunctionPointersWithContext.h +++ b/connectivity/FEATURE_BLE/include/ble/common/CallChainOfFunctionPointersWithContext.h @@ -19,9 +19,9 @@ #ifndef MBED_CALLCHAIN_OF_FUNCTION_POINTERS_WITH_CONTEXT_H #define MBED_CALLCHAIN_OF_FUNCTION_POINTERS_WITH_CONTEXT_H -#include -#include "FunctionPointerWithContext.h" -#include "SafeBool.h" +#include +#include "ble/common/FunctionPointerWithContext.h" +#include "ble/common/SafeBool.h" /** * @addtogroup ble @@ -96,6 +96,14 @@ class CallChainOfFunctionPointersWithContext : */ CallChainOfFunctionPointersWithContext() : chainHead(NULL) { } + /* Disallow copy constructor and assignment operators. */ + CallChainOfFunctionPointersWithContext( + const CallChainOfFunctionPointersWithContext& + ) = delete; + CallChainOfFunctionPointersWithContext &operator=( + const CallChainOfFunctionPointersWithContext& + ) = delete; + /** * Destruction of the callchain. */ @@ -186,7 +194,7 @@ class CallChainOfFunctionPointersWithContext : /** * Remove all functions registered in the chain. */ - void clear(void) + void clear() { pFunctionPointerWithContext_t fptr = chainHead; while (fptr) { @@ -203,7 +211,7 @@ class CallChainOfFunctionPointersWithContext : * * @return true if the callchain is not empty and false otherwise. */ - bool hasCallbacksAttached(void) const + bool hasCallbacksAttached() const { return (chainHead != NULL); } @@ -324,16 +332,6 @@ class CallChainOfFunctionPointersWithContext : * const from an external standpoint. */ mutable pFunctionPointerWithContext_t currentCalled; - - - /* Disallow copy constructor and assignment operators. */ -private: - CallChainOfFunctionPointersWithContext( - const CallChainOfFunctionPointersWithContext& - ); - CallChainOfFunctionPointersWithContext &operator=( - const CallChainOfFunctionPointersWithContext& - ); }; /** diff --git a/connectivity/FEATURE_BLE/include/ble/common/ble/Duration.h b/connectivity/FEATURE_BLE/include/ble/common/Duration.h similarity index 99% rename from connectivity/FEATURE_BLE/include/ble/common/ble/Duration.h rename to connectivity/FEATURE_BLE/include/ble/common/Duration.h index 7d78bdebcd4..4862ebb60f6 100644 --- a/connectivity/FEATURE_BLE/include/ble/common/ble/Duration.h +++ b/connectivity/FEATURE_BLE/include/ble/common/Duration.h @@ -19,8 +19,8 @@ #ifndef BLE_COMMON_DURATION_H_ #define BLE_COMMON_DURATION_H_ -#include -#include +#include +#include #include "platform/mbed_assert.h" #include "platform/mbed_chrono.h" @@ -155,7 +155,7 @@ struct Duration { * @param other_ms The Duration in millisecond to convert. */ template - explicit Duration(Duration other_ms, void* = NULL) : + explicit Duration(Duration other_ms, void* = nullptr) : duration(clamp(((other_ms.value() * 1000) + TB - 1) / TB)) { } diff --git a/connectivity/FEATURE_BLE/include/ble/common/ble/FunctionPointerWithContext.h b/connectivity/FEATURE_BLE/include/ble/common/FunctionPointerWithContext.h similarity index 98% rename from connectivity/FEATURE_BLE/include/ble/common/ble/FunctionPointerWithContext.h rename to connectivity/FEATURE_BLE/include/ble/common/FunctionPointerWithContext.h index 5fcfc19e592..aa9205278da 100644 --- a/connectivity/FEATURE_BLE/include/ble/common/ble/FunctionPointerWithContext.h +++ b/connectivity/FEATURE_BLE/include/ble/common/FunctionPointerWithContext.h @@ -19,8 +19,8 @@ #ifndef MBED_FUNCTIONPOINTER_WITH_CONTEXT_H #define MBED_FUNCTIONPOINTER_WITH_CONTEXT_H -#include -#include "SafeBool.h" +#include +#include "ble/common/SafeBool.h" /** * @file @@ -106,6 +106,10 @@ class FunctionPointerWithContext : public SafeBool -#include +#include +#include namespace ble { diff --git a/connectivity/FEATURE_BLE/include/ble/common/ble/UUID.h b/connectivity/FEATURE_BLE/include/ble/common/UUID.h similarity index 96% rename from connectivity/FEATURE_BLE/include/ble/common/ble/UUID.h rename to connectivity/FEATURE_BLE/include/ble/common/UUID.h index 7d560a5e8e8..9d471e69015 100644 --- a/connectivity/FEATURE_BLE/include/ble/common/ble/UUID.h +++ b/connectivity/FEATURE_BLE/include/ble/common/UUID.h @@ -19,12 +19,12 @@ #ifndef MBED_UUID_H__ #define MBED_UUID_H__ -#include -#include -#include +#include +#include +#include #include -#include "ble/common/ble/blecommon.h" +#include "ble/common/blecommon.h" /** * @file @@ -235,6 +235,13 @@ class UUID { memcpy(baseUUID, source.baseUUID, LENGTH_OF_LONG_UUID); } + /** + * UUID copy assignment. + * + * @param[in] source The UUID to copy. + */ + UUID& operator=(const UUID &source) = default; + /** * Default constructor. * @@ -243,7 +250,7 @@ class UUID { * @post shortOrLong() returns the value UUID_TYPE_SHORT. * @post getShortUUID() returns the value BLE_UUID_UNKNOWN. */ - UUID(void) : + UUID() : type(UUID_TYPE_SHORT), shortUUID(BLE_UUID_UNKNOWN) { } @@ -276,7 +283,7 @@ class UUID { * @return UUID_TYPE_SHORT if the UUID is 16-bit wide. * @return UUID_TYPE_LONG if the UUID is 128-bit wide. */ - UUID_Type_t shortOrLong(void) const + UUID_Type_t shortOrLong() const { return type; } @@ -287,7 +294,7 @@ class UUID { * @return A pointer to an uint16_t object if the UUID is 16 bits long. * @return A pointer to an array of 16 bytes if the UUID is 128 bits long. */ - const uint8_t *getBaseUUID(void) const + const uint8_t *getBaseUUID() const { if (type == UUID_TYPE_SHORT) { return (const uint8_t*)&shortUUID; @@ -303,7 +310,7 @@ class UUID { * * @return The value of the shortened UUID. */ - ShortUUIDBytes_t getShortUUID(void) const + ShortUUIDBytes_t getShortUUID() const { return shortUUID; } @@ -314,7 +321,7 @@ class UUID { * @return sizeof(ShortUUIDBytes_t) if the UUID type is UUID_TYPE_SHORT. * @return LENGTH_OF_LONG_UUID if the UUID type is UUID_TYPE_LONG. */ - uint8_t getLen(void) const + uint8_t getLen() const { return ((type == UUID_TYPE_SHORT) ? sizeof(ShortUUIDBytes_t) : diff --git a/connectivity/FEATURE_BLE/include/ble/common/ble/blecommon.h b/connectivity/FEATURE_BLE/include/ble/common/blecommon.h similarity index 100% rename from connectivity/FEATURE_BLE/include/ble/common/ble/blecommon.h rename to connectivity/FEATURE_BLE/include/ble/common/blecommon.h diff --git a/connectivity/FEATURE_BLE/include/ble/compatibility/ble/BLERoles.h b/connectivity/FEATURE_BLE/include/ble/compatibility/ble/BLERoles.h new file mode 100644 index 00000000000..f78a6fb88b7 --- /dev/null +++ b/connectivity/FEATURE_BLE/include/ble/compatibility/ble/BLERoles.h @@ -0,0 +1,21 @@ +/* mbed Microcontroller Library + * Copyright (c) 2006-2020 ARM Limited + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* for backwards compatibility */ +#warning "please include ble/common/BLERoles.h directly" +#include "ble/common/BLERoles.h" \ No newline at end of file diff --git a/connectivity/FEATURE_BLE/include/ble/compatibility/ble/BLETypes.h b/connectivity/FEATURE_BLE/include/ble/compatibility/ble/BLETypes.h new file mode 100644 index 00000000000..6556fcc1ade --- /dev/null +++ b/connectivity/FEATURE_BLE/include/ble/compatibility/ble/BLETypes.h @@ -0,0 +1,21 @@ +/* mbed Microcontroller Library + * Copyright (c) 2006-2020 ARM Limited + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* for backwards compatibility */ +#warning "please include ble/common/BLETypes.h directly" +#include "ble/common/BLETypes.h" diff --git a/connectivity/FEATURE_BLE/include/ble/compatibility/ble/CallChainOfFunctionPointersWithContext.h b/connectivity/FEATURE_BLE/include/ble/compatibility/ble/CallChainOfFunctionPointersWithContext.h new file mode 100644 index 00000000000..6807f5196a9 --- /dev/null +++ b/connectivity/FEATURE_BLE/include/ble/compatibility/ble/CallChainOfFunctionPointersWithContext.h @@ -0,0 +1,21 @@ +/* mbed Microcontroller Library + * Copyright (c) 2006-2020 ARM Limited + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* for backwards compatibility */ +#warning "please include ble/common/CallChainOfFunctionPointersWithContext.h directly" +#include "ble/common/CallChainOfFunctionPointersWithContext.h" diff --git a/connectivity/FEATURE_BLE/include/ble/compatibility/ble/CharacteristicDescriptorDiscovery.h b/connectivity/FEATURE_BLE/include/ble/compatibility/ble/CharacteristicDescriptorDiscovery.h new file mode 100644 index 00000000000..e860d04b96e --- /dev/null +++ b/connectivity/FEATURE_BLE/include/ble/compatibility/ble/CharacteristicDescriptorDiscovery.h @@ -0,0 +1,21 @@ +/* mbed Microcontroller Library + * Copyright (c) 2006-2020 ARM Limited + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* for backwards compatibility */ +#warning "please include ble/gatt/CharacteristicDescriptorDiscovery.h directly" +#include "ble/gatt/CharacteristicDescriptorDiscovery.h" diff --git a/connectivity/FEATURE_BLE/include/ble/compatibility/ble/DiscoveredCharacteristic.h b/connectivity/FEATURE_BLE/include/ble/compatibility/ble/DiscoveredCharacteristic.h new file mode 100644 index 00000000000..1c109804039 --- /dev/null +++ b/connectivity/FEATURE_BLE/include/ble/compatibility/ble/DiscoveredCharacteristic.h @@ -0,0 +1,21 @@ +/* mbed Microcontroller Library + * Copyright (c) 2006-2020 ARM Limited + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* for backwards compatibility */ +#warning "please include ble/gatt/DiscoveredCharacteristic.h directly" +#include "ble/gatt/DiscoveredCharacteristic.h" diff --git a/connectivity/FEATURE_BLE/include/ble/compatibility/ble/DiscoveredCharacteristicDescriptor.h b/connectivity/FEATURE_BLE/include/ble/compatibility/ble/DiscoveredCharacteristicDescriptor.h new file mode 100644 index 00000000000..2c17354bf89 --- /dev/null +++ b/connectivity/FEATURE_BLE/include/ble/compatibility/ble/DiscoveredCharacteristicDescriptor.h @@ -0,0 +1,21 @@ +/* mbed Microcontroller Library + * Copyright (c) 2006-2020 ARM Limited + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* for backwards compatibility */ +#warning "please include ble/gatt/DiscoveredCharacteristicDescriptor.h directly" +#include "ble/gatt/DiscoveredCharacteristicDescriptor.h" diff --git a/connectivity/FEATURE_BLE/include/ble/compatibility/ble/DiscoveredService.h b/connectivity/FEATURE_BLE/include/ble/compatibility/ble/DiscoveredService.h new file mode 100644 index 00000000000..27b6de8c798 --- /dev/null +++ b/connectivity/FEATURE_BLE/include/ble/compatibility/ble/DiscoveredService.h @@ -0,0 +1,21 @@ +/* mbed Microcontroller Library + * Copyright (c) 2006-2020 ARM Limited + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* for backwards compatibility */ +#warning "please include ble/gatt/DiscoveredService.h directly" +#include "ble/gatt/DiscoveredService.h" diff --git a/connectivity/FEATURE_BLE/include/ble/compatibility/ble/FunctionPointerWithContext.h b/connectivity/FEATURE_BLE/include/ble/compatibility/ble/FunctionPointerWithContext.h new file mode 100644 index 00000000000..65a753ae40d --- /dev/null +++ b/connectivity/FEATURE_BLE/include/ble/compatibility/ble/FunctionPointerWithContext.h @@ -0,0 +1,21 @@ +/* mbed Microcontroller Library + * Copyright (c) 2006-2020 ARM Limited + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* for backwards compatibility */ +#warning "please include ble/common/FunctionPointerWithContext.h directly" +#include "ble/common/FunctionPointerWithContext.h" diff --git a/connectivity/FEATURE_BLE/include/ble/compatibility/ble/GattAttribute.h b/connectivity/FEATURE_BLE/include/ble/compatibility/ble/GattAttribute.h new file mode 100644 index 00000000000..00c08cbfe91 --- /dev/null +++ b/connectivity/FEATURE_BLE/include/ble/compatibility/ble/GattAttribute.h @@ -0,0 +1,21 @@ +/* mbed Microcontroller Library + * Copyright (c) 2006-2020 ARM Limited + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* for backwards compatibility */ +#warning "please include ble/gatt/GattAttribute.h directly" +#include "ble/gatt/GattAttribute.h" diff --git a/connectivity/FEATURE_BLE/include/ble/compatibility/ble/GattCallbackParamTypes.h b/connectivity/FEATURE_BLE/include/ble/compatibility/ble/GattCallbackParamTypes.h new file mode 100644 index 00000000000..c5485ecf417 --- /dev/null +++ b/connectivity/FEATURE_BLE/include/ble/compatibility/ble/GattCallbackParamTypes.h @@ -0,0 +1,21 @@ +/* mbed Microcontroller Library + * Copyright (c) 2006-2020 ARM Limited + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* for backwards compatibility */ +#warning "please include ble/gatt/GattCallbackParamTypes.h directly" +#include "ble/gatt/GattCallbackParamTypes.h" diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/include/ble/internal/PalSigningMonitorImpl.h b/connectivity/FEATURE_BLE/include/ble/compatibility/ble/GattCharacteristic.h similarity index 66% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/include/ble/internal/PalSigningMonitorImpl.h rename to connectivity/FEATURE_BLE/include/ble/compatibility/ble/GattCharacteristic.h index 0551a9b80a5..ab7e73f464c 100644 --- a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/include/ble/internal/PalSigningMonitorImpl.h +++ b/connectivity/FEATURE_BLE/include/ble/compatibility/ble/GattCharacteristic.h @@ -16,20 +16,7 @@ * limitations under the License. */ -#ifndef IMPL_PAL_SIGNING_MONITOR_H_ -#define IMPL_PAL_SIGNING_MONITOR_H_ +/* for backwards compatibility */ +#warning "please include ble/gatt/GattCharacteristic.h directly" +#include "ble/gatt/GattCharacteristic.h" -#include "ble/internal/PalSigningMonitor.h" - -namespace ble { - -class SecurityManager; - -class PalSigningMonitor : public interface::PalSigningMonitor { -public: - void set_signing_event_handler(SecurityManager *handler); -}; - -} // ble - -#endif // CORDIO_PAL_SIGNING_MONITOR_H_ diff --git a/connectivity/FEATURE_BLE/include/ble/compatibility/ble/GattService.h b/connectivity/FEATURE_BLE/include/ble/compatibility/ble/GattService.h new file mode 100644 index 00000000000..a7a6b00d503 --- /dev/null +++ b/connectivity/FEATURE_BLE/include/ble/compatibility/ble/GattService.h @@ -0,0 +1,21 @@ +/* mbed Microcontroller Library + * Copyright (c) 2006-2020 ARM Limited + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* for backwards compatibility */ +#warning "please include ble/gatt/GattService.h directly" +#include "ble/gatt/GattService.h" diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/source/PalSigningMonitorImpl.cpp b/connectivity/FEATURE_BLE/include/ble/compatibility/ble/SafeBool.h similarity index 56% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/source/PalSigningMonitorImpl.cpp rename to connectivity/FEATURE_BLE/include/ble/compatibility/ble/SafeBool.h index dc9ce09c683..5f84eaea073 100644 --- a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/source/PalSigningMonitorImpl.cpp +++ b/connectivity/FEATURE_BLE/include/ble/compatibility/ble/SafeBool.h @@ -16,20 +16,7 @@ * limitations under the License. */ -#include "ble/internal/PalSigningMonitor.h" -#include "ble/internal/BLEInstanceBase.h" -#include "ble/GattClient.h" +/* for backwards compatibility */ +#warning "please include ble/common/SafeBool.h directly" +#include "ble/common/SafeBool.h" -namespace ble { - -void PalSigningMonitor::set_signing_event_handler(SecurityManager *handler) -{ -#if BLE_FEATURE_GATT_CLIENT - BLEInstanceBase::deviceInstance().getGattClient().set_signing_event_handler(handler); -#endif // BLE_FEATURE_GATT_CLIENT -#if BLE_FEATURE_GATT_SERVER - BLEInstanceBase::deviceInstance().getGattServer().set_signing_event_handler(handler); -#endif // BLE_FEATURE_GATT_SERVER -} - -} diff --git a/connectivity/FEATURE_BLE/include/ble/compatibility/ble/SafeEnum.h b/connectivity/FEATURE_BLE/include/ble/compatibility/ble/SafeEnum.h new file mode 100644 index 00000000000..8986cb99580 --- /dev/null +++ b/connectivity/FEATURE_BLE/include/ble/compatibility/ble/SafeEnum.h @@ -0,0 +1,22 @@ +/* mbed Microcontroller Library + * Copyright (c) 2006-2020 ARM Limited + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* for backwards compatibility */ +#warning "please include ble/common/SafeEnum.h directly" +#include "ble/common/SafeEnum.h" + diff --git a/connectivity/FEATURE_BLE/include/ble/compatibility/ble/ServiceDiscovery.h b/connectivity/FEATURE_BLE/include/ble/compatibility/ble/ServiceDiscovery.h new file mode 100644 index 00000000000..bfadc46404f --- /dev/null +++ b/connectivity/FEATURE_BLE/include/ble/compatibility/ble/ServiceDiscovery.h @@ -0,0 +1,21 @@ +/* mbed Microcontroller Library + * Copyright (c) 2006-2020 ARM Limited + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* for backwards compatibility */ +#warning "please include ble/gatt/ServiceDiscovery.h directly" +#include "ble/gatt/ServiceDiscovery.h" diff --git a/connectivity/FEATURE_BLE/include/ble/compatibility/ble/UUID.h b/connectivity/FEATURE_BLE/include/ble/compatibility/ble/UUID.h new file mode 100644 index 00000000000..3519c6bfdb1 --- /dev/null +++ b/connectivity/FEATURE_BLE/include/ble/compatibility/ble/UUID.h @@ -0,0 +1,21 @@ +/* mbed Microcontroller Library + * Copyright (c) 2006-2020 ARM Limited + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* for backwards compatibility */ +#warning "please include ble/common/UUID.h directly" +#include "ble/common/UUID.h" diff --git a/connectivity/FEATURE_BLE/include/ble/compatibility/ble/blecommon.h b/connectivity/FEATURE_BLE/include/ble/compatibility/ble/blecommon.h new file mode 100644 index 00000000000..85bc8fc9ff6 --- /dev/null +++ b/connectivity/FEATURE_BLE/include/ble/compatibility/ble/blecommon.h @@ -0,0 +1,21 @@ +/* mbed Microcontroller Library + * Copyright (c) 2006-2020 ARM Limited + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* for backwards compatibility */ +#warning "please include ble/common/blecommon.h directly" +#include "ble/common/blecommon.h" diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/driver/CordioHCIDriver.h b/connectivity/FEATURE_BLE/include/ble/driver/CordioHCIDriver.h similarity index 96% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/driver/CordioHCIDriver.h rename to connectivity/FEATURE_BLE/include/ble/driver/CordioHCIDriver.h index 2641f87b1f9..3fd186e8726 100644 --- a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/driver/CordioHCIDriver.h +++ b/connectivity/FEATURE_BLE/include/ble/driver/CordioHCIDriver.h @@ -17,13 +17,15 @@ #ifndef IMPL_HCI_DRIVER_H_ #define IMPL_HCI_DRIVER_H_ -#include -#include -#include +#include +#include +#include "platform/Callback.h" +#include "ble/common/BLETypes.h" +#include "ble/driver/CordioHCITransportDriver.h" +#include "ble/common/blecommon.h" + +// FIXME: make this invisible! #include "wsf_buf.h" -#include "CordioHCITransportDriver.h" -#include "ble/common/ble/blecommon.h" -#include "mbed.h" namespace ble { @@ -73,7 +75,7 @@ class CordioHCIDriver { /** * Driver destructor */ - virtual ~CordioHCIDriver() { } + virtual ~CordioHCIDriver() = default; /** * Return the set of memory pool which will be used by the Cordio stack diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/driver/CordioHCITransportDriver.h b/connectivity/FEATURE_BLE/include/ble/driver/CordioHCITransportDriver.h similarity index 97% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/driver/CordioHCITransportDriver.h rename to connectivity/FEATURE_BLE/include/ble/driver/CordioHCITransportDriver.h index 93d46e49710..5db197aee5a 100644 --- a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/driver/CordioHCITransportDriver.h +++ b/connectivity/FEATURE_BLE/include/ble/driver/CordioHCITransportDriver.h @@ -17,7 +17,7 @@ #ifndef IMPL_HCI_TRANSPORT_DRIVER_H_ #define IMPL_HCI_TRANSPORT_DRIVER_H_ -#include +#include namespace ble { @@ -34,7 +34,7 @@ class CordioHCITransportDriver { /** * Driver destructor. */ - virtual ~CordioHCITransportDriver() { } + virtual ~CordioHCITransportDriver() = default; /** * Inialization of the transport. diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/driver/H4TransportDriver.h b/connectivity/FEATURE_BLE/include/ble/driver/H4TransportDriver.h similarity index 85% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/driver/H4TransportDriver.h rename to connectivity/FEATURE_BLE/include/ble/driver/H4TransportDriver.h index 9f07babb01f..2142667be55 100644 --- a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/driver/H4TransportDriver.h +++ b/connectivity/FEATURE_BLE/include/ble/driver/H4TransportDriver.h @@ -19,9 +19,9 @@ #if (DEVICE_SERIAL && DEVICE_SERIAL_FC) || defined(DOXYGEN_ONLY) -#include -#include "mbed.h" -#include "CordioHCITransportDriver.h" +#include +#include "drivers/UnbufferedSerial.h" +#include "ble/driver/CordioHCITransportDriver.h" namespace ble { @@ -47,29 +47,29 @@ class H4TransportDriver : public CordioHCITransportDriver { /** * Destructor */ - virtual ~H4TransportDriver() { } + ~H4TransportDriver() override = default; /** * @see CordioHCITransportDriver::initialize */ - virtual void initialize(); + void initialize() override; /** * @see CordioHCITransportDriver::terminate */ - virtual void terminate(); + void terminate() override; /** * @see CordioHCITransportDriver::write */ - virtual uint16_t write(uint8_t type, uint16_t len, uint8_t *pData); + uint16_t write(uint8_t type, uint16_t len, uint8_t *pData) override; private: void on_controller_irq(); // Use UnbufferedSerial as we don't require locking primitives. // We access the peripheral in interrupt context. - UnbufferedSerial uart; + mbed::UnbufferedSerial uart; PinName cts; PinName rts; }; diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/doc/HCIAbstraction.md b/connectivity/FEATURE_BLE/include/ble/driver/doc/HCIAbstraction.md similarity index 91% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/doc/HCIAbstraction.md rename to connectivity/FEATURE_BLE/include/ble/driver/doc/HCIAbstraction.md index 1df670ba4ae..fa9919e70a3 100644 --- a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/doc/HCIAbstraction.md +++ b/connectivity/FEATURE_BLE/include/ble/driver/doc/HCIAbstraction.md @@ -25,7 +25,7 @@ in the future with an implementation of the H5 interface. However, there is no plan to provide the SDIO implementation at the moment. This interface is defined in the header file -[CordioHCITransportDriver.h](../driver/CordioHCITransportDriver.h) +[CordioHCITransportDriver.h](../CordioHCITransportDriver.h) ## CordioHCIDriver @@ -35,10 +35,10 @@ The responsibilities of this driver are: * Handle the reset/startup sequence of the Bluetooth controller. This interface is defined in the header file -[CordioHCIDriver.h](../driver/CordioHCIDriver.h) +[CordioHCIDriver.h](../CordioHCIDriver.h) A partial implementation is present in the file -[CordioHCIDriver.cpp](../driver/CordioHCIDriver.cpp). It defines the function +[CordioHCIDriver.cpp](../../../../source/cordio/driver/CordioHCIDriver.cpp). It defines the function delivering memory to the stack and a complete reset sequence. However, it does not define any initialization for the Bluetooth controller, this part being specific to the controller used. diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/doc/PortingGuide.md b/connectivity/FEATURE_BLE/include/ble/driver/doc/PortingGuide.md similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/doc/PortingGuide.md rename to connectivity/FEATURE_BLE/include/ble/driver/doc/PortingGuide.md diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/doc/resources/architecture.png b/connectivity/FEATURE_BLE/include/ble/driver/doc/resources/architecture.png similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/doc/resources/architecture.png rename to connectivity/FEATURE_BLE/include/ble/driver/doc/resources/architecture.png diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/doc/resources/architecture_layer.png b/connectivity/FEATURE_BLE/include/ble/driver/doc/resources/architecture_layer.png similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/doc/resources/architecture_layer.png rename to connectivity/FEATURE_BLE/include/ble/driver/doc/resources/architecture_layer.png diff --git a/connectivity/FEATURE_BLE/include/ble/common/ble/gap/AdvertisingDataBuilder.h b/connectivity/FEATURE_BLE/include/ble/gap/AdvertisingDataBuilder.h similarity index 98% rename from connectivity/FEATURE_BLE/include/ble/common/ble/gap/AdvertisingDataBuilder.h rename to connectivity/FEATURE_BLE/include/ble/gap/AdvertisingDataBuilder.h index 4e2f91ba89a..a7151c0c46f 100644 --- a/connectivity/FEATURE_BLE/include/ble/common/ble/gap/AdvertisingDataBuilder.h +++ b/connectivity/FEATURE_BLE/include/ble/gap/AdvertisingDataBuilder.h @@ -19,16 +19,16 @@ #ifndef MBED_GAP_ADVERTISING_DATA_H__ #define MBED_GAP_ADVERTISING_DATA_H__ -#include -#include -#include +#include +#include +#include #include "platform/NonCopyable.h" -#include "ble/common/ble/UUID.h" -#include "ble/common/ble/BLETypes.h" -#include "ble/common/ble/blecommon.h" -#include "ble/common/ble/gap/AdvertisingDataTypes.h" -#include "ble/common/ble/gap/Types.h" +#include "ble/common/UUID.h" +#include "ble/common/BLETypes.h" +#include "ble/common/blecommon.h" +#include "ble/gap/AdvertisingDataTypes.h" +#include "ble/gap/Types.h" namespace ble { diff --git a/connectivity/FEATURE_BLE/include/ble/common/ble/gap/AdvertisingDataParser.h b/connectivity/FEATURE_BLE/include/ble/gap/AdvertisingDataParser.h similarity index 93% rename from connectivity/FEATURE_BLE/include/ble/common/ble/gap/AdvertisingDataParser.h rename to connectivity/FEATURE_BLE/include/ble/gap/AdvertisingDataParser.h index dc7a18286e6..5ad0b223e68 100644 --- a/connectivity/FEATURE_BLE/include/ble/common/ble/gap/AdvertisingDataParser.h +++ b/connectivity/FEATURE_BLE/include/ble/gap/AdvertisingDataParser.h @@ -19,10 +19,10 @@ #ifndef BLE_GAP_ADVERTISINGDATAPARSER_H #define BLE_GAP_ADVERTISINGDATAPARSER_H -#include +#include #include "platform/Span.h" -#include "ble/common/ble/gap/AdvertisingDataTypes.h" +#include "ble/gap/AdvertisingDataTypes.h" namespace ble { @@ -70,7 +70,7 @@ class AdvertisingDataParser { */ bool hasNext() const { - if (position >= data.size()) { + if (position >= (size_t) data.size()) { return false; } @@ -79,7 +79,7 @@ class AdvertisingDataParser { return false; } - if (position + current_length() >= data.size()) { + if (position + current_length() >= (size_t) data.size()) { return false; } diff --git a/connectivity/FEATURE_BLE/include/ble/common/ble/gap/AdvertisingDataSimpleBuilder.h b/connectivity/FEATURE_BLE/include/ble/gap/AdvertisingDataSimpleBuilder.h similarity index 97% rename from connectivity/FEATURE_BLE/include/ble/common/ble/gap/AdvertisingDataSimpleBuilder.h rename to connectivity/FEATURE_BLE/include/ble/gap/AdvertisingDataSimpleBuilder.h index bc7c69d09b3..dc9e3bd9d8f 100644 --- a/connectivity/FEATURE_BLE/include/ble/common/ble/gap/AdvertisingDataSimpleBuilder.h +++ b/connectivity/FEATURE_BLE/include/ble/gap/AdvertisingDataSimpleBuilder.h @@ -21,8 +21,8 @@ #include "platform/Span.h" -#include "ble/common/ble/UUID.h" -#include "ble/common/ble/gap/AdvertisingDataBuilder.h" +#include "ble/common/UUID.h" +#include "ble/gap/AdvertisingDataBuilder.h" namespace ble { @@ -68,7 +68,7 @@ class AdvertisingDataSimpleBuilder { /** * Construct a AdvertisingDataSimpleBuilder */ - AdvertisingDataSimpleBuilder() : _builder(_buffer) + AdvertisingDataSimpleBuilder() : _buffer(), _builder(_buffer) { } @@ -200,7 +200,7 @@ class AdvertisingDataSimpleBuilder { * * @return A reference to this object. */ - AdvertisingDataSimpleBuilder &setServiceData(UUID service, mbed::Span data) + AdvertisingDataSimpleBuilder &setServiceData(const UUID& service, mbed::Span data) { ble_error_t res = _builder.setServiceData(service, data); MBED_ASSERT(res == BLE_ERROR_NONE); diff --git a/connectivity/FEATURE_BLE/include/ble/common/ble/gap/AdvertisingDataTypes.h b/connectivity/FEATURE_BLE/include/ble/gap/AdvertisingDataTypes.h similarity index 97% rename from connectivity/FEATURE_BLE/include/ble/common/ble/gap/AdvertisingDataTypes.h rename to connectivity/FEATURE_BLE/include/ble/gap/AdvertisingDataTypes.h index 701c1285b6a..cc6e14653ff 100644 --- a/connectivity/FEATURE_BLE/include/ble/common/ble/gap/AdvertisingDataTypes.h +++ b/connectivity/FEATURE_BLE/include/ble/gap/AdvertisingDataTypes.h @@ -19,7 +19,7 @@ #ifndef BLE_GAP_ADVERTISINGDATATYPES_H #define BLE_GAP_ADVERTISINGDATATYPES_H -#include "ble/common/ble/SafeEnum.h" +#include "ble/common/SafeEnum.h" namespace ble { @@ -180,7 +180,7 @@ struct adv_data_flags_t { adv_data_flags_t &setGeneralDiscoverable(bool enable = true) { - _value &= ~0x03; + _value &= ~0x03U; if (enable) { _value |= LE_GENERAL_DISCOVERABLE; } @@ -189,7 +189,7 @@ struct adv_data_flags_t { adv_data_flags_t &setLimitedDiscoverable(bool enable = true) { - _value &= ~0x03; + _value &= ~0x03U; if (enable) { _value |= LE_LIMITED_DISCOVERABLE; } @@ -223,27 +223,27 @@ struct adv_data_flags_t { return *this; } - bool getGeneralDiscoverable() + bool getGeneralDiscoverable() const { return _value & LE_GENERAL_DISCOVERABLE; } - bool getlimitedDiscoverable() + bool getlimitedDiscoverable() const { return _value & LE_LIMITED_DISCOVERABLE; } - bool getBrEdrNotSupported() + bool getBrEdrNotSupported() const { return _value & BREDR_NOT_SUPPORTED; } - bool getSimultaneousLeBredrC() + bool getSimultaneousLeBredrC() const { return _value & SIMULTANEOUS_LE_BREDR_C; } - bool getSimultaneousLeBredrH() + bool getSimultaneousLeBredrH() const { return _value & SIMULTANEOUS_LE_BREDR_H; } @@ -253,7 +253,7 @@ struct adv_data_flags_t { _value = 0; } - uint8_t value() + uint8_t value() const { return _value; } diff --git a/connectivity/FEATURE_BLE/include/ble/common/ble/gap/AdvertisingParameters.h b/connectivity/FEATURE_BLE/include/ble/gap/AdvertisingParameters.h similarity index 99% rename from connectivity/FEATURE_BLE/include/ble/common/ble/gap/AdvertisingParameters.h rename to connectivity/FEATURE_BLE/include/ble/gap/AdvertisingParameters.h index 2bda38a4947..c00328ad520 100644 --- a/connectivity/FEATURE_BLE/include/ble/common/ble/gap/AdvertisingParameters.h +++ b/connectivity/FEATURE_BLE/include/ble/gap/AdvertisingParameters.h @@ -21,9 +21,9 @@ #include -#include "ble/common/ble/BLETypes.h" -#include "ble/common/ble/blecommon.h" -#include "ble/common/ble/SafeEnum.h" +#include "ble/common/BLETypes.h" +#include "ble/common/blecommon.h" +#include "ble/common/SafeEnum.h" namespace ble { diff --git a/connectivity/FEATURE_BLE/include/ble/common/ble/gap/ConnectionParameters.h b/connectivity/FEATURE_BLE/include/ble/gap/ConnectionParameters.h similarity index 99% rename from connectivity/FEATURE_BLE/include/ble/common/ble/gap/ConnectionParameters.h rename to connectivity/FEATURE_BLE/include/ble/gap/ConnectionParameters.h index dfdc33c72ab..dec35812ada 100644 --- a/connectivity/FEATURE_BLE/include/ble/common/ble/gap/ConnectionParameters.h +++ b/connectivity/FEATURE_BLE/include/ble/gap/ConnectionParameters.h @@ -19,9 +19,9 @@ #ifndef MBED_EXTENDED_CONNECT_PARAMETERS_H__ #define MBED_EXTENDED_CONNECT_PARAMETERS_H__ -#include "mbed_assert.h" +#include "platform/mbed_assert.h" -#include "ble/common/ble/BLETypes.h" +#include "ble/common/BLETypes.h" namespace ble { @@ -429,7 +429,7 @@ class ConnectionParameters { return index; } - uint8_t phyToIndex(phy_t phy) const + static uint8_t phyToIndex(phy_t phy) { uint8_t index; switch (phy.value()) { diff --git a/connectivity/FEATURE_BLE/include/ble/common/ble/gap/Events.h b/connectivity/FEATURE_BLE/include/ble/gap/Events.h similarity index 99% rename from connectivity/FEATURE_BLE/include/ble/common/ble/gap/Events.h rename to connectivity/FEATURE_BLE/include/ble/gap/Events.h index 454748eea90..b8f561a12c8 100644 --- a/connectivity/FEATURE_BLE/include/ble/common/ble/gap/Events.h +++ b/connectivity/FEATURE_BLE/include/ble/gap/Events.h @@ -19,8 +19,8 @@ #ifndef BLE_GAP_EVENTS_H #define BLE_GAP_EVENTS_H -#include "ble/common/ble/blecommon.h" -#include "ble/common/ble/BLETypes.h" +#include "ble/common/blecommon.h" +#include "ble/common/BLETypes.h" namespace ble { diff --git a/connectivity/FEATURE_BLE/include/ble/common/ble/gap/Gap.h b/connectivity/FEATURE_BLE/include/ble/gap/Gap.h similarity index 100% rename from connectivity/FEATURE_BLE/include/ble/common/ble/gap/Gap.h rename to connectivity/FEATURE_BLE/include/ble/gap/Gap.h diff --git a/connectivity/FEATURE_BLE/include/ble/common/ble/gap/ScanParameters.h b/connectivity/FEATURE_BLE/include/ble/gap/ScanParameters.h similarity index 98% rename from connectivity/FEATURE_BLE/include/ble/common/ble/gap/ScanParameters.h rename to connectivity/FEATURE_BLE/include/ble/gap/ScanParameters.h index b4eead0a349..f6d1d82cfd8 100644 --- a/connectivity/FEATURE_BLE/include/ble/common/ble/gap/ScanParameters.h +++ b/connectivity/FEATURE_BLE/include/ble/gap/ScanParameters.h @@ -19,10 +19,10 @@ #ifndef MBED_GAP_SCAN_PARAMETERS_H__ #define MBED_GAP_SCAN_PARAMETERS_H__ -#include +#include -#include "ble/common/ble/blecommon.h" -#include "ble/common/ble/BLETypes.h" +#include "ble/common/blecommon.h" +#include "ble/common/BLETypes.h" namespace ble { diff --git a/connectivity/FEATURE_BLE/include/ble/common/ble/gap/Types.h b/connectivity/FEATURE_BLE/include/ble/gap/Types.h similarity index 99% rename from connectivity/FEATURE_BLE/include/ble/common/ble/gap/Types.h rename to connectivity/FEATURE_BLE/include/ble/gap/Types.h index 45f47eb819b..71b411124ea 100644 --- a/connectivity/FEATURE_BLE/include/ble/common/ble/gap/Types.h +++ b/connectivity/FEATURE_BLE/include/ble/gap/Types.h @@ -19,9 +19,9 @@ #ifndef BLE_GAP_TYPES_H #define BLE_GAP_TYPES_H -#include "ble/common/ble/Duration.h" -#include "ble/common/ble/Bounded.h" -#include "ble/common/ble/SafeEnum.h" +#include "ble/common/Duration.h" +#include "ble/common/Bounded.h" +#include "ble/common/SafeEnum.h" namespace ble { diff --git a/connectivity/FEATURE_BLE/include/ble/common/ble/CharacteristicDescriptorDiscovery.h b/connectivity/FEATURE_BLE/include/ble/gatt/CharacteristicDescriptorDiscovery.h similarity index 98% rename from connectivity/FEATURE_BLE/include/ble/common/ble/CharacteristicDescriptorDiscovery.h rename to connectivity/FEATURE_BLE/include/ble/gatt/CharacteristicDescriptorDiscovery.h index 996f38fa51c..8ad501fbad5 100644 --- a/connectivity/FEATURE_BLE/include/ble/common/ble/CharacteristicDescriptorDiscovery.h +++ b/connectivity/FEATURE_BLE/include/ble/gatt/CharacteristicDescriptorDiscovery.h @@ -19,7 +19,7 @@ #ifndef MBED_CHARACTERISTIC_DESCRIPTOR_DISCOVERY_H__ #define MBED_CHARACTERISTIC_DESCRIPTOR_DISCOVERY_H__ -#include "FunctionPointerWithContext.h" +#include "ble/common/FunctionPointerWithContext.h" class DiscoveredCharacteristic; // forward declaration class DiscoveredCharacteristicDescriptor; // forward declaration diff --git a/connectivity/FEATURE_BLE/include/ble/common/ble/DiscoveredCharacteristic.h b/connectivity/FEATURE_BLE/include/ble/gatt/DiscoveredCharacteristic.h similarity index 96% rename from connectivity/FEATURE_BLE/include/ble/common/ble/DiscoveredCharacteristic.h rename to connectivity/FEATURE_BLE/include/ble/gatt/DiscoveredCharacteristic.h index 7439ad36795..3f290fe4b26 100644 --- a/connectivity/FEATURE_BLE/include/ble/common/ble/DiscoveredCharacteristic.h +++ b/connectivity/FEATURE_BLE/include/ble/gatt/DiscoveredCharacteristic.h @@ -19,11 +19,11 @@ #ifndef MBED_DISCOVERED_CHARACTERISTIC_H__ #define MBED_DISCOVERED_CHARACTERISTIC_H__ -#include "ble/common/ble/UUID.h" -#include "ble/common/ble/GattAttribute.h" -#include "ble/common/ble/GattCallbackParamTypes.h" -#include "ble/common/ble/CharacteristicDescriptorDiscovery.h" -#include "ble/common/ble/DiscoveredCharacteristicDescriptor.h" +#include "ble/common/UUID.h" +#include "ble/gatt/GattAttribute.h" +#include "ble/gatt/GattCallbackParamTypes.h" +#include "ble/gatt/CharacteristicDescriptorDiscovery.h" +#include "ble/gatt/DiscoveredCharacteristicDescriptor.h" namespace ble { class GattClient; @@ -155,7 +155,7 @@ class DiscoveredCharacteristic { * * @see _broadcast */ - bool broadcast(void) const + bool broadcast() const { return _broadcast; } @@ -168,7 +168,7 @@ class DiscoveredCharacteristic { * * @see _read */ - bool read(void) const + bool read() const { return _read; } @@ -181,7 +181,7 @@ class DiscoveredCharacteristic { * * @see _writeWoResp */ - bool writeWoResp(void) const + bool writeWoResp() const { return _writeWoResp; } @@ -194,7 +194,7 @@ class DiscoveredCharacteristic { * * @see _write */ - bool write(void) const + bool write() const { return _write; } @@ -211,7 +211,7 @@ class DiscoveredCharacteristic { * * @see _notify */ - bool notify(void) const + bool notify() const { return _notify; } @@ -228,7 +228,7 @@ class DiscoveredCharacteristic { * * @see _indicate */ - bool indicate(void) const + bool indicate() const { return _indicate; } @@ -239,7 +239,7 @@ class DiscoveredCharacteristic { * @return true if the characteristic accepts authenticated signed write * and false otherwise. */ - bool authSignedWrite(void) const + bool authSignedWrite() const { return _authSignedWrite; } @@ -447,7 +447,7 @@ class DiscoveredCharacteristic { * * @return The UUID of this characteristic. */ - const UUID &getUUID(void) const + const UUID &getUUID() const { return uuid; } @@ -457,7 +457,7 @@ class DiscoveredCharacteristic { * * @return The set of properties of this characteristic. */ - const Properties_t &getProperties(void) const + const Properties_t &getProperties() const { return props; } @@ -477,7 +477,7 @@ class DiscoveredCharacteristic { * * @return the declaration handle of this characteristic. */ - GattAttribute::Handle_t getDeclHandle(void) const + GattAttribute::Handle_t getDeclHandle() const { return declHandle; } @@ -489,7 +489,7 @@ class DiscoveredCharacteristic { * * @return The handle to access the value of this characteristic. */ - GattAttribute::Handle_t getValueHandle(void) const + GattAttribute::Handle_t getValueHandle() const { return valueHandle; } @@ -510,7 +510,7 @@ class DiscoveredCharacteristic { * * @note This function is public for informative purposes. */ - GattAttribute::Handle_t getLastHandle(void) const + GattAttribute::Handle_t getLastHandle() const { return lastHandle; } @@ -583,7 +583,7 @@ class DiscoveredCharacteristic { public: DiscoveredCharacteristic() : - gattc(NULL), + gattc(nullptr), uuid(UUID::ShortUUIDBytes_t(0)), props(), declHandle(GattAttribute::INVALID_HANDLE), diff --git a/connectivity/FEATURE_BLE/include/ble/common/ble/DiscoveredCharacteristicDescriptor.h b/connectivity/FEATURE_BLE/include/ble/gatt/DiscoveredCharacteristicDescriptor.h similarity index 96% rename from connectivity/FEATURE_BLE/include/ble/common/ble/DiscoveredCharacteristicDescriptor.h rename to connectivity/FEATURE_BLE/include/ble/gatt/DiscoveredCharacteristicDescriptor.h index 5c7ac0786da..509f9f911fd 100644 --- a/connectivity/FEATURE_BLE/include/ble/common/ble/DiscoveredCharacteristicDescriptor.h +++ b/connectivity/FEATURE_BLE/include/ble/gatt/DiscoveredCharacteristicDescriptor.h @@ -19,10 +19,10 @@ #ifndef MBED_DISCOVERED_CHARACTERISTIC_DESCRIPTOR_H__ #define MBED_DISCOVERED_CHARACTERISTIC_DESCRIPTOR_H__ -#include "ble/common/ble/UUID.h" #include "ble/Gap.h" -#include "ble/common/ble/GattAttribute.h" -#include "ble/common/ble/CharacteristicDescriptorDiscovery.h" +#include "ble/common/UUID.h" +#include "ble/gatt/GattAttribute.h" +#include "ble/gatt/CharacteristicDescriptorDiscovery.h" namespace ble { class GattClient; @@ -124,7 +124,7 @@ class DiscoveredCharacteristicDescriptor { * * @return UUID of this descriptor. */ - const UUID& getUUID(void) const + const UUID& getUUID() const { return _uuid; } diff --git a/connectivity/FEATURE_BLE/include/ble/common/ble/DiscoveredService.h b/connectivity/FEATURE_BLE/include/ble/gatt/DiscoveredService.h similarity index 92% rename from connectivity/FEATURE_BLE/include/ble/common/ble/DiscoveredService.h rename to connectivity/FEATURE_BLE/include/ble/gatt/DiscoveredService.h index baead1fb6ce..b416ee04234 100644 --- a/connectivity/FEATURE_BLE/include/ble/common/ble/DiscoveredService.h +++ b/connectivity/FEATURE_BLE/include/ble/gatt/DiscoveredService.h @@ -19,8 +19,8 @@ #ifndef MBED_DISCOVERED_SERVICE_H__ #define MBED_DISCOVERED_SERVICE_H__ -#include "ble/common/ble/UUID.h" -#include "ble/common/ble/GattAttribute.h" +#include "ble/common/UUID.h" +#include "ble/gatt/GattAttribute.h" /** * @addtogroup ble @@ -57,7 +57,7 @@ class DiscoveredService { * * @return A reference to the UUID of the discovered service. */ - const UUID &getUUID(void) const + const UUID &getUUID() const { return uuid; } @@ -67,7 +67,7 @@ class DiscoveredService { * * @return A reference to the start handle. */ - const GattAttribute::Handle_t& getStartHandle(void) const + const GattAttribute::Handle_t& getStartHandle() const { return startHandle; } @@ -77,7 +77,7 @@ class DiscoveredService { * * @return A reference to the end handle. */ - const GattAttribute::Handle_t& getEndHandle(void) const + const GattAttribute::Handle_t& getEndHandle() const { return endHandle; } @@ -95,6 +95,9 @@ class DiscoveredService { endHandle(GattAttribute::INVALID_HANDLE) { } + DiscoveredService(const DiscoveredService &) = delete; + DiscoveredService operator=(const DiscoveredService &) = delete; + /** * Set information about the discovered service. * @@ -108,7 +111,7 @@ class DiscoveredService { * peer's GATT server. */ void setup( - UUID uuidIn, + const UUID& uuidIn, GattAttribute::Handle_t startHandleIn, GattAttribute::Handle_t endHandleIn ) { @@ -153,10 +156,6 @@ class DiscoveredService { uuid.setupLong(longUUID, order); } - -private: - DiscoveredService(const DiscoveredService &); - private: /** * UUID of the service. diff --git a/connectivity/FEATURE_BLE/include/ble/common/ble/GattAttribute.h b/connectivity/FEATURE_BLE/include/ble/gatt/GattAttribute.h similarity index 94% rename from connectivity/FEATURE_BLE/include/ble/common/ble/GattAttribute.h rename to connectivity/FEATURE_BLE/include/ble/gatt/GattAttribute.h index 6988981ac9e..c5f2534c4ff 100644 --- a/connectivity/FEATURE_BLE/include/ble/common/ble/GattAttribute.h +++ b/connectivity/FEATURE_BLE/include/ble/gatt/GattAttribute.h @@ -19,8 +19,8 @@ #ifndef MBED_GATT_ATTRIBUTE_H__ #define MBED_GATT_ATTRIBUTE_H__ -#include "ble/common/ble/UUID.h" -#include "ble/common/ble/BLETypes.h" +#include "ble/common/UUID.h" +#include "ble/common/BLETypes.h" /** * @addtogroup ble @@ -113,7 +113,7 @@ class GattAttribute { */ GattAttribute( const UUID &uuid, - uint8_t *valuePtr = NULL, + uint8_t *valuePtr = nullptr, uint16_t len = 0, uint16_t maxLen = 0, bool hasVariableLen = true @@ -129,6 +129,9 @@ class GattAttribute { _write_security(Security_t::NONE) { } + GattAttribute(const GattAttribute &) = delete; + GattAttribute& operator=(const GattAttribute &) = delete; + public: /** * Get the attribute's handle in the ATT table. @@ -138,7 +141,7 @@ class GattAttribute { * * @return The attribute's handle. */ - Handle_t getHandle(void) const + Handle_t getHandle() const { return _handle; } @@ -150,7 +153,7 @@ class GattAttribute { * * @return The attribute. */ - const UUID &getUUID(void) const + const UUID &getUUID() const { return _uuid; } @@ -160,7 +163,7 @@ class GattAttribute { * * @return The current length of the attribute value. */ - uint16_t getLength(void) const + uint16_t getLength() const { return _len; } @@ -170,7 +173,7 @@ class GattAttribute { * * The maximum length of the attribute value. */ - uint16_t getMaxLength(void) const + uint16_t getMaxLength() const { return _lenMax; } @@ -182,7 +185,7 @@ class GattAttribute { * * @return A pointer to the current length of the attribute value. */ - uint16_t *getLengthPtr(void) + uint16_t *getLengthPtr() { return &_len; } @@ -205,7 +208,7 @@ class GattAttribute { * * @return A pointer to the attribute value. */ - uint8_t *getValuePtr(void) + uint8_t *getValuePtr() { return _valuePtr; } @@ -216,7 +219,7 @@ class GattAttribute { * @return true if the attribute value has a variable length and false * otherwise. */ - bool hasVariableLength(void) const + bool hasVariableLength() const { return _hasVariableLen; } @@ -234,7 +237,7 @@ class GattAttribute { * Indicate if a client is allowed to read the attribute. * @return true if a client is allowed to read the attribute. */ - bool isReadAllowed(void) const + bool isReadAllowed() const { return _read_allowed; } @@ -270,7 +273,7 @@ class GattAttribute { * Indicate if a client is allowed to write the attribute. * @return true if a client is allowed to write the attribute. */ - bool isWriteAllowed(void) const + bool isWriteAllowed() const { return _write_allowed; } @@ -343,11 +346,6 @@ class GattAttribute { * Security applied to the write operation. */ uint8_t _write_security: Security_t::size; - -private: - /* Disallow copy and assignment. */ - GattAttribute(const GattAttribute &); - GattAttribute& operator=(const GattAttribute &); }; /** diff --git a/connectivity/FEATURE_BLE/include/ble/common/ble/GattCallbackParamTypes.h b/connectivity/FEATURE_BLE/include/ble/gatt/GattCallbackParamTypes.h similarity index 99% rename from connectivity/FEATURE_BLE/include/ble/common/ble/GattCallbackParamTypes.h rename to connectivity/FEATURE_BLE/include/ble/gatt/GattCallbackParamTypes.h index 90e1b90813a..a425c94f7c4 100644 --- a/connectivity/FEATURE_BLE/include/ble/common/ble/GattCallbackParamTypes.h +++ b/connectivity/FEATURE_BLE/include/ble/gatt/GattCallbackParamTypes.h @@ -15,7 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include "CallChainOfFunctionPointersWithContext.h" +#include "ble/common/CallChainOfFunctionPointersWithContext.h" #ifndef MBED_BLE_GATT_CALLBACK_PARAM_TYPES_H__ #define MBED_BLE_GATT_CALLBACK_PARAM_TYPES_H__ diff --git a/connectivity/FEATURE_BLE/include/ble/common/ble/GattCharacteristic.h b/connectivity/FEATURE_BLE/include/ble/gatt/GattCharacteristic.h similarity index 98% rename from connectivity/FEATURE_BLE/include/ble/common/ble/GattCharacteristic.h rename to connectivity/FEATURE_BLE/include/ble/gatt/GattCharacteristic.h index 9ec36729f6b..2e0510854bd 100644 --- a/connectivity/FEATURE_BLE/include/ble/common/ble/GattCharacteristic.h +++ b/connectivity/FEATURE_BLE/include/ble/gatt/GattCharacteristic.h @@ -19,10 +19,10 @@ #ifndef __GATT_CHARACTERISTIC_H__ #define __GATT_CHARACTERISTIC_H__ -#include "FunctionPointerWithContext.h" +#include "ble/common/FunctionPointerWithContext.h" -#include "ble/common/ble/GattAttribute.h" -#include "ble/common/ble/GattCallbackParamTypes.h" +#include "ble/gatt/GattAttribute.h" +#include "ble/gatt/GattCallbackParamTypes.h" /** * @addtogroup ble @@ -1384,7 +1384,7 @@ class GattCharacteristic { * @param[in] hasVariableLen Flag that indicates if the attribute's value * length can change throughout time. * - * @note If valuePtr is NULL, length is equal to 0 and the characteristic + * @note If valuePtr is nullptr, length is equal to 0 and the characteristic * is readable, then that particular characteristic may be considered * optional and dropped while instantiating the service with the underlying * BLE stack. @@ -1398,11 +1398,11 @@ class GattCharacteristic { */ GattCharacteristic( const UUID &uuid, - uint8_t *valuePtr = NULL, + uint8_t *valuePtr = nullptr, uint16_t len = 0, uint16_t maxLen = 0, uint8_t props = BLE_GATT_CHAR_PROPERTIES_NONE, - GattAttribute *descriptors[] = NULL, + GattAttribute *descriptors[] = nullptr, unsigned numDescriptors = 0, bool hasVariableLen = true ) : _valueAttribute(uuid, valuePtr, len, maxLen, hasVariableLen), @@ -1426,6 +1426,9 @@ class GattCharacteristic { #endif // BLE_FEATURE_SECURITY } + GattCharacteristic(const GattCharacteristic &) = delete; + GattCharacteristic& operator=(const GattCharacteristic &) = delete; + public: /** @@ -1639,7 +1642,7 @@ class GattCharacteristic { * @return A GattAuthCallbackReply_t value indicating whether authorization * is granted. * - * @note If the read request is approved and params->data remains NULL, then + * @note If the read request is approved and params->data remains nullptr, then * the current characteristic value is used in the read response payload. * * @note If the read is approved, the event handler can specify an outgoing @@ -1687,7 +1690,7 @@ class GattCharacteristic { * @note The underlying BLE stack assigns the attribute handle when the * enclosing service is added. */ - GattAttribute::Handle_t getValueHandle(void) const + GattAttribute::Handle_t getValueHandle() const { return getValueAttribute().getHandle(); } @@ -1699,7 +1702,7 @@ class GattCharacteristic { * * @return The characteristic's properties. */ - uint8_t getProperties(void) const + uint8_t getProperties() const { return _properties; } @@ -1709,7 +1712,7 @@ class GattCharacteristic { * * @return The total number of descriptors. */ - uint8_t getDescriptorCount(void) const + uint8_t getDescriptorCount() const { return _descriptorCount; } @@ -1746,12 +1749,12 @@ class GattCharacteristic { * @param[in] index The index of the descriptor to get. * * @return A pointer the requested descriptor if @p index is within the - * range of the descriptor array or NULL otherwise. + * range of the descriptor array or nullptr otherwise. */ GattAttribute *getDescriptor(uint8_t index) { if (index >= _descriptorCount) { - return NULL; + return nullptr; } return _descriptors[index]; @@ -1799,11 +1802,6 @@ class GattCharacteristic { * receive updates */ uint8_t _update_security: SecurityRequirement_t::size; - -private: - /* Disallow copy and assignment. */ - GattCharacteristic(const GattCharacteristic &); - GattCharacteristic& operator=(const GattCharacteristic &); }; /** @@ -1834,7 +1832,7 @@ class ReadOnlyGattCharacteristic : public GattCharacteristic { const UUID &uuid, T *valuePtr, uint8_t additionalProperties = BLE_GATT_CHAR_PROPERTIES_NONE, - GattAttribute *descriptors[] = NULL, + GattAttribute *descriptors[] = nullptr, unsigned numDescriptors = 0 ) : GattCharacteristic( uuid, @@ -1877,7 +1875,7 @@ class WriteOnlyGattCharacteristic : public GattCharacteristic { const UUID &uuid, T *valuePtr, uint8_t additionalProperties = BLE_GATT_CHAR_PROPERTIES_NONE, - GattAttribute *descriptors[] = NULL, + GattAttribute *descriptors[] = nullptr, unsigned numDescriptors = 0 ) : GattCharacteristic( uuid, @@ -1919,7 +1917,7 @@ class ReadWriteGattCharacteristic : public GattCharacteristic { const UUID &uuid, T *valuePtr, uint8_t additionalProperties = BLE_GATT_CHAR_PROPERTIES_NONE, - GattAttribute *descriptors[] = NULL, + GattAttribute *descriptors[] = nullptr, unsigned numDescriptors = 0 ) : GattCharacteristic( uuid, @@ -1962,7 +1960,7 @@ class WriteOnlyArrayGattCharacteristic : public GattCharacteristic { const UUID &uuid, T valuePtr[NUM_ELEMENTS], uint8_t additionalProperties = BLE_GATT_CHAR_PROPERTIES_NONE, - GattAttribute *descriptors[] = NULL, + GattAttribute *descriptors[] = nullptr, unsigned numDescriptors = 0 ) : GattCharacteristic( uuid, @@ -2006,7 +2004,7 @@ class ReadOnlyArrayGattCharacteristic : public GattCharacteristic { const UUID &uuid, T valuePtr[NUM_ELEMENTS], uint8_t additionalProperties = BLE_GATT_CHAR_PROPERTIES_NONE, - GattAttribute *descriptors[] = NULL, + GattAttribute *descriptors[] = nullptr, unsigned numDescriptors = 0 ) : GattCharacteristic( uuid, @@ -2051,7 +2049,7 @@ class ReadWriteArrayGattCharacteristic : public GattCharacteristic { const UUID &uuid, T valuePtr[NUM_ELEMENTS], uint8_t additionalProperties = BLE_GATT_CHAR_PROPERTIES_NONE, - GattAttribute *descriptors[] = NULL, + GattAttribute *descriptors[] = nullptr, unsigned numDescriptors = 0 ) : GattCharacteristic( uuid, diff --git a/connectivity/FEATURE_BLE/include/ble/common/ble/GattService.h b/connectivity/FEATURE_BLE/include/ble/gatt/GattService.h similarity index 96% rename from connectivity/FEATURE_BLE/include/ble/common/ble/GattService.h rename to connectivity/FEATURE_BLE/include/ble/gatt/GattService.h index a5a72c25289..1dc47bb382d 100644 --- a/connectivity/FEATURE_BLE/include/ble/common/ble/GattService.h +++ b/connectivity/FEATURE_BLE/include/ble/gatt/GattService.h @@ -19,8 +19,8 @@ #ifndef MBED_GATT_SERVICE_H__ #define MBED_GATT_SERVICE_H__ -#include "ble/common/ble/UUID.h" -#include "ble/common/ble/GattCharacteristic.h" +#include "ble/common/UUID.h" +#include "ble/gatt/GattCharacteristic.h" /** * @addtogroup ble @@ -164,7 +164,7 @@ class GattService { * * @return A reference to the service's UUID. */ - const UUID &getUUID(void) const + const UUID &getUUID() const { return _primaryServiceID; } @@ -174,7 +174,7 @@ class GattService { * * @return The service's handle. */ - uint16_t getHandle(void) const + uint16_t getHandle() const { return _handle; } @@ -184,7 +184,7 @@ class GattService { * * @return The total number of characteristics within this service. */ - uint8_t getCharacteristicCount(void) const + uint8_t getCharacteristicCount() const { return _characteristicCount; } @@ -211,7 +211,7 @@ class GattService { GattCharacteristic *getCharacteristic(uint8_t index) { if (index >= _characteristicCount) { - return NULL; + return nullptr; } return _characteristics[index]; diff --git a/connectivity/FEATURE_BLE/include/ble/common/ble/ServiceDiscovery.h b/connectivity/FEATURE_BLE/include/ble/gatt/ServiceDiscovery.h similarity index 94% rename from connectivity/FEATURE_BLE/include/ble/common/ble/ServiceDiscovery.h rename to connectivity/FEATURE_BLE/include/ble/gatt/ServiceDiscovery.h index 9e203e2af01..5d8602cd78b 100644 --- a/connectivity/FEATURE_BLE/include/ble/common/ble/ServiceDiscovery.h +++ b/connectivity/FEATURE_BLE/include/ble/gatt/ServiceDiscovery.h @@ -19,9 +19,9 @@ #ifndef MBED_BLE_SERVICE_DISOVERY_H__ #define MBED_BLE_SERVICE_DISOVERY_H__ -#include "ble/common/ble/blecommon.h" -#include "ble/common/ble/UUID.h" -#include "ble/common/ble/GattAttribute.h" +#include "ble/common/blecommon.h" +#include "ble/common/UUID.h" +#include "ble/gatt/GattAttribute.h" class DiscoveredService; class DiscoveredCharacteristic; @@ -138,21 +138,21 @@ class ServiceDiscovery { * BLE_ERROR_NONE if service discovery is launched successfully; else an appropriate error. */ virtual ble_error_t launch(ble::connection_handle_t connectionHandle, - ServiceCallback_t sc = NULL, - CharacteristicCallback_t cc = NULL, + ServiceCallback_t sc = nullptr, + CharacteristicCallback_t cc = nullptr, const UUID &matchingServiceUUID = UUID::ShortUUIDBytes_t(BLE_UUID_UNKNOWN), const UUID &matchingCharacteristicUUIDIn = UUID::ShortUUIDBytes_t(BLE_UUID_UNKNOWN)) = 0; /** * Check whether service-discovery is currently active. */ - virtual bool isActive(void) const = 0; + virtual bool isActive() const = 0; /** * Terminate an ongoing service discovery. This should result in an * invocation of the TerminationCallback if service discovery is active. */ - virtual void terminate(void) = 0; + virtual void terminate() = 0; /** * Set up a callback to be invoked when service discovery is terminated. @@ -170,12 +170,12 @@ class ServiceDiscovery { * * @return BLE_ERROR_NONE on success. */ - virtual ble_error_t reset(void) { + virtual ble_error_t reset() { connHandle = 0; matchingServiceUUID = UUID::ShortUUIDBytes_t(BLE_UUID_UNKNOWN); - serviceCallback = NULL; + serviceCallback = nullptr; matchingCharacteristicUUID = UUID::ShortUUIDBytes_t(BLE_UUID_UNKNOWN); - characteristicCallback = NULL; + characteristicCallback = nullptr; return BLE_ERROR_NONE; } diff --git a/connectivity/FEATURE_BLE/include/ble/services/BatteryService.h b/connectivity/FEATURE_BLE/include/ble/services/BatteryService.h index 4c5adabe8f8..7c44e35cbe8 100644 --- a/connectivity/FEATURE_BLE/include/ble/services/BatteryService.h +++ b/connectivity/FEATURE_BLE/include/ble/services/BatteryService.h @@ -86,7 +86,7 @@ class BatteryService { GattService batteryService( GattService::UUID_BATTERY_SERVICE, charTable, - sizeof(charTable) / sizeof(GattCharacteristic *) + sizeof(charTable) / sizeof(charTable[0]) ); ble.gattServer().addService(batteryService); diff --git a/connectivity/FEATURE_BLE/include/ble/services/DeviceInformationService.h b/connectivity/FEATURE_BLE/include/ble/services/DeviceInformationService.h index 4672d7f2817..d021a06fd92 100644 --- a/connectivity/FEATURE_BLE/include/ble/services/DeviceInformationService.h +++ b/connectivity/FEATURE_BLE/include/ble/services/DeviceInformationService.h @@ -53,42 +53,42 @@ class DeviceInformationService { * The device's software version. */ DeviceInformationService(BLE &_ble, - const char *manufacturersName = NULL, - const char *modelNumber = NULL, - const char *serialNumber = NULL, - const char *hardwareRevision = NULL, - const char *firmwareRevision = NULL, - const char *softwareRevision = NULL) : + const char *manufacturersName = nullptr, + const char *modelNumber = nullptr, + const char *serialNumber = nullptr, + const char *hardwareRevision = nullptr, + const char *firmwareRevision = nullptr, + const char *softwareRevision = nullptr) : ble(_ble), manufacturersNameStringCharacteristic(GattCharacteristic::UUID_MANUFACTURER_NAME_STRING_CHAR, (uint8_t *)manufacturersName, - (manufacturersName != NULL) ? strlen(manufacturersName) : 0, /* Min length */ - (manufacturersName != NULL) ? strlen(manufacturersName) : 0, /* Max length */ + (manufacturersName != nullptr) ? strlen(manufacturersName) : 0, /* Min length */ + (manufacturersName != nullptr) ? strlen(manufacturersName) : 0, /* Max length */ GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ), modelNumberStringCharacteristic(GattCharacteristic::UUID_MODEL_NUMBER_STRING_CHAR, (uint8_t *)modelNumber, - (modelNumber != NULL) ? strlen(modelNumber) : 0, /* Min length */ - (modelNumber != NULL) ? strlen(modelNumber) : 0, /* Max length */ + (modelNumber != nullptr) ? strlen(modelNumber) : 0, /* Min length */ + (modelNumber != nullptr) ? strlen(modelNumber) : 0, /* Max length */ GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ), serialNumberStringCharacteristic(GattCharacteristic::UUID_SERIAL_NUMBER_STRING_CHAR, (uint8_t *)serialNumber, - (serialNumber != NULL) ? strlen(serialNumber) : 0, /* Min length */ - (serialNumber != NULL) ? strlen(serialNumber) : 0, /* Max length */ + (serialNumber != nullptr) ? strlen(serialNumber) : 0, /* Min length */ + (serialNumber != nullptr) ? strlen(serialNumber) : 0, /* Max length */ GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ), hardwareRevisionStringCharacteristic(GattCharacteristic::UUID_HARDWARE_REVISION_STRING_CHAR, (uint8_t *)hardwareRevision, - (hardwareRevision != NULL) ? strlen(hardwareRevision) : 0, /* Min length */ - (hardwareRevision != NULL) ? strlen(hardwareRevision) : 0, /* Max length */ + (hardwareRevision != nullptr) ? strlen(hardwareRevision) : 0, /* Min length */ + (hardwareRevision != nullptr) ? strlen(hardwareRevision) : 0, /* Max length */ GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ), firmwareRevisionStringCharacteristic(GattCharacteristic::UUID_FIRMWARE_REVISION_STRING_CHAR, (uint8_t *)firmwareRevision, - (firmwareRevision != NULL) ? strlen(firmwareRevision) : 0, /* Min length */ - (firmwareRevision != NULL) ? strlen(firmwareRevision) : 0, /* Max length */ + (firmwareRevision != nullptr) ? strlen(firmwareRevision) : 0, /* Min length */ + (firmwareRevision != nullptr) ? strlen(firmwareRevision) : 0, /* Max length */ GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ), softwareRevisionStringCharacteristic(GattCharacteristic::UUID_SOFTWARE_REVISION_STRING_CHAR, (uint8_t *)softwareRevision, - (softwareRevision != NULL) ? strlen(softwareRevision) : 0, /* Min length */ - (softwareRevision != NULL) ? strlen(softwareRevision) : 0, /* Max length */ + (softwareRevision != nullptr) ? strlen(softwareRevision) : 0, /* Min length */ + (softwareRevision != nullptr) ? strlen(softwareRevision) : 0, /* Max length */ GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ) { static bool serviceAdded = false; /* We only add the information service once. */ @@ -103,7 +103,7 @@ class DeviceInformationService { &firmwareRevisionStringCharacteristic, &softwareRevisionStringCharacteristic}; GattService deviceInformationService(GattService::UUID_DEVICE_INFORMATION_SERVICE, charTable, - sizeof(charTable) / sizeof(GattCharacteristic *)); + sizeof(charTable) / sizeof(charTable[0])); ble.gattServer().addService(deviceInformationService); serviceAdded = true; diff --git a/connectivity/FEATURE_BLE/include/ble/services/EnvironmentalService.h b/connectivity/FEATURE_BLE/include/ble/services/EnvironmentalService.h index 402dcc9163a..fdb5bf7b115 100644 --- a/connectivity/FEATURE_BLE/include/ble/services/EnvironmentalService.h +++ b/connectivity/FEATURE_BLE/include/ble/services/EnvironmentalService.h @@ -58,7 +58,7 @@ class EnvironmentalService { &pressureCharacteristic, &temperatureCharacteristic }; - GattService environmentalService(GattService::UUID_ENVIRONMENTAL_SERVICE, charTable, sizeof(charTable) / sizeof(GattCharacteristic *)); + GattService environmentalService(GattService::UUID_ENVIRONMENTAL_SERVICE, charTable, sizeof(charTable) / sizeof(charTable[0])); ble.gattServer().addService(environmentalService); serviceAdded = true; @@ -97,9 +97,9 @@ class EnvironmentalService { private: BLE& ble; - TemperatureType_t temperature; - HumidityType_t humidity; - PressureType_t pressure; + TemperatureType_t temperature{}; + HumidityType_t humidity{}; + PressureType_t pressure{}; ReadOnlyGattCharacteristic temperatureCharacteristic; ReadOnlyGattCharacteristic humidityCharacteristic; diff --git a/connectivity/FEATURE_BLE/include/ble/services/HealthThermometerService.h b/connectivity/FEATURE_BLE/include/ble/services/HealthThermometerService.h index a1ad710ad09..6e946baaea6 100644 --- a/connectivity/FEATURE_BLE/include/ble/services/HealthThermometerService.h +++ b/connectivity/FEATURE_BLE/include/ble/services/HealthThermometerService.h @@ -63,7 +63,7 @@ class HealthThermometerService { tempLocation(GattCharacteristic::UUID_TEMPERATURE_TYPE_CHAR, &_location) { GattCharacteristic *hrmChars[] = {&tempMeasurement, &tempLocation, }; - GattService hrmService(GattService::UUID_HEALTH_THERMOMETER_SERVICE, hrmChars, sizeof(hrmChars) / sizeof(GattCharacteristic *)); + GattService hrmService(GattService::UUID_HEALTH_THERMOMETER_SERVICE, hrmChars, sizeof(hrmChars) / sizeof(hrmChars[0])); ble.gattServer().addService(hrmService); } @@ -116,11 +116,11 @@ class HealthThermometerService { memcpy(&bytes[OFFSET_OF_VALUE], &temp_ieee11073, sizeof(float)); } - uint8_t *getPointer(void) { + uint8_t *getPointer() { return bytes; } - const uint8_t *getPointer(void) const { + const uint8_t *getPointer() const { return bytes; } @@ -130,7 +130,7 @@ class HealthThermometerService { * @param temperature The temperature as a float. * @return The temperature in 11073-20601 FLOAT-Type format. */ - uint32_t quick_ieee11073_from_float(float temperature) { + static uint32_t quick_ieee11073_from_float(float temperature) { uint8_t exponent = 0xFE; //Exponent is -2 uint32_t mantissa = (uint32_t)(temperature * 100); diff --git a/connectivity/FEATURE_BLE/include/ble/services/HeartRateService.h b/connectivity/FEATURE_BLE/include/ble/services/HeartRateService.h index d4d871b8ea2..405aaf9290a 100644 --- a/connectivity/FEATURE_BLE/include/ble/services/HeartRateService.h +++ b/connectivity/FEATURE_BLE/include/ble/services/HeartRateService.h @@ -161,7 +161,7 @@ class HeartRateService { /** * Construct and add to the GattServer the heart rate service. */ - void setupService(void) { + void setupService() { GattCharacteristic *charTable[] = { &hrmRate, &hrmLocation @@ -169,7 +169,7 @@ class HeartRateService { GattService hrmService( GattService::UUID_HEART_RATE_SERVICE, charTable, - sizeof(charTable) / sizeof(GattCharacteristic*) + sizeof(charTable) / sizeof(charTable[0]) ); ble.gattServer().addService(hrmService); @@ -204,17 +204,17 @@ class HeartRateService { } } - uint8_t *getPointer(void) + uint8_t *getPointer() { return valueBytes; } - const uint8_t *getPointer(void) const + const uint8_t *getPointer() const { return valueBytes; } - unsigned getNumValueBytes(void) const + unsigned getNumValueBytes() const { if (valueBytes[FLAGS_BYTE_INDEX] & VALUE_FORMAT_FLAG) { return 1 + sizeof(uint16_t); diff --git a/connectivity/FEATURE_BLE/include/ble/services/LinkLossService.h b/connectivity/FEATURE_BLE/include/ble/services/LinkLossService.h index 01d64b63022..ded7fafcaea 100644 --- a/connectivity/FEATURE_BLE/include/ble/services/LinkLossService.h +++ b/connectivity/FEATURE_BLE/include/ble/services/LinkLossService.h @@ -59,7 +59,7 @@ class LinkLossService : public ble::Gap::EventHandler } GattCharacteristic *charTable[] = {&alertLevelChar}; - GattService linkLossService(GattService::UUID_LINK_LOSS_SERVICE, charTable, sizeof(charTable) / sizeof(GattCharacteristic *)); + GattService linkLossService(GattService::UUID_LINK_LOSS_SERVICE, charTable, sizeof(charTable) / sizeof(charTable[0])); ble.gattServer().addService(linkLossService); serviceAdded = true; @@ -95,7 +95,7 @@ class LinkLossService : public ble::Gap::EventHandler } } - virtual void onDisconnectionComplete(const ble::DisconnectionCompleteEvent &) { + void onDisconnectionComplete(const ble::DisconnectionCompleteEvent &) override { if (alertLevel != NO_ALERT) { callback(alertLevel); } diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/include/att_api.h b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/include/att_api.h similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/include/att_api.h rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/include/att_api.h diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/include/att_defs.h b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/include/att_defs.h similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/include/att_defs.h rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/include/att_defs.h diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/include/att_handler.h b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/include/att_handler.h similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/include/att_handler.h rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/include/att_handler.h diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/include/att_uuid.h b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/include/att_uuid.h similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/include/att_uuid.h rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/include/att_uuid.h diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/include/dm_api.h b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/include/dm_api.h similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/include/dm_api.h rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/include/dm_api.h diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/include/dm_handler.h b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/include/dm_handler.h similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/include/dm_handler.h rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/include/dm_handler.h diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/include/eatt_api.h b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/include/eatt_api.h similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/include/eatt_api.h rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/include/eatt_api.h diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/include/hci_api.h b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/include/hci_api.h similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/include/hci_api.h rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/include/hci_api.h diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/include/hci_cmd.h b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/include/hci_cmd.h similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/include/hci_cmd.h rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/include/hci_cmd.h diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/include/hci_core.h b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/include/hci_core.h similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/include/hci_core.h rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/include/hci_core.h diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/include/hci_drv.h b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/include/hci_drv.h similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/include/hci_drv.h rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/include/hci_drv.h diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/include/hci_evt.h b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/include/hci_evt.h similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/include/hci_evt.h rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/include/hci_evt.h diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/include/hci_handler.h b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/include/hci_handler.h similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/include/hci_handler.h rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/include/hci_handler.h diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/include/hci_tr.h b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/include/hci_tr.h similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/include/hci_tr.h rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/include/hci_tr.h diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/include/l2c_api.h b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/include/l2c_api.h similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/include/l2c_api.h rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/include/l2c_api.h diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/include/l2c_defs.h b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/include/l2c_defs.h similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/include/l2c_defs.h rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/include/l2c_defs.h diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/include/l2c_handler.h b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/include/l2c_handler.h similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/include/l2c_handler.h rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/include/l2c_handler.h diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/include/sec_api.h b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/include/sec_api.h similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/include/sec_api.h rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/include/sec_api.h diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/include/smp_api.h b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/include/smp_api.h similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/include/smp_api.h rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/include/smp_api.h diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/include/smp_defs.h b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/include/smp_defs.h similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/include/smp_defs.h rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/include/smp_defs.h diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/include/smp_handler.h b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/include/smp_handler.h similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/include/smp_handler.h rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/include/smp_handler.h diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/include/svc_core.h b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/include/svc_core.h similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/include/svc_core.h rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/include/svc_core.h diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/hci/common/hci_core.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/hci/common/hci_core.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/hci/common/hci_core.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/hci/common/hci_core.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/hci/dual_chip/hci_cmd.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/hci/dual_chip/hci_cmd.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/hci/dual_chip/hci_cmd.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/hci/dual_chip/hci_cmd.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/hci/dual_chip/hci_cmd_ae.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/hci/dual_chip/hci_cmd_ae.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/hci/dual_chip/hci_cmd_ae.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/hci/dual_chip/hci_cmd_ae.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/hci/dual_chip/hci_cmd_bis.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/hci/dual_chip/hci_cmd_bis.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/hci/dual_chip/hci_cmd_bis.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/hci/dual_chip/hci_cmd_bis.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/hci/dual_chip/hci_cmd_cis.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/hci/dual_chip/hci_cmd_cis.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/hci/dual_chip/hci_cmd_cis.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/hci/dual_chip/hci_cmd_cis.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/hci/dual_chip/hci_cmd_cte.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/hci/dual_chip/hci_cmd_cte.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/hci/dual_chip/hci_cmd_cte.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/hci/dual_chip/hci_cmd_cte.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/hci/dual_chip/hci_cmd_iso.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/hci/dual_chip/hci_cmd_iso.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/hci/dual_chip/hci_cmd_iso.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/hci/dual_chip/hci_cmd_iso.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/hci/dual_chip/hci_cmd_past.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/hci/dual_chip/hci_cmd_past.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/hci/dual_chip/hci_cmd_past.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/hci/dual_chip/hci_cmd_past.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/hci/dual_chip/hci_cmd_phy.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/hci/dual_chip/hci_cmd_phy.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/hci/dual_chip/hci_cmd_phy.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/hci/dual_chip/hci_cmd_phy.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/hci/dual_chip/hci_core_ps.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/hci/dual_chip/hci_core_ps.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/hci/dual_chip/hci_core_ps.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/hci/dual_chip/hci_core_ps.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/hci/dual_chip/hci_core_ps.h b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/hci/dual_chip/hci_core_ps.h similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/hci/dual_chip/hci_core_ps.h rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/hci/dual_chip/hci_core_ps.h diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/hci/dual_chip/hci_evt.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/hci/dual_chip/hci_evt.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/hci/dual_chip/hci_evt.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/hci/dual_chip/hci_evt.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/hci/dual_chip/hci_vs_ae.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/hci/dual_chip/hci_vs_ae.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/hci/dual_chip/hci_vs_ae.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/hci/dual_chip/hci_vs_ae.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/sec/common/sec_aes.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/sec/common/sec_aes.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/sec/common/sec_aes.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/sec/common/sec_aes.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/sec/common/sec_aes_rev.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/sec/common/sec_aes_rev.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/sec/common/sec_aes_rev.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/sec/common/sec_aes_rev.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/sec/common/sec_ccm_hci.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/sec/common/sec_ccm_hci.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/sec/common/sec_ccm_hci.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/sec/common/sec_ccm_hci.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/sec/common/sec_cmac_hci.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/sec/common/sec_cmac_hci.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/sec/common/sec_cmac_hci.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/sec/common/sec_cmac_hci.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/sec/common/sec_ecc_debug.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/sec/common/sec_ecc_debug.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/sec/common/sec_ecc_debug.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/sec/common/sec_ecc_debug.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/sec/common/sec_ecc_hci.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/sec/common/sec_ecc_hci.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/sec/common/sec_ecc_hci.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/sec/common/sec_ecc_hci.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/sec/common/sec_main.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/sec/common/sec_main.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/sec/common/sec_main.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/sec/common/sec_main.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/sec/common/sec_main.h b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/sec/common/sec_main.h similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/sec/common/sec_main.h rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/sec/common/sec_main.h diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/att/att_eatt.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/att/att_eatt.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/att/att_eatt.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/att/att_eatt.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/att/att_eatt.h b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/att/att_eatt.h similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/att/att_eatt.h rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/att/att_eatt.h diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/att/att_main.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/att/att_main.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/att/att_main.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/att/att_main.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/att/att_main.h b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/att/att_main.h similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/att/att_main.h rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/att/att_main.h diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/att/att_sign.h b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/att/att_sign.h similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/att/att_sign.h rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/att/att_sign.h diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/att/att_uuid.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/att/att_uuid.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/att/att_uuid.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/att/att_uuid.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/att/attc_disc.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/att/attc_disc.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/att/attc_disc.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/att/attc_disc.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/att/attc_eatt.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/att/attc_eatt.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/att/attc_eatt.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/att/attc_eatt.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/att/attc_main.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/att/attc_main.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/att/attc_main.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/att/attc_main.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/att/attc_main.h b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/att/attc_main.h similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/att/attc_main.h rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/att/attc_main.h diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/att/attc_proc.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/att/attc_proc.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/att/attc_proc.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/att/attc_proc.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/att/attc_read.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/att/attc_read.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/att/attc_read.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/att/attc_read.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/att/attc_sign.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/att/attc_sign.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/att/attc_sign.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/att/attc_sign.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/att/attc_write.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/att/attc_write.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/att/attc_write.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/att/attc_write.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/att/atts_ccc.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/att/atts_ccc.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/att/atts_ccc.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/att/atts_ccc.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/att/atts_csf.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/att/atts_csf.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/att/atts_csf.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/att/atts_csf.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/att/atts_dyn.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/att/atts_dyn.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/att/atts_dyn.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/att/atts_dyn.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/att/atts_eatt.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/att/atts_eatt.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/att/atts_eatt.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/att/atts_eatt.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/att/atts_ind.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/att/atts_ind.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/att/atts_ind.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/att/atts_ind.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/att/atts_main.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/att/atts_main.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/att/atts_main.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/att/atts_main.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/att/atts_main.h b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/att/atts_main.h similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/att/atts_main.h rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/att/atts_main.h diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/att/atts_proc.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/att/atts_proc.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/att/atts_proc.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/att/atts_proc.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/att/atts_read.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/att/atts_read.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/att/atts_read.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/att/atts_read.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/att/atts_sign.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/att/atts_sign.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/att/atts_sign.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/att/atts_sign.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/att/atts_write.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/att/atts_write.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/att/atts_write.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/att/atts_write.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/cfg/cfg_stack.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/cfg/cfg_stack.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/cfg/cfg_stack.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/cfg/cfg_stack.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/cfg/cfg_stack.h b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/cfg/cfg_stack.h similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/cfg/cfg_stack.h rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/cfg/cfg_stack.h diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_adv.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/dm/dm_adv.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_adv.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/dm/dm_adv.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_adv.h b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/dm/dm_adv.h similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_adv.h rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/dm/dm_adv.h diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_adv_ae.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/dm/dm_adv_ae.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_adv_ae.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/dm/dm_adv_ae.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_adv_leg.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/dm/dm_adv_leg.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_adv_leg.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/dm/dm_adv_leg.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_bis_master.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/dm/dm_bis_master.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_bis_master.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/dm/dm_bis_master.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_bis_slave.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/dm/dm_bis_slave.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_bis_slave.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/dm/dm_bis_slave.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_cis.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/dm/dm_cis.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_cis.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/dm/dm_cis.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_cis.h b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/dm/dm_cis.h similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_cis.h rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/dm/dm_cis.h diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_cis_master.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/dm/dm_cis_master.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_cis_master.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/dm/dm_cis_master.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_cis_slave.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/dm/dm_cis_slave.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_cis_slave.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/dm/dm_cis_slave.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_cis_sm.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/dm/dm_cis_sm.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_cis_sm.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/dm/dm_cis_sm.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_conn.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/dm/dm_conn.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_conn.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/dm/dm_conn.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_conn.h b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/dm/dm_conn.h similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_conn.h rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/dm/dm_conn.h diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_conn_cte.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/dm/dm_conn_cte.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_conn_cte.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/dm/dm_conn_cte.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_conn_master.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/dm/dm_conn_master.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_conn_master.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/dm/dm_conn_master.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_conn_master_ae.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/dm/dm_conn_master_ae.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_conn_master_ae.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/dm/dm_conn_master_ae.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_conn_master_leg.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/dm/dm_conn_master_leg.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_conn_master_leg.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/dm/dm_conn_master_leg.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_conn_slave.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/dm/dm_conn_slave.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_conn_slave.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/dm/dm_conn_slave.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_conn_slave_ae.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/dm/dm_conn_slave_ae.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_conn_slave_ae.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/dm/dm_conn_slave_ae.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_conn_slave_leg.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/dm/dm_conn_slave_leg.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_conn_slave_leg.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/dm/dm_conn_slave_leg.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_conn_sm.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/dm/dm_conn_sm.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_conn_sm.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/dm/dm_conn_sm.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_dev.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/dm/dm_dev.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_dev.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/dm/dm_dev.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_dev.h b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/dm/dm_dev.h similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_dev.h rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/dm/dm_dev.h diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_dev_priv.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/dm/dm_dev_priv.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_dev_priv.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/dm/dm_dev_priv.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_iso.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/dm/dm_iso.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_iso.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/dm/dm_iso.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_main.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/dm/dm_main.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_main.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/dm/dm_main.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_main.h b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/dm/dm_main.h similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_main.h rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/dm/dm_main.h diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_past.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/dm/dm_past.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_past.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/dm/dm_past.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_phy.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/dm/dm_phy.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_phy.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/dm/dm_phy.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_phy.h b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/dm/dm_phy.h similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_phy.h rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/dm/dm_phy.h diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_priv.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/dm/dm_priv.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_priv.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/dm/dm_priv.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_priv.h b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/dm/dm_priv.h similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_priv.h rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/dm/dm_priv.h diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_scan.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/dm/dm_scan.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_scan.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/dm/dm_scan.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_scan.h b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/dm/dm_scan.h similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_scan.h rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/dm/dm_scan.h diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_scan_ae.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/dm/dm_scan_ae.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_scan_ae.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/dm/dm_scan_ae.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_scan_leg.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/dm/dm_scan_leg.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_scan_leg.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/dm/dm_scan_leg.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_sec.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/dm/dm_sec.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_sec.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/dm/dm_sec.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_sec.h b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/dm/dm_sec.h similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_sec.h rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/dm/dm_sec.h diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_sec_lesc.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/dm/dm_sec_lesc.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_sec_lesc.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/dm/dm_sec_lesc.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_sec_master.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/dm/dm_sec_master.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_sec_master.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/dm/dm_sec_master.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_sec_slave.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/dm/dm_sec_slave.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_sec_slave.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/dm/dm_sec_slave.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_sync_ae.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/dm/dm_sync_ae.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_sync_ae.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/dm/dm_sync_ae.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/hci/hci_main.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/hci/hci_main.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/hci/hci_main.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/hci/hci_main.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/hci/hci_main.h b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/hci/hci_main.h similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/hci/hci_main.h rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/hci/hci_main.h diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/l2c/l2c_coc.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/l2c/l2c_coc.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/l2c/l2c_coc.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/l2c/l2c_coc.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/l2c/l2c_main.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/l2c/l2c_main.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/l2c/l2c_main.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/l2c/l2c_main.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/l2c/l2c_main.h b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/l2c/l2c_main.h similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/l2c/l2c_main.h rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/l2c/l2c_main.h diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/l2c/l2c_master.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/l2c/l2c_master.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/l2c/l2c_master.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/l2c/l2c_master.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/l2c/l2c_slave.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/l2c/l2c_slave.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/l2c/l2c_slave.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/l2c/l2c_slave.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/smp/smp_act.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/smp/smp_act.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/smp/smp_act.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/smp/smp_act.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/smp/smp_db.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/smp/smp_db.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/smp/smp_db.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/smp/smp_db.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/smp/smp_main.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/smp/smp_main.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/smp/smp_main.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/smp/smp_main.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/smp/smp_main.h b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/smp/smp_main.h similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/smp/smp_main.h rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/smp/smp_main.h diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/smp/smp_non.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/smp/smp_non.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/smp/smp_non.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/smp/smp_non.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/smp/smp_sc_act.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/smp/smp_sc_act.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/smp/smp_sc_act.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/smp/smp_sc_act.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/smp/smp_sc_main.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/smp/smp_sc_main.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/smp/smp_sc_main.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/smp/smp_sc_main.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/smp/smp_sc_main.h b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/smp/smp_sc_main.h similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/smp/smp_sc_main.h rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/smp/smp_sc_main.h diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/smp/smpi_act.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/smp/smpi_act.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/smp/smpi_act.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/smp/smpi_act.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/smp/smpi_main.h b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/smp/smpi_main.h similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/smp/smpi_main.h rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/smp/smpi_main.h diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/smp/smpi_sc_act.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/smp/smpi_sc_act.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/smp/smpi_sc_act.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/smp/smpi_sc_act.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/smp/smpi_sc_sm.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/smp/smpi_sc_sm.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/smp/smpi_sc_sm.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/smp/smpi_sc_sm.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/smp/smpi_sm.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/smp/smpi_sm.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/smp/smpi_sm.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/smp/smpi_sm.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/smp/smpr_act.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/smp/smpr_act.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/smp/smpr_act.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/smp/smpr_act.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/smp/smpr_main.h b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/smp/smpr_main.h similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/smp/smpr_main.h rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/smp/smpr_main.h diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/smp/smpr_sc_act.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/smp/smpr_sc_act.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/smp/smpr_sc_act.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/smp/smpr_sc_act.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/smp/smpr_sc_sm.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/smp/smpr_sc_sm.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/smp/smpr_sc_sm.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/smp/smpr_sc_sm.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/smp/smpr_sm.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/smp/smpr_sm.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/ble-host/sources/stack/smp/smpr_sm.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/smp/smpr_sm.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/platform/include/pal_bb.h b/connectivity/FEATURE_BLE/libraries/cordio_stack/platform/include/pal_bb.h similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/platform/include/pal_bb.h rename to connectivity/FEATURE_BLE/libraries/cordio_stack/platform/include/pal_bb.h diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/platform/include/pal_bb_154.h b/connectivity/FEATURE_BLE/libraries/cordio_stack/platform/include/pal_bb_154.h similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/platform/include/pal_bb_154.h rename to connectivity/FEATURE_BLE/libraries/cordio_stack/platform/include/pal_bb_154.h diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/platform/include/pal_bb_ble.h b/connectivity/FEATURE_BLE/libraries/cordio_stack/platform/include/pal_bb_ble.h similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/platform/include/pal_bb_ble.h rename to connectivity/FEATURE_BLE/libraries/cordio_stack/platform/include/pal_bb_ble.h diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/platform/include/pal_bb_ble_tester.h b/connectivity/FEATURE_BLE/libraries/cordio_stack/platform/include/pal_bb_ble_tester.h similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/platform/include/pal_bb_ble_tester.h rename to connectivity/FEATURE_BLE/libraries/cordio_stack/platform/include/pal_bb_ble_tester.h diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/platform/include/pal_btn.h b/connectivity/FEATURE_BLE/libraries/cordio_stack/platform/include/pal_btn.h similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/platform/include/pal_btn.h rename to connectivity/FEATURE_BLE/libraries/cordio_stack/platform/include/pal_btn.h diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/platform/include/pal_cfg.h b/connectivity/FEATURE_BLE/libraries/cordio_stack/platform/include/pal_cfg.h similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/platform/include/pal_cfg.h rename to connectivity/FEATURE_BLE/libraries/cordio_stack/platform/include/pal_cfg.h diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/platform/include/pal_codec.h b/connectivity/FEATURE_BLE/libraries/cordio_stack/platform/include/pal_codec.h similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/platform/include/pal_codec.h rename to connectivity/FEATURE_BLE/libraries/cordio_stack/platform/include/pal_codec.h diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/platform/include/pal_crypto.h b/connectivity/FEATURE_BLE/libraries/cordio_stack/platform/include/pal_crypto.h similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/platform/include/pal_crypto.h rename to connectivity/FEATURE_BLE/libraries/cordio_stack/platform/include/pal_crypto.h diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/platform/include/pal_flash.h b/connectivity/FEATURE_BLE/libraries/cordio_stack/platform/include/pal_flash.h similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/platform/include/pal_flash.h rename to connectivity/FEATURE_BLE/libraries/cordio_stack/platform/include/pal_flash.h diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/platform/include/pal_i2s.h b/connectivity/FEATURE_BLE/libraries/cordio_stack/platform/include/pal_i2s.h similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/platform/include/pal_i2s.h rename to connectivity/FEATURE_BLE/libraries/cordio_stack/platform/include/pal_i2s.h diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/platform/include/pal_io_exp.h b/connectivity/FEATURE_BLE/libraries/cordio_stack/platform/include/pal_io_exp.h similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/platform/include/pal_io_exp.h rename to connectivity/FEATURE_BLE/libraries/cordio_stack/platform/include/pal_io_exp.h diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/platform/include/pal_led.h b/connectivity/FEATURE_BLE/libraries/cordio_stack/platform/include/pal_led.h similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/platform/include/pal_led.h rename to connectivity/FEATURE_BLE/libraries/cordio_stack/platform/include/pal_led.h diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/platform/include/pal_radio.h b/connectivity/FEATURE_BLE/libraries/cordio_stack/platform/include/pal_radio.h similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/platform/include/pal_radio.h rename to connectivity/FEATURE_BLE/libraries/cordio_stack/platform/include/pal_radio.h diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/platform/include/pal_radio2.h b/connectivity/FEATURE_BLE/libraries/cordio_stack/platform/include/pal_radio2.h similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/platform/include/pal_radio2.h rename to connectivity/FEATURE_BLE/libraries/cordio_stack/platform/include/pal_radio2.h diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/platform/include/pal_rtc.h b/connectivity/FEATURE_BLE/libraries/cordio_stack/platform/include/pal_rtc.h similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/platform/include/pal_rtc.h rename to connectivity/FEATURE_BLE/libraries/cordio_stack/platform/include/pal_rtc.h diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/platform/include/pal_spi.h b/connectivity/FEATURE_BLE/libraries/cordio_stack/platform/include/pal_spi.h similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/platform/include/pal_spi.h rename to connectivity/FEATURE_BLE/libraries/cordio_stack/platform/include/pal_spi.h diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/platform/include/pal_sys.h b/connectivity/FEATURE_BLE/libraries/cordio_stack/platform/include/pal_sys.h similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/platform/include/pal_sys.h rename to connectivity/FEATURE_BLE/libraries/cordio_stack/platform/include/pal_sys.h diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/platform/include/pal_timer.h b/connectivity/FEATURE_BLE/libraries/cordio_stack/platform/include/pal_timer.h similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/platform/include/pal_timer.h rename to connectivity/FEATURE_BLE/libraries/cordio_stack/platform/include/pal_timer.h diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/platform/include/pal_twi.h b/connectivity/FEATURE_BLE/libraries/cordio_stack/platform/include/pal_twi.h similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/platform/include/pal_twi.h rename to connectivity/FEATURE_BLE/libraries/cordio_stack/platform/include/pal_twi.h diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/platform/include/pal_types.h b/connectivity/FEATURE_BLE/libraries/cordio_stack/platform/include/pal_types.h similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/platform/include/pal_types.h rename to connectivity/FEATURE_BLE/libraries/cordio_stack/platform/include/pal_types.h diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/platform/include/pal_uart.h b/connectivity/FEATURE_BLE/libraries/cordio_stack/platform/include/pal_uart.h similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/platform/include/pal_uart.h rename to connectivity/FEATURE_BLE/libraries/cordio_stack/platform/include/pal_uart.h diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/wsf/include/hci_defs.h b/connectivity/FEATURE_BLE/libraries/cordio_stack/wsf/include/hci_defs.h similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/wsf/include/hci_defs.h rename to connectivity/FEATURE_BLE/libraries/cordio_stack/wsf/include/hci_defs.h diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/wsf/include/ll_defs.h b/connectivity/FEATURE_BLE/libraries/cordio_stack/wsf/include/ll_defs.h similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/wsf/include/ll_defs.h rename to connectivity/FEATURE_BLE/libraries/cordio_stack/wsf/include/ll_defs.h diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/wsf/include/util/bda.h b/connectivity/FEATURE_BLE/libraries/cordio_stack/wsf/include/util/bda.h similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/wsf/include/util/bda.h rename to connectivity/FEATURE_BLE/libraries/cordio_stack/wsf/include/util/bda.h diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/wsf/include/util/bstream.h b/connectivity/FEATURE_BLE/libraries/cordio_stack/wsf/include/util/bstream.h similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/wsf/include/util/bstream.h rename to connectivity/FEATURE_BLE/libraries/cordio_stack/wsf/include/util/bstream.h diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/wsf/include/util/calc128.h b/connectivity/FEATURE_BLE/libraries/cordio_stack/wsf/include/util/calc128.h similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/wsf/include/util/calc128.h rename to connectivity/FEATURE_BLE/libraries/cordio_stack/wsf/include/util/calc128.h diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/wsf/include/util/crc32.h b/connectivity/FEATURE_BLE/libraries/cordio_stack/wsf/include/util/crc32.h similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/wsf/include/util/crc32.h rename to connectivity/FEATURE_BLE/libraries/cordio_stack/wsf/include/util/crc32.h diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/wsf/include/util/fcs.h b/connectivity/FEATURE_BLE/libraries/cordio_stack/wsf/include/util/fcs.h similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/wsf/include/util/fcs.h rename to connectivity/FEATURE_BLE/libraries/cordio_stack/wsf/include/util/fcs.h diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/wsf/include/util/prand.h b/connectivity/FEATURE_BLE/libraries/cordio_stack/wsf/include/util/prand.h similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/wsf/include/util/prand.h rename to connectivity/FEATURE_BLE/libraries/cordio_stack/wsf/include/util/prand.h diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/wsf/include/util/print.h b/connectivity/FEATURE_BLE/libraries/cordio_stack/wsf/include/util/print.h similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/wsf/include/util/print.h rename to connectivity/FEATURE_BLE/libraries/cordio_stack/wsf/include/util/print.h diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/wsf/include/util/terminal.h b/connectivity/FEATURE_BLE/libraries/cordio_stack/wsf/include/util/terminal.h similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/wsf/include/util/terminal.h rename to connectivity/FEATURE_BLE/libraries/cordio_stack/wsf/include/util/terminal.h diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/wsf/include/util/wstr.h b/connectivity/FEATURE_BLE/libraries/cordio_stack/wsf/include/util/wstr.h similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/wsf/include/util/wstr.h rename to connectivity/FEATURE_BLE/libraries/cordio_stack/wsf/include/util/wstr.h diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/wsf/include/wsf_assert.h b/connectivity/FEATURE_BLE/libraries/cordio_stack/wsf/include/wsf_assert.h similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/wsf/include/wsf_assert.h rename to connectivity/FEATURE_BLE/libraries/cordio_stack/wsf/include/wsf_assert.h diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/wsf/include/wsf_buf.h b/connectivity/FEATURE_BLE/libraries/cordio_stack/wsf/include/wsf_buf.h similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/wsf/include/wsf_buf.h rename to connectivity/FEATURE_BLE/libraries/cordio_stack/wsf/include/wsf_buf.h diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/wsf/include/wsf_bufio.h b/connectivity/FEATURE_BLE/libraries/cordio_stack/wsf/include/wsf_bufio.h similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/wsf/include/wsf_bufio.h rename to connectivity/FEATURE_BLE/libraries/cordio_stack/wsf/include/wsf_bufio.h diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/wsf/include/wsf_cs.h b/connectivity/FEATURE_BLE/libraries/cordio_stack/wsf/include/wsf_cs.h similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/wsf/include/wsf_cs.h rename to connectivity/FEATURE_BLE/libraries/cordio_stack/wsf/include/wsf_cs.h diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/wsf/include/wsf_detoken.h b/connectivity/FEATURE_BLE/libraries/cordio_stack/wsf/include/wsf_detoken.h similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/wsf/include/wsf_detoken.h rename to connectivity/FEATURE_BLE/libraries/cordio_stack/wsf/include/wsf_detoken.h diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/wsf/include/wsf_efs.h b/connectivity/FEATURE_BLE/libraries/cordio_stack/wsf/include/wsf_efs.h similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/wsf/include/wsf_efs.h rename to connectivity/FEATURE_BLE/libraries/cordio_stack/wsf/include/wsf_efs.h diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/wsf/include/wsf_heap.h b/connectivity/FEATURE_BLE/libraries/cordio_stack/wsf/include/wsf_heap.h similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/wsf/include/wsf_heap.h rename to connectivity/FEATURE_BLE/libraries/cordio_stack/wsf/include/wsf_heap.h diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/wsf/include/wsf_math.h b/connectivity/FEATURE_BLE/libraries/cordio_stack/wsf/include/wsf_math.h similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/wsf/include/wsf_math.h rename to connectivity/FEATURE_BLE/libraries/cordio_stack/wsf/include/wsf_math.h diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/wsf/include/wsf_msg.h b/connectivity/FEATURE_BLE/libraries/cordio_stack/wsf/include/wsf_msg.h similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/wsf/include/wsf_msg.h rename to connectivity/FEATURE_BLE/libraries/cordio_stack/wsf/include/wsf_msg.h diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/wsf/include/wsf_os.h b/connectivity/FEATURE_BLE/libraries/cordio_stack/wsf/include/wsf_os.h similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/wsf/include/wsf_os.h rename to connectivity/FEATURE_BLE/libraries/cordio_stack/wsf/include/wsf_os.h diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/wsf/include/wsf_queue.h b/connectivity/FEATURE_BLE/libraries/cordio_stack/wsf/include/wsf_queue.h similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/wsf/include/wsf_queue.h rename to connectivity/FEATURE_BLE/libraries/cordio_stack/wsf/include/wsf_queue.h diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/wsf/include/wsf_timer.h b/connectivity/FEATURE_BLE/libraries/cordio_stack/wsf/include/wsf_timer.h similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/wsf/include/wsf_timer.h rename to connectivity/FEATURE_BLE/libraries/cordio_stack/wsf/include/wsf_timer.h diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/wsf/include/wsf_trace.h b/connectivity/FEATURE_BLE/libraries/cordio_stack/wsf/include/wsf_trace.h similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/wsf/include/wsf_trace.h rename to connectivity/FEATURE_BLE/libraries/cordio_stack/wsf/include/wsf_trace.h diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/wsf/include/wsf_types.h b/connectivity/FEATURE_BLE/libraries/cordio_stack/wsf/include/wsf_types.h similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/wsf/include/wsf_types.h rename to connectivity/FEATURE_BLE/libraries/cordio_stack/wsf/include/wsf_types.h diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/wsf/sources/port/baremetal/wsf_assert.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/wsf/sources/port/baremetal/wsf_assert.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/wsf/sources/port/baremetal/wsf_assert.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/wsf/sources/port/baremetal/wsf_assert.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/wsf/sources/port/baremetal/wsf_buf.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/wsf/sources/port/baremetal/wsf_buf.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/wsf/sources/port/baremetal/wsf_buf.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/wsf/sources/port/baremetal/wsf_buf.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/wsf/sources/port/baremetal/wsf_bufio.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/wsf/sources/port/baremetal/wsf_bufio.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/wsf/sources/port/baremetal/wsf_bufio.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/wsf/sources/port/baremetal/wsf_bufio.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/wsf/sources/port/baremetal/wsf_detoken.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/wsf/sources/port/baremetal/wsf_detoken.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/wsf/sources/port/baremetal/wsf_detoken.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/wsf/sources/port/baremetal/wsf_detoken.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/wsf/sources/port/baremetal/wsf_efs.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/wsf/sources/port/baremetal/wsf_efs.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/wsf/sources/port/baremetal/wsf_efs.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/wsf/sources/port/baremetal/wsf_efs.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/wsf/sources/port/baremetal/wsf_heap.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/wsf/sources/port/baremetal/wsf_heap.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/wsf/sources/port/baremetal/wsf_heap.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/wsf/sources/port/baremetal/wsf_heap.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/wsf/sources/port/baremetal/wsf_msg.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/wsf/sources/port/baremetal/wsf_msg.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/wsf/sources/port/baremetal/wsf_msg.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/wsf/sources/port/baremetal/wsf_msg.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/wsf/sources/port/baremetal/wsf_queue.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/wsf/sources/port/baremetal/wsf_queue.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/wsf/sources/port/baremetal/wsf_queue.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/wsf/sources/port/baremetal/wsf_queue.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/wsf/sources/port/baremetal/wsf_timer.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/wsf/sources/port/baremetal/wsf_timer.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/wsf/sources/port/baremetal/wsf_timer.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/wsf/sources/port/baremetal/wsf_timer.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/wsf/sources/port/baremetal/wsf_trace.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/wsf/sources/port/baremetal/wsf_trace.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/wsf/sources/port/baremetal/wsf_trace.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/wsf/sources/port/baremetal/wsf_trace.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/wsf/sources/util/bda.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/wsf/sources/util/bda.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/wsf/sources/util/bda.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/wsf/sources/util/bda.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/wsf/sources/util/bstream.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/wsf/sources/util/bstream.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/wsf/sources/util/bstream.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/wsf/sources/util/bstream.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/wsf/sources/util/calc128.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/wsf/sources/util/calc128.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/wsf/sources/util/calc128.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/wsf/sources/util/calc128.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/wsf/sources/util/crc32.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/wsf/sources/util/crc32.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/wsf/sources/util/crc32.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/wsf/sources/util/crc32.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/wsf/sources/util/fcs.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/wsf/sources/util/fcs.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/wsf/sources/util/fcs.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/wsf/sources/util/fcs.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/wsf/sources/util/prand.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/wsf/sources/util/prand.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/wsf/sources/util/prand.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/wsf/sources/util/prand.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/wsf/sources/util/print.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/wsf/sources/util/print.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/wsf/sources/util/print.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/wsf/sources/util/print.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/wsf/sources/util/terminal.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/wsf/sources/util/terminal.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/wsf/sources/util/terminal.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/wsf/sources/util/terminal.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/wsf/sources/util/wstr.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/wsf/sources/util/wstr.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack/wsf/sources/util/wstr.c rename to connectivity/FEATURE_BLE/libraries/cordio_stack/wsf/sources/util/wstr.c diff --git a/connectivity/FEATURE_BLE/source/BLE.cpp b/connectivity/FEATURE_BLE/source/BLE.cpp index b0fa05d63b2..7f6e3525a34 100644 --- a/connectivity/FEATURE_BLE/source/BLE.cpp +++ b/connectivity/FEATURE_BLE/source/BLE.cpp @@ -18,7 +18,7 @@ #include #include "platform/mbed_critical.h" -#include "ble/internal/BLEInstanceBase.h" +#include "BLEInstanceBase.h" #if defined(TARGET_OTA_ENABLED) #include "services/DFUService.h" @@ -28,7 +28,7 @@ #include #include "ble/BLE.h" -#include "ble/internal/BLEInstanceBase.h" +#include "BLEInstanceBase.h" static const char *error_strings[] = { "BLE_ERROR_NONE: No error", diff --git a/connectivity/FEATURE_BLE/include/ble/internal/BLEInstanceBase.h b/connectivity/FEATURE_BLE/source/BLEInstanceBase.h similarity index 87% rename from connectivity/FEATURE_BLE/include/ble/internal/BLEInstanceBase.h rename to connectivity/FEATURE_BLE/source/BLEInstanceBase.h index 041d2161aba..cbbe12e44e1 100644 --- a/connectivity/FEATURE_BLE/include/ble/internal/BLEInstanceBase.h +++ b/connectivity/FEATURE_BLE/source/BLEInstanceBase.h @@ -49,10 +49,6 @@ namespace ble { * * @see BLE */ -#if !defined(DOXYGEN_ONLY) -namespace interface { -#endif // !defined(DOXYGEN_ONLY) - class BLEInstanceBase { public: /** @@ -116,7 +112,7 @@ class BLEInstanceBase { * * @see BLE::init() BLE::hasInitialized() */ - virtual bool hasInitialized(void) const = 0; + virtual bool hasInitialized() const = 0; /** * Shutdown the vendor BLE subsystem. @@ -139,7 +135,7 @@ class BLEInstanceBase { * @see BLE::shutdown() BLE::init() BLE::hasInitialized() Gap::reset() * GattClient::reset() GattServer::reset() SecurityManager::reset() . */ - virtual ble_error_t shutdown(void) = 0; + virtual ble_error_t shutdown() = 0; /** * Fetches a NULL terminated string representation of the underlying BLE @@ -150,7 +146,7 @@ class BLEInstanceBase { * * @see BLE::getVersion() */ - virtual const char *getVersion(void) = 0; + virtual const char *getVersion() = 0; /** * Accessor to the vendor implementation of the Gap interface. @@ -160,7 +156,7 @@ class BLEInstanceBase { * * @see BLE::gap() Gap */ - virtual ble::Gap &getGap(void) = 0; + virtual ble::Gap &getGap() = 0; /** * Const alternative to getGap(). @@ -170,7 +166,7 @@ class BLEInstanceBase { * * @see BLE::gap() Gap */ - virtual const ble::Gap &getGap(void) const = 0; + virtual const ble::Gap &getGap() const = 0; #if BLE_FEATURE_GATT_SERVER @@ -183,7 +179,7 @@ class BLEInstanceBase { * * @see BLE::gattServer() GattServer */ - virtual ble::GattServer &getGattServer(void) = 0; + virtual ble::GattServer &getGattServer() = 0; /** * A const alternative to getGattServer(). @@ -193,7 +189,7 @@ class BLEInstanceBase { * * @see BLE::gattServer() GattServer */ - virtual const ble::GattServer &getGattServer(void) const = 0; + virtual const ble::GattServer &getGattServer() const = 0; #endif // BLE_FEATURE_GATT_SERVER @@ -207,7 +203,7 @@ class BLEInstanceBase { * * @see BLE::gattClient() GattClient */ - virtual ble::GattClient &getGattClient(void) = 0; + virtual ble::GattClient &getGattClient() = 0; #endif @@ -221,7 +217,7 @@ class BLEInstanceBase { * * @see BLE::securityManager() SecurityManager */ - virtual ble::SecurityManager &getSecurityManager(void) = 0; + virtual ble::SecurityManager &getSecurityManager() = 0; /** * A const alternative to getSecurityManager(). @@ -231,16 +227,11 @@ class BLEInstanceBase { * * @see BLE::securityManager() SecurityManager */ - virtual const ble::SecurityManager &getSecurityManager(void) const = 0; + virtual const ble::SecurityManager &getSecurityManager() const = 0; #endif // BLE_FEATURE_SECURITY }; -#if !defined(DOXYGEN_ONLY) -} // namespace interface -#endif // !defined(DOXYGEN_ONLY) -} // namespace ble - /** * Return the instance of the vendor implementation of BLEInstanceBase. * @@ -250,15 +241,13 @@ class BLEInstanceBase { * @attention The vendor library must provide an implementation for this function * library. Otherwise, there will be a linker error. */ -extern ble::BLEInstanceBase *createBLEInstance(void); - -/* This includes the concrete class implementation, to provide a an alternative BLE PAL implementation - * disable Cordio and place your header in a path with the same structure */ -#include "ble/internal/BLEInstanceBaseImpl.h" +extern ble::BLEInstanceBase *createBLEInstance(); /** * @} * @} */ +} // namespace ble + #endif // ifndef MBED_BLE_DEVICE_INSTANCE_BASE__ diff --git a/connectivity/FEATURE_BLE/source/Gap.cpp b/connectivity/FEATURE_BLE/source/Gap.cpp new file mode 100644 index 00000000000..727d2a285c9 --- /dev/null +++ b/connectivity/FEATURE_BLE/source/Gap.cpp @@ -0,0 +1,504 @@ +/* mbed Microcontroller Library + * Copyright (c) 2020 ARM Limited + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ble/Gap.h" +#include "source/generic/GapImpl.h" + +namespace ble { + +void Gap::setEventHandler(EventHandler *handler) +{ + impl->setEventHandler(handler); +} + + +bool Gap::isFeatureSupported(controller_supported_features_t feature) +{ + return impl->isFeatureSupported(feature); +} + +/* advertising */ +#if BLE_ROLE_BROADCASTER + +uint8_t Gap::getMaxAdvertisingSetNumber() +{ + return impl->getMaxAdvertisingSetNumber(); +} + + +uint16_t Gap::getMaxAdvertisingDataLength() +{ + return impl->getMaxAdvertisingDataLength(); +} + + +uint16_t Gap::getMaxConnectableAdvertisingDataLength() +{ + return impl->getMaxConnectableAdvertisingDataLength(); +} + + +uint16_t Gap::getMaxActiveSetAdvertisingDataLength() +{ + return impl->getMaxActiveSetAdvertisingDataLength(); +} + +#if BLE_FEATURE_EXTENDED_ADVERTISING + +ble_error_t Gap::createAdvertisingSet( + advertising_handle_t *handle, + const AdvertisingParameters ¶meters +) +{ + return impl->createAdvertisingSet(handle, parameters); +} + + +ble_error_t Gap::destroyAdvertisingSet(advertising_handle_t handle) +{ + return impl->destroyAdvertisingSet(handle); +} + +#endif // BLE_FEATURE_EXTENDED_ADVERTISING + + +ble_error_t Gap::setAdvertisingParameters( + advertising_handle_t handle, + const AdvertisingParameters ¶ms +) +{ + return impl->setAdvertisingParameters(handle, params); +} + + +ble_error_t Gap::setAdvertisingPayload( + advertising_handle_t handle, + mbed::Span payload +) +{ + return impl->setAdvertisingPayload(handle, payload); +} + + +ble_error_t Gap::setAdvertisingScanResponse( + advertising_handle_t handle, + mbed::Span response +) +{ + return impl->setAdvertisingScanResponse(handle, response); +} + +ble_error_t Gap::startAdvertising( + advertising_handle_t handle, + adv_duration_t maxDuration, + uint8_t maxEvents +) +{ + return impl->startAdvertising(handle, maxDuration, maxEvents); +} + +ble_error_t Gap::stopAdvertising(advertising_handle_t handle) +{ + return impl->stopAdvertising(handle); +} + + +bool Gap::isAdvertisingActive(advertising_handle_t handle) +{ + return impl->isAdvertisingActive(handle); +} + +#endif // BLE_ROLE_BROADCASTER + +#if BLE_ROLE_BROADCASTER +#if BLE_FEATURE_PERIODIC_ADVERTISING + +ble_error_t Gap::setPeriodicAdvertisingParameters( + advertising_handle_t handle, + periodic_interval_t periodicAdvertisingIntervalMin, + periodic_interval_t periodicAdvertisingIntervalMax, + bool advertiseTxPower +) +{ + return impl->setPeriodicAdvertisingParameters( + handle, + periodicAdvertisingIntervalMin, + periodicAdvertisingIntervalMax, + advertiseTxPower + ); +} + + +ble_error_t Gap::setPeriodicAdvertisingPayload( + advertising_handle_t handle, + mbed::Span payload +) +{ + return impl->setPeriodicAdvertisingPayload(handle, payload); +} + + +ble_error_t Gap::startPeriodicAdvertising(advertising_handle_t handle) +{ + return impl->startPeriodicAdvertising(handle); +} + + +ble_error_t Gap::stopPeriodicAdvertising(advertising_handle_t handle) +{ + return impl->stopAdvertising(handle); +} + + +bool Gap::isPeriodicAdvertisingActive(advertising_handle_t handle) +{ + return impl->isPeriodicAdvertisingActive(handle); +} + +#endif // BLE_ROLE_BROADCASTER +#endif // BLE_FEATURE_PERIODIC_ADVERTISING + +/* scanning */ +#if BLE_ROLE_OBSERVER + +ble_error_t Gap::setScanParameters(const ScanParameters ¶ms) +{ + return impl->setScanParameters(params); +} + + +ble_error_t Gap::startScan( + scan_duration_t duration, + duplicates_filter_t filtering, + scan_period_t period +) +{ + return impl->startScan(duration, filtering, period); +} + +ble_error_t Gap::stopScan() +{ + return impl->stopScan(); +} + +#endif // BLE_ROLE_OBSERVER + +#if BLE_ROLE_OBSERVER +#if BLE_FEATURE_PERIODIC_ADVERTISING + +ble_error_t Gap::createSync( + peer_address_type_t peerAddressType, + const address_t &peerAddress, + uint8_t sid, + slave_latency_t maxPacketSkip, + sync_timeout_t timeout +) +{ + return impl->createSync(peerAddressType, peerAddress, sid, maxPacketSkip, timeout); +} + + +ble_error_t Gap::createSync( + slave_latency_t maxPacketSkip, + sync_timeout_t timeout +) +{ + return impl->createSync(maxPacketSkip, timeout); +} + + +ble_error_t Gap::cancelCreateSync() +{ + return impl->cancelCreateSync(); +} + + +ble_error_t Gap::terminateSync(periodic_sync_handle_t handle) +{ + return impl->terminateSync(handle); +} + + +ble_error_t Gap::addDeviceToPeriodicAdvertiserList( + peer_address_type_t peerAddressType, + const address_t &peerAddress, + advertising_sid_t sid +) +{ + return impl->addDeviceToPeriodicAdvertiserList(peerAddressType, peerAddress, sid); +} + + +ble_error_t Gap::removeDeviceFromPeriodicAdvertiserList( + peer_address_type_t peerAddressType, + const address_t &peerAddress, + advertising_sid_t sid +) +{ + return impl->removeDeviceFromPeriodicAdvertiserList(peerAddressType, peerAddress, sid); +} + + +ble_error_t Gap::clearPeriodicAdvertiserList() +{ + return impl->clearPeriodicAdvertiserList(); +} + + +uint8_t Gap::getMaxPeriodicAdvertiserListSize() +{ + return impl->getMaxPeriodicAdvertiserListSize(); +} + +#endif // BLE_ROLE_OBSERVER +#endif // BLE_FEATURE_PERIODIC_ADVERTISING + +#if BLE_ROLE_CENTRAL + +ble_error_t Gap::connect( + peer_address_type_t peerAddressType, + const address_t &peerAddress, + const ConnectionParameters &connectionParams +) +{ + return impl->connect(peerAddressType, peerAddress, connectionParams); +} + + +ble_error_t Gap::cancelConnect() +{ + return impl->cancelConnect(); +} + + +#endif // BLE_ROLE_CENTRAL + +#if BLE_FEATURE_CONNECTABLE + +ble_error_t Gap::updateConnectionParameters( + connection_handle_t connectionHandle, + conn_interval_t minConnectionInterval, + conn_interval_t maxConnectionInterval, + slave_latency_t slaveLatency, + supervision_timeout_t supervision_timeout, + conn_event_length_t minConnectionEventLength, + conn_event_length_t maxConnectionEventLength +) +{ + return impl->updateConnectionParameters( + connectionHandle, + minConnectionInterval, + maxConnectionInterval, + slaveLatency, + supervision_timeout, + minConnectionEventLength, + maxConnectionEventLength + ); +} + + +ble_error_t Gap::manageConnectionParametersUpdateRequest( + bool userManageConnectionUpdateRequest +) +{ + return impl->manageConnectionParametersUpdateRequest(userManageConnectionUpdateRequest); +} + + +ble_error_t Gap::acceptConnectionParametersUpdate( + connection_handle_t connectionHandle, + conn_interval_t minConnectionInterval, + conn_interval_t maxConnectionInterval, + slave_latency_t slaveLatency, + supervision_timeout_t supervision_timeout, + conn_event_length_t minConnectionEventLength, + conn_event_length_t maxConnectionEventLength +) +{ + return impl->acceptConnectionParametersUpdate( + connectionHandle, + minConnectionInterval, + maxConnectionInterval, + slaveLatency, + supervision_timeout, + minConnectionEventLength, + maxConnectionEventLength + ); +} + + +ble_error_t Gap::rejectConnectionParametersUpdate( + connection_handle_t connectionHandle +) +{ + return impl->rejectConnectionParametersUpdate(connectionHandle); +} + + +ble_error_t Gap::disconnect( + connection_handle_t connectionHandle, + local_disconnection_reason_t reason +) +{ + return impl->disconnect(connectionHandle, reason); +} + +#endif // BLE_FEATURE_CONNECTABLE +#if BLE_FEATURE_PHY_MANAGEMENT + +ble_error_t Gap::readPhy(connection_handle_t connection) +{ + return impl->readPhy(connection); +} + + +ble_error_t Gap::setPreferredPhys( + const phy_set_t *txPhys, + const phy_set_t *rxPhys +) +{ + return impl->setPreferredPhys(txPhys, rxPhys); +} + + +ble_error_t Gap::setPhy( + connection_handle_t connection, + const phy_set_t *txPhys, + const phy_set_t *rxPhys, + coded_symbol_per_bit_t codedSymbol +) +{ + return impl->setPhy( + connection, + txPhys, + rxPhys, + codedSymbol + ); +} + +#endif // BLE_FEATURE_PHY_MANAGEMENT + +#if BLE_FEATURE_PRIVACY + +ble_error_t Gap::enablePrivacy(bool enable) +{ + return impl->enablePrivacy(enable); +} + +#if BLE_ROLE_BROADCASTER + +ble_error_t Gap::setPeripheralPrivacyConfiguration( + const peripheral_privacy_configuration_t *configuration +) +{ + return impl->setPeripheralPrivacyConfiguration(configuration); +} + + +ble_error_t Gap::getPeripheralPrivacyConfiguration( + peripheral_privacy_configuration_t *configuration +) +{ + return impl->getPeripheralPrivacyConfiguration(configuration); +} + +#endif // BLE_ROLE_BROADCASTER + +#if BLE_ROLE_OBSERVER + +ble_error_t Gap::setCentralPrivacyConfiguration( + const central_privacy_configuration_t *configuration +) +{ + return impl->setCentralPrivacyConfiguration(configuration); +} + + +ble_error_t Gap::getCentralPrivacyConfiguration( + central_privacy_configuration_t *configuration +) +{ + return impl->getCentralPrivacyConfiguration(configuration); +} + +#endif // BLE_ROLE_OBSERVER +#endif // BLE_FEATURE_PRIVACY + +#if BLE_FEATURE_WHITELIST + +uint8_t Gap::getMaxWhitelistSize() const +{ + return impl->getMaxWhitelistSize(); +} + + +ble_error_t Gap::getWhitelist(whitelist_t &whitelist) const +{ + return impl->getWhitelist(whitelist); +} + + +ble_error_t Gap::setWhitelist(const whitelist_t &whitelist) +{ + return impl->setWhitelist(whitelist); +} + +#endif // BLE_FEATURE_WHITELIST + + +ble_error_t Gap::getAddress( + own_address_type_t &typeP, + address_t &address +) +{ + return impl->getAddress(typeP, address); +} + + +ble_error_t Gap::getRandomAddressType( + ble::address_t address, + ble::random_address_type_t *addressType +) +{ + return impl::Gap::getRandomAddressType(address, addressType); +} + + +ble_error_t Gap::reset() +{ + return impl->reset(); +} + + +void Gap::onShutdown(const GapShutdownCallback_t &callback) +{ + return impl->onShutdown(callback); +} + + +Gap::GapShutdownCallbackChain_t &Gap::onShutdown() +{ + return impl->onShutdown(); +} + + +ble_error_t Gap::setRandomStaticAddress(const ble::address_t &address) +{ + return impl->setRandomStaticAddress(address); +} + +} // namespace ble \ No newline at end of file diff --git a/connectivity/FEATURE_BLE/source/GattClient.cpp b/connectivity/FEATURE_BLE/source/GattClient.cpp new file mode 100644 index 00000000000..2d924219116 --- /dev/null +++ b/connectivity/FEATURE_BLE/source/GattClient.cpp @@ -0,0 +1,193 @@ +/* mbed Microcontroller Library + * Copyright (c) 2020 ARM Limited + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ble/GattClient.h" +#include "source/generic/GattClientImpl.h" + +namespace ble { + +void GattClient::setEventHandler(EventHandler *handler) +{ + impl->setEventHandler(handler); +} + +ble_error_t GattClient::launchServiceDiscovery( + ble::connection_handle_t connectionHandle, + ServiceDiscovery::ServiceCallback_t sc, + ServiceDiscovery::CharacteristicCallback_t cc, + const UUID &matchingServiceUUID, + const UUID &matchingCharacteristicUUIDIn +) +{ + return impl->launchServiceDiscovery( + connectionHandle, sc, cc, matchingServiceUUID, matchingCharacteristicUUIDIn + ); +} + +ble_error_t GattClient::discoverServices( + ble::connection_handle_t connectionHandle, + ServiceDiscovery::ServiceCallback_t callback, + const UUID &matchingServiceUUID +) +{ + return impl->discoverServices(connectionHandle, callback, matchingServiceUUID); +} + +ble_error_t GattClient::discoverServices( + ble::connection_handle_t connectionHandle, + ServiceDiscovery::ServiceCallback_t callback, + GattAttribute::Handle_t startHandle, + GattAttribute::Handle_t endHandle +) +{ + return impl->discoverServices(connectionHandle, callback, startHandle, endHandle); +} + +bool GattClient::isServiceDiscoveryActive(void) const +{ + return impl->isServiceDiscoveryActive(); +} + +void GattClient::terminateServiceDiscovery(void) +{ + return impl->terminateServiceDiscovery(); +} + +ble_error_t GattClient::read( + ble::connection_handle_t connHandle, + GattAttribute::Handle_t attributeHandle, + uint16_t offset +) const +{ + return impl->read(connHandle, attributeHandle, offset); +} + +ble_error_t GattClient::write( + GattClient::WriteOp_t cmd, + ble::connection_handle_t connHandle, + GattAttribute::Handle_t attributeHandle, + size_t length, + const uint8_t *value +) const +{ + return impl->write(cmd, connHandle, attributeHandle, length, value); +} + +/* Event callback handlers. */ + +void GattClient::onDataRead(ble::ReadCallback_t callback) +{ + return impl->onDataRead(callback); +} + +ble::ReadCallbackChain_t& GattClient::onDataRead() +{ + return impl->onDataRead(); +} + +void GattClient::onDataWritten(ble::WriteCallback_t callback) +{ + impl->onDataWritten(callback); +} + +ble::WriteCallbackChain_t& GattClient::onDataWritten() +{ + return impl->onDataWritten(); +} + +void GattClient::onServiceDiscoveryTermination( + ServiceDiscovery::TerminationCallback_t callback +) +{ + return impl->onServiceDiscoveryTermination(callback); +} + +ble_error_t GattClient::discoverCharacteristicDescriptors( + const DiscoveredCharacteristic& characteristic, + const CharacteristicDescriptorDiscovery::DiscoveryCallback_t& discoveryCallback, + const CharacteristicDescriptorDiscovery::TerminationCallback_t& terminationCallback +) +{ + return impl->discoverCharacteristicDescriptors( + characteristic, + discoveryCallback, + terminationCallback + ); +} + +bool GattClient::isCharacteristicDescriptorDiscoveryActive( + const DiscoveredCharacteristic& characteristic +) const +{ + return impl->isCharacteristicDescriptorDiscoveryActive(characteristic); +} + +void GattClient::terminateCharacteristicDescriptorDiscovery( + const DiscoveredCharacteristic& characteristic +) +{ + return impl->terminateCharacteristicDescriptorDiscovery(characteristic); +} + +ble_error_t GattClient::negotiateAttMtu(ble::connection_handle_t connection) +{ + return impl->negotiateAttMtu(connection); +} + +void GattClient::onHVX(HVXCallback_t callback) +{ + return impl->onHVX(callback); +} + + +void GattClient::onShutdown(const GattClientShutdownCallback_t& callback) +{ + return impl->onShutdown(callback); +} + +GattClient::GattClientShutdownCallbackChain_t& GattClient::onShutdown() +{ + return impl->onShutdown(); +} + +GattClient::HVXCallbackChain_t& GattClient::onHVX() +{ + return impl->onHVX(); +} + +ble_error_t GattClient::reset(void) +{ + return impl->reset(); +} + +void GattClient::processReadResponse(const GattReadCallbackParams *params) +{ + return impl->processReadResponse(params); +} + +void GattClient::processWriteResponse(const GattWriteCallbackParams *params) +{ + return impl->processWriteResponse(params); +} + +void GattClient::processHVXEvent(const GattHVXCallbackParams *params) +{ + return impl->processHVXEvent(params); +} + +} // namespace ble + diff --git a/connectivity/FEATURE_BLE/source/GattServer.cpp b/connectivity/FEATURE_BLE/source/GattServer.cpp new file mode 100644 index 00000000000..583903023e5 --- /dev/null +++ b/connectivity/FEATURE_BLE/source/GattServer.cpp @@ -0,0 +1,155 @@ +/* mbed Microcontroller Library + * Copyright (c) 2020 ARM Limited + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ble/GattServer.h" +#include "source/GattServerImpl.h" + +namespace ble { + +void GattServer::setEventHandler(EventHandler *handler) +{ + return impl->setEventHandler(handler); +} + +ble_error_t GattServer::reset() +{ + return impl->reset(this); +} + +ble_error_t GattServer::addService(GattService &service) +{ + return impl->addService(service); +} + +ble_error_t GattServer::read( + GattAttribute::Handle_t attributeHandle, + uint8_t buffer[], + uint16_t *lengthP +) +{ + return impl->read(attributeHandle, buffer, lengthP); +} + +ble_error_t GattServer::read( + ble::connection_handle_t connectionHandle, + GattAttribute::Handle_t attributeHandle, + uint8_t *buffer, + uint16_t *lengthP +) +{ + return impl->read(connectionHandle, attributeHandle, buffer, lengthP); +} + +ble_error_t GattServer::write( + GattAttribute::Handle_t attributeHandle, + const uint8_t *value, + uint16_t size, + bool localOnly +) +{ + return impl->write(attributeHandle, value, size, localOnly); +} + +ble_error_t GattServer::write( + ble::connection_handle_t connectionHandle, + GattAttribute::Handle_t attributeHandle, + const uint8_t *value, + uint16_t size, + bool localOnly +) +{ + return impl->write(connectionHandle, attributeHandle, value, size, localOnly); +} + +ble_error_t GattServer::areUpdatesEnabled( + const GattCharacteristic &characteristic, + bool *enabledP +) +{ + return impl->areUpdatesEnabled(characteristic, enabledP); +} + +ble_error_t GattServer::areUpdatesEnabled( + ble::connection_handle_t connectionHandle, + const GattCharacteristic &characteristic, + bool *enabledP +) +{ + return impl->areUpdatesEnabled(connectionHandle, characteristic, enabledP); +} + +bool GattServer::isOnDataReadAvailable() const +{ + return impl->isOnDataReadAvailable(); +} + +void GattServer::onDataSent(const DataSentCallback_t &callback) +{ + return impl->onDataSent(callback); +} + +GattServer::DataSentCallbackChain_t &GattServer::onDataSent() +{ + return impl->onDataSent(); +} + +void GattServer::onDataWritten(const DataWrittenCallback_t &callback) +{ + return impl->onDataWritten(callback); +} + +GattServer::DataWrittenCallbackChain_t &GattServer::onDataWritten() +{ + return impl->onDataWritten(); +} + +ble_error_t GattServer::onDataRead(const DataReadCallback_t &callback) +{ + return impl->onDataRead(callback); +} + +GattServer::DataReadCallbackChain_t &GattServer::onDataRead() +{ + return impl->onDataRead(); +} + +void GattServer::onShutdown(const GattServerShutdownCallback_t &callback) +{ + return impl->onShutdown(callback); +} + +GattServer::GattServerShutdownCallbackChain_t& GattServer::onShutdown() +{ + return impl->onShutdown(); +} + +void GattServer::onUpdatesEnabled(EventCallback_t callback) +{ + return impl->onUpdatesEnabled(callback); +} + +void GattServer::onUpdatesDisabled(EventCallback_t callback) +{ + return impl->onUpdatesDisabled(callback); +} + +void GattServer::onConfirmationReceived(EventCallback_t callback) +{ + return impl->onConfirmationReceived(callback); +} + +} // ble \ No newline at end of file diff --git a/connectivity/FEATURE_BLE/source/SecurityManager.cpp b/connectivity/FEATURE_BLE/source/SecurityManager.cpp new file mode 100644 index 00000000000..71c16c86e42 --- /dev/null +++ b/connectivity/FEATURE_BLE/source/SecurityManager.cpp @@ -0,0 +1,218 @@ +/* mbed Microcontroller Library + * Copyright (c) 2020 ARM Limited + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ble/SecurityManager.h" +#include "source/generic/SecurityManagerImpl.h" + +namespace ble { + +ble_error_t SecurityManager::init( + bool enableBonding, + bool requireMITM, + SecurityIOCapabilities_t iocaps, + const Passkey_t passkey, + bool signing, + const char *dbFilepath +) +{ + return impl->init(enableBonding, requireMITM, iocaps, passkey, signing, dbFilepath); +} + +ble_error_t SecurityManager::setDatabaseFilepath(const char *dbFilepath) +{ + return impl->setDatabaseFilepath(dbFilepath); +} + +ble_error_t SecurityManager::reset() +{ + return impl->reset(); +} + +ble_error_t SecurityManager::preserveBondingStateOnReset(bool enable) +{ + return impl->preserveBondingStateOnReset(enable); +} + +ble_error_t SecurityManager::purgeAllBondingState() +{ + return impl->purgeAllBondingState(); +} + +ble_error_t SecurityManager::generateWhitelistFromBondTable(::ble::whitelist_t *whitelist) const +{ + return impl->generateWhitelistFromBondTable(whitelist); +} + +ble_error_t SecurityManager::requestPairing(ble::connection_handle_t connectionHandle) +{ + return impl->requestPairing(connectionHandle); +} + +ble_error_t SecurityManager::acceptPairingRequest(ble::connection_handle_t connectionHandle) +{ + return impl->acceptPairingRequest(connectionHandle); +} + +ble_error_t SecurityManager::cancelPairingRequest(ble::connection_handle_t connectionHandle) +{ + return impl->cancelPairingRequest(connectionHandle); +} + +ble_error_t SecurityManager::setPairingRequestAuthorisation(bool required) +{ + return impl->setPairingRequestAuthorisation(required); +} + +ble_error_t SecurityManager::getPeerIdentity(ble::connection_handle_t connectionHandle) +{ + return impl->getPeerIdentity(connectionHandle); +} + +ble_error_t SecurityManager::allowLegacyPairing(bool allow) +{ + return impl->allowLegacyPairing(allow); +} + +ble_error_t SecurityManager::getSecureConnectionsSupport(bool *enabled) +{ + return impl->getSecureConnectionsSupport(enabled); +} + +ble_error_t SecurityManager::setIoCapability(SecurityIOCapabilities_t iocaps) +{ + return impl->setIoCapability(iocaps); +} + +ble_error_t SecurityManager::setDisplayPasskey(const Passkey_t passkey) +{ + return impl->setDisplayPasskey(passkey); +} + +ble_error_t SecurityManager::setLinkSecurity(ble::connection_handle_t connectionHandle, SecurityMode_t securityMode) +{ + return impl->setLinkSecurity(connectionHandle, securityMode); +} + +ble_error_t SecurityManager::setKeypressNotification(bool enabled) +{ + return impl->setKeypressNotification(enabled); +} + +#if BLE_FEATURE_SIGNING +ble_error_t SecurityManager::enableSigning(ble::connection_handle_t connectionHandle, bool enabled) +{ + return impl->enableSigning(connectionHandle, enabled); +} +#endif // BLE_FEATURE_SIGNING + +ble_error_t SecurityManager::setHintFutureRoleReversal(bool enable) +{ + return impl->setHintFutureRoleReversal(enable); +} + +ble_error_t SecurityManager::getLinkEncryption(ble::connection_handle_t connectionHandle, ble::link_encryption_t *encryption) +{ + return impl->getLinkEncryption(connectionHandle, encryption); +} + +ble_error_t SecurityManager::setLinkEncryption(ble::connection_handle_t connectionHandle, ble::link_encryption_t encryption) +{ + return impl->setLinkEncryption(connectionHandle, encryption); +} + +ble_error_t SecurityManager::setEncryptionKeyRequirements(uint8_t minimumByteSize, uint8_t maximumByteSize) +{ + return impl->setEncryptionKeyRequirements(minimumByteSize, maximumByteSize); +} + +ble_error_t SecurityManager::getEncryptionKeySize( + connection_handle_t connectionHandle, + uint8_t *size +) +{ + return impl->getEncryptionKeySize(connectionHandle, size); +} + +ble_error_t SecurityManager::requestAuthentication(ble::connection_handle_t connectionHandle) +{ + return impl->requestAuthentication(connectionHandle); +} + +ble_error_t SecurityManager::generateOOB(const ble::address_t *address) +{ + return impl->generateOOB(address); +} + +ble_error_t SecurityManager::setOOBDataUsage(ble::connection_handle_t connectionHandle, bool useOOB, bool OOBProvidesMITM) +{ + return impl->setOOBDataUsage(connectionHandle, useOOB, OOBProvidesMITM); +} + +ble_error_t SecurityManager::confirmationEntered(ble::connection_handle_t connectionHandle, bool confirmation) +{ + return impl->confirmationEntered(connectionHandle, confirmation); +} + +ble_error_t SecurityManager::passkeyEntered(ble::connection_handle_t connectionHandle, Passkey_t passkey) +{ + return impl->passkeyEntered(connectionHandle, passkey); +} + +ble_error_t SecurityManager::sendKeypressNotification(ble::connection_handle_t connectionHandle, ble::Keypress_t keypress) +{ + return impl->sendKeypressNotification(connectionHandle, keypress); +} + +ble_error_t SecurityManager::legacyPairingOobReceived(const ble::address_t *address, const ble::oob_tk_t *tk) +{ + return impl->legacyPairingOobReceived(address, tk); +} + +ble_error_t SecurityManager::oobReceived(const ble::address_t *address, const ble::oob_lesc_value_t *random, const ble::oob_confirm_t *confirm) +{ + return impl->oobReceived(address, random, confirm); +} + +ble_error_t SecurityManager::getSigningKey(ble::connection_handle_t connectionHandle, bool authenticated) +{ + return impl->getSigningKey(connectionHandle, authenticated); +} + +ble_error_t SecurityManager::setPrivateAddressTimeout( + uint16_t timeout_in_seconds +) +{ + return impl->setPrivateAddressTimeout(timeout_in_seconds); +} + +void SecurityManager::onShutdown(const SecurityManagerShutdownCallback_t& callback) +{ + return impl->onShutdown(callback); +} + +SecurityManager::SecurityManagerShutdownCallbackChain_t& SecurityManager::onShutdown() +{ + return impl->onShutdown(); +} + +void SecurityManager::setSecurityManagerEventHandler(EventHandler* handler) +{ + return impl->setSecurityManagerEventHandler(handler); +} + +} // ble + diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/README.md b/connectivity/FEATURE_BLE/source/cordio/README.md similarity index 88% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/README.md rename to connectivity/FEATURE_BLE/source/cordio/README.md index 1f1c8a8bed8..628eadb5dc2 100644 --- a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/README.md +++ b/connectivity/FEATURE_BLE/source/cordio/README.md @@ -29,5 +29,5 @@ Build time configuration may be controlled through options set in: ## Documentation -* [HCI architecture](doc/HCIAbstraction.md) -* [Porting guide](doc/PortingGuide.md) +* [HCI architecture](../../include/ble/driver/doc/HCIAbstraction.md) +* [Porting guide](../../include/ble/driver/doc/PortingGuide.md) diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/TESTS/cordio_hci/driver/main.cpp b/connectivity/FEATURE_BLE/source/cordio/TESTS/cordio_hci/driver/main.cpp similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/TESTS/cordio_hci/driver/main.cpp rename to connectivity/FEATURE_BLE/source/cordio/TESTS/cordio_hci/driver/main.cpp diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/TESTS/cordio_hci/transport/main.cpp b/connectivity/FEATURE_BLE/source/cordio/TESTS/cordio_hci/transport/main.cpp similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/TESTS/cordio_hci/transport/main.cpp rename to connectivity/FEATURE_BLE/source/cordio/TESTS/cordio_hci/transport/main.cpp diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/driver/CordioHCIDriver.cpp b/connectivity/FEATURE_BLE/source/cordio/driver/CordioHCIDriver.cpp similarity index 98% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/driver/CordioHCIDriver.cpp rename to connectivity/FEATURE_BLE/source/cordio/driver/CordioHCIDriver.cpp index 1da41550bb8..340de1008b9 100644 --- a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/driver/CordioHCIDriver.cpp +++ b/connectivity/FEATURE_BLE/source/cordio/driver/CordioHCIDriver.cpp @@ -17,10 +17,9 @@ #include #include -#include "ble/internal/BLEInstanceBase.h" #include "ble/BLE.h" #include "ble/Gap.h" -#include "CordioHCIDriver.h" +#include "ble/driver/CordioHCIDriver.h" #include "hci_api.h" #include "hci_cmd.h" #include "hci_core.h" @@ -98,7 +97,7 @@ buf_pool_desc_t CordioHCIDriver::get_default_buffer_pool_description() void CordioHCIDriver::set_random_static_address(const ble::address_t& address) { - ble_error_t err = BLEInstanceBase::deviceInstance().getGap().setRandomStaticAddress(address); + ble_error_t err = BLE::Instance().gap().setRandomStaticAddress(address); MBED_ASSERT(err == BLE_ERROR_NONE); } diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/driver/CordioHCITransportDriver.cpp b/connectivity/FEATURE_BLE/source/cordio/driver/CordioHCITransportDriver.cpp similarity index 93% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/driver/CordioHCITransportDriver.cpp rename to connectivity/FEATURE_BLE/source/cordio/driver/CordioHCITransportDriver.cpp index b2f27ed16e1..bb4834e3ef8 100644 --- a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/driver/CordioHCITransportDriver.cpp +++ b/connectivity/FEATURE_BLE/source/cordio/driver/CordioHCITransportDriver.cpp @@ -17,8 +17,8 @@ #include #include -#include "CordioHCITransportDriver.h" -#include "CordioHCIDriver.h" +#include "ble/driver/CordioHCITransportDriver.h" +#include "ble/driver/CordioHCIDriver.h" extern "C" void hciTrSerialRxIncoming(uint8_t *pBuf, uint8_t len); diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/driver/H4TransportDriver.cpp b/connectivity/FEATURE_BLE/source/cordio/driver/H4TransportDriver.cpp similarity index 87% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/driver/H4TransportDriver.cpp rename to connectivity/FEATURE_BLE/source/cordio/driver/H4TransportDriver.cpp index c8a40a4b0ed..a988a49cb3b 100644 --- a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/driver/H4TransportDriver.cpp +++ b/connectivity/FEATURE_BLE/source/cordio/driver/H4TransportDriver.cpp @@ -16,7 +16,7 @@ #if DEVICE_SERIAL && DEVICE_SERIAL_FC -#include "H4TransportDriver.h" +#include "ble/driver/H4TransportDriver.h" namespace ble { @@ -27,19 +27,19 @@ void H4TransportDriver::initialize() { uart.format( /* bits */ 8, - /* parity */ SerialBase::None, + /* parity */ mbed::SerialBase::None, /* stop bit */ 1 ); uart.set_flow_control( - /* flow */ SerialBase::RTSCTS, + /* flow */ mbed::SerialBase::RTSCTS, /* rts */ rts, /* cts */ cts ); uart.attach( - callback(this, &H4TransportDriver::on_controller_irq), - SerialBase::RxIrq + mbed::callback(this, &H4TransportDriver::on_controller_irq), + mbed::SerialBase::RxIrq ); } diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/mbed_lib.json b/connectivity/FEATURE_BLE/source/cordio/mbed_lib.json similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/mbed_lib.json rename to connectivity/FEATURE_BLE/source/cordio/mbed_lib.json diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/source/BLEInstanceBaseImpl.cpp b/connectivity/FEATURE_BLE/source/cordio/source/BLEInstanceBaseImpl.cpp similarity index 77% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/source/BLEInstanceBaseImpl.cpp rename to connectivity/FEATURE_BLE/source/cordio/source/BLEInstanceBaseImpl.cpp index 266b6f0f422..50bad5d4cfa 100644 --- a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/source/BLEInstanceBaseImpl.cpp +++ b/connectivity/FEATURE_BLE/source/cordio/source/BLEInstanceBaseImpl.cpp @@ -16,10 +16,26 @@ * limitations under the License. */ -#include "mbed.h" -#include "us_ticker_api.h" +#include "platform/CriticalSectionLock.h" +#include "hal/us_ticker_api.h" +#include "platform/mbed_assert.h" + #include "ble/BLE.h" -#include "CriticalSectionLock.h" +#include "ble/driver/CordioHCIDriver.h" + +#include "source/pal/PalAttClient.h" +#include "source/pal/PalSecurityManager.h" +#include "source/pal/PalGap.h" +#include "source/pal/PalSigningMonitor.h" +#include "source/pal/PalAttClientToGattClient.h" + +#include "source/BLEInstanceBaseImpl.h" +#include "source/GattServerImpl.h" +#include "source/PalSecurityManagerImpl.h" +#include "source/PalAttClientImpl.h" +#include "source/PalGenericAccessServiceImpl.h" +#include "source/PalGapImpl.h" + #include "wsf_types.h" #include "wsf_msg.h" #include "wsf_os.h" @@ -34,15 +50,8 @@ #include "att_api.h" #include "smp_api.h" #include "hci_drv.h" -#include "mbed_assert.h" #include "bstream.h" -#include "ble/internal/PalAttClient.h" -#include "ble/internal/PalSecurityManager.h" -#include "ble/internal/PalGap.h" -#include "ble/internal/PalSigningMonitor.h" -#include "ble/internal/BLEInstanceBase.h" -#include "CordioHCIDriver.h" using namespace std::chrono; @@ -97,12 +106,13 @@ extern "C" MBED_WEAK void wsf_mbed_ble_signal_event(void) * BLE-API requires an implementation of the following function in order to * obtain its transport handle. */ -ble::BLEInstanceBase *createBLEInstance() +ble::BLEInstanceBase *ble::createBLEInstance() { - return (&(ble::BLEInstanceBase::deviceInstance())); + return (&(ble::impl::BLEInstanceBase::deviceInstance())); } namespace ble { +namespace impl { BLEInstanceBase::BLEInstanceBase(CordioHCIDriver &hci_driver) : initialization_status(NOT_INITIALIZED), @@ -113,8 +123,7 @@ BLEInstanceBase::BLEInstanceBase(CordioHCIDriver &hci_driver) : stack_setup(); } -BLEInstanceBase::~BLEInstanceBase() -{} +BLEInstanceBase::~BLEInstanceBase() = default; /** * The singleton which represents the BLE transport for the BLE. @@ -128,7 +137,8 @@ BLEInstanceBase &BLEInstanceBase::deviceInstance() } ble_error_t BLEInstanceBase::init( - FunctionPointerWithContext<::BLE::InitializationCompleteCallbackContext *> initCallback) + FunctionPointerWithContext<::BLE::InitializationCompleteCallbackContext *> initCallback +) { switch (initialization_status) { case NOT_INITIALIZED: @@ -184,51 +194,71 @@ const char *BLEInstanceBase::getVersion() return version; } -ble::Gap &BLEInstanceBase::getGap() +ble::impl::Gap &BLEInstanceBase::getGapImpl() { - static ble::PalGenericAccessService cordio_gap_service; - static ble::Gap gap( + static ble::impl::PalGenericAccessService cordio_gap_service; + static ble::impl::Gap gap( _event_queue, - ble::PalGap::get_gap(), + ble::impl::PalGap::get_gap(), cordio_gap_service, - ble::PalSecurityManager::get_security_manager() + ble::impl::PalSecurityManager::get_security_manager() ); + return gap; +} +ble::Gap &BLEInstanceBase::getGap() +{ + auto &impl = getGapImpl(); + static ble::Gap gap(&impl); return gap; } const ble::Gap &BLEInstanceBase::getGap() const { - BLEInstanceBase &self = const_cast(*this); + auto &self = const_cast(*this); return const_cast(self.getGap()); }; #if BLE_FEATURE_GATT_SERVER -GattServer &BLEInstanceBase::getGattServer() +ble::impl::GattServer &BLEInstanceBase::getGattServerImpl() +{ + return ble::impl::GattServer::getInstance(); +} + +ble::GattServer &BLEInstanceBase::getGattServer() { - return GattServer::getInstance(); + auto &impl = getGattServerImpl(); + static ble::GattServer server(&impl); + return server; } -const GattServer &BLEInstanceBase::getGattServer() const +const ble::GattServer &BLEInstanceBase::getGattServer() const { - return GattServer::getInstance(); + auto &self = const_cast(*this); + return const_cast(self.getGattServer()); } #endif // BLE_FEATURE_GATT_SERVER #if BLE_FEATURE_GATT_CLIENT -ble::GattClient &BLEInstanceBase::getGattClient() +ble::impl::GattClient &BLEInstanceBase::getGattClientImpl() { - static ble::GattClient gatt_client(getPalGattClient()); + static ble::impl::GattClient gatt_client(getPalGattClient()); + return gatt_client; +} +ble::GattClient &BLEInstanceBase::getGattClient() +{ + auto &impl = getGattClientImpl(); + static ble::GattClient gatt_client(&impl); return gatt_client; } PalGattClient &BLEInstanceBase::getPalGattClient() { - static PalGattClient pal_gatt_client(PalAttClient::get_client()); + static PalAttClientToGattClient pal_gatt_client(impl::PalAttClient::get_client()); return pal_gatt_client; } @@ -236,29 +266,48 @@ PalGattClient &BLEInstanceBase::getPalGattClient() #if BLE_FEATURE_SECURITY -SecurityManager &BLEInstanceBase::getSecurityManager() +ble::impl::SecurityManager &BLEInstanceBase::getSecurityManagerImpl() { - static PalSigningMonitor signing_event_monitor; - static ble::SecurityManager m_instance( - ble::PalSecurityManager::get_security_manager(), - getGap(), + // Creation of a proxy monitor to let the security manager register to + // the gatt client and gatt server. + static struct : ble::PalSigningMonitor { + void set_signing_event_handler(PalSigningMonitorEventHandler *handler) final + { +#if BLE_FEATURE_GATT_CLIENT + BLEInstanceBase::deviceInstance().getGattClientImpl().set_signing_event_handler(handler); +#endif // BLE_FEATURE_GATT_CLIENT +#if BLE_FEATURE_GATT_SERVER + BLEInstanceBase::deviceInstance().getGattServerImpl().set_signing_event_handler(handler); +#endif // BLE_FEATURE_GATT_SERVER + } + } signing_event_monitor; + + static ble::impl::SecurityManager m_instance( + ble::impl::PalSecurityManager::get_security_manager(), + getGapImpl(), signing_event_monitor ); return m_instance; } -const SecurityManager &BLEInstanceBase::getSecurityManager() const +ble::SecurityManager &BLEInstanceBase::getSecurityManager() +{ + static ble::SecurityManager m_instance(&getSecurityManagerImpl()); + return m_instance; +} + +const ble::SecurityManager &BLEInstanceBase::getSecurityManager() const { const BLEInstanceBase &self = const_cast(*this); - return const_cast(self.getSecurityManager()); + return const_cast(self.getSecurityManager()); } #endif // BLE_FEATURE_SECURITY void BLEInstanceBase::waitForEvent() { - static Timeout nextTimeout; + static mbed::Timeout nextTimeout; timestamp_t nextTimestamp; bool_t pTimerRunning; @@ -285,7 +334,7 @@ void BLEInstanceBase::stack_handler(wsfEventMask_t event, wsfMsgHdr_t *msg) } #if BLE_FEATURE_SECURITY - if (ble::PalSecurityManager::get_security_manager().sm_handler(msg)) { + if (ble::impl::PalSecurityManager::get_security_manager().sm_handler(msg)) { return; } #endif // BLE_FEATURE_SECURITY @@ -293,7 +342,7 @@ void BLEInstanceBase::stack_handler(wsfEventMask_t event, wsfMsgHdr_t *msg) switch (msg->event) { case DM_RESET_CMPL_IND: { ::BLE::InitializationCompleteCallbackContext context = { - ::BLE::Instance(::BLE::DEFAULT_INSTANCE), + ::BLE::Instance(), BLE_ERROR_NONE }; #if BLE_FEATURE_EXTENDED_ADVERTISING @@ -314,12 +363,12 @@ void BLEInstanceBase::stack_handler(wsfEventMask_t event, wsfMsgHdr_t *msg) } #endif // BLE_FEATURE_EXTENDED_ADVERTISING #if BLE_FEATURE_GATT_SERVER - deviceInstance().getGattServer().initialize(); + deviceInstance().getGattServerImpl().initialize(); #endif deviceInstance().initialization_status = INITIALIZED; _init_callback.call(&context); - } - break; + } break; + #if MBED_CONF_CORDIO_ROUTE_UNHANDLED_COMMAND_COMPLETE_EVENTS case DM_UNHANDLED_CMD_CMPL_EVT_IND: { // upcast to unhandled command complete event to access the payload @@ -334,12 +383,11 @@ void BLEInstanceBase::stack_handler(wsfEventMask_t event, wsfMsgHdr_t *msg) _hci_driver->handle_test_end(status == 0, packet_number); return; } - } - break; + } break; #endif // MBED_CONF_CORDIO_ROUTE_UNHANDLED_COMMAND_COMPLETE_EVENTS default: - ble::PalGap::gap_handler(msg); + ble::impl::PalGap::gap_handler(msg); break; } } @@ -349,7 +397,7 @@ void BLEInstanceBase::device_manager_cb(dmEvt_t *dm_event) if (dm_event->hdr.status == HCI_SUCCESS && dm_event->hdr.event == DM_CONN_DATA_LEN_CHANGE_IND) { // this event can only happen after a connection has been established therefore gap is present ble::PalGapEventHandler *handler; - handler = ble::PalGap::get_gap().get_event_handler(); + handler = ble::impl::PalGap::get_gap().get_event_handler(); if (handler) { handler->on_data_length_change( dm_event->hdr.param, @@ -415,8 +463,8 @@ void BLEInstanceBase::stack_setup() // This warning will be raised if we've allocated too much memory if (bytes_used < buf_pool_desc.buffer_size) { MBED_WARNING1(MBED_MAKE_ERROR(MBED_MODULE_BLE, MBED_ERROR_CODE_INVALID_SIZE), - "Too much memory allocated for Cordio memory pool, reduce buf_pool_desc.buffer_size by value below.", - buf_pool_desc.buffer_size - bytes_used); + "Too much memory allocated for Cordio memory pool, reduce buf_pool_desc.buffer_size by value below.", + buf_pool_desc.buffer_size - bytes_used); } WsfTimerInit(); @@ -499,7 +547,7 @@ void BLEInstanceBase::stack_setup() AttsInit(); AttsIndInit(); #if BLE_FEATURE_SECURITY - AttsAuthorRegister(GattServer::atts_auth_cb); + AttsAuthorRegister(impl::GattServer::atts_auth_cb); #endif #if BLE_FEATURE_SIGNING AttsSignInit(); @@ -550,7 +598,7 @@ void BLEInstanceBase::stack_setup() #if BLE_FEATURE_ATT #if BLE_FEATURE_GATT_CLIENT - AttRegister((attCback_t) ble::PalAttClient::att_client_handler); + AttRegister((attCback_t) impl::PalAttClient::att_client_handler); #else AttRegister((attCback_t) ble::GattServer::att_cb); #endif // BLE_FEATURE_GATT_CLIENT @@ -582,8 +630,8 @@ void BLEInstanceBase::callDispatcher() wsfOsDispatcher(); - static LowPowerTimeout nextTimeout; - CriticalSectionLock critical_section; + static mbed::LowPowerTimeout nextTimeout; + mbed::CriticalSectionLock critical_section; if (wsfOsReadyToSleep()) { // setup an mbed timer for the next Cordio timeout @@ -602,4 +650,5 @@ CordioHCIDriver *BLEInstanceBase::_hci_driver = nullptr; FunctionPointerWithContext<::BLE::InitializationCompleteCallbackContext *> BLEInstanceBase::_init_callback; +} // namespace impl } // namespace ble diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/include/ble/internal/BLEInstanceBaseImpl.h b/connectivity/FEATURE_BLE/source/cordio/source/BLEInstanceBaseImpl.h similarity index 58% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/include/ble/internal/BLEInstanceBaseImpl.h rename to connectivity/FEATURE_BLE/source/cordio/source/BLEInstanceBaseImpl.h index bd8dc70a9c0..b91e9e30e07 100644 --- a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/include/ble/internal/BLEInstanceBaseImpl.h +++ b/connectivity/FEATURE_BLE/source/cordio/source/BLEInstanceBaseImpl.h @@ -20,35 +20,47 @@ #define IMPL_BLE_INSTANCE_BASE_H_ #include "ble/BLE.h" -#include "ble/common/ble/blecommon.h" -#include "ble/internal/BLEInstanceBase.h" -#include "CordioHCIDriver.h" #include "ble/GattServer.h" -#include "PalAttClient.h" -#include "PalGattClient.h" #include "ble/GattClient.h" -#include "ble/internal/PalGap.h" #include "ble/Gap.h" -#include "PalGenericAccessService.h" #include "ble/SecurityManager.h" -#include "PalEventQueue.h" + +#include "ble/common/blecommon.h" +#include "ble/driver/CordioHCIDriver.h" + +#include "source/BLEInstanceBase.h" +#include "source/pal/PalAttClient.h" +#include "source/pal/PalGattClient.h" +#include "source/pal/PalGap.h" +#include "source/pal/PalGenericAccessService.h" +#include "source/pal/PalEventQueue.h" +#include "source/pal/PalSecurityManager.h" + +#include "source/generic/GapImpl.h" +#include "source/generic/GattClientImpl.h" +#include "source/generic/SecurityManagerImpl.h" +#include "source/GattServerImpl.h" +#include "source/PalEventQueueImpl.h" + #include "drivers/LowPowerTimer.h" -#include "ble/internal/PalSecurityManager.h" namespace ble { class PalSigningMonitor; +namespace impl { + /** * @see BLEInstanceBase */ -class BLEInstanceBase : public interface::BLEInstanceBase { +class BLEInstanceBase final : public ble::BLEInstanceBase { friend PalSigningMonitor; + /** * Construction with an HCI driver. */ - BLEInstanceBase(CordioHCIDriver& hci_driver); + BLEInstanceBase(CordioHCIDriver &hci_driver); /** * Destructor @@ -61,57 +73,66 @@ class BLEInstanceBase : public interface::BLEInstanceBase { * Access to the singleton containing the implementation of BLEInstanceBase * for the Cordio stack. */ - static BLEInstanceBase& deviceInstance(); + static BLEInstanceBase &deviceInstance(); /** * @see BLEInstanceBase::init */ - virtual ble_error_t init( - FunctionPointerWithContext< ::BLE::InitializationCompleteCallbackContext*> initCallback - ); + ble_error_t init( + FunctionPointerWithContext<::BLE::InitializationCompleteCallbackContext *> initCallback + ) final; /** * @see BLEInstanceBase::hasInitialized */ - virtual bool hasInitialized() const; + bool hasInitialized() const final; /** * @see BLEInstanceBase::shutdown */ - virtual ble_error_t shutdown(); + ble_error_t shutdown() final; /** * @see BLEInstanceBase::getVersion */ - virtual const char *getVersion(); + const char *getVersion() final; + + ble::impl::Gap &getGapImpl(); /** * @see BLEInstanceBase::getGap */ - virtual ble::Gap& getGap(); + ble::Gap &getGap() final; /** * @see BLEInstanceBase::getGap */ - virtual const ble::Gap& getGap() const; + const ble::Gap &getGap() const final; #if BLE_FEATURE_GATT_SERVER + + ble::impl::GattServer &getGattServerImpl(); + /** * @see BLEInstanceBase::getGattServer */ - virtual GattServer &getGattServer(); + ble::GattServer &getGattServer() final; /** * @see BLEInstanceBase::getGattServer */ - virtual const GattServer &getGattServer() const; + const ble::GattServer &getGattServer() const final; + #endif // BLE_FEATURE_GATT_SERVER #if BLE_FEATURE_GATT_CLIENT + + ble::impl::GattClient &getGattClientImpl(); + /** * @see BLEInstanceBase::getGattClient */ - virtual ble::GattClient &getGattClient(); + ble::GattClient &getGattClient() final; /** * Get the PAL Gatt Client. @@ -119,43 +140,52 @@ class BLEInstanceBase : public interface::BLEInstanceBase { * @return PAL Gatt Client. */ PalGattClient &getPalGattClient(); + #endif // BLE_FEATURE_GATT_CLIENT #if BLE_FEATURE_SECURITY + + ble::impl::SecurityManager &getSecurityManagerImpl(); + /** * @see BLEInstanceBase::getSecurityManager */ - virtual ble::SecurityManager &getSecurityManager(); + ble::SecurityManager &getSecurityManager() final; /** * @see BLEInstanceBase::getSecurityManager */ - virtual const ble::SecurityManager &getSecurityManager() const; + const ble::SecurityManager &getSecurityManager() const final; #endif // BLE_FEATURE_SECURITY /** * @see BLEInstanceBase::waitForEvent */ - virtual void waitForEvent(); + void waitForEvent(); /** * @see BLEInstanceBase::processEvents */ - virtual void processEvents(); + void processEvents() final; private: - static void stack_handler(wsfEventMask_t event, wsfMsgHdr_t* msg); - static void device_manager_cb(dmEvt_t* dm_event); - static void connection_handler(dmEvt_t* dm_event); + static void stack_handler(wsfEventMask_t event, wsfMsgHdr_t *msg); + + static void device_manager_cb(dmEvt_t *dm_event); + + static void connection_handler(dmEvt_t *dm_event); + static void timeoutCallback(); void stack_setup(); + void start_stack_reset(); + void callDispatcher(); - static CordioHCIDriver* _hci_driver; - static FunctionPointerWithContext< ::BLE::InitializationCompleteCallbackContext*> _init_callback; + static CordioHCIDriver *_hci_driver; + static FunctionPointerWithContext<::BLE::InitializationCompleteCallbackContext *> _init_callback; enum { NOT_INITIALIZED, @@ -163,11 +193,12 @@ class BLEInstanceBase : public interface::BLEInstanceBase { INITIALIZED } initialization_status; - mutable ble::PalEventQueue _event_queue; + mutable ble::impl::PalEventQueue _event_queue; mbed::LowPowerTimer _timer; uint64_t _last_update_us; }; +} // namespace impl } // namespace ble diff --git a/connectivity/FEATURE_BLE/libraries/ble-api-implementation/source/GattServerImpl.cpp b/connectivity/FEATURE_BLE/source/cordio/source/GattServerImpl.cpp similarity index 90% rename from connectivity/FEATURE_BLE/libraries/ble-api-implementation/source/GattServerImpl.cpp rename to connectivity/FEATURE_BLE/source/cordio/source/GattServerImpl.cpp index cc902aeafc3..a7ca14d5674 100644 --- a/connectivity/FEATURE_BLE/libraries/ble-api-implementation/source/GattServerImpl.cpp +++ b/connectivity/FEATURE_BLE/source/cordio/source/GattServerImpl.cpp @@ -16,14 +16,15 @@ * limitations under the License. */ -#include "BLERoles.h" +#include "ble/common/BLERoles.h" #include -#include "ble/GattServer.h" -#include "ble/internal/BLEInstanceBase.h" +#include "source/GattServerImpl.h" +#include "source/BLEInstanceBaseImpl.h" #include "wsf_types.h" #include "att_api.h" namespace ble { +namespace impl { namespace { @@ -45,12 +46,12 @@ static const unsigned int INDICATE_PROPERTY = static const uint8_t WRITABLE_PROPERTIES = WRITE_PROPERTY | - WRITE_WITHOUT_RESPONSE_PROPERTY | - SIGNED_WRITE_PROPERTY; + WRITE_WITHOUT_RESPONSE_PROPERTY | + SIGNED_WRITE_PROPERTY; static const uint8_t UPDATE_PROPERTIES = NOTIFY_PROPERTY | - INDICATE_PROPERTY; + INDICATE_PROPERTY; static const uint16_t CONNECTION_ID_LIMIT = 0x100; @@ -93,7 +94,7 @@ ble_error_t GattServer::addService(GattService &service) // Create cordio attribute list att_service->attGroup.pAttr = - (attsAttr_t*) alloc_block(attributes_count * sizeof(attsAttr_t)); + (attsAttr_t *) alloc_block(attributes_count * sizeof(attsAttr_t)); if (att_service->attGroup.pAttr == nullptr) { delete att_service; return BLE_ERROR_BUFFER_OVERFLOW; @@ -135,11 +136,11 @@ ble_error_t GattServer::addService(GattService &service) // register services and update cccds AttsAddGroup(&att_service->attGroup); - AttsCccRegister(cccd_cnt, (attsCccSet_t*)cccds, cccd_cb); + AttsCccRegister(cccd_cnt, (attsCccSet_t *) cccds, cccd_cb); return BLE_ERROR_NONE; } -uint16_t GattServer::compute_attributes_count(GattService& service) +uint16_t GattServer::compute_attributes_count(GattService &service) { // start at 1, one attribute is required for the service itself uint16_t attributes_count = 1; @@ -155,7 +156,7 @@ uint16_t GattServer::compute_attributes_count(GattService& service) for (size_t j = 0; j < p_char->getDescriptorCount(); ++j) { if (p_char->getDescriptor(j)->getUUID() == UUID(BLE_UUID_DESCRIPTOR_CLIENT_CHAR_CONFIG) - ) { + ) { --attributes_count; break; } @@ -167,12 +168,12 @@ uint16_t GattServer::compute_attributes_count(GattService& service) } void GattServer::insert_service_attribute( - GattService& service, + GattService &service, attsAttr_t *&attribute_it ) { ++currentHandle; - const UUID& service_uuid = service.getUUID(); + const UUID &service_uuid = service.getUUID(); attribute_it->pUuid = attPrimSvcUuid; if (service_uuid.shortOrLong() == UUID::UUID_TYPE_LONG) { @@ -180,7 +181,7 @@ void GattServer::insert_service_attribute( } else { attribute_it->maxLen = sizeof(UUID::ShortUUIDBytes_t); } - attribute_it->pValue = (uint8_t*) alloc_block(attribute_it->maxLen); + attribute_it->pValue = (uint8_t *) alloc_block(attribute_it->maxLen); memcpy(attribute_it->pValue, service_uuid.getBaseUUID(), attribute_it->maxLen); attribute_it->pLen = &attribute_it->maxLen; attribute_it->settings = 0; @@ -243,7 +244,7 @@ bool GattServer::is_characteristic_valid(GattCharacteristic *characteristic) (characteristic->getValueAttribute().getMaxLength() == 0) && (properties == READ_PROPERTY) && (characteristic->isReadAuthorizationEnabled() == false) - ) { + ) { return false; } @@ -252,20 +253,21 @@ bool GattServer::is_characteristic_valid(GattCharacteristic *characteristic) (characteristic->getValueAttribute().getMaxLength() == 0) && (properties & WRITABLE_PROPERTIES) && (characteristic->isWriteAuthorizationEnabled() == false) - ) { + ) { return false; } #if BLE_FEATURE_SIGNING // check for invalid permissions if ((properties == SIGNED_WRITE_PROPERTY) && - (characteristic->getWriteSecurityRequirement() == att_security_requirement_t::NONE + ( + characteristic->getWriteSecurityRequirement() == att_security_requirement_t::NONE #if BLE_FEATURE_SECURE_CONNECTIONS - || characteristic->getWriteSecurityRequirement() == att_security_requirement_t::SC_AUTHENTICATED + || characteristic->getWriteSecurityRequirement() == att_security_requirement_t::SC_AUTHENTICATED #endif // BLE_FEATURE_SECURE_CONNECTIONS - ) - ) { + ) + ) { return false; } #endif // BLE_FEATURE_SIGNING @@ -278,7 +280,7 @@ void GattServer::insert_characteristic_declaration_attribute( attsAttr_t *&attribute_it ) { - const UUID& value_uuid = characteristic->getValueAttribute().getUUID(); + const UUID &value_uuid = characteristic->getValueAttribute().getUUID(); // move the current handle to point to the value handle currentHandle += 2; @@ -288,7 +290,7 @@ void GattServer::insert_characteristic_declaration_attribute( attribute_it->pUuid = attChUuid; attribute_it->maxLen = 1 + sizeof(currentHandle) + value_uuid.getLen(); attribute_it->pLen = &attribute_it->maxLen; - attribute_it->pValue = (uint8_t*) alloc_block(attribute_it->maxLen); + attribute_it->pValue = (uint8_t *) alloc_block(attribute_it->maxLen); attribute_it->settings = 0; attribute_it->permissions = ATTS_PERMIT_READ; @@ -315,9 +317,9 @@ ble_error_t GattServer::insert_characteristic_value_attribute( // Create Value Attribute attribute_it->pUuid = value_attribute.getUUID().getBaseUUID(); attribute_it->maxLen = characteristic->getValueAttribute().getMaxLength(); - attribute_it->pLen = (uint16_t*) alloc_block(attribute_it->maxLen + sizeof(uint16_t)); + attribute_it->pLen = (uint16_t *) alloc_block(attribute_it->maxLen + sizeof(uint16_t)); *attribute_it->pLen = value_attribute.getLength(); - attribute_it->pValue = (uint8_t*) ((uint16_t*)attribute_it->pLen + 1); + attribute_it->pValue = (uint8_t *) ((uint16_t *) attribute_it->pLen + 1); memcpy(attribute_it->pValue, value_attribute.getValuePtr(), *attribute_it->pLen); memset(attribute_it->pValue + *attribute_it->pLen, 0, attribute_it->maxLen - *attribute_it->pLen); @@ -357,7 +359,7 @@ ble_error_t GattServer::insert_characteristic_value_attribute( case att_security_requirement_t::AUTHENTICATED: attribute_it->permissions |= ATTS_PERMIT_READ_ENC | - ATTS_PERMIT_READ_AUTH; + ATTS_PERMIT_READ_AUTH; break; #if BLE_FEATURE_SECURE_CONNECTIONS case att_security_requirement_t::SC_AUTHENTICATED: @@ -365,8 +367,8 @@ ble_error_t GattServer::insert_characteristic_value_attribute( // so this one is done in attsAuthorCback attribute_it->permissions |= ATTS_PERMIT_READ_ENC | - ATTS_PERMIT_READ_AUTH | - ATTS_PERMIT_READ_AUTHORIZ; + ATTS_PERMIT_READ_AUTH | + ATTS_PERMIT_READ_AUTHORIZ; break; #endif // BLE_FEATURE_SECURE_CONNECTIONS #endif // BLE_FEATURE_SECURITY @@ -386,7 +388,7 @@ ble_error_t GattServer::insert_characteristic_value_attribute( case att_security_requirement_t::AUTHENTICATED: attribute_it->permissions |= ATTS_PERMIT_WRITE_ENC | - ATTS_PERMIT_WRITE_AUTH; + ATTS_PERMIT_WRITE_AUTH; break; #if BLE_FEATURE_SECURE_CONNECTIONS case att_security_requirement_t::SC_AUTHENTICATED: @@ -394,8 +396,8 @@ ble_error_t GattServer::insert_characteristic_value_attribute( // so this one is done in attsAuthorCback attribute_it->permissions |= ATTS_PERMIT_WRITE_ENC | - ATTS_PERMIT_WRITE_AUTH | - ATTS_PERMIT_WRITE_AUTHORIZ; + ATTS_PERMIT_WRITE_AUTH | + ATTS_PERMIT_WRITE_AUTHORIZ; break; #endif // BLE_FEATURE_SECURE_CONNECTIONS #endif // BLE_FEATURE_SECURITY @@ -411,8 +413,8 @@ ble_error_t GattServer::insert_characteristic_value_attribute( (properties & UPDATE_PROPERTIES) || characteristic->isReadAuthorizationEnabled() || characteristic->isWriteAuthorizationEnabled() - ) { - if ( _auth_char_count >= MBED_CONF_BLE_API_IMPLEMENTATION_MAX_CHARACTERISTIC_AUTHORISATION_COUNT) { + ) { + if (_auth_char_count >= MBED_CONF_BLE_API_IMPLEMENTATION_MAX_CHARACTERISTIC_AUTHORISATION_COUNT) { return BLE_ERROR_NO_MEM; } _auth_char[_auth_char_count] = characteristic; @@ -426,9 +428,9 @@ ble_error_t GattServer::insert_characteristic_value_attribute( ble_error_t GattServer::insert_descriptor( GattCharacteristic *characteristic, - GattAttribute* descriptor, + GattAttribute *descriptor, attsAttr_t *&attribute_it, - bool& cccd_created + bool &cccd_created ) { uint8_t properties = characteristic->getProperties(); @@ -439,9 +441,9 @@ ble_error_t GattServer::insert_descriptor( attribute_it->pUuid = descriptor->getUUID().getBaseUUID(); attribute_it->maxLen = descriptor->getMaxLength(); - attribute_it->pLen = (uint16_t*) alloc_block(attribute_it->maxLen + sizeof(uint16_t)); + attribute_it->pLen = (uint16_t *) alloc_block(attribute_it->maxLen + sizeof(uint16_t)); *attribute_it->pLen = descriptor->getLength(); - attribute_it->pValue = (uint8_t*) ((uint16_t*)attribute_it->pLen + 1); + attribute_it->pValue = (uint8_t *) ((uint16_t *) attribute_it->pLen + 1); memcpy(attribute_it->pValue, descriptor->getValuePtr(), *attribute_it->pLen); memset(attribute_it->pValue + *attribute_it->pLen, 0, attribute_it->maxLen - *attribute_it->pLen); @@ -459,7 +461,7 @@ ble_error_t GattServer::insert_descriptor( if (descriptor->isReadAllowed() == false || descriptor->getReadSecurityRequirement() != att_security_requirement_t::NONE - ) { + ) { return BLE_ERROR_INVALID_PARAM; } @@ -498,7 +500,7 @@ ble_error_t GattServer::insert_descriptor( case att_security_requirement_t::AUTHENTICATED: attribute_it->permissions |= ATTS_PERMIT_READ_ENC | - ATTS_PERMIT_READ_AUTH; + ATTS_PERMIT_READ_AUTH; break; #if BLE_FEATURE_SECURE_CONNECTIONS case att_security_requirement_t::SC_AUTHENTICATED: @@ -506,8 +508,8 @@ ble_error_t GattServer::insert_descriptor( // so this one is done in attsAuthorCback attribute_it->permissions |= ATTS_PERMIT_READ_ENC | - ATTS_PERMIT_READ_AUTH | - ATTS_PERMIT_READ_AUTHORIZ; + ATTS_PERMIT_READ_AUTH | + ATTS_PERMIT_READ_AUTHORIZ; break; #endif // BLE_FEATURE_SECURE_CONNECTIONS #endif // BLE_FEATURE_SECURITY @@ -531,7 +533,7 @@ ble_error_t GattServer::insert_descriptor( case att_security_requirement_t::AUTHENTICATED: attribute_it->permissions |= ATTS_PERMIT_WRITE_ENC | - ATTS_PERMIT_WRITE_AUTH; + ATTS_PERMIT_WRITE_AUTH; break; #if BLE_FEATURE_SECURE_CONNECTIONS case att_security_requirement_t::SC_AUTHENTICATED: @@ -539,8 +541,8 @@ ble_error_t GattServer::insert_descriptor( // so this one is done in attsAuthorCback attribute_it->permissions |= ATTS_PERMIT_WRITE_ENC | - ATTS_PERMIT_WRITE_AUTH | - ATTS_PERMIT_WRITE_AUTHORIZ; + ATTS_PERMIT_WRITE_AUTH | + ATTS_PERMIT_WRITE_AUTHORIZ; break; #endif // BLE_FEATURE_SECURE_CONNECTIONS #endif // BLE_FEATURE_SECURITY @@ -569,7 +571,7 @@ ble_error_t GattServer::insert_cccd( currentHandle++; attribute_it->pUuid = CCCD_UUID.getBaseUUID(); - attribute_it->pValue = (uint8_t*) &cccd_values[cccd_cnt]; + attribute_it->pValue = (uint8_t *) &cccd_values[cccd_cnt]; attribute_it->maxLen = CCCD_SIZE; attribute_it->pLen = &attribute_it->maxLen; attribute_it->settings = ATTS_SET_CCC; @@ -595,11 +597,11 @@ ble_error_t GattServer::insert_cccd( ble_error_t GattServer::read( GattAttribute::Handle_t att_handle, uint8_t buffer[], - uint16_t * buffer_length + uint16_t *buffer_length ) { uint16_t att_length = 0; - uint8_t* att_value = nullptr; + uint8_t *att_value = nullptr; if (AttsGetAttr(att_handle, &att_length, &att_value) != ATT_SUCCESS) { return BLE_ERROR_PARAM_OUT_OF_RANGE; @@ -670,7 +672,7 @@ ble_error_t GattServer::write( } // write the value to the attribute handle - if (AttsSetAttr(att_handle, len, (uint8_t*)buffer) != ATT_SUCCESS) { + if (AttsSetAttr(att_handle, len, (uint8_t *) buffer) != ATT_SUCCESS) { return BLE_ERROR_PARAM_OUT_OF_RANGE; } @@ -690,11 +692,11 @@ ble_error_t GattServer::write( if (is_update_authorized(conn_id, att_handle)) { uint16_t cccd_config = AttsCccEnabled(conn_id, cccd_index); if (cccd_config & ATT_CLIENT_CFG_NOTIFY) { - AttsHandleValueNtf(conn_id, att_handle, len, (uint8_t*)buffer); + AttsHandleValueNtf(conn_id, att_handle, len, (uint8_t *) buffer); updates_sent++; } if (cccd_config & ATT_CLIENT_CFG_INDICATE) { - AttsHandleValueInd(conn_id, att_handle, len, (uint8_t*)buffer); + AttsHandleValueInd(conn_id, att_handle, len, (uint8_t *) buffer); updates_sent++; } } @@ -727,7 +729,7 @@ ble_error_t GattServer::write( } // write the value to the attribute handle - if (AttsSetAttr(att_handle, len, (uint8_t*)buffer) != ATT_SUCCESS) { + if (AttsSetAttr(att_handle, len, (uint8_t *) buffer) != ATT_SUCCESS) { return BLE_ERROR_PARAM_OUT_OF_RANGE; } @@ -743,11 +745,11 @@ ble_error_t GattServer::write( if (is_update_authorized(connection, att_handle)) { uint16_t cccEnabled = AttsCccEnabled(connection, cccd_index); if (cccEnabled & ATT_CLIENT_CFG_NOTIFY) { - AttsHandleValueNtf(connection, att_handle, len, (uint8_t*)buffer); + AttsHandleValueNtf(connection, att_handle, len, (uint8_t *) buffer); updates_sent++; } if (cccEnabled & ATT_CLIENT_CFG_INDICATE) { - AttsHandleValueInd(connection, att_handle, len, (uint8_t*)buffer); + AttsHandleValueInd(connection, att_handle, len, (uint8_t *) buffer); updates_sent++; } } @@ -810,9 +812,9 @@ bool GattServer::isOnDataReadAvailable() const return true; } -Gap::PreferredConnectionParams_t GattServer::getPreferredConnectionParams() +ble::Gap::PreferredConnectionParams_t GattServer::getPreferredConnectionParams() { - Gap::PreferredConnectionParams_t params = { 0 }; + ble::Gap::PreferredConnectionParams_t params = {0}; memcpy(¶ms.minConnectionInterval, generic_access_service.ppcp, 2); memcpy(¶ms.maxConnectionInterval, generic_access_service.ppcp + 2, 2); memcpy(¶ms.slaveLatency, generic_access_service.ppcp + 4, 2); @@ -820,7 +822,7 @@ Gap::PreferredConnectionParams_t GattServer::getPreferredConnectionParams() return params; } -void GattServer::setPreferredConnectionParams(const Gap::PreferredConnectionParams_t& params) +void GattServer::setPreferredConnectionParams(const ble::Gap::PreferredConnectionParams_t ¶ms) { memcpy(generic_access_service.ppcp, ¶ms.minConnectionInterval, 2); memcpy(generic_access_service.ppcp + 2, ¶ms.maxConnectionInterval, 2); @@ -873,10 +875,10 @@ GapAdvertisingData::Appearance GattServer::getAppearance() #endif // Disabled until reworked and reintroduced to GattServer API -ble_error_t GattServer::reset(void) +ble_error_t GattServer::reset(ble::GattServer* server) { /* Notify that the instance is about to shutdown */ - shutdownCallChain.call(this); + shutdownCallChain.call(server); shutdownCallChain.clear(); serviceCount = 0; @@ -885,19 +887,19 @@ ble_error_t GattServer::reset(void) dataSentCallChain.clear(); dataWrittenCallChain.clear(); dataReadCallChain.clear(); - updatesEnabledCallback = nullptr; - updatesDisabledCallback = nullptr; + updatesEnabledCallback = nullptr; + updatesDisabledCallback = nullptr; confirmationReceivedCallback = nullptr; while (registered_service) { - internal_service_t* s = registered_service; + internal_service_t *s = registered_service; registered_service = s->next; AttsRemoveGroup(s->attGroup.startHandle); delete s; } while (allocated_blocks) { - alloc_block_t* b = allocated_blocks; + alloc_block_t *b = allocated_blocks; allocated_blocks = b->next; free(b); } @@ -911,7 +913,7 @@ ble_error_t GattServer::reset(void) _auth_char_count = 0; - AttsCccRegister(cccd_cnt, (attsCccSet_t*)cccds, cccd_cb); + AttsCccRegister(cccd_cnt, (attsCccSet_t *) cccds, cccd_cb); return BLE_ERROR_NONE; } @@ -946,7 +948,7 @@ uint8_t GattServer::atts_read_cb( attsAttr_t *pAttr ) { - GattCharacteristic* auth_char = getInstance().get_auth_char(handle); + GattCharacteristic *auth_char = getInstance().get_auth_char(handle); if (auth_char && auth_char->isReadAuthorizationEnabled()) { GattReadAuthCallbackParams read_auth_params = { connId, @@ -989,8 +991,6 @@ uint8_t GattServer::atts_write_cb( attsAttr_t *pAttr ) { - uint8_t err; - GattCharacteristic* auth_char = getInstance().get_auth_char(handle); if (auth_char && auth_char->isWriteAuthorizationEnabled()) { GattWriteAuthCallbackParams write_auth_params = { @@ -1078,7 +1078,7 @@ uint8_t GattServer::atts_auth_cb(dmConnId_t connId, uint8_t permit, uint16_t han #if BLE_FEATURE_SECURITY // this CB is triggered when read or write of an attribute (either a value // handle or a descriptor) requires secure connection security. - SecurityManager& security_manager = BLEInstanceBase::deviceInstance().getSecurityManager(); + ble::SecurityManager &security_manager = impl::BLEInstanceBase::deviceInstance().getSecurityManager(); link_encryption_t encryption(link_encryption_t::NOT_ENCRYPTED); ble_error_t err = security_manager.getLinkEncryption(connId, &encryption); @@ -1108,11 +1108,11 @@ void GattServer::add_generic_access_service() // bind attributes to the service generic_access_service.service.pAttr = generic_access_service.attributes; - attsAttr_t* current_attribute = generic_access_service.attributes; + attsAttr_t *current_attribute = generic_access_service.attributes; // service attribute current_attribute->pUuid = attPrimSvcUuid; - current_attribute->pValue = (uint8_t*) attGapSvcUuid; + current_attribute->pValue = (uint8_t *) attGapSvcUuid; current_attribute->maxLen = sizeof(attGapSvcUuid); current_attribute->pLen = ¤t_attribute->maxLen; current_attribute->settings = 0; @@ -1170,7 +1170,7 @@ void GattServer::add_generic_access_service() current_attribute->pUuid = attApChUuid; current_attribute->maxLen = sizeof(generic_access_service.appearance); current_attribute->pLen = ¤t_attribute->maxLen; - current_attribute->pValue = (uint8_t*) &generic_access_service.appearance; + current_attribute->pValue = (uint8_t *) &generic_access_service.appearance; current_attribute->settings = 0; current_attribute->permissions = ATTS_PERMIT_READ; @@ -1224,11 +1224,11 @@ void GattServer::add_generic_attribute_service() // bind attributes to the service generic_attribute_service.service.pAttr = generic_attribute_service.attributes; - attsAttr_t* current_attribute = generic_attribute_service.attributes; + attsAttr_t *current_attribute = generic_attribute_service.attributes; // service attribute current_attribute->pUuid = attPrimSvcUuid; - current_attribute->pValue = (uint8_t*) attGattSvcUuid; + current_attribute->pValue = (uint8_t *) attGattSvcUuid; current_attribute->maxLen = sizeof(attGattSvcUuid); current_attribute->pLen = ¤t_attribute->maxLen; current_attribute->settings = 0; @@ -1264,7 +1264,7 @@ void GattServer::add_generic_attribute_service() // CCCD ++current_attribute; current_attribute->pUuid = attCliChCfgUuid; - current_attribute->pValue = (uint8_t*)&cccd_values[cccd_cnt]; + current_attribute->pValue = (uint8_t *) &cccd_values[cccd_cnt]; current_attribute->maxLen = 2; current_attribute->pLen = ¤t_attribute->maxLen; current_attribute->settings = ATTS_SET_CCC; @@ -1278,12 +1278,12 @@ void GattServer::add_generic_attribute_service() generic_attribute_service.service.endHandle = currentHandle; AttsAddGroup(&generic_attribute_service.service); - AttsCccRegister(cccd_cnt, (attsCccSet_t*)cccds, cccd_cb); + AttsCccRegister(cccd_cnt, (attsCccSet_t *) cccds, cccd_cb); } -void* GattServer::alloc_block(size_t block_size) +void *GattServer::alloc_block(size_t block_size) { - alloc_block_t* block = (alloc_block_t*) malloc(sizeof(alloc_block_t) + block_size); + auto *block = (alloc_block_t *) malloc(sizeof(alloc_block_t) + block_size); if (block == nullptr) { return nullptr; } @@ -1299,7 +1299,7 @@ void* GattServer::alloc_block(size_t block_size) return block->data; } -GattCharacteristic* GattServer::get_auth_char(uint16_t value_handle) +GattCharacteristic *GattServer::get_auth_char(uint16_t value_handle) { for (size_t i = 0; i < _auth_char_count; ++i) { if (_auth_char[i]->getValueHandle() == value_handle) { @@ -1309,7 +1309,7 @@ GattCharacteristic* GattServer::get_auth_char(uint16_t value_handle) return nullptr; } -bool GattServer::get_cccd_index_by_cccd_handle(GattAttribute::Handle_t cccd_handle, uint8_t& idx) const +bool GattServer::get_cccd_index_by_cccd_handle(GattAttribute::Handle_t cccd_handle, uint8_t &idx) const { for (idx = 0; idx < cccd_cnt; idx++) { if (cccd_handle == cccds[idx].handle) { @@ -1319,7 +1319,7 @@ bool GattServer::get_cccd_index_by_cccd_handle(GattAttribute::Handle_t cccd_hand return false; } -bool GattServer::get_cccd_index_by_value_handle(GattAttribute::Handle_t char_handle, uint8_t& idx) const +bool GattServer::get_cccd_index_by_value_handle(GattAttribute::Handle_t char_handle, uint8_t &idx) const { for (idx = 0; idx < cccd_cnt; ++idx) { if (char_handle == cccd_handles[idx]) { @@ -1334,7 +1334,7 @@ bool GattServer::is_update_authorized( GattAttribute::Handle_t value_handle ) { - GattCharacteristic* auth_char = get_auth_char(value_handle); + GattCharacteristic *auth_char = get_auth_char(value_handle); if (!auth_char) { return true; } @@ -1347,7 +1347,7 @@ bool GattServer::is_update_authorized( } #if BLE_FEATURE_SECURITY - SecurityManager& security_manager = BLEInstanceBase::deviceInstance().getSecurityManager(); + ble::SecurityManager &security_manager = impl::BLEInstanceBase::deviceInstance().getSecurityManager(); link_encryption_t encryption(link_encryption_t::NOT_ENCRYPTED); ble_error_t err = security_manager.getLinkEncryption(connection, &encryption); if (err) { @@ -1382,9 +1382,9 @@ bool GattServer::is_update_authorized( } GattServer::GattServer() : + eventHandler(nullptr), serviceCount(0), characteristicCount(0), - eventHandler(nullptr), dataSentCallChain(), dataWrittenCallChain(), dataReadCallChain(), @@ -1419,12 +1419,6 @@ void GattServer::onDataSent(const DataSentCallback_t &callback) dataSentCallChain.add(callback); } -template -void GattServer::onDataSent(T *objPtr, void (T::*memberPtr)(unsigned count)) -{ - dataSentCallChain.add(objPtr, memberPtr); -} - ble::GattServer::DataSentCallbackChain_t &GattServer::onDataSent() { return dataSentCallChain; @@ -1445,20 +1439,6 @@ ble_error_t GattServer::onDataRead(const DataReadCallback_t &callback) return BLE_ERROR_NONE; } -template -ble_error_t GattServer::onDataRead( - T *objPtr, - void (T::*memberPtr)(const GattReadCallbackParams *context) -) -{ - if (!isOnDataReadAvailable()) { - return BLE_ERROR_NOT_IMPLEMENTED; - } - - dataReadCallChain.add(objPtr, memberPtr); - return BLE_ERROR_NONE; -} - ble::GattServer::DataReadCallbackChain_t &GattServer::onDataRead() { return dataReadCallChain; @@ -1469,13 +1449,7 @@ void GattServer::onShutdown(const GattServerShutdownCallback_t &callback) shutdownCallChain.add(callback); } -template -void GattServer::onShutdown(T *objPtr, void (T::*memberPtr)(const ble::GattServer *)) -{ - shutdownCallChain.add(objPtr, memberPtr); -} - -ble::GattServer::GattServerShutdownCallbackChain_t& GattServer::onShutdown() +GattServer::GattServerShutdownCallbackChain_t &GattServer::onShutdown() { return shutdownCallChain; } @@ -1500,7 +1474,7 @@ void GattServer::setEventHandler(EventHandler *handler) eventHandler = handler; } -GattServer::EventHandler* GattServer::getEventHandler() +GattServer::EventHandler *GattServer::getEventHandler() { return eventHandler; } @@ -1552,4 +1526,5 @@ void GattServer::handleDataSentEvent(unsigned count) dataSentCallChain.call(count); } +} // namespace impl } // namespace ble diff --git a/connectivity/FEATURE_BLE/libraries/ble-api-implementation/include/ble/internal/GattServerImpl.h b/connectivity/FEATURE_BLE/source/cordio/source/GattServerImpl.h similarity index 69% rename from connectivity/FEATURE_BLE/libraries/ble-api-implementation/include/ble/internal/GattServerImpl.h rename to connectivity/FEATURE_BLE/source/cordio/source/GattServerImpl.h index f4dd6755dfd..32d44005e8f 100644 --- a/connectivity/FEATURE_BLE/libraries/ble-api-implementation/include/ble/internal/GattServerImpl.h +++ b/connectivity/FEATURE_BLE/source/cordio/source/GattServerImpl.h @@ -19,52 +19,58 @@ #ifndef MBED_CORDIO_GATT_SERVER_H__ #define MBED_CORDIO_GATT_SERVER_H__ -#include "CallChainOfFunctionPointersWithContext.h" -#include "ble/common/ble/GattService.h" -#include "ble/common/ble/GattAttribute.h" -#include "ble/common/ble/GattServerEvents.h" -#include "ble/common/ble/GattCallbackParamTypes.h" +#include -#include -#include "ble/common/ble/blecommon.h" -#include "ble/Gap.h" #include "wsf_types.h" #include "att_api.h" -#include "SecurityManager.h" -#include "ble/common/ble/GattCallbackParamTypes.h" -#include "ble/internal/PalSigningMonitor.h" +#include "ble/GattServer.h" +#include "ble/Gap.h" +#include "ble/SecurityManager.h" + +#include "ble/gatt/GattService.h" +#include "ble/gatt/GattAttribute.h" +#include "ble/gatt/GattCallbackParamTypes.h" +#include "ble/gatt/GattCallbackParamTypes.h" + +#include "ble/common/CallChainOfFunctionPointersWithContext.h" +#include "ble/common/blecommon.h" + +#include "source/BLEInstanceBase.h" +#include "source/generic/GattServerEvents.h" +#include "source/pal/PalSigningMonitor.h" namespace ble { -// fwd declaration of PalAttClient and BLE +// fwd declaration of PalAttClient, PalGenericAccessService and BLE class PalAttClient; +class PalGenericAccessService; class BLE; -class GattServer : - public ble::interface::GattServer, - public PalSigningMonitor -{ +namespace impl { +class GattServer : public PalSigningMonitor { friend ble::BLE; friend ble::PalAttClient; friend PalSigningMonitor; - friend BLEInstanceBase; friend PalGenericAccessService; -// inherited typedefs have the wrong types so we have to redefine them -public: - - typedef FunctionPointerWithContext - GattServerShutdownCallback_t; - - typedef CallChainOfFunctionPointersWithContext - GattServerShutdownCallbackChain_t; + using EventHandler = ble::GattServer::EventHandler; + using DataSentCallback_t = ble::GattServer::DataSentCallback_t ; + using DataSentCallbackChain_t = ble::GattServer::DataSentCallbackChain_t ; + using DataWrittenCallback_t = ble::GattServer::DataWrittenCallback_t ; + using DataWrittenCallbackChain_t = ble::GattServer::DataWrittenCallbackChain_t ; + using DataReadCallback_t = ble::GattServer::DataReadCallback_t; + using DataReadCallbackChain_t = ble::GattServer::DataReadCallbackChain_t; + using GattServerShutdownCallback_t = ble::GattServer::GattServerShutdownCallback_t; + using GattServerShutdownCallbackChain_t = ble::GattServer::GattServerShutdownCallbackChain_t; + using EventCallback_t = ble::GattServer::EventCallback_t; + + // inherited typedefs have the wrong types so we have to redefine them public: - void setEventHandler(EventHandler *handler); - ble_error_t reset(void); + ble_error_t reset(ble::GattServer* server); ble_error_t addService(GattService &service); @@ -107,49 +113,30 @@ class GattServer : bool *enabledP ); - Gap::PreferredConnectionParams_t getPreferredConnectionParams(); + ble::Gap::PreferredConnectionParams_t getPreferredConnectionParams(); - void setPreferredConnectionParams(const Gap::PreferredConnectionParams_t& params); + void setPreferredConnectionParams(const ble::Gap::PreferredConnectionParams_t ¶ms); bool isOnDataReadAvailable() const; void onDataSent(const DataSentCallback_t &callback); - template - void onDataSent(T *objPtr, void (T::*memberPtr)(unsigned count)); - DataSentCallbackChain_t &onDataSent(); - void onDataWritten(const DataWrittenCallback_t &callback) { + void onDataWritten(const DataWrittenCallback_t &callback) + { dataWrittenCallChain.add(callback); } - template - void onDataWritten( - T *objPtr, - void (T::*memberPtr)(const GattWriteCallbackParams *context) - ) { - dataWrittenCallChain.add(objPtr, memberPtr); - }; - DataWrittenCallbackChain_t &onDataWritten(); ble_error_t onDataRead(const DataReadCallback_t &callback); - template - ble_error_t onDataRead( - T *objPtr, - void (T::*memberPtr)(const GattReadCallbackParams *context) - ); - DataReadCallbackChain_t &onDataRead(); void onShutdown(const GattServerShutdownCallback_t &callback); - template - void onShutdown(T *objPtr, void (T::*memberPtr)(const GattServer *)); - - GattServerShutdownCallbackChain_t& onShutdown(); + GattServerShutdownCallbackChain_t &onShutdown(); void onUpdatesEnabled(EventCallback_t callback); @@ -158,7 +145,7 @@ class GattServer : void onConfirmationReceived(EventCallback_t callback); /* Entry points for the underlying stack to report events back to the user. */ -protected: + protected: void handleDataWrittenEvent(const GattWriteCallbackParams *params); @@ -174,59 +161,66 @@ class GattServer : /* ===================================================================== */ /* private implementation follows */ -#if 0 // Disabled until reworked and reintroduced to GattServer API -public: - /** - * @see ble::GattServer::setDeviceName - */ - ble_error_t setDeviceName(const uint8_t *deviceName); + #if 0 // Disabled until reworked and reintroduced to GattServer API + public: + /** + * @see ble::GattServer::setDeviceName + */ + ble_error_t setDeviceName(const uint8_t *deviceName); - /** - * @see ble::GattServer::getDeviceName - */ - void getDeviceName(const uint8_t*& name, uint16_t& length); + /** + * @see ble::GattServer::getDeviceName + */ + void getDeviceName(const uint8_t*& name, uint16_t& length); - /** - * @see ble::GattServer::setAppearance - */ - void setAppearance(GapAdvertisingData::Appearance appearance); - - /** - * @see ble::GattServer::getAppearance - */ - GapAdvertisingData::Appearance getAppearance(); - -#endif // Disabled until reworked and reintroduced to GattServer API + /** + * @see ble::GattServer::setAppearance + */ + void setAppearance(GapAdvertisingData::Appearance appearance); -private: - GattServer(); + /** + * @see ble::GattServer::getAppearance + */ + GapAdvertisingData::Appearance getAppearance(); - GattServer(const GattServer &); - const GattServer& operator=(const GattServer &); + #endif // Disabled until reworked and reintroduced to GattServer API +public: /** - * Return the singleton of the Cordio implementation of ble::GattServer. + * Return the singleton of ble::GattServer. */ static GattServer &getInstance(); + static void att_cb(const attEvt_t *pEvt); + /** * Initialize the GattServer and add mandatory services (generic access and * generic attribute service). */ void initialize(); + static uint8_t atts_auth_cb(dmConnId_t connId, uint8_t permit, uint16_t handle); + void set_signing_event_handler( PalSigningMonitorEventHandler *signing_event_handler - ); + ) override; + +private: + + GattServer(); + + GattServer(const GattServer &); - EventHandler* getEventHandler(); + const GattServer &operator=(const GattServer &); + + EventHandler *getEventHandler(); void add_default_services(); - static uint16_t compute_attributes_count(GattService& service); + static uint16_t compute_attributes_count(GattService &service); void insert_service_attribute( - GattService& service, + GattService &service, attsAttr_t *&attribute_it ); @@ -249,9 +243,9 @@ class GattServer : ble_error_t insert_descriptor( GattCharacteristic *characteristic, - GattAttribute* descriptor, + GattAttribute *descriptor, attsAttr_t *&attribute_it, - bool& cccd_created + bool &cccd_created ); ble_error_t insert_cccd( @@ -260,20 +254,35 @@ class GattServer : ); static void cccd_cb(attsCccEvt_t *pEvt); - static void att_cb(const attEvt_t *pEvt); + static uint8_t atts_read_cb(dmConnId_t connId, uint16_t handle, uint8_t operation, uint16_t offset, attsAttr_t *pAttr); - static uint8_t atts_write_cb(dmConnId_t connId, uint16_t handle, uint8_t operation, uint16_t offset, uint16_t len, uint8_t *pValue, attsAttr_t *pAttr); - static uint8_t atts_auth_cb(dmConnId_t connId, uint8_t permit, uint16_t handle); + + static uint8_t atts_write_cb( + dmConnId_t connId, + uint16_t handle, + uint8_t operation, + uint16_t offset, + uint16_t len, + uint8_t *pValue, + attsAttr_t *pAttr + ); + void add_generic_access_service(); + void add_generic_attribute_service(); - void* alloc_block(size_t block_size); - GattCharacteristic* get_auth_char(uint16_t value_handle); - bool get_cccd_index_by_cccd_handle(GattAttribute::Handle_t cccd_handle, uint8_t& idx) const; - bool get_cccd_index_by_value_handle(GattAttribute::Handle_t char_handle, uint8_t& idx) const; + + void *alloc_block(size_t block_size); + + GattCharacteristic *get_auth_char(uint16_t value_handle); + + bool get_cccd_index_by_cccd_handle(GattAttribute::Handle_t cccd_handle, uint8_t &idx) const; + + bool get_cccd_index_by_value_handle(GattAttribute::Handle_t char_handle, uint8_t &idx) const; + bool is_update_authorized(connection_handle_t connection, GattAttribute::Handle_t value_handle); struct alloc_block_t { - alloc_block_t* next; + alloc_block_t *next; uint8_t data[1]; }; @@ -357,7 +366,8 @@ class GattServer : uint8_t ppcp_declaration_value[5]; uint8_t ppcp[8]; - uint8_t*& device_name_value() { + uint8_t *&device_name_value() + { return attributes[2].pValue; } } generic_access_service; @@ -368,14 +378,15 @@ class GattServer : uint8_t service_changed_declaration[5]; } generic_attribute_service; - internal_service_t* registered_service; - alloc_block_t* allocated_blocks; + internal_service_t *registered_service; + alloc_block_t *allocated_blocks; uint16_t currentHandle; bool default_services_added; }; +} // namespace impl } // ble #endif /* ifndef MBED_CORDIO_GATT_SERVER_H__ */ diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/source/PalAttClientImpl.cpp b/connectivity/FEATURE_BLE/source/cordio/source/PalAttClientImpl.cpp similarity index 94% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/source/PalAttClientImpl.cpp rename to connectivity/FEATURE_BLE/source/cordio/source/PalAttClientImpl.cpp index 353b8c58da5..35c299d7810 100644 --- a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/source/PalAttClientImpl.cpp +++ b/connectivity/FEATURE_BLE/source/cordio/source/PalAttClientImpl.cpp @@ -16,21 +16,25 @@ * limitations under the License. */ -#include "ble/internal/PalAttClient.h" -#include "ble/GattServer.h" -#include "ble/internal/PalSimpleAttServerMessage.h" -#include "ble/internal/PalGap.h" -#include "ble/internal/PalGattClient.h" -#include "ble/internal/BLEInstanceBase.h" +#include "source/pal/PalAttClient.h" +#include "source/pal/PalSimpleAttServerMessage.h" +#include "source/pal/PalGattClient.h" + +#include "source/GattServerImpl.h" +#include "source/BLEInstanceBaseImpl.h" +#include "source/PalAttClientImpl.h" #include "att_api.h" #include "att_defs.h" namespace ble { +namespace impl { -PalAttClient::PalAttClient() : _local_sign_counter(0) {} +PalAttClient::PalAttClient() : _local_sign_counter(0) +{ +} -PalAttClient::~PalAttClient() {} +PalAttClient::~PalAttClient() = default; /** * @see ble::PalAttClient::exchange_mtu_request @@ -392,13 +396,13 @@ void PalAttClient::att_client_handler(const attEvt_t *event) { #if BLE_FEATURE_GATT_CLIENT if (event->hdr.status == ATT_SUCCESS && event->hdr.event == ATT_MTU_UPDATE_IND) { - ble::BLEInstanceBase &ble = ble::BLEInstanceBase::deviceInstance(); + ble::impl::BLEInstanceBase &ble = BLEInstanceBase::deviceInstance(); PalGattClientEventHandler *handler = ble.getPalGattClient().get_event_handler(); if (handler) { handler->on_att_mtu_change(event->hdr.param, event->mtu); } } else if (event->hdr.event == ATTC_WRITE_CMD_RSP) { - ble::BLEInstanceBase &ble = ble::BLEInstanceBase::deviceInstance(); + ble::impl::BLEInstanceBase &ble = BLEInstanceBase::deviceInstance(); PalGattClientEventHandler *handler = ble.getPalGattClient().get_event_handler(); if (handler) { handler->on_write_command_sent( @@ -434,8 +438,8 @@ void PalAttClient::att_client_handler(const attEvt_t *event) // traverse all handlers and execute them with the event in input. // exit if an handler has handled the event. - for (size_t i = 0; i < (sizeof(handlers) / sizeof(handlers[0])); ++i) { - if (handlers[i](event)) { + for (auto handler : handlers) { + if (handler(event)) { return; } } @@ -444,8 +448,9 @@ void PalAttClient::att_client_handler(const attEvt_t *event) #if BLE_FEATURE_GATT_SERVER // pass events not handled to the server side - ble::GattServer::getInstance().att_cb(event); + ble::impl::GattServer::att_cb(event); #endif // BLE_FEATURE_GATT_SERVER } +} // namespace impl } // ble diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/include/ble/internal/PalAttClientImpl.h b/connectivity/FEATURE_BLE/source/cordio/source/PalAttClientImpl.h similarity index 83% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/include/ble/internal/PalAttClientImpl.h rename to connectivity/FEATURE_BLE/source/cordio/source/PalAttClientImpl.h index 44fc5f09b3e..02f69236f6e 100644 --- a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/include/ble/internal/PalAttClientImpl.h +++ b/connectivity/FEATURE_BLE/source/cordio/source/PalAttClientImpl.h @@ -19,13 +19,15 @@ #ifndef IMPL_PAL_ATT_CLIENT_ #define IMPL_PAL_ATT_CLIENT_ -#include "PalSimpleAttServerMessage.h" +#include "source/pal/PalSimpleAttServerMessage.h" +#include "source/pal/PalAttClient.h" + #include "att_api.h" -#include "ble/internal/PalAttClient.h" namespace ble { +namespace impl { -class PalAttClient : public interface::PalAttClient { +class PalAttClient final : public ble::PalAttClient { public: PalAttClient(); @@ -35,15 +37,15 @@ class PalAttClient : public interface::PalAttClient { /** * @see ble::PalAttClient::exchange_mtu_request */ - ble_error_t exchange_mtu_request(connection_handle_t connection); + ble_error_t exchange_mtu_request(connection_handle_t connection) final; /** * @see ble::PalGattClient::get_mtu_size */ ble_error_t get_mtu_size( connection_handle_t connection_handle, - uint16_t& mtu_size - ); + uint16_t &mtu_size + ) final; /** * @see ble::PalAttClient::find_information_request @@ -51,7 +53,7 @@ class PalAttClient : public interface::PalAttClient { ble_error_t find_information_request( connection_handle_t connection_handle, attribute_handle_range_t discovery_range - ); + ) final; /** * @see ble::PalAttClient::find_by_type_value_request @@ -60,8 +62,8 @@ class PalAttClient : public interface::PalAttClient { connection_handle_t connection_handle, attribute_handle_range_t discovery_range, uint16_t type, - const Span& value - ); + const Span &value + ) final; /** * @see ble::PalAttClient::read_by_type_request @@ -69,8 +71,8 @@ class PalAttClient : public interface::PalAttClient { ble_error_t read_by_type_request( connection_handle_t connection_handle, attribute_handle_range_t read_range, - const UUID& type - ); + const UUID &type + ) final; /** * @see ble::PalAttClient::read_request @@ -78,7 +80,7 @@ class PalAttClient : public interface::PalAttClient { ble_error_t read_request( connection_handle_t connection_handle, attribute_handle_t attribute_handle - ); + ) final; /** * @see ble::PalAttClient::read_blob_request @@ -87,15 +89,15 @@ class PalAttClient : public interface::PalAttClient { connection_handle_t connection_handle, attribute_handle_t attribute_handle, uint16_t offset - ); + ) final; /** * @see ble::PalAttClient::read_multiple_request */ ble_error_t read_multiple_request( connection_handle_t connection_handle, - const Span& attribute_handles - ); + const Span &attribute_handles + ) final; /** * @see ble::PalAttClient::read_by_group_type_request @@ -103,8 +105,8 @@ class PalAttClient : public interface::PalAttClient { ble_error_t read_by_group_type_request( connection_handle_t connection_handle, attribute_handle_range_t read_range, - const UUID& group_type - ); + const UUID &group_type + ) final; /** * @see ble::PalAttClient::write_request @@ -112,8 +114,8 @@ class PalAttClient : public interface::PalAttClient { ble_error_t write_request( connection_handle_t connection_handle, attribute_handle_t attribute_handle, - const Span& value - ); + const Span &value + ) final; /** * @see ble::PalAttClient::write_command @@ -121,8 +123,8 @@ class PalAttClient : public interface::PalAttClient { ble_error_t write_command( connection_handle_t connection_handle, attribute_handle_t attribute_handle, - const Span& value - ); + const Span &value + ) final; /** * @see ble::PalAttClient::signed_write_command @@ -130,8 +132,8 @@ class PalAttClient : public interface::PalAttClient { ble_error_t signed_write_command( connection_handle_t connection_handle, attribute_handle_t attribute_handle, - const Span& value - ); + const Span &value + ) final; /** * Initialises the counter used to sign messages. Counter will be incremented every @@ -150,8 +152,8 @@ class PalAttClient : public interface::PalAttClient { connection_handle_t connection_handle, attribute_handle_t attribute_handle, uint16_t offset, - const Span& value - ); + const Span &value + ) final; /** * @see ble::PalAttClient::execute_write_request @@ -159,45 +161,45 @@ class PalAttClient : public interface::PalAttClient { ble_error_t execute_write_request( connection_handle_t connection_handle, bool execute - ); + ) final; /** * @see ble::PalAttClient::initialize */ - ble_error_t initialize(); + ble_error_t initialize() final; /** * @see ble::PalAttClient::terminate */ - ble_error_t terminate(); + ble_error_t terminate() final; // singleton of the ARM Cordio client - static PalAttClient& get_client(); + static PalAttClient &get_client(); void when_server_message_received( - mbed::Callback cb - ); + mbed::Callback cb + ) final; void when_transaction_timeout( - mbed::Callback cb - ); + mbed::Callback cb + ) final; private: // convert an array of byte to an uint16_t - static uint16_t to_uint16_t(const uint8_t* array); + static uint16_t to_uint16_t(const uint8_t *array); /** * Type of an event handler. * @param The event to handle * @return true if the event has been handled and false otherwise. */ - typedef bool (*event_handler_t)(const attEvt_t*); + typedef bool (*event_handler_t)(const attEvt_t *); public: /** * Callback which handle attEvt_t and forward them to on_server_event. */ - static void att_client_handler(const attEvt_t* event); + static void att_client_handler(const attEvt_t *event); private: /** @@ -212,13 +214,13 @@ class PalAttClient : public interface::PalAttClient { * @return */ template - static bool event_handler(const attEvt_t* event); + static bool event_handler(const attEvt_t *event); - static bool timeout_event_handler(const attEvt_t* event); + static bool timeout_event_handler(const attEvt_t *event); template static void generated_handler( - const attEvt_t* event, ResultType (*convert)(const attEvt_t*) + const attEvt_t *event, ResultType (*convert)(const attEvt_t *) ); /** @@ -226,9 +228,9 @@ class PalAttClient : public interface::PalAttClient { */ template struct ResponseConverter { - static bool can_convert(const attEvt_t* event) + static bool can_convert(const attEvt_t *event) { - if(event->hdr.status == ATT_SUCCESS && event->hdr.event == RequestID) { + if (event->hdr.status == ATT_SUCCESS && event->hdr.event == RequestID) { return true; } return false; @@ -239,15 +241,15 @@ class PalAttClient : public interface::PalAttClient { * Converter for an AttErrorResponse. */ struct ErrorResponseConverter { - static bool can_convert(const attEvt_t* event) + static bool can_convert(const attEvt_t *event) { - if(event->hdr.status != ATT_SUCCESS) { + if (event->hdr.status != ATT_SUCCESS) { return true; } return false; } - static AttErrorResponse convert(const attEvt_t* event) + static AttErrorResponse convert(const attEvt_t *event) { return AttErrorResponse( static_cast(event->hdr.event * 2), @@ -261,7 +263,7 @@ class PalAttClient : public interface::PalAttClient { * Converter for a PalSimpleAttFindInformationResponse. */ struct FindInformationResponseConverter : ResponseConverter { - static PalSimpleAttFindInformationResponse convert(const attEvt_t* event) + static PalSimpleAttFindInformationResponse convert(const attEvt_t *event) { return PalSimpleAttFindInformationResponse( static_cast(event->pValue[0]), @@ -277,7 +279,7 @@ class PalAttClient : public interface::PalAttClient { * Converter for a PalSimpleAttFindByTypeValueResponse. */ struct FindByTypeValueResponseConverter : ResponseConverter { - static PalSimpleAttFindByTypeValueResponse convert(const attEvt_t* event) + static PalSimpleAttFindByTypeValueResponse convert(const attEvt_t *event) { return PalSimpleAttFindByTypeValueResponse( make_const_Span( @@ -292,7 +294,7 @@ class PalAttClient : public interface::PalAttClient { * Converter for a PalSimpleAttReadByTypeResponse. */ struct ReadByTypeResponseConverter : ResponseConverter { - static PalSimpleAttReadByTypeResponse convert(const attEvt_t* event) + static PalSimpleAttReadByTypeResponse convert(const attEvt_t *event) { return PalSimpleAttReadByTypeResponse( event->pValue[0], @@ -308,7 +310,7 @@ class PalAttClient : public interface::PalAttClient { * Converter for a AttReadResponse. */ struct ReadResponseConverter : ResponseConverter { - static AttReadResponse convert(const attEvt_t* event) + static AttReadResponse convert(const attEvt_t *event) { return AttReadResponse( make_const_Span( @@ -323,7 +325,7 @@ class PalAttClient : public interface::PalAttClient { * Converter for a AttReadBlobResponse. */ struct ReadBlobResponseConverter : ResponseConverter { - static AttReadBlobResponse convert(const attEvt_t* event) + static AttReadBlobResponse convert(const attEvt_t *event) { return AttReadBlobResponse( make_const_Span( @@ -338,7 +340,7 @@ class PalAttClient : public interface::PalAttClient { * Converter for a AttReadMultipleResponse. */ struct ReadMultipleResponseConverter : ResponseConverter { - static AttReadMultipleResponse convert(const attEvt_t* event) + static AttReadMultipleResponse convert(const attEvt_t *event) { return AttReadMultipleResponse( make_const_Span( @@ -353,7 +355,7 @@ class PalAttClient : public interface::PalAttClient { * Converter for a PalSimpleAttReadByGroupTypeResponse. */ struct ReadBygroupTypeResponseConverter : ResponseConverter { - static PalSimpleAttReadByGroupTypeResponse convert(const attEvt_t* event) + static PalSimpleAttReadByGroupTypeResponse convert(const attEvt_t *event) { return PalSimpleAttReadByGroupTypeResponse( event->pValue[0], @@ -369,7 +371,7 @@ class PalAttClient : public interface::PalAttClient { * Converter for a AttWriteResponse. */ struct WriteResponseConverter : ResponseConverter { - static AttWriteResponse convert(const attEvt_t* event) + static AttWriteResponse convert(const attEvt_t *event) { return AttWriteResponse(); } @@ -379,7 +381,7 @@ class PalAttClient : public interface::PalAttClient { * Converter for a AttPrepareWriteResponse. */ struct PrepareWriteResponseConverter : ResponseConverter { - static AttPrepareWriteResponse convert(const attEvt_t* event) + static AttPrepareWriteResponse convert(const attEvt_t *event) { return AttPrepareWriteResponse( event->handle, @@ -396,7 +398,7 @@ class PalAttClient : public interface::PalAttClient { * Converter for a AttExecuteWriteResponse. */ struct ExecuteWriteResponseConverter : ResponseConverter { - static AttExecuteWriteResponse convert(const attEvt_t* event) + static AttExecuteWriteResponse convert(const attEvt_t *event) { return AttExecuteWriteResponse(); } @@ -406,7 +408,7 @@ class PalAttClient : public interface::PalAttClient { * Converter for a AttHandleValueNotification. */ struct HandleValueNotificationConverter : ResponseConverter { - static AttHandleValueNotification convert(const attEvt_t* event) + static AttHandleValueNotification convert(const attEvt_t *event) { return AttHandleValueNotification( event->handle, @@ -422,7 +424,7 @@ class PalAttClient : public interface::PalAttClient { * Converter for a AttHandleValueIndication. */ struct HandleValueIndicationConverter : ResponseConverter { - static AttHandleValueIndication convert(const attEvt_t* event) + static AttHandleValueIndication convert(const attEvt_t *event) { return AttHandleValueIndication( event->handle, @@ -433,6 +435,7 @@ class PalAttClient : public interface::PalAttClient { ); } }; + private: /** * Upon server message reception an implementation shall call this function. @@ -443,7 +446,7 @@ class PalAttClient : public interface::PalAttClient { */ void on_server_event( connection_handle_t connection_handle, - const AttServerMessage& server_message + const AttServerMessage &server_message ); /** @@ -457,13 +460,14 @@ class PalAttClient : public interface::PalAttClient { void on_transaction_timeout( connection_handle_t connection_handle ); + private: sign_count_t _local_sign_counter; /** * Callback called when the client receive a message from the server. */ - mbed::Callback _server_message_cb; + mbed::Callback _server_message_cb; /** * Callback called when a transaction times out. @@ -471,6 +475,7 @@ class PalAttClient : public interface::PalAttClient { mbed::Callback _transaction_timeout_cb; }; -} // ble +} // namespace impl +} // namespace ble #endif /* IMPL_PAL_ATT_CLIENT_ */ diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/source/PalEventQueueImpl.cpp b/connectivity/FEATURE_BLE/source/cordio/source/PalEventQueueImpl.cpp similarity index 87% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/source/PalEventQueueImpl.cpp rename to connectivity/FEATURE_BLE/source/cordio/source/PalEventQueueImpl.cpp index a483ff03ba5..e1079df2da9 100644 --- a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/source/PalEventQueueImpl.cpp +++ b/connectivity/FEATURE_BLE/source/cordio/source/PalEventQueueImpl.cpp @@ -16,14 +16,16 @@ * limitations under the License. */ -#include "ble/internal/PalEventQueue.h" -#include "ble/internal/BLEInstanceBase.h" +#include "source/BLEInstanceBase.h" +#include "source/PalEventQueueImpl.h" namespace ble { +namespace impl { void PalEventQueue::signal_event() { _ble_base->signalEventsToProcess(); } +} // namespace impl } // namespace ble diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/include/ble/internal/PalEventQueueImpl.h b/connectivity/FEATURE_BLE/source/cordio/source/PalEventQueueImpl.h similarity index 73% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/include/ble/internal/PalEventQueueImpl.h rename to connectivity/FEATURE_BLE/source/cordio/source/PalEventQueueImpl.h index d99a0f5785f..507b7f09ea2 100644 --- a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/include/ble/internal/PalEventQueueImpl.h +++ b/connectivity/FEATURE_BLE/source/cordio/source/PalEventQueueImpl.h @@ -20,7 +20,7 @@ #define BLE_PAL_SIMPLE_EVENT_QUEUE_H_ #include -#include "ble/internal/PalEventQueue.h" +#include "source/pal/PalEventQueue.h" #include "wsf_buf.h" @@ -28,10 +28,12 @@ namespace ble { class BLEInstanceBase; +namespace impl { + /** * Simple implementation of the EventQueue. */ -class PalEventQueue : interface::PalEventQueue { +class PalEventQueue final : public ble::PalEventQueue { public: typedef mbed::Callback event_t; @@ -41,7 +43,9 @@ class PalEventQueue : interface::PalEventQueue { * @attention a call to initialize is mandatory before any other call. */ PalEventQueue() : - _ble_base(NULL), _events(NULL) { } + _ble_base(nullptr), _events(nullptr) + { + } /** * Initialize the event queue with a BLEInstanceBase and a ble id. @@ -49,7 +53,7 @@ class PalEventQueue : interface::PalEventQueue { * @param ble_base the instance which will be used to signal the presence * of new events. */ - void initialize(BLEInstanceBase* ble_base) + void initialize(ble::BLEInstanceBase *ble_base) { _ble_base = ble_base; } @@ -65,25 +69,22 @@ class PalEventQueue : interface::PalEventQueue { /** * @see ble::post */ - virtual bool post(const mbed::Callback& event) + bool post(const mbed::Callback &event) final { - if (_ble_base == NULL) { + if (_ble_base == nullptr) { return false; } - void* event_buf = WsfBufAlloc(sizeof(EventNode)); - MBED_ASSERT(event_buf != NULL); - if (event_buf == NULL) { - return false; - } - EventNode* next = new(event_buf) EventNode(event); - if (next == NULL) { + void *event_buf = WsfBufAlloc(sizeof(EventNode)); + MBED_ASSERT(event_buf != nullptr); + if (event_buf == nullptr) { return false; } + auto *next = new(event_buf) EventNode(event); - if (_events == NULL) { + if (_events == nullptr) { _events = next; } else { - EventNode* previous = _events; + EventNode *previous = _events; while (previous->next) { previous = previous->next; } @@ -102,7 +103,7 @@ class PalEventQueue : interface::PalEventQueue { void clear() { while (_events) { - EventNode* next = _events->next; + EventNode *next = _events->next; _events->~EventNode(); WsfBufFree(_events); _events = next; @@ -115,7 +116,7 @@ class PalEventQueue : interface::PalEventQueue { void process() { while (_events) { - EventNode* next = _events->next; + EventNode *next = _events->next; _events->event(); _events->~EventNode(); WsfBufFree(_events); @@ -125,17 +126,21 @@ class PalEventQueue : interface::PalEventQueue { private: struct EventNode { - EventNode(const event_t event) : event(event), next(NULL) { } + EventNode(const event_t event) : event(event), next(nullptr) + { + } + event_t event; - EventNode* next; + EventNode *next; }; void signal_event(); - BLEInstanceBase* _ble_base; - EventNode* _events; + ble::BLEInstanceBase *_ble_base; + EventNode *_events; }; +} // namespace impl } // namespace ble #endif /* BLE_PAL_SIMPLE_EVENT_QUEUE_H_ */ diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/source/PalGapImpl.cpp b/connectivity/FEATURE_BLE/source/cordio/source/PalGapImpl.cpp similarity index 92% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/source/PalGapImpl.cpp rename to connectivity/FEATURE_BLE/source/cordio/source/PalGapImpl.cpp index 38af1710371..07af6795820 100644 --- a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/source/PalGapImpl.cpp +++ b/connectivity/FEATURE_BLE/source/cordio/source/PalGapImpl.cpp @@ -15,13 +15,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include "PalGap.h" +#include "source/PalGapImpl.h" #include "hci_api.h" #include "dm_api.h" #include "dm_main.h" #include "dm_conn.h" namespace ble { +namespace impl { namespace { bool dummy_gap_event_handler(const wsfMsgHdr_t *msg) @@ -67,8 +68,8 @@ bool PalGap::is_feature_supported( ble_error_t PalGap::initialize() { - for (size_t i = 0; i < DM_NUM_ADV_SETS; ++i) { - direct_adv_cb[i] = direct_adv_cb_t(); + for (auto & cb : direct_adv_cb) { + cb = direct_adv_cb_t(); } return BLE_ERROR_NONE; } @@ -76,8 +77,8 @@ ble_error_t PalGap::initialize() ble_error_t PalGap::terminate() { - for (size_t i = 0; i < DM_NUM_ADV_SETS; ++i) { - direct_adv_cb[i] = direct_adv_cb_t(); + for (auto & cb : direct_adv_cb) { + cb = direct_adv_cb_t(); } return BLE_ERROR_NONE; } @@ -189,7 +190,7 @@ ble_error_t PalGap::advertising_enable(bool enable) // the function DmConnAccept instead of the function DmAdvStart. // First the algorithm retrieves if direct advertising has been // configured and depending on the result use the right function. - direct_adv_cb_t* direct_adv_cb = get_pending_direct_adv_cb(DM_ADV_HANDLE_DEFAULT); + direct_adv_cb_t *direct_adv_cb = get_pending_direct_adv_cb(DM_ADV_HANDLE_DEFAULT); if (direct_adv_cb) { direct_adv_cb->connection_handle = DmConnAccept( DM_CLIENT_ID_APP, @@ -215,7 +216,7 @@ ble_error_t PalGap::advertising_enable(bool enable) // Functions to call to stop advertising if connectable direct // advertising is used or not. DmConnClose is used if direct // advertising is started otherwise use DmAdvStop. - direct_adv_cb_t* direct_adv_cb = get_running_direct_adv_cb(DM_ADV_HANDLE_DEFAULT); + direct_adv_cb_t *direct_adv_cb = get_running_direct_adv_cb(DM_ADV_HANDLE_DEFAULT); if (direct_adv_cb) { DmConnClose( DM_CLIENT_ID_APP, @@ -561,7 +562,7 @@ void PalGap::gap_handler(const wsfMsgHdr_t *msg) if (!handler) { break; } - const hciLeReadPhyCmdCmplEvt_t *evt = (const hciLeReadPhyCmdCmplEvt_t *) msg; + const auto *evt = (const hciLeReadPhyCmdCmplEvt_t *) msg; handler->on_read_phy( (hci_error_code_t::type) msg->status, @@ -570,14 +571,14 @@ void PalGap::gap_handler(const wsfMsgHdr_t *msg) (ble::phy_t::type) evt->rxPhy ); } - break; + break; case DM_PHY_UPDATE_IND: { if (!handler) { break; } - const hciLePhyUpdateEvt_t *evt = (const hciLePhyUpdateEvt_t *) msg; + const auto *evt = (const hciLePhyUpdateEvt_t *) msg; handler->on_phy_update_complete( (hci_error_code_t::type) msg->status, @@ -586,7 +587,7 @@ void PalGap::gap_handler(const wsfMsgHdr_t *msg) (ble::phy_t::type) evt->rxPhy ); } - break; + break; #endif // BLE_FEATURE_PHY_MANAGEMENT #if BLE_FEATURE_PERIODIC_ADVERTISING case DM_PER_ADV_SYNC_EST_IND: { @@ -594,7 +595,7 @@ void PalGap::gap_handler(const wsfMsgHdr_t *msg) break; } - const hciLePerAdvSyncEstEvt_t *evt = (const hciLePerAdvSyncEstEvt_t *) msg; + const auto *evt = (const hciLePerAdvSyncEstEvt_t *) msg; handler->on_periodic_advertising_sync_established( hci_error_code_t(evt->status), @@ -607,14 +608,14 @@ void PalGap::gap_handler(const wsfMsgHdr_t *msg) clock_accuracy_t(evt->clockAccuracy) ); } - break; + break; case DM_PER_ADV_REPORT_IND: { if (!handler) { break; } - const hciLePerAdvReportEvt_t *evt = (const hciLePerAdvReportEvt_t *) msg; + const auto *evt = (const hciLePerAdvReportEvt_t *) msg; handler->on_periodic_advertising_report( evt->syncHandle, @@ -625,17 +626,17 @@ void PalGap::gap_handler(const wsfMsgHdr_t *msg) evt->pData ); } - break; + break; case DM_PER_ADV_SYNC_LOST_IND: { if (!handler) { break; } - const hciLePerAdvSyncLostEvt_t *evt = (const hciLePerAdvSyncLostEvt_t *) msg; + const auto *evt = (const hciLePerAdvSyncLostEvt_t *) msg; handler->on_periodic_advertising_sync_loss(evt->syncHandle); } - break; + break; #endif // BLE_FEATURE_PERIODIC_ADVERTISING #if BLE_FEATURE_EXTENDED_ADVERTISING && BLE_ROLE_BROADCASTER @@ -644,22 +645,22 @@ void PalGap::gap_handler(const wsfMsgHdr_t *msg) break; } - const hciLeScanReqRcvdEvt_t *evt = (const hciLeScanReqRcvdEvt_t *) msg; + const auto *evt = (const hciLeScanReqRcvdEvt_t *) msg; handler->on_scan_request_received( evt->advHandle, connection_peer_address_type_t(evt->scanAddrType), evt->scanAddr ); } - break; + break; case DM_ADV_SET_STOP_IND: { - const hciLeAdvSetTermEvt_t *evt = (const hciLeAdvSetTermEvt_t *) msg; + const auto *evt = (const hciLeAdvSetTermEvt_t *) msg; // cleanup state in direct advertising list. This event is only // called for set using extended advertsing when the advertising // module is reset. - direct_adv_cb_t* adv_cb = get_gap().get_running_direct_adv_cb(evt->advHandle); + direct_adv_cb_t *adv_cb = get_gap().get_running_direct_adv_cb(evt->advHandle); if (adv_cb) { adv_cb->state = direct_adv_cb_t::free; @@ -676,7 +677,7 @@ void PalGap::gap_handler(const wsfMsgHdr_t *msg) evt->numComplEvts ); } - break; + break; #endif // BLE_FEATURE_EXTENDED_ADVERTISING && BLE_ROLE_BROADCASTER #if BLE_FEATURE_EXTENDED_ADVERTISING && BLE_ROLE_OBSERVER @@ -688,14 +689,14 @@ void PalGap::gap_handler(const wsfMsgHdr_t *msg) //const hciLeScanTimeoutEvt_t *evt = (const hciLeScanTimeoutEvt_t *) msg; handler->on_scan_timeout(); } - break; + break; case DM_EXT_SCAN_REPORT_IND: { if (!handler) { break; } - const hciLeExtAdvReportEvt_t *evt = (const hciLeExtAdvReportEvt_t *) msg; + const auto *evt = (const hciLeExtAdvReportEvt_t *) msg; connection_peer_address_type_t addr_type(evt->addrType); phy_t sec_phy(evt->secPhy); @@ -715,7 +716,7 @@ void PalGap::gap_handler(const wsfMsgHdr_t *msg) evt->pData ); } - break; + break; #endif // BLE_FEATURE_EXTENDED_ADVERTISING && BLE_ROLE_OBSERVER #if BLE_ROLE_CENTRAL || BLE_ROLE_PERIPHERAL @@ -724,7 +725,7 @@ void PalGap::gap_handler(const wsfMsgHdr_t *msg) break; } - const hciLeRemConnParamReqEvt_t *evt = (const hciLeRemConnParamReqEvt_t *) msg; + const auto *evt = (const hciLeRemConnParamReqEvt_t *) msg; handler->on_remote_connection_parameter( evt->hdr.param, evt->intervalMin, @@ -733,14 +734,14 @@ void PalGap::gap_handler(const wsfMsgHdr_t *msg) evt->timeout ); } - break; + break; case DM_CONN_CLOSE_IND: { // Intercept connection close indication received when direct advertising timeout. // Leave the rest of the processing to the event handlers bellow. - const hciDisconnectCmplEvt_t *evt = (const hciDisconnectCmplEvt_t *) msg; + const auto *evt = (const hciDisconnectCmplEvt_t *) msg; if (evt->status == HCI_ERR_ADV_TIMEOUT) { - direct_adv_cb_t* adv_cb = + direct_adv_cb_t *adv_cb = get_gap().get_running_conn_direct_adv_cb(evt->hdr.param); if (adv_cb) { adv_cb->state = direct_adv_cb_t::free; @@ -756,19 +757,19 @@ void PalGap::gap_handler(const wsfMsgHdr_t *msg) } } } - break; + break; case DM_CONN_OPEN_IND: { // Intercept connection open indication received when direct advertising timeout. // Leave the rest of the processing to the event handlers bellow. // There is no advertising stop event generated for directed connectable advertising. - const hciLeConnCmplEvt_t *evt = (const hciLeConnCmplEvt_t *) msg; - direct_adv_cb_t* adv_cb = get_gap().get_running_conn_direct_adv_cb(evt->hdr.param); + const auto *evt = (const hciLeConnCmplEvt_t *) msg; + direct_adv_cb_t *adv_cb = get_gap().get_running_conn_direct_adv_cb(evt->hdr.param); if (adv_cb) { adv_cb->state = direct_adv_cb_t::free; } } - break; + break; #endif // BLE_ROLE_CENTRAL || BLE_ROLE_PERIPHERAL } @@ -790,8 +791,8 @@ void PalGap::gap_handler(const wsfMsgHdr_t *msg) // traverse all handlers and execute them with the event in input. // exit if an handler has handled the event. - for (size_t i = 0; i < (sizeof(handlers) / sizeof(handlers[0])); ++i) { - if (handlers[i](msg)) { + for (auto handler : handlers) { + if (handler(msg)) { return; } } @@ -856,7 +857,7 @@ ble_error_t PalGap::set_extended_advertising_parameters( adv_type = DM_ADV_CONN_UNDIRECT; } else if (event_properties.scannable) { adv_type = DM_ADV_SCAN_UNDIRECT; - } else { + } else { adv_type = DM_ADV_NONCONN_UNDIRECT; } } else { @@ -886,7 +887,7 @@ ble_error_t PalGap::set_extended_advertising_parameters( adv_type = DM_ADV_SCAN_UNDIRECT; } else if (event_properties.connectable) { adv_type = DM_EXT_ADV_CONN_UNDIRECT; - } else { + } else { adv_type = DM_ADV_NONCONN_UNDIRECT; } } else { @@ -1075,7 +1076,7 @@ ble_error_t PalGap::extended_advertising_enable( uint32_t duration = in_durations[i] * 10; duration = duration > 0xFFFF ? 0xFFFF : duration; - direct_adv_cb_t* direct_adv_cb = get_pending_direct_adv_cb(in_handles[i]); + direct_adv_cb_t *direct_adv_cb = get_pending_direct_adv_cb(in_handles[i]); if (direct_adv_cb) { direct_adv_cb->connection_handle = DmConnAccept( DM_CLIENT_ID_APP, @@ -1116,7 +1117,7 @@ ble_error_t PalGap::extended_advertising_enable( // sets broadcasting with direct advertising with DmConnClose then pass // the remaining advertising sets to DmAdvStop. for (size_t i = 0; i < number_of_sets; ++i) { - direct_adv_cb_t* direct_adv_cb = get_running_direct_adv_cb(in_handles[i]); + direct_adv_cb_t *direct_adv_cb = get_running_direct_adv_cb(in_handles[i]); if (direct_adv_cb) { DmConnClose( DM_CLIENT_ID_APP, @@ -1407,13 +1408,13 @@ ble_error_t PalGap::update_direct_advertising_parameters( { // The case where a direct advertising is running and parameters are updated // is considered to be a programming error. User should stop advertising first. - direct_adv_cb_t* running = get_running_direct_adv_cb(advertising_handle); + direct_adv_cb_t *running = get_running_direct_adv_cb(advertising_handle); if (running) { return BLE_ERROR_INVALID_STATE; } // For pending direct advertising, update the configuration data structure - direct_adv_cb_t* pending = get_pending_direct_adv_cb(DM_ADV_HANDLE_DEFAULT); + direct_adv_cb_t *pending = get_pending_direct_adv_cb(DM_ADV_HANDLE_DEFAULT); if (pending) { // Update existing config if (advertising_type == DM_ADV_CONN_DIRECT || @@ -1433,7 +1434,7 @@ ble_error_t PalGap::update_direct_advertising_parameters( // then configure it. if (advertising_type == DM_ADV_CONN_DIRECT || advertising_type == DM_ADV_CONN_DIRECT_LO_DUTY) { - direct_adv_cb_t* adv_cb = get_free_direct_adv_cb(); + direct_adv_cb_t *adv_cb = get_free_direct_adv_cb(); if (!adv_cb) { return BLE_ERROR_INTERNAL_STACK_FAILURE; } @@ -1449,8 +1450,8 @@ ble_error_t PalGap::update_direct_advertising_parameters( template -typename PalGap::direct_adv_cb_t* -PalGap::get_adv_cb(const Predicate& predicate) +typename PalGap::direct_adv_cb_t * +PalGap::get_adv_cb(const Predicate &predicate) { for (size_t i = 0; i < DM_NUM_ADV_SETS; ++i) { if (predicate(direct_adv_cb[i])) { @@ -1461,42 +1462,50 @@ PalGap::get_adv_cb(const Predicate& predicate) } -typename PalGap::direct_adv_cb_t* +typename PalGap::direct_adv_cb_t * PalGap::get_running_direct_adv_cb(advertising_handle_t adv_handle) { - return get_adv_cb([adv_handle] (const direct_adv_cb_t& cb) { - return cb.state == direct_adv_cb_t::running && - cb.advertising_handle == adv_handle; - }); + return get_adv_cb( + [adv_handle](const direct_adv_cb_t &cb) { + return cb.state == direct_adv_cb_t::running && + cb.advertising_handle == adv_handle; + } + ); } -typename PalGap::direct_adv_cb_t* +typename PalGap::direct_adv_cb_t * PalGap::get_running_conn_direct_adv_cb(connection_handle_t conn_handle) { - return get_adv_cb([conn_handle] (const direct_adv_cb_t& cb) { - return cb.state == direct_adv_cb_t::running && - cb.connection_handle == conn_handle; - }); + return get_adv_cb( + [conn_handle](const direct_adv_cb_t &cb) { + return cb.state == direct_adv_cb_t::running && + cb.connection_handle == conn_handle; + } + ); } -typename PalGap::direct_adv_cb_t* +typename PalGap::direct_adv_cb_t * PalGap::get_pending_direct_adv_cb(advertising_handle_t adv_handle) { - return get_adv_cb([adv_handle] (const direct_adv_cb_t& cb) { - return cb.state == direct_adv_cb_t::pending && - cb.advertising_handle == adv_handle; - }); + return get_adv_cb( + [adv_handle](const direct_adv_cb_t &cb) { + return cb.state == direct_adv_cb_t::pending && + cb.advertising_handle == adv_handle; + } + ); } -typename PalGap::direct_adv_cb_t* +typename PalGap::direct_adv_cb_t * PalGap::get_free_direct_adv_cb() { - return get_adv_cb([](const direct_adv_cb_t& cb) { - return cb.state == direct_adv_cb_t::free; - }); + return get_adv_cb( + [](const direct_adv_cb_t &cb) { + return cb.state == direct_adv_cb_t::free; + } + ); } void PalGap::when_gap_event_received(mbed::Callback cb) @@ -1509,9 +1518,10 @@ void PalGap::set_event_handler(PalGapEventHandler *event_handler) _pal_event_handler = event_handler; } -PalGapEventHandler* PalGap::get_event_handler() +PalGapEventHandler *PalGap::get_event_handler() { return _pal_event_handler; } +} // namespace impl } // ble diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/include/ble/internal/PalGapImpl.h b/connectivity/FEATURE_BLE/source/cordio/source/PalGapImpl.h similarity index 79% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/include/ble/internal/PalGapImpl.h rename to connectivity/FEATURE_BLE/source/cordio/source/PalGapImpl.h index f5bf251f3ce..50829fab5a9 100644 --- a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/include/ble/internal/PalGapImpl.h +++ b/connectivity/FEATURE_BLE/source/cordio/source/PalGapImpl.h @@ -19,32 +19,36 @@ #ifndef IMPL_PAL_GAP_ #define IMPL_PAL_GAP_ -#include "ble/internal/PalGap.h" +#include "source/pal/PalGap.h" #include "dm_api.h" namespace ble { +namespace impl { /** * Implementation of ble::PalGap for the Cordio stack. */ -class PalGap : public interface::PalGap { +class PalGap final : public ble::PalGap { public: - PalGap() : use_active_scanning(false), _pal_event_handler(NULL) { }; - ~PalGap() { }; + PalGap() : _pal_event_handler(nullptr), use_active_scanning(false) + { + }; + + ~PalGap() = default; bool is_feature_supported( ble::controller_supported_features_t feature - ); + ) final; - ble_error_t initialize(); + ble_error_t initialize() final; - ble_error_t terminate(); + ble_error_t terminate() final; - address_t get_device_address(); + address_t get_device_address() final; - address_t get_random_address(); + address_t get_random_address() final; - ble_error_t set_random_address(const address_t& address); + ble_error_t set_random_address(const address_t &address) final; ble_error_t set_advertising_parameters( uint16_t advertising_interval_min, @@ -52,22 +56,22 @@ class PalGap : public interface::PalGap { advertising_type_t advertising_type, own_address_type_t own_address_type, advertising_peer_address_type_t peer_address_type, - const address_t& peer_address, + const address_t &peer_address, advertising_channel_map_t advertising_channel_map, advertising_filter_policy_t advertising_filter_policy - ); + ) final; ble_error_t set_advertising_data( uint8_t advertising_data_length, - const advertising_data_t& advertising_data - ); + const advertising_data_t &advertising_data + ) final; ble_error_t set_scan_response_data( uint8_t scan_response_data_length, - const advertising_data_t& scan_response_data - ); + const advertising_data_t &scan_response_data + ) final; - ble_error_t advertising_enable(bool enable); + ble_error_t advertising_enable(bool enable) final; ble_error_t set_scan_parameters( bool active_scanning, @@ -75,19 +79,19 @@ class PalGap : public interface::PalGap { uint16_t scan_window, own_address_type_t own_address_type, scanning_filter_policy_t filter_policy - ); + ) final; ble_error_t scan_enable( bool enable, bool filter_duplicates - ); + ) final; ble_error_t create_connection( uint16_t scan_interval, uint16_t scan_window, initiator_policy_t initiator_policy, connection_peer_address_type_t peer_address_type, - const address_t& peer_address, + const address_t &peer_address, own_address_type_t own_address_type, uint16_t connection_interval_min, uint16_t connection_interval_max, @@ -95,23 +99,23 @@ class PalGap : public interface::PalGap { uint16_t supervision_timeout, uint16_t minimum_connection_event_length, uint16_t maximum_connection_event_length - ); + ) final; ble_error_t cancel_connection_creation(); - uint8_t read_white_list_capacity(); + uint8_t read_white_list_capacity() final; - ble_error_t clear_whitelist(); + ble_error_t clear_whitelist() final; ble_error_t add_device_to_whitelist( whitelist_address_type_t address_type, address_t address - ); + ) final; ble_error_t remove_device_from_whitelist( whitelist_address_type_t address_type, address_t address - ); + ) final; ble_error_t connection_parameters_update( connection_handle_t connection, @@ -121,7 +125,7 @@ class PalGap : public interface::PalGap { uint16_t supervision_timeout, uint16_t minimum_connection_event_length, uint16_t maximum_connection_event_length - ); + ) final; ble_error_t accept_connection_parameter_request( connection_handle_t connection_handle, @@ -131,50 +135,50 @@ class PalGap : public interface::PalGap { uint16_t supervision_timeout, uint16_t minimum_connection_event_length, uint16_t maximum_connection_event_length - ); + ) final; ble_error_t reject_connection_parameter_request( connection_handle_t connection_handle, hci_error_code_t rejection_reason - ); + ) final; ble_error_t disconnect( connection_handle_t connection, local_disconnection_reason_t disconnection_reason - ); + ) final; - bool is_privacy_supported(); + bool is_privacy_supported() final; ble_error_t set_address_resolution( bool enable - ); + ) final; - ble_error_t read_phy(connection_handle_t connection); + ble_error_t read_phy(connection_handle_t connection) final; ble_error_t set_preferred_phys( - const phy_set_t& tx_phys, - const phy_set_t& rx_phys - ); + const phy_set_t &tx_phys, + const phy_set_t &rx_phys + ) final; ble_error_t set_phy( connection_handle_t connection, - const phy_set_t& tx_phys, - const phy_set_t& rx_phys, + const phy_set_t &tx_phys, + const phy_set_t &rx_phys, coded_symbol_per_bit_t coded_symbol - ); + ) final; // singleton of the ARM Cordio client - static PalGap& get_gap(); + static PalGap &get_gap(); /** * Callback which handle wsfMsgHdr_t and forward them to emit_gap_event. */ - static void gap_handler(const wsfMsgHdr_t* msg); + static void gap_handler(const wsfMsgHdr_t *msg); ble_error_t set_advertising_set_random_address( advertising_handle_t advertising_handle, const address_t &address - ); + ) final; ble_error_t set_extended_advertising_parameters( advertising_handle_t advertising_handle, @@ -192,14 +196,14 @@ class PalGap : public interface::PalGap { phy_t secondary_phy, uint8_t advertising_sid, bool scan_request_notification - ); + ) final; ble_error_t set_periodic_advertising_parameters( advertising_handle_t advertising_handle, periodic_advertising_interval_t periodic_advertising_min, periodic_advertising_interval_t periodic_advertising_max, bool advertise_power - ); + ) final; ble_error_t set_extended_advertising_data( advertising_handle_t advertising_handle, @@ -207,14 +211,14 @@ class PalGap : public interface::PalGap { bool minimize_fragmentation, uint8_t advertising_data_size, const uint8_t *advertising_data - ); + ) final; ble_error_t set_periodic_advertising_data( advertising_handle_t advertising_handle, advertising_fragment_description_t fragment_description, uint8_t advertising_data_size, const uint8_t *advertising_data - ); + ) final; ble_error_t set_extended_scan_response_data( advertising_handle_t advertising_handle, @@ -222,7 +226,7 @@ class PalGap : public interface::PalGap { bool minimize_fragmentation, uint8_t scan_response_data_size, const uint8_t *scan_response_data - ); + ) final; ble_error_t extended_advertising_enable( bool enable, @@ -230,26 +234,26 @@ class PalGap : public interface::PalGap { const advertising_handle_t *handles, const uint16_t *durations, const uint8_t *max_extended_advertising_events - ); + ) final; ble_error_t periodic_advertising_enable( bool enable, advertising_handle_t advertising_handle - ); + ) final; - uint16_t get_maximum_advertising_data_length(); + uint16_t get_maximum_advertising_data_length() final; - uint16_t get_maximum_connectable_advertising_data_length(); + uint16_t get_maximum_connectable_advertising_data_length() final; - uint8_t get_maximum_hci_advertising_data_length(); + uint8_t get_maximum_hci_advertising_data_length() final; - uint8_t get_max_number_of_advertising_sets(); + uint8_t get_max_number_of_advertising_sets() final; ble_error_t remove_advertising_set( advertising_handle_t advertising_handle - ); + ) final; - ble_error_t clear_advertising_sets(); + ble_error_t clear_advertising_sets() final; ble_error_t set_extended_scan_parameters( own_address_type_t own_address_type, @@ -258,14 +262,14 @@ class PalGap : public interface::PalGap { const bool *active_scanning, const uint16_t *scan_interval, const uint16_t *scan_window - ); + ) final; ble_error_t extended_scan_enable( bool enable, duplicates_filter_t filter_duplicates, uint16_t duration, uint16_t period - ); + ) final; ble_error_t periodic_advertising_create_sync( bool use_periodic_advertiser_list, @@ -274,29 +278,29 @@ class PalGap : public interface::PalGap { const address_t &peer_address, uint16_t allowed_skip, uint16_t sync_timeout - ); + ) final; - ble_error_t cancel_periodic_advertising_create_sync(); + ble_error_t cancel_periodic_advertising_create_sync() final; ble_error_t periodic_advertising_terminate_sync( sync_handle_t sync_handle - ); + ) final; ble_error_t add_device_to_periodic_advertiser_list( advertising_peer_address_type_t advertiser_address_type, const address_t &advertiser_address, uint8_t advertising_sid - ); + ) final; ble_error_t remove_device_from_periodic_advertiser_list( advertising_peer_address_type_t advertiser_address_type, const address_t &advertiser_address, uint8_t advertising_sid - ); + ) final; - ble_error_t clear_periodic_advertiser_list(); + ble_error_t clear_periodic_advertiser_list() final; - uint8_t read_periodic_advertiser_list_size(); + uint8_t read_periodic_advertiser_list_size() final; ble_error_t extended_create_connection( initiator_policy_t initiator_policy, @@ -312,9 +316,9 @@ class PalGap : public interface::PalGap { const uint16_t *supervision_timeouts, const uint16_t *minimum_connection_event_lengths, const uint16_t *maximum_connection_event_lengths - ); + ) final; - void when_gap_event_received(mbed::Callback cb); + void when_gap_event_received(mbed::Callback cb) final; /** * Sets the event handler that us called by the PAL porters to notify the stack of events @@ -323,9 +327,9 @@ class PalGap : public interface::PalGap { * @param[in] event_handler the new event handler interface implementation. Memory * owned by caller who is responsible for updating this pointer if interface changes. */ - void set_event_handler(PalGapEventHandler *event_handler); + void set_event_handler(PalGapEventHandler *event_handler) final; - PalGapEventHandler *get_event_handler(); + PalGapEventHandler *get_event_handler() final; private: /** @@ -345,14 +349,15 @@ class PalGap : public interface::PalGap { * T shall define a can_convert and convert function and a type */ template - static bool event_handler(const wsfMsgHdr_t* msg); + static bool event_handler(const wsfMsgHdr_t *msg); /** * Traits defining can_convert for events. */ template struct MessageConverter { - static bool can_convert(const wsfMsgHdr_t* msg) { + static bool can_convert(const wsfMsgHdr_t *msg) + { if (msg->event == EventID) { return true; } @@ -360,10 +365,11 @@ class PalGap : public interface::PalGap { } }; - struct ConnectionCompleteMessageConverter : public MessageConverter { + struct ConnectionCompleteMessageConverter final : public MessageConverter { typedef hciLeConnCmplEvt_t type; - static GapConnectionCompleteEvent convert(const hciLeConnCmplEvt_t* conn_evt) { + static GapConnectionCompleteEvent convert(const hciLeConnCmplEvt_t *conn_evt) + { return GapConnectionCompleteEvent( conn_evt->status, // note the usage of the stack handle, not the HCI handle @@ -380,28 +386,30 @@ class PalGap : public interface::PalGap { } }; - struct GapAdvertisingReportMessageConverter : public MessageConverter { + struct GapAdvertisingReportMessageConverter final : public MessageConverter { typedef hciLeAdvReportEvt_t type; - struct CordioGapAdvertisingReportEvent : public GapAdvertisingReportEvent { - CordioGapAdvertisingReportEvent(const advertising_t& advertising) : - GapAdvertisingReportEvent(), advertising(advertising) { + struct CordioGapAdvertisingReportEvent final : public GapAdvertisingReportEvent { + CordioGapAdvertisingReportEvent(const advertising_t &advertising) : + GapAdvertisingReportEvent(), advertising(advertising) + { } - virtual ~CordioGapAdvertisingReportEvent() { } - - virtual uint8_t size() const { + uint8_t size() const final + { return 1; } - virtual advertising_t operator[](uint8_t i) const { + advertising_t operator[](uint8_t i) const final + { return advertising; } advertising_t advertising; }; - static CordioGapAdvertisingReportEvent convert(const hciLeAdvReportEvt_t *scan_report) { + static CordioGapAdvertisingReportEvent convert(const hciLeAdvReportEvt_t *scan_report) + { GapAdvertisingReportEvent::advertising_t advertising = { (received_advertising_type_t::type) scan_report->eventType, (connection_peer_address_type_t::type) scan_report->addrType, @@ -413,10 +421,11 @@ class PalGap : public interface::PalGap { } }; - struct DisconnectionMessageConverter : public MessageConverter { + struct DisconnectionMessageConverter final : public MessageConverter { typedef hciDisconnectCmplEvt_t type; - static GapDisconnectionCompleteEvent convert(const hciDisconnectCmplEvt_t* disc_evt) { + static GapDisconnectionCompleteEvent convert(const hciDisconnectCmplEvt_t *disc_evt) + { return GapDisconnectionCompleteEvent( disc_evt->status, // note the usage of the stack handle, not the HCI handle @@ -426,10 +435,11 @@ class PalGap : public interface::PalGap { } }; - struct ConnectionUpdateMessageConverter : public MessageConverter { + struct ConnectionUpdateMessageConverter final : public MessageConverter { typedef hciLeConnUpdateCmplEvt_t type; - static GapConnectionUpdateEvent convert(const hciLeConnUpdateCmplEvt_t* evt) { + static GapConnectionUpdateEvent convert(const hciLeConnUpdateCmplEvt_t *evt) + { return GapConnectionUpdateEvent( evt->status, evt->hdr.param, @@ -440,10 +450,11 @@ class PalGap : public interface::PalGap { } }; - struct RemoteConnectionParameterRequestMessageConverter : public MessageConverter { + struct RemoteConnectionParameterRequestMessageConverter final : public MessageConverter { typedef hciLeRemConnParamReqEvt_t type; - static GapRemoteConnectionParameterRequestEvent convert(const hciLeRemConnParamReqEvt_t* evt) { + static GapRemoteConnectionParameterRequestEvent convert(const hciLeRemConnParamReqEvt_t *evt) + { return GapRemoteConnectionParameterRequestEvent( evt->hdr.param, evt->intervalMin, @@ -467,7 +478,8 @@ class PalGap : public interface::PalGap { direct_adv_cb_t() : peer_address_type(advertising_peer_address_type_t::PUBLIC), state(free) - {} + { + } address_t peer_address; advertising_peer_address_type_t peer_address_type; @@ -484,15 +496,15 @@ class PalGap : public interface::PalGap { /* Predicate expect a const reference to a direct_adv_cb_t * It must returns true if the criteria are met and false otherwise. */ template - direct_adv_cb_t* get_adv_cb(const Predicate& predicate); + direct_adv_cb_t *get_adv_cb(const Predicate &predicate); - direct_adv_cb_t* get_running_direct_adv_cb(advertising_handle_t adv_handle); + direct_adv_cb_t *get_running_direct_adv_cb(advertising_handle_t adv_handle); - direct_adv_cb_t* get_running_conn_direct_adv_cb(connection_handle_t adv_handle); + direct_adv_cb_t *get_running_conn_direct_adv_cb(connection_handle_t adv_handle); - direct_adv_cb_t* get_pending_direct_adv_cb(advertising_handle_t adv_handle); + direct_adv_cb_t *get_pending_direct_adv_cb(advertising_handle_t adv_handle); - direct_adv_cb_t* get_free_direct_adv_cb(); + direct_adv_cb_t *get_free_direct_adv_cb(); ble_error_t update_direct_advertising_parameters( advertising_handle_t advertising_handle, @@ -523,7 +535,7 @@ class PalGap : public interface::PalGap { } private: - PalGapEventHandler* _pal_event_handler; + PalGapEventHandler *_pal_event_handler; address_t device_random_address; bool use_active_scanning; uint8_t extended_scan_type[3]; @@ -536,6 +548,7 @@ class PalGap : public interface::PalGap { mbed::Callback _gap_event_cb; }; +} // namespace impl } // ble #endif /* IMPL_PAL_GAP_ */ diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/source/PalGenericAccessServiceImpl.cpp b/connectivity/FEATURE_BLE/source/cordio/source/PalGenericAccessServiceImpl.cpp similarity index 89% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/source/PalGenericAccessServiceImpl.cpp rename to connectivity/FEATURE_BLE/source/cordio/source/PalGenericAccessServiceImpl.cpp index c828779879d..0e2fe68ab99 100644 --- a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/source/PalGenericAccessServiceImpl.cpp +++ b/connectivity/FEATURE_BLE/source/cordio/source/PalGenericAccessServiceImpl.cpp @@ -16,9 +16,11 @@ * limitations under the License. */ -#include "ble/internal/PalGenericAccessService.h" +#include "source/PalGenericAccessServiceImpl.h" +#include "source/GattServerImpl.h" namespace ble { +namespace impl { #if 0 // Disabled until reworked and reintroduced to GattServer API @@ -90,7 +92,7 @@ virtual ble_error_t PalGenericAccessService::get_device_name_length(uint8_t& len ble_error_t PalGenericAccessService::get_peripheral_preferred_connection_parameters( - ble::Gap::PreferredConnectionParams_t& parameters + ble::Gap::PreferredConnectionParams_t ¶meters ) { #if BLE_FEATURE_GATT_SERVER @@ -102,7 +104,7 @@ ble_error_t PalGenericAccessService::get_peripheral_preferred_connection_paramet } ble_error_t PalGenericAccessService::set_peripheral_preferred_connection_parameters( - const ble::Gap::PreferredConnectionParams_t& parameters + const ble::Gap::PreferredConnectionParams_t ¶meters ) { #if BLE_FEATURE_GATT_SERVER @@ -115,11 +117,15 @@ ble_error_t PalGenericAccessService::set_peripheral_preferred_connection_paramet #if BLE_FEATURE_GATT_SERVER -ble::GattServer& PalGenericAccessService::gatt_server() + +ble::impl::GattServer &PalGenericAccessService::gatt_server() { - return ble::GattServer::getInstance(); + return ble::impl::GattServer::getInstance(); } -} // ble - #endif // BLE_FEATURE_GATT_SERVER + +} // namespace impl +} // namespace ble + + diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/include/ble/internal/PalGenericAccessServiceImpl.h b/connectivity/FEATURE_BLE/source/cordio/source/PalGenericAccessServiceImpl.h similarity index 71% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/include/ble/internal/PalGenericAccessServiceImpl.h rename to connectivity/FEATURE_BLE/source/cordio/source/PalGenericAccessServiceImpl.h index 58a647e37f0..86b3531d61c 100644 --- a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/include/ble/internal/PalGenericAccessServiceImpl.h +++ b/connectivity/FEATURE_BLE/source/cordio/source/PalGenericAccessServiceImpl.h @@ -19,20 +19,23 @@ #ifndef IMPL_PAL_GENERIC_ACCESS_SERVICE_ #define IMPL_PAL_GENERIC_ACCESS_SERVICE_ -#include "ble/internal/PalGenericAccessService.h" -#include "ble/GattServer.h" +#include "source/pal/PalGenericAccessService.h" #include "ble/Gap.h" namespace ble { +namespace impl { +class GattServer; +} +namespace impl { /** * Implementation of ble::PalGenericAccessService for the Cordio stack. */ -class PalGenericAccessService : public interface::PalGenericAccessService { +class PalGenericAccessService final : public ble::PalGenericAccessService { public: - PalGenericAccessService() { } + PalGenericAccessService() = default; - virtual ~PalGenericAccessService() { } + ~PalGenericAccessService() = default; #if 0 // Disabled until reworked and reintroduced to GattServer API virtual ble_error_t get_device_name_length(uint8_t& length); @@ -42,20 +45,23 @@ class PalGenericAccessService : public interface::PalGenericAccessService { virtual ble_error_t set_appearance(GapAdvertisingData::Appearance appearance); #endif // Disabled until reworked and reintroduced to GattServer API - virtual ble_error_t get_peripheral_preferred_connection_parameters( - ble::Gap::PreferredConnectionParams_t& parameters - ); + ble_error_t get_peripheral_preferred_connection_parameters( + ble::Gap::PreferredConnectionParams_t ¶meters + ) final; - virtual ble_error_t set_peripheral_preferred_connection_parameters( - const ble::Gap::PreferredConnectionParams_t& parameters - ); + ble_error_t set_peripheral_preferred_connection_parameters( + const ble::Gap::PreferredConnectionParams_t ¶meters + ) final; private: #if BLE_FEATURE_GATT_SERVER - ble::GattServer& gatt_server(); + + ble::impl::GattServer &gatt_server(); + #endif // BLE_FEATURE_GATT_SERVER }; -} // ble +} // namespace impl +} // namespace ble #endif /* IMPL_PAL_GENERIC_ACCESS_SERVICE_ */ diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/source/PalSecurityManagerImpl.cpp b/connectivity/FEATURE_BLE/source/cordio/source/PalSecurityManagerImpl.cpp similarity index 83% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/source/PalSecurityManagerImpl.cpp rename to connectivity/FEATURE_BLE/source/cordio/source/PalSecurityManagerImpl.cpp index 84ab4e37579..83094d06e91 100644 --- a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/source/PalSecurityManagerImpl.cpp +++ b/connectivity/FEATURE_BLE/source/cordio/source/PalSecurityManagerImpl.cpp @@ -16,13 +16,12 @@ * limitations under the License. */ -#include "BLERoles.h" +#include -#include - -#include "ble/common/ble/blecommon.h" -#include "ble/internal/PalSecurityManager.h" -#include "ble/internal/PalAttClient.h" +#include "ble/common/BLERoles.h" +#include "ble/common/blecommon.h" +#include "source/PalSecurityManagerImpl.h" +#include "source/PalAttClientImpl.h" #include "dm_api.h" #include "att_api.h" #include "smp_api.h" @@ -30,6 +29,7 @@ #include "hci_core.h" namespace ble { +namespace impl { PalSecurityManager::PalSecurityManager() : _pal_event_handler(nullptr), @@ -113,8 +113,7 @@ ble_error_t PalSecurityManager::add_device_to_resolving_list( const irk_t &peer_irk ) { - if( read_resolving_list_capacity() == 0 ) - { + if (read_resolving_list_capacity() == 0) { // If 0 is returned as capacity, it means the controller does not support resolving addresses return BLE_ERROR_NOT_IMPLEMENTED; } @@ -128,11 +127,10 @@ ble_error_t PalSecurityManager::add_device_to_resolving_list( ble_error_t PalSecurityManager::remove_device_from_resolving_list( advertising_peer_address_type_t peer_identity_address_type, - const address_t& peer_identity_address + const address_t &peer_identity_address ) { - if( read_resolving_list_capacity() == 0 ) - { + if (read_resolving_list_capacity() == 0) { // If 0 is returned as capacity, it means the controller does not support resolving addresses return BLE_ERROR_NOT_IMPLEMENTED; } @@ -146,8 +144,7 @@ ble_error_t PalSecurityManager::remove_device_from_resolving_list( ble_error_t PalSecurityManager::clear_resolving_list() { - if( read_resolving_list_capacity() == 0 ) - { + if (read_resolving_list_capacity() == 0) { // If 0 is returned as capacity, it means the controller does not support resolving addresses return BLE_ERROR_NOT_IMPLEMENTED; } @@ -255,7 +252,7 @@ ble_error_t PalSecurityManager::enable_encryption( bool mitm ) { - dmSecLtk_t sec_ltk = { 0 }; + dmSecLtk_t sec_ltk = {0}; memcpy(sec_ltk.key, ltk.data(), ltk.size()); DmSecEncryptReq( @@ -295,8 +292,8 @@ ble_error_t PalSecurityManager::set_private_address_timeout( */ ble_error_t PalSecurityManager::get_identity_address( - address_t& address, - bool& public_address + address_t &address, + bool &public_address ) { // On cordio, the public address is hardcoded as the identity address. @@ -312,7 +309,7 @@ ble_error_t PalSecurityManager::get_identity_address( ble_error_t PalSecurityManager::set_ltk( connection_handle_t connection, - const ltk_t& ltk, + const ltk_t <k, bool mitm, bool secure_connections ) @@ -320,7 +317,7 @@ ble_error_t PalSecurityManager::set_ltk( uint8_t security_level = DM_SEC_LEVEL_NONE; if (secure_connections) { security_level = DM_SEC_LEVEL_ENC_LESC; - } else if(mitm) { + } else if (mitm) { security_level = DM_SEC_LEVEL_ENC_AUTH; } else { security_level = DM_SEC_LEVEL_ENC; @@ -330,7 +327,7 @@ ble_error_t PalSecurityManager::set_ltk( connection, /* key found */ true, /* sec level */ security_level, - const_cast(ltk.data()) + const_cast(ltk.data()) ); return BLE_ERROR_NONE; } @@ -351,7 +348,7 @@ ble_error_t PalSecurityManager::set_ltk_not_found( } -ble_error_t PalSecurityManager::set_irk(const irk_t& irk) +ble_error_t PalSecurityManager::set_irk(const irk_t &irk) { _irk = irk; DmSecSetLocalIrk(_irk.data()); @@ -360,14 +357,14 @@ ble_error_t PalSecurityManager::set_irk(const irk_t& irk) ble_error_t PalSecurityManager::set_csrk( - const csrk_t& csrk, + const csrk_t &csrk, sign_count_t sign_counter ) { _csrk = csrk; DmSecSetLocalCsrk(_csrk.data()); // extra set the sign counter used by the client - PalAttClient::get_client().set_sign_counter(sign_counter); + impl::PalAttClient::get_client().set_sign_counter(sign_counter); return BLE_ERROR_NONE; } @@ -389,7 +386,7 @@ ble_error_t PalSecurityManager::set_peer_csrk( if (_peer_csrks[connection_index]) { *_peer_csrks[connection_index] = csrk; } else { - _peer_csrks[connection_index] = new (std::nothrow) csrk_t(csrk); + _peer_csrks[connection_index] = new(std::nothrow) csrk_t(csrk); if (_peer_csrks[connection_index] == nullptr) { return BLE_ERROR_NO_MEM; } @@ -530,7 +527,7 @@ ble_error_t PalSecurityManager::passkey_request_reply( DmSecAuthRsp( connection, /* datalength */ 3, - reinterpret_cast(&passkey) + reinterpret_cast(&passkey) ); return BLE_ERROR_NONE; @@ -545,7 +542,7 @@ ble_error_t PalSecurityManager::legacy_pairing_oob_request_reply( DmSecAuthRsp( connection, /* data length */16, - const_cast(oob_data.data()) + const_cast(oob_data.data()) ); return BLE_ERROR_NONE; @@ -573,7 +570,6 @@ ble_error_t PalSecurityManager::send_keypress_notification( } - ble_error_t PalSecurityManager::generate_secure_connections_oob() { uint8_t oobLocalRandom[SMP_RAND_LEN]; @@ -590,7 +586,7 @@ ble_error_t PalSecurityManager::secure_connections_oob_request_reply( const oob_confirm_t &peer_confirm ) { - dmSecLescOobCfg_t oob_config = { 0 }; + dmSecLescOobCfg_t oob_config = {0}; memcpy(oob_config.localRandom, local_random.data(), local_random.size()); // FIXME: @@ -605,17 +601,17 @@ ble_error_t PalSecurityManager::secure_connections_oob_request_reply( } -PalSecurityManager& PalSecurityManager::get_security_manager() +PalSecurityManager &PalSecurityManager::get_security_manager() { static PalSecurityManager _security_manager; return _security_manager; } -bool PalSecurityManager::sm_handler(const wsfMsgHdr_t* msg) +bool PalSecurityManager::sm_handler(const wsfMsgHdr_t *msg) { - PalSecurityManager& self = get_security_manager(); - PalSecurityManagerEventHandler* handler = self.get_event_handler(); + PalSecurityManager &self = get_security_manager(); + PalSecurityManagerEventHandler *handler = self.get_event_handler(); if ((msg == nullptr) || (handler == nullptr)) { return false; @@ -623,7 +619,7 @@ bool PalSecurityManager::sm_handler(const wsfMsgHdr_t* msg) switch (msg->event) { case DM_SEC_PAIR_CMPL_IND: { - dmSecPairCmplIndEvt_t* evt = (dmSecPairCmplIndEvt_t*) msg; + auto *evt = (dmSecPairCmplIndEvt_t *) msg; // Note: authentication and bonding flags present in the auth field handler->on_pairing_completed(evt->hdr.param); return true; @@ -658,7 +654,7 @@ bool PalSecurityManager::sm_handler(const wsfMsgHdr_t* msg) } case DM_SEC_ENCRYPT_IND: { - dmSecEncryptIndEvt_t* evt = (dmSecEncryptIndEvt_t*) msg; + auto *evt = (dmSecEncryptIndEvt_t *) msg; // note: the field usingLtk of the message indicates if an LTK was // used to encrypt the link // FIXME: How to indicate the level of encryption ? @@ -673,7 +669,7 @@ bool PalSecurityManager::sm_handler(const wsfMsgHdr_t* msg) } case DM_SEC_AUTH_REQ_IND: { - dmSecAuthReqIndEvt_t* evt = (dmSecAuthReqIndEvt_t*) msg; + auto *evt = (dmSecAuthReqIndEvt_t *) msg; connection_handle_t connection = evt->hdr.param; if (evt->oob) { @@ -692,7 +688,7 @@ bool PalSecurityManager::sm_handler(const wsfMsgHdr_t* msg) DmSecAuthRsp( connection, /* data length */ SMP_PIN_LEN, - reinterpret_cast(&(get_security_manager()._default_passkey)) + reinterpret_cast(&(get_security_manager()._default_passkey)) ); } else { /* generate random passkey, limit to 6 digit max */ @@ -701,7 +697,7 @@ bool PalSecurityManager::sm_handler(const wsfMsgHdr_t* msg) passkey %= 1000000; handler->on_passkey_display(connection, passkey); DmSecAuthRsp( - connection, SMP_PIN_LEN, reinterpret_cast(&passkey) + connection, SMP_PIN_LEN, reinterpret_cast(&passkey) ); } } else { @@ -712,19 +708,19 @@ bool PalSecurityManager::sm_handler(const wsfMsgHdr_t* msg) case DM_SEC_KEY_IND: { // NOTE: also report security level and encryption key len - dmSecKeyIndEvt_t* evt = (dmSecKeyIndEvt_t*) msg; + auto *evt = (dmSecKeyIndEvt_t *) msg; connection_handle_t connection = evt->hdr.param; - switch(evt->type) { + switch (evt->type) { case DM_KEY_LOCAL_LTK: handler->on_keys_distributed_local_ltk( connection, - ltk_t(reinterpret_cast(evt->keyData.ltk.key)) + ltk_t(reinterpret_cast(evt->keyData.ltk.key)) ); handler->on_keys_distributed_local_ediv_rand( connection, - ediv_t(reinterpret_cast(&(evt->keyData.ltk.ediv))), + ediv_t(reinterpret_cast(&(evt->keyData.ltk.ediv))), evt->keyData.ltk.rand ); break; @@ -732,12 +728,12 @@ bool PalSecurityManager::sm_handler(const wsfMsgHdr_t* msg) case DM_KEY_PEER_LTK: handler->on_keys_distributed_ltk( connection, - ltk_t(reinterpret_cast(evt->keyData.ltk.key)) + ltk_t(reinterpret_cast(evt->keyData.ltk.key)) ); handler->on_keys_distributed_ediv_rand( connection, - ediv_t(reinterpret_cast(&(evt->keyData.ltk.ediv))), + ediv_t(reinterpret_cast(&(evt->keyData.ltk.ediv))), evt->keyData.ltk.rand ); break; @@ -751,7 +747,7 @@ bool PalSecurityManager::sm_handler(const wsfMsgHdr_t* msg) handler->on_keys_distributed_irk( connection, - irk_t(reinterpret_cast(evt->keyData.irk.key)) + irk_t(reinterpret_cast(evt->keyData.irk.key)) ); break; #endif // BLE_FEATURE_PRIVACY @@ -768,8 +764,8 @@ bool PalSecurityManager::sm_handler(const wsfMsgHdr_t* msg) } case DM_SEC_LTK_REQ_IND: { - uint8_t null_rand[HCI_RAND_LEN] = { 0 }; - hciLeLtkReqEvt_t* evt = (hciLeLtkReqEvt_t*) msg; + uint8_t null_rand[HCI_RAND_LEN] = {0}; + auto *evt = (hciLeLtkReqEvt_t *) msg; if (evt->encDiversifier == 0 && memcmp(evt->randNum, null_rand, sizeof(null_rand))) { @@ -779,7 +775,7 @@ bool PalSecurityManager::sm_handler(const wsfMsgHdr_t* msg) } else { handler->on_ltk_request( evt->hdr.param, - reinterpret_cast(&evt->encDiversifier), + reinterpret_cast(&evt->encDiversifier), evt->randNum ); } @@ -787,7 +783,7 @@ bool PalSecurityManager::sm_handler(const wsfMsgHdr_t* msg) } case DM_SEC_PAIR_IND: { - dmSecPairIndEvt_t* evt = (dmSecPairIndEvt_t*) msg; + auto *evt = (dmSecPairIndEvt_t *) msg; handler->on_pairing_request( /* connection */ evt->hdr.param, evt->oob, @@ -799,7 +795,7 @@ bool PalSecurityManager::sm_handler(const wsfMsgHdr_t* msg) } case DM_SEC_SLAVE_REQ_IND: { - dmSecPairIndEvt_t* evt = (dmSecPairIndEvt_t*) msg; + auto *evt = (dmSecPairIndEvt_t *) msg; handler->on_slave_security_request( /* connection */ evt->hdr.param, evt->auth @@ -808,7 +804,7 @@ bool PalSecurityManager::sm_handler(const wsfMsgHdr_t* msg) } case DM_SEC_CALC_OOB_IND: { - dmSecOobCalcIndEvt_t* evt = (dmSecOobCalcIndEvt_t*) msg; + auto *evt = (dmSecOobCalcIndEvt_t *) msg; handler->on_secure_connections_oob_generated( evt->random, evt->confirm @@ -818,7 +814,7 @@ bool PalSecurityManager::sm_handler(const wsfMsgHdr_t* msg) #if BLE_FEATURE_SECURE_CONNECTIONS case DM_SEC_ECC_KEY_IND: { - secEccMsg_t* evt = (secEccMsg_t*) msg; + auto *evt = (secEccMsg_t *) msg; DmSecSetEccKey(&evt->data.key); memcpy(self._public_key_x, evt->data.key.pubKey_x, sizeof(self._public_key_x)); self._lesc_keys_generated = true; @@ -827,7 +823,7 @@ bool PalSecurityManager::sm_handler(const wsfMsgHdr_t* msg) #endif // BLE_FEATURE_SECURE_CONNECTIONS case DM_SEC_COMPARE_IND: { - dmSecCnfIndEvt_t* evt = (dmSecCnfIndEvt_t*) msg; + auto *evt = (dmSecCnfIndEvt_t *) msg; handler->on_passkey_display( /* connection */ evt->hdr.param, DmSecGetCompareValue(evt->confirm) @@ -837,7 +833,7 @@ bool PalSecurityManager::sm_handler(const wsfMsgHdr_t* msg) } case DM_SEC_KEYPRESS_IND: { - dmSecKeypressIndEvt_t* evt = (dmSecKeypressIndEvt_t*) msg; + auto *evt = (dmSecKeypressIndEvt_t *) msg; handler->on_keypress_notification( /* connection */ evt->hdr.param, (ble::Keypress_t) evt->notificationType @@ -846,7 +842,7 @@ bool PalSecurityManager::sm_handler(const wsfMsgHdr_t* msg) } #if BLE_FEATURE_PRIVACY - // Privacy + // Privacy case DM_PRIV_ADD_DEV_TO_RES_LIST_IND: // Device added to resolving list case DM_PRIV_REM_DEV_FROM_RES_LIST_IND: // Device removed from resolving list case DM_PRIV_CLEAR_RES_LIST_IND: // Resolving list cleared @@ -862,43 +858,44 @@ bool PalSecurityManager::sm_handler(const wsfMsgHdr_t* msg) } -struct PalSecurityManager::PrivacyControlBlock -{ - PrivacyControlBlock() : _next(nullptr) {} +struct PalSecurityManager::PrivacyControlBlock { + PrivacyControlBlock() : _next(nullptr) + { + } - virtual ~PrivacyControlBlock() {} + virtual ~PrivacyControlBlock() = default; virtual void execute() = 0; - void set_next(PrivacyControlBlock* next) { + void set_next(PrivacyControlBlock *next) + { _next = next; } - PrivacyControlBlock* next() const { + PrivacyControlBlock *next() const + { return _next; } private: - PrivacyControlBlock* _next; + PrivacyControlBlock *_next; }; -struct PalSecurityManager::PrivacyClearResListControlBlock : PalSecurityManager::PrivacyControlBlock -{ +struct PalSecurityManager::PrivacyClearResListControlBlock final : PalSecurityManager::PrivacyControlBlock { PrivacyClearResListControlBlock() : PrivacyControlBlock() - {} - - virtual ~PrivacyClearResListControlBlock() {} + { + } - virtual void execute() { + void execute() final + { // Execute command DmPrivClearResList(); } }; -struct PalSecurityManager::PrivacyAddDevToResListControlBlock : PalSecurityManager::PrivacyControlBlock -{ +struct PalSecurityManager::PrivacyAddDevToResListControlBlock final : PalSecurityManager::PrivacyControlBlock { PrivacyAddDevToResListControlBlock( advertising_peer_address_type_t peer_identity_address_type, const address_t &peer_identity_address, @@ -907,13 +904,20 @@ struct PalSecurityManager::PrivacyAddDevToResListControlBlock : PalSecurityManag _peer_identity_address_type(peer_identity_address_type), _peer_identity_address(peer_identity_address), _peer_irk(peer_irk) - {} - - virtual ~PrivacyAddDevToResListControlBlock() {} + { + } - virtual void execute() { + void execute() final + { // Execute command - DmPrivAddDevToResList(_peer_identity_address_type.value(), _peer_identity_address.data(), _peer_irk.data(), DmSecGetLocalIrk(), false, 0); + DmPrivAddDevToResList( + _peer_identity_address_type.value(), + _peer_identity_address.data(), + _peer_irk.data(), + DmSecGetLocalIrk(), + false, + 0 + ); } private: @@ -923,8 +927,7 @@ struct PalSecurityManager::PrivacyAddDevToResListControlBlock : PalSecurityManag }; -struct PalSecurityManager::PrivacyRemoveDevFromResListControlBlock : PalSecurityManager::PrivacyControlBlock -{ +struct PalSecurityManager::PrivacyRemoveDevFromResListControlBlock final : PalSecurityManager::PrivacyControlBlock { PrivacyRemoveDevFromResListControlBlock( advertising_peer_address_type_t peer_identity_address_type, const address_t &peer_identity_address @@ -935,9 +938,8 @@ struct PalSecurityManager::PrivacyRemoveDevFromResListControlBlock : PalSecurity } - virtual ~PrivacyRemoveDevFromResListControlBlock() {} - - virtual void execute() { + void execute() final + { // Execute command DmPrivRemDevFromResList(_peer_identity_address_type.value(), _peer_identity_address.data(), 0); } @@ -955,10 +957,12 @@ void PalSecurityManager::queue_add_device_to_resolving_list( const irk_t &peer_irk ) { - PrivacyAddDevToResListControlBlock* cb = - new (std::nothrow) PrivacyAddDevToResListControlBlock(peer_identity_address_type, peer_identity_address, peer_irk); - if( cb == nullptr ) - { + auto *cb = new(std::nothrow) PrivacyAddDevToResListControlBlock( + peer_identity_address_type, + peer_identity_address, + peer_irk + ); + if (cb == nullptr) { // Cannot go further return; } @@ -972,10 +976,11 @@ void PalSecurityManager::queue_remove_device_from_resolving_list( const address_t &peer_identity_address ) { - PrivacyRemoveDevFromResListControlBlock* cb = - new (std::nothrow) PrivacyRemoveDevFromResListControlBlock(peer_identity_address_type, peer_identity_address); - if( cb == nullptr ) - { + auto *cb = new(std::nothrow) PrivacyRemoveDevFromResListControlBlock( + peer_identity_address_type, + peer_identity_address + ); + if (cb == nullptr) { // Cannot go further return; } @@ -989,10 +994,8 @@ void PalSecurityManager::queue_clear_resolving_list() // Remove any pending control blocks, there's no point executing them as we're about to queue the list clear_privacy_control_blocks(); - PrivacyClearResListControlBlock* cb = - new (std::nothrow) PrivacyClearResListControlBlock(); - if( cb == nullptr ) - { + auto *cb = new(std::nothrow) PrivacyClearResListControlBlock(); + if (cb == nullptr) { // Cannot go further return; } @@ -1003,23 +1006,21 @@ void PalSecurityManager::queue_clear_resolving_list() void PalSecurityManager::clear_privacy_control_blocks() { - while(_pending_privacy_control_blocks != nullptr) - { - PrivacyControlBlock* next = _pending_privacy_control_blocks->next(); + while (_pending_privacy_control_blocks != nullptr) { + PrivacyControlBlock *next = _pending_privacy_control_blocks->next(); delete _pending_privacy_control_blocks; _pending_privacy_control_blocks = next; } } -void PalSecurityManager::queue_privacy_control_block(PrivacyControlBlock* block) +void PalSecurityManager::queue_privacy_control_block(PrivacyControlBlock *block) { - if( _pending_privacy_control_blocks == nullptr ) { + if (_pending_privacy_control_blocks == nullptr) { _pending_privacy_control_blocks = block; - } - else { - PrivacyControlBlock* node = _pending_privacy_control_blocks; - while(node->next() != nullptr) { + } else { + PrivacyControlBlock *node = _pending_privacy_control_blocks; + while (node->next() != nullptr) { node = node->next(); } node->set_next(block); @@ -1032,14 +1033,13 @@ void PalSecurityManager::queue_privacy_control_block(PrivacyControlBlock* block) void PalSecurityManager::process_privacy_control_blocks(bool cb_completed) { - if( (_processing_privacy_control_block == true) && !cb_completed ) - { + if ((_processing_privacy_control_block == true) && !cb_completed) { // Busy, cannot process next control block for now return; } - PrivacyControlBlock* cb = _pending_privacy_control_blocks; - if(cb == nullptr) { + PrivacyControlBlock *cb = _pending_privacy_control_blocks; + if (cb == nullptr) { // All control blocks processed _processing_privacy_control_block = false; return; @@ -1048,7 +1048,7 @@ void PalSecurityManager::process_privacy_control_blocks(bool cb_completed) // Process next block and free it _processing_privacy_control_block = true; - PrivacyControlBlock* next = cb->next(); + PrivacyControlBlock *next = cb->next(); cb->execute(); delete cb; _pending_privacy_control_blocks = next; @@ -1057,23 +1057,25 @@ void PalSecurityManager::process_privacy_control_blocks(bool cb_completed) void PalSecurityManager::cleanup_peer_csrks() { - for (size_t i = 0; i < DM_CONN_MAX; ++i) { - if (_peer_csrks[i]) { - delete _peer_csrks[i]; - _peer_csrks[i] = nullptr; + for (auto & peer_csrk : _peer_csrks) { + if (peer_csrk) { + delete peer_csrk; + peer_csrk = nullptr; } } } -void PalSecurityManager::set_event_handler(PalSecurityManagerEventHandler *event_handler +void PalSecurityManager::set_event_handler( + PalSecurityManagerEventHandler *event_handler ) { _pal_event_handler = event_handler; } -PalSecurityManagerEventHandler* PalSecurityManager::get_event_handler() +PalSecurityManagerEventHandler *PalSecurityManager::get_event_handler() { return _pal_event_handler; } -} // ble +} // namespace impl +} // namespace ble diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/include/ble/internal/PalSecurityManagerImpl.h b/connectivity/FEATURE_BLE/source/cordio/source/PalSecurityManagerImpl.h similarity index 87% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/include/ble/internal/PalSecurityManagerImpl.h rename to connectivity/FEATURE_BLE/source/cordio/source/PalSecurityManagerImpl.h index 8086df7fa76..95cca71034b 100644 --- a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/include/ble/internal/PalSecurityManagerImpl.h +++ b/connectivity/FEATURE_BLE/source/cordio/source/PalSecurityManagerImpl.h @@ -19,8 +19,8 @@ #ifndef IMPL_PAL_SECURITY_MANAGER_ #define IMPL_PAL_SECURITY_MANAGER_ -#include "ble/internal/PalSecurityManager.h" -#include "ble/common/ble/blecommon.h" +#include "source/pal/PalSecurityManager.h" +#include "ble/common/blecommon.h" #include "wsf_types.h" #include "wsf_os.h" #include "sec_api.h" @@ -28,10 +28,11 @@ #include "cfg_stack.h" namespace ble { +namespace impl { class BLEInstanceBase; -class PalSecurityManager : public interface::PalSecurityManager { +class PalSecurityManager final : public ble::PalSecurityManager { friend BLEInstanceBase; public: @@ -46,17 +47,17 @@ class PalSecurityManager : public interface::PalSecurityManager { /** * @see ::ble::PalSecurityManager::initialize */ - ble_error_t initialize(); + ble_error_t initialize() final; /** * @see ::ble::PalSecurityManager::terminate */ - ble_error_t terminate(); + ble_error_t terminate() final; /** * @see ::ble::PalSecurityManager::reset */ - ble_error_t reset(); + ble_error_t reset() final; //////////////////////////////////////////////////////////////////////////// // Resolving list management @@ -65,7 +66,7 @@ class PalSecurityManager : public interface::PalSecurityManager { /** * @see ::ble::PalSecurityManager::read_resolving_list_capacity */ - uint8_t read_resolving_list_capacity(); + uint8_t read_resolving_list_capacity() final; /** * @see ::ble::PalSecurityManager::add_device_to_resolving_list @@ -74,7 +75,7 @@ class PalSecurityManager : public interface::PalSecurityManager { advertising_peer_address_type_t peer_identity_address_type, const address_t &peer_identity_address, const irk_t &peer_irk - ); + ) final; /** * @see ::ble::PalSecurityManager::remove_device_from_resolving_list @@ -82,12 +83,12 @@ class PalSecurityManager : public interface::PalSecurityManager { ble_error_t remove_device_from_resolving_list( advertising_peer_address_type_t peer_identity_address_type, const address_t &peer_identity_address - ); + ) final; /** * @see ::ble::PalSecurityManager::clear_resolving_list */ - ble_error_t clear_resolving_list(); + ble_error_t clear_resolving_list() final; //////////////////////////////////////////////////////////////////////////// // Pairing @@ -102,7 +103,7 @@ class PalSecurityManager : public interface::PalSecurityManager { AuthenticationMask authentication_requirements, KeyDistribution initiator_dist, KeyDistribution responder_dist - ); + ) final; /** * @see ::ble::PalSecurityManager::send_pairing_response @@ -113,14 +114,14 @@ class PalSecurityManager : public interface::PalSecurityManager { AuthenticationMask authentication_requirements, KeyDistribution initiator_dist, KeyDistribution responder_dist - ); + ) final; /** * @see ::ble::PalSecurityManager::cancel_pairing */ ble_error_t cancel_pairing( connection_handle_t connection, pairing_failure_t reason - ); + ) final; //////////////////////////////////////////////////////////////////////////// // Feature support @@ -131,12 +132,12 @@ class PalSecurityManager : public interface::PalSecurityManager { */ ble_error_t get_secure_connections_support( bool &enabled - ); + ) final; /** * @see ::ble::PalSecurityManager::set_io_capability */ - ble_error_t set_io_capability(io_capability_t io_capability); + ble_error_t set_io_capability(io_capability_t io_capability) final; //////////////////////////////////////////////////////////////////////////// // Security settings @@ -147,14 +148,14 @@ class PalSecurityManager : public interface::PalSecurityManager { */ ble_error_t set_authentication_timeout( connection_handle_t, uint16_t timeout_in_10ms - ); + ) final; /** * @see ::ble::PalSecurityManager::get_authentication_timeout */ ble_error_t get_authentication_timeout( connection_handle_t, uint16_t &timeout_in_10ms - ); + ) final; /** * @see ::ble::PalSecurityManager::set_encryption_key_requirements @@ -162,7 +163,7 @@ class PalSecurityManager : public interface::PalSecurityManager { ble_error_t set_encryption_key_requirements( uint8_t min_encryption_key_size, uint8_t max_encryption_key_size - ); + ) final; /** * @see ::ble::PalSecurityManager::slave_security_request @@ -170,7 +171,7 @@ class PalSecurityManager : public interface::PalSecurityManager { ble_error_t slave_security_request( connection_handle_t connection, AuthenticationMask authentication - ); + ) final; //////////////////////////////////////////////////////////////////////////// // Encryption @@ -185,7 +186,7 @@ class PalSecurityManager : public interface::PalSecurityManager { const rand_t &rand, const ediv_t &ediv, bool mitm - ); + ) final; /** * @see ::ble::PalSecurityManager::enable_encryption @@ -194,7 +195,7 @@ class PalSecurityManager : public interface::PalSecurityManager { connection_handle_t connection, const ltk_t <k, bool mitm - ); + ) final; /** * @see ::ble::PalSecurityManager::encrypt_data @@ -202,7 +203,7 @@ class PalSecurityManager : public interface::PalSecurityManager { ble_error_t encrypt_data( const byte_array_t<16> &key, encryption_block_t &data - ); + ) final; //////////////////////////////////////////////////////////////////////////// // Privacy @@ -211,12 +212,12 @@ class PalSecurityManager : public interface::PalSecurityManager { /** * @see ::ble::PalSecurityManager::set_private_address_timeout */ - ble_error_t set_private_address_timeout(uint16_t timeout_in_seconds); + ble_error_t set_private_address_timeout(uint16_t timeout_in_seconds) final; /** * @see ::ble::PalSecurityManager::get_identity_address */ - ble_error_t get_identity_address(address_t& address, bool& public_address); + ble_error_t get_identity_address(address_t &address, bool &public_address) final; //////////////////////////////////////////////////////////////////////////// // Keys @@ -230,19 +231,19 @@ class PalSecurityManager : public interface::PalSecurityManager { const ltk_t <k, bool mitm, bool secure_connections - ); + ) final; /** * @see ::ble::PalSecurityManager::set_ltk_not_found */ ble_error_t set_ltk_not_found( connection_handle_t connection - ); + ) final; /** * @see ::ble::PalSecurityManager::set_irk */ - ble_error_t set_irk(const irk_t &irk); + ble_error_t set_irk(const irk_t &irk) final; /** * @see ::ble::PalSecurityManager::set_csrk @@ -250,7 +251,7 @@ class PalSecurityManager : public interface::PalSecurityManager { ble_error_t set_csrk( const csrk_t &csrk, sign_count_t sign_counter - ); + ) final; /** * @see ::ble::PalSecurityManager::set_peer_csrk @@ -260,9 +261,9 @@ class PalSecurityManager : public interface::PalSecurityManager { const csrk_t &csrk, bool authenticated, sign_count_t sign_counter - ); + ) final; - ble_error_t remove_peer_csrk(connection_handle_t connection); + ble_error_t remove_peer_csrk(connection_handle_t connection) final; //////////////////////////////////////////////////////////////////////////// // Authentication @@ -271,7 +272,7 @@ class PalSecurityManager : public interface::PalSecurityManager { /** * @see ::ble::PalSecurityManager::get_random_data */ - ble_error_t get_random_data(byte_array_t<8> &random_data); + ble_error_t get_random_data(byte_array_t<8> &random_data) final; //////////////////////////////////////////////////////////////////////////// // MITM @@ -280,7 +281,7 @@ class PalSecurityManager : public interface::PalSecurityManager { /** * @see ::ble::PalSecurityManager::set_display_passkey */ - ble_error_t set_display_passkey(passkey_num_t passkey); + ble_error_t set_display_passkey(passkey_num_t passkey) final; /** * @see ::ble::PalSecurityManager::passkey_request_reply @@ -288,7 +289,7 @@ class PalSecurityManager : public interface::PalSecurityManager { ble_error_t passkey_request_reply( connection_handle_t connection, passkey_num_t passkey - ); + ) final; /** * @see ::ble::PalSecurityManager::secure_connections_oob_request_reply @@ -298,7 +299,7 @@ class PalSecurityManager : public interface::PalSecurityManager { const oob_lesc_value_t &local_random, const oob_lesc_value_t &peer_random, const oob_confirm_t &peer_confirm - ); + ) final; /** * @see ::ble::PalSecurityManager::legacy_pairing_oob_request_reply @@ -306,43 +307,43 @@ class PalSecurityManager : public interface::PalSecurityManager { ble_error_t legacy_pairing_oob_request_reply( connection_handle_t connection, const oob_tk_t &oob_data - ); + ) final; /** * @see ::ble::PalSecurityManager::confirmation_entered */ ble_error_t confirmation_entered( connection_handle_t connection, bool confirmation - ); + ) final; /** * @see ::ble::PalSecurityManager::send_keypress_notification */ ble_error_t send_keypress_notification( connection_handle_t connection, ble::Keypress_t keypress - ); + ) final; /** * @see ::ble::PalSecurityManager::generate_secure_connections_oob */ - ble_error_t generate_secure_connections_oob(); + ble_error_t generate_secure_connections_oob() final; /** * @see ::ble::PalSecurityManager::set_event_handler */ - void set_event_handler(PalSecurityManagerEventHandler *event_handler); + void set_event_handler(PalSecurityManagerEventHandler *event_handler) final; /** * @see ::ble::PalSecurityManager::get_event_handler */ - PalSecurityManagerEventHandler* get_event_handler(); + PalSecurityManagerEventHandler *get_event_handler() final; -private: +public: /* used by the PAL to get the singleton */ static PalSecurityManager &get_security_manager(); /* used by PAL to handle security messages coming from the stack Event handler */ - static bool sm_handler(const wsfMsgHdr_t* msg); + static bool sm_handler(const wsfMsgHdr_t *msg); private: @@ -371,7 +372,7 @@ class PalSecurityManager : public interface::PalSecurityManager { void clear_privacy_control_blocks(); // Queue a control block - void queue_privacy_control_block(PrivacyControlBlock* block); + void queue_privacy_control_block(PrivacyControlBlock *block); // Try to dequeue and process the next control block // cb_completed is set when the previous block has completed @@ -379,20 +380,21 @@ class PalSecurityManager : public interface::PalSecurityManager { void cleanup_peer_csrks(); - PalSecurityManagerEventHandler* _pal_event_handler; + PalSecurityManagerEventHandler *_pal_event_handler; bool _use_default_passkey; passkey_num_t _default_passkey; bool _lesc_keys_generated; uint8_t _public_key_x[SEC_ECC_KEY_LEN]; - PrivacyControlBlock* _pending_privacy_control_blocks; + PrivacyControlBlock *_pending_privacy_control_blocks; bool _processing_privacy_control_block; irk_t _irk; csrk_t _csrk; - csrk_t* _peer_csrks[DM_CONN_MAX]; + csrk_t *_peer_csrks[DM_CONN_MAX]; }; -} // ble +} // namespace impl +} // namespace ble #endif /* IMPL_PAL_SECURITY_MANAGER_ */ diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack_adaptation/hci_mbed_os_adaptation.h b/connectivity/FEATURE_BLE/source/cordio/stack_adaptation/hci_mbed_os_adaptation.h similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack_adaptation/hci_mbed_os_adaptation.h rename to connectivity/FEATURE_BLE/source/cordio/stack_adaptation/hci_mbed_os_adaptation.h diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack_adaptation/hci_tr.c b/connectivity/FEATURE_BLE/source/cordio/stack_adaptation/hci_tr.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack_adaptation/hci_tr.c rename to connectivity/FEATURE_BLE/source/cordio/stack_adaptation/hci_tr.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack_adaptation/hci_vs.c b/connectivity/FEATURE_BLE/source/cordio/stack_adaptation/hci_vs.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack_adaptation/hci_vs.c rename to connectivity/FEATURE_BLE/source/cordio/stack_adaptation/hci_vs.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack_adaptation/pal_mbed_os_adaptation.cpp b/connectivity/FEATURE_BLE/source/cordio/stack_adaptation/pal_mbed_os_adaptation.cpp similarity index 96% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack_adaptation/pal_mbed_os_adaptation.cpp rename to connectivity/FEATURE_BLE/source/cordio/stack_adaptation/pal_mbed_os_adaptation.cpp index f1843cc62f1..3ef6aa6913d 100644 --- a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack_adaptation/pal_mbed_os_adaptation.cpp +++ b/connectivity/FEATURE_BLE/source/cordio/stack_adaptation/pal_mbed_os_adaptation.cpp @@ -14,12 +14,12 @@ * limitations under the License. */ -#include "mbed.h" -#include "stack/platform/include/pal_types.h" -#include "stack/platform/include/pal_uart.h" +#include "cordio_stack/platform/include/pal_types.h" +#include "cordio_stack/platform/include/pal_uart.h" #include "hal/ticker_api.h" -#include "mbed_critical.h" +#include "platform/mbed_critical.h" #include "pal_codec.h" +#include "platform/mbed_error.h" #ifdef __cplusplus extern "C" { diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack_adaptation/wsf_cs.c b/connectivity/FEATURE_BLE/source/cordio/stack_adaptation/wsf_cs.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack_adaptation/wsf_cs.c rename to connectivity/FEATURE_BLE/source/cordio/stack_adaptation/wsf_cs.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack_adaptation/wsf_mbed_os_adaptation.c b/connectivity/FEATURE_BLE/source/cordio/stack_adaptation/wsf_mbed_os_adaptation.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack_adaptation/wsf_mbed_os_adaptation.c rename to connectivity/FEATURE_BLE/source/cordio/stack_adaptation/wsf_mbed_os_adaptation.c diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack_adaptation/wsf_mbed_os_adaptation.h b/connectivity/FEATURE_BLE/source/cordio/stack_adaptation/wsf_mbed_os_adaptation.h similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack_adaptation/wsf_mbed_os_adaptation.h rename to connectivity/FEATURE_BLE/source/cordio/stack_adaptation/wsf_mbed_os_adaptation.h diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack_adaptation/wsf_os.c b/connectivity/FEATURE_BLE/source/cordio/stack_adaptation/wsf_os.c similarity index 100% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/stack_adaptation/wsf_os.c rename to connectivity/FEATURE_BLE/source/cordio/stack_adaptation/wsf_os.c diff --git a/connectivity/FEATURE_BLE/source/DiscoveredCharacteristic.cpp b/connectivity/FEATURE_BLE/source/gatt/DiscoveredCharacteristic.cpp similarity index 98% rename from connectivity/FEATURE_BLE/source/DiscoveredCharacteristic.cpp rename to connectivity/FEATURE_BLE/source/gatt/DiscoveredCharacteristic.cpp index d7575ab3aff..b018f9b9e63 100644 --- a/connectivity/FEATURE_BLE/source/DiscoveredCharacteristic.cpp +++ b/connectivity/FEATURE_BLE/source/gatt/DiscoveredCharacteristic.cpp @@ -16,7 +16,8 @@ * limitations under the License. */ -#include "ble/common/ble/DiscoveredCharacteristic.h" +#include "ble/BLE.h" +#include "ble/gatt/DiscoveredCharacteristic.h" #include "ble/GattClient.h" ble_error_t diff --git a/connectivity/FEATURE_BLE/source/FileSecurityDb.cpp b/connectivity/FEATURE_BLE/source/generic/FileSecurityDb.cpp similarity index 99% rename from connectivity/FEATURE_BLE/source/FileSecurityDb.cpp rename to connectivity/FEATURE_BLE/source/generic/FileSecurityDb.cpp index a693f610d95..abae3e70207 100644 --- a/connectivity/FEATURE_BLE/source/FileSecurityDb.cpp +++ b/connectivity/FEATURE_BLE/source/generic/FileSecurityDb.cpp @@ -18,7 +18,7 @@ #if BLE_SECURITY_DATABASE_FILESYSTEM -#include "ble/internal/FileSecurityDb.h" +#include "FileSecurityDb.h" namespace ble { diff --git a/connectivity/FEATURE_BLE/include/ble/internal/FileSecurityDb.h b/connectivity/FEATURE_BLE/source/generic/FileSecurityDb.h similarity index 99% rename from connectivity/FEATURE_BLE/include/ble/internal/FileSecurityDb.h rename to connectivity/FEATURE_BLE/source/generic/FileSecurityDb.h index 59e043774e2..f96a55385c7 100644 --- a/connectivity/FEATURE_BLE/include/ble/internal/FileSecurityDb.h +++ b/connectivity/FEATURE_BLE/source/generic/FileSecurityDb.h @@ -23,7 +23,7 @@ #include -#include "ble/internal/SecurityDb.h" +#include "SecurityDb.h" namespace ble { diff --git a/connectivity/FEATURE_BLE/libraries/ble-api-implementation/source/GapImpl.cpp b/connectivity/FEATURE_BLE/source/generic/GapImpl.cpp similarity index 95% rename from connectivity/FEATURE_BLE/libraries/ble-api-implementation/source/GapImpl.cpp rename to connectivity/FEATURE_BLE/source/generic/GapImpl.cpp index 593ee3aca31..e915802ab43 100644 --- a/connectivity/FEATURE_BLE/libraries/ble-api-implementation/source/GapImpl.cpp +++ b/connectivity/FEATURE_BLE/source/generic/GapImpl.cpp @@ -17,20 +17,21 @@ */ #include -#include +#include -#include "ble/Gap.h" -#include "ble/internal/BLEInstanceBase.h" #include "ble/Gap.h" #include "ble/SecurityManager.h" -#include "ble/internal/PalGap.h" -#include "ble/common/ble/GapEvents.h" -#include "ble/common/ble/GapTypes.h" -#include "ble/internal/PalGenericAccessService.h" -#include "ble/internal/PalEventQueue.h" -#include "ble/internal/PalGap.h" -#include "drivers/Timeout.h" +#include "source/BLEInstanceBase.h" +#include "source/generic/GapImpl.h" + +#include "source/pal/PalGap.h" +#include "source/pal/GapEvents.h" +#include "source/pal/GapTypes.h" +#include "source/pal/PalGenericAccessService.h" +#include "source/pal/PalEventQueue.h" +#include "source/pal/PalSecurityManager.h" + using namespace std::chrono; @@ -38,25 +39,26 @@ MBED_STATIC_ASSERT(BLE_GAP_MAX_ADVERTISING_SETS < 0xFF, "BLE_GAP_MAX_ADVERTISING MBED_STATIC_ASSERT(BLE_GAP_MAX_ADVERTISING_SETS > 0, "BLE_GAP_MAX_ADVERTISING_SETS must be a positive number"); namespace ble { +namespace impl { namespace { // Constants -static const uint16_t scan_interval_min = 0x0004; -static const uint16_t scan_interval_max = 0x4000; -static const uint16_t connection_interval_min = 0x0006; -static const uint16_t connection_interval_max = 0x0C80; -static const uint16_t slave_latency_min = 0x0000; -static const uint16_t slave_latency_max = 0x01F3; -static const uint16_t advertising_interval_min = 0x0020; -static const uint16_t advertising_interval_max = 0x4000; -static const uint16_t supervision_timeout_min = 0x000A; -static const uint16_t supervision_timeout_max = 0x0C80; - -static const mbed_error_status_t mixed_scan_api_error = +const uint16_t scan_interval_min = 0x0004; +const uint16_t scan_interval_max = 0x4000; +const uint16_t connection_interval_min = 0x0006; +const uint16_t connection_interval_max = 0x0C80; +const uint16_t slave_latency_min = 0x0000; +const uint16_t slave_latency_max = 0x01F3; +const uint16_t advertising_interval_min = 0x0020; +const uint16_t advertising_interval_max = 0x4000; +const uint16_t supervision_timeout_min = 0x000A; +const uint16_t supervision_timeout_max = 0x0C80; + +const mbed_error_status_t mixed_scan_api_error = MBED_MAKE_ERROR(MBED_MODULE_BLE, MBED_ERROR_CODE_BLE_USE_INCOMPATIBLE_API); -static const mbed_error_status_t illegal_state_error = +const mbed_error_status_t illegal_state_error = MBED_MAKE_ERROR(MBED_MODULE_BLE, MBED_ERROR_CODE_BLE_ILLEGAL_STATE); /* @@ -80,13 +82,13 @@ static bool is_in_range(T value, T lower_bound, T higher_bound) * timeout to be equal to 0xFFFF. When it is the case that value can be * interpreted as "non specific". */ -static bool is_preferred_connection_params_valid(const Gap::PreferredConnectionParams_t *params) +bool is_preferred_connection_params_valid(const Gap::PreferredConnectionParams_t *params) { if (params == nullptr) { return false; } - if (is_in_range(params->slaveLatency, slave_latency_min, slave_latency_max) == false) { + if (!is_in_range(params->slaveLatency, slave_latency_min, slave_latency_max) == false) { return false; } @@ -104,7 +106,10 @@ static bool is_preferred_connection_params_valid(const Gap::PreferredConnectionP return true; } - if ((is_in_range(params->connectionSupervisionTimeout, supervision_timeout_min, supervision_timeout_max) == false)) { + if (( + is_in_range(params->connectionSupervisionTimeout, supervision_timeout_min, supervision_timeout_max) == + false + )) { return false; } @@ -127,7 +132,7 @@ static bool is_preferred_connection_params_valid(const Gap::PreferredConnectionP /** * Check if random bytes of an address are valid. */ -static bool is_prand_valid(const uint8_t *bytes, size_t len) +bool is_prand_valid(const uint8_t *bytes, size_t len) { // at least one bit of the random part of the static address shall be // equal to 0 and at least one bit of the random part of the static @@ -158,7 +163,7 @@ static bool is_prand_valid(const uint8_t *bytes, size_t len) * or not. * Return true if it is the case and false otherwise. */ -static bool is_prand_48_bits_valid(const address_t &address) +bool is_prand_48_bits_valid(const address_t &address) { return is_prand_valid(address.data(), 6); } @@ -168,7 +173,7 @@ static bool is_prand_48_bits_valid(const address_t &address) * or not. * Return true if it is the case and false otherwise. */ -static bool is_prand_24_bits_valid(const address_t &address) +bool is_prand_24_bits_valid(const address_t &address) { return is_prand_valid(address.data() + 3, 3); } @@ -176,7 +181,7 @@ static bool is_prand_24_bits_valid(const address_t &address) /* * Return true if address is a random static address. */ -static bool is_random_static_address(const address_t &address) +bool is_random_static_address(const address_t &address) { // top two msb bits shall be equal to 0b11. if ((address[5] & 0xC0) != 0xC0) { @@ -189,7 +194,7 @@ static bool is_random_static_address(const address_t &address) /* * Return true if address is a random private non resolvable address. */ -static bool is_random_private_non_resolvable_address( +bool is_random_private_non_resolvable_address( const address_t &address ) { @@ -204,7 +209,7 @@ static bool is_random_private_non_resolvable_address( /* * Return true if address is a random private resolvable address. */ -static bool is_random_private_resolvable_address( +bool is_random_private_resolvable_address( const address_t &address ) { @@ -219,7 +224,7 @@ static bool is_random_private_resolvable_address( /* * Return true if the address is a random address. */ -static bool is_random_address(const address_t &address) +bool is_random_address(const address_t &address) { return is_random_private_resolvable_address(address) || is_random_private_non_resolvable_address(address) || @@ -229,7 +234,7 @@ static bool is_random_address(const address_t &address) /* * Return true if the whitelist in input is valid or false otherwise. */ -static bool is_whitelist_valid(const ::ble::whitelist_t &whitelist) +bool is_whitelist_valid(const ::ble::whitelist_t &whitelist) { if (whitelist.size > whitelist.capacity) { return false; @@ -261,7 +266,7 @@ static bool is_whitelist_valid(const ::ble::whitelist_t &whitelist) /* * Return true if device is present in the whitelist. */ -static bool is_in_whitelist( +bool is_in_whitelist( const whitelist_t::entry_t &device, const whitelist_t &whitelist ) { @@ -278,12 +283,14 @@ static bool is_in_whitelist( /* * Convert a peer_address_type_t into a whitelist_address_type_t. */ -static whitelist_address_type_t to_whitelist_address_type( +whitelist_address_type_t to_whitelist_address_type( peer_address_type_t address_type ) { - return (address_type == peer_address_type_t::PUBLIC - || address_type == peer_address_type_t::PUBLIC_IDENTITY) ? + return ( + address_type == peer_address_type_t::PUBLIC + || address_type == peer_address_type_t::PUBLIC_IDENTITY + ) ? whitelist_address_type_t::PUBLIC_DEVICE_ADDRESS : whitelist_address_type_t::RANDOM_DEVICE_ADDRESS; } @@ -312,10 +319,10 @@ const central_privacy_configuration_t Gap::default_central_privacy_configuration }; Gap::Gap( - PalEventQueue &event_queue, - PalGap &pal_gap, - PalGenericAccessService &generic_access_service, - PalSecurityManager &pal_sm + ble::PalEventQueue &event_queue, + ble::PalGap &pal_gap, + ble::PalGenericAccessService &generic_access_service, + ble::PalSecurityManager &pal_sm ) : _event_queue(event_queue), _pal_gap(pal_gap), _gap_service(generic_access_service), @@ -347,9 +354,7 @@ Gap::Gap( } -Gap::~Gap() -{ -} +Gap::~Gap() = default; bool Gap::isFeatureSupported(controller_supported_features_t feature) @@ -385,7 +390,7 @@ bool Gap::isFeatureSupported(controller_supported_features_t feature) ble_error_t Gap::setRandomStaticAddress( - const ble::address_t& address + const ble::address_t &address ) { if (is_random_static_address(address.data()) == false) { @@ -423,7 +428,7 @@ ble_error_t Gap::getAddress( ble_error_t Gap::getRandomAddressType( const address_t address, - ble::random_address_type_t* type + ble::random_address_type_t *type ) { // see section Device address in Bluetooth Link Layer specification @@ -496,7 +501,7 @@ ble_error_t Gap::connect( conn_interval_t(connectionParams.getMaxConnectionIntervalArray()[i]), slave_latency_t(connectionParams.getSlaveLatencyArray()[i]) ) - ) { + ) { return BLE_ERROR_INVALID_PARAM; } } @@ -534,7 +539,7 @@ ble_error_t Gap::connect( if (peerAddressType == peer_address_type_t::RANDOM || peerAddressType == peer_address_type_t::RANDOM_STATIC_IDENTITY - ) { + ) { adjusted_address_type = peer_address_type_t::RANDOM; } @@ -900,10 +905,10 @@ ble_error_t Gap::getCentralPrivacyConfiguration( } -ble_error_t Gap::reset(void) +ble_error_t Gap::reset() { /* Notify that the instance is about to shut down */ - shutdownCallChain.call(this); +// shutdownCallChain.call(this); shutdownCallChain.clear(); _event_handler = nullptr; @@ -923,7 +928,7 @@ ble_error_t Gap::reset(void) _pal_gap.extended_advertising_enable( /* enable */ false, /* number of advertising sets */ 1, - (advertising_handle_t*)&i, + (advertising_handle_t *) &i, nullptr, nullptr ); @@ -932,7 +937,7 @@ ble_error_t Gap::reset(void) if (_active_periodic_sets.get(i)) { _pal_gap.periodic_advertising_enable( /* enable */ false, - (advertising_handle_t)i + (advertising_handle_t) i ); } #endif // BLE_FEATURE_PERIODIC_ADVERTISING @@ -948,7 +953,7 @@ ble_error_t Gap::reset(void) _pal_gap.extended_advertising_enable( /* enable */ false, /* number of advertising sets */ 1, - (advertising_handle_t*)&LEGACY_ADVERTISING_HANDLE, + (advertising_handle_t *) &LEGACY_ADVERTISING_HANDLE, nullptr, nullptr ); @@ -966,6 +971,16 @@ ble_error_t Gap::reset(void) return BLE_ERROR_NONE; } +void Gap::onShutdown(const GapShutdownCallback_t &callback) +{ + shutdownCallChain.add(callback); +} + +Gap::GapShutdownCallbackChain_t &Gap::onShutdown() +{ + return shutdownCallChain; +} + void Gap::on_scan_timeout() { @@ -1120,7 +1135,7 @@ void Gap::on_advertising_report(const GapAdvertisingReportEvent &e) advertising.rssi, /* NO PERIODIC ADVERTISING */ 0, peer_address_type_t::ANONYMOUS, - ble::address_t (), + ble::address_t(), Span(advertising.data.data(), advertising.data.size()) ) ); @@ -1161,7 +1176,7 @@ void Gap::on_connection_complete(const GapConnectionCompleteEvent &e) if (_privacy_enabled && e.role.value() == e.role.PERIPHERAL && e.peer_address_type == peer_address_type_t::RANDOM - ) { + ) { // Apply privacy policy if in peripheral mode for non-resolved addresses ble::random_address_type_t random_address_type(ble::random_address_type_t::RESOLVABLE_PRIVATE); ble_error_t err = getRandomAddressType(e.peer_address.data(), &random_address_type); @@ -1409,7 +1424,8 @@ ble_error_t Gap::update_address_resolution_setting() if (_privacy_enabled) { #if BLE_ROLE_BROADCASTER - if (_peripheral_privacy_configuration.resolution_strategy != peripheral_privacy_configuration_t::DO_NOT_RESOLVE) { + if (_peripheral_privacy_configuration.resolution_strategy != + peripheral_privacy_configuration_t::DO_NOT_RESOLVE) { enable = true; } #endif // BLE_ROLE_BROADCASTER @@ -1544,7 +1560,7 @@ uint8_t Gap::getMaxAdvertisingSetNumber() #if BLE_FEATURE_EXTENDED_ADVERTISING if (is_extended_advertising_available()) { uint8_t set_number = _pal_gap.get_max_number_of_advertising_sets(); - return std::min((uint8_t)BLE_GAP_MAX_ADVERTISING_SETS, set_number); + return std::min((uint8_t) BLE_GAP_MAX_ADVERTISING_SETS, set_number); } else #endif // BLE_FEATURE_EXTENDED_ADVERTISING { @@ -1706,8 +1722,10 @@ ble_error_t Gap::setExtendedAdvertisingParameters( } /* check for illegal parameter combination */ - if ((params.getType() == advertising_type_t::CONNECTABLE_UNDIRECTED || - params.getType() == advertising_type_t::CONNECTABLE_DIRECTED) && + if (( + params.getType() == advertising_type_t::CONNECTABLE_UNDIRECTED || + params.getType() == advertising_type_t::CONNECTABLE_DIRECTED + ) && params.getUseLegacyPDU() == false) { /* these types can only be used with legacy PDUs */ return BLE_ERROR_INVALID_PARAM; @@ -1852,7 +1870,7 @@ ble_error_t Gap::setAdvertisingData( if (!_active_sets.get(handle) && payload.size() > this->getMaxActiveSetAdvertisingDataLength()) { MBED_WARNING(MBED_ERROR_INVALID_SIZE, "Payload size for active sets needs to fit in a single operation" - " - not greater than getMaxActiveSetAdvertisingDataLength()."); + " - not greater than getMaxActiveSetAdvertisingDataLength()."); return BLE_ERROR_INVALID_PARAM; } @@ -1860,7 +1878,7 @@ ble_error_t Gap::setAdvertisingData( if (payload.size() > this->getMaxConnectableAdvertisingDataLength()) { if (_active_sets.get(handle) && _set_is_connectable.get(handle)) { MBED_WARNING(MBED_ERROR_INVALID_SIZE, "Payload size for connectable advertising" - " exceeds getMaxAdvertisingDataLength()."); + " exceeds getMaxAdvertisingDataLength()."); return BLE_ERROR_INVALID_PARAM; } else { _connectable_payload_size_exceeded.set(handle); @@ -2125,7 +2143,8 @@ ble_error_t Gap::setPeriodicAdvertisingPayload( } i += hci_length; - } while (i < end); + } + while (i < end); return BLE_ERROR_NONE; } @@ -2260,7 +2279,7 @@ void Gap::on_extended_advertising_report( address_type != nullptr && *address_type == connection_peer_address_type_t::RANDOM_ADDRESS && is_random_private_resolvable_address(address.data()) - ) { + ) { return; } #endif // BLE_FEATURE_PRIVACY @@ -2436,11 +2455,12 @@ void Gap::on_remote_connection_parameter( if (_user_manage_connection_parameter_requests) { if (_event_handler) { _event_handler->onUpdateConnectionParametersRequest( - UpdateConnectionParametersRequestEvent(connection_handle, - conn_interval_t(connection_interval_min), - conn_interval_t(connection_interval_max), - connection_latency, - supervision_timeout_t(supervision_timeout)) + UpdateConnectionParametersRequestEvent( + connection_handle, + conn_interval_t(connection_interval_min), + conn_interval_t(connection_interval_max), + connection_latency, + supervision_timeout_t(supervision_timeout)) ); } else { MBED_ERROR(illegal_state_error, "Event handler required if connection params are user handled"); @@ -2735,4 +2755,5 @@ void Gap::setEventHandler(Gap::EventHandler *handler) _event_handler = handler; } +} // impl } // ble diff --git a/connectivity/FEATURE_BLE/libraries/ble-api-implementation/include/ble/internal/GapImpl.h b/connectivity/FEATURE_BLE/source/generic/GapImpl.h similarity index 91% rename from connectivity/FEATURE_BLE/libraries/ble-api-implementation/include/ble/internal/GapImpl.h rename to connectivity/FEATURE_BLE/source/generic/GapImpl.h index a89c8ba5ba4..577292d2d63 100644 --- a/connectivity/FEATURE_BLE/libraries/ble-api-implementation/include/ble/internal/GapImpl.h +++ b/connectivity/FEATURE_BLE/source/generic/GapImpl.h @@ -19,7 +19,7 @@ #ifndef IMPL_GAP_GAP_H #define IMPL_GAP_GAP_H -#include "CallChainOfFunctionPointersWithContext.h" +#include "ble/common/CallChainOfFunctionPointersWithContext.h" #include @@ -27,41 +27,48 @@ #include "drivers/LowPowerTicker.h" #include "platform/mbed_error.h" -#include "ble/common/ble/BLERoles.h" -#include "ble/common/ble/BLETypes.h" -#include "ble/common/ble/gap/AdvertisingDataBuilder.h" -#include "ble/common/ble/gap/AdvertisingDataSimpleBuilder.h" -#include "ble/common/ble/gap/ConnectionParameters.h" -#include "ble/common/ble/gap/ScanParameters.h" -#include "ble/common/ble/gap/AdvertisingParameters.h" -#include "ble/common/ble/gap/Events.h" - -#include "ble/internal/PalGap.h" -#include "ble/common/ble/GapEvents.h" -#include "ble/common/ble/GapTypes.h" -#include "ble/internal/PalEventQueue.h" -#include "ble/internal/PalConnectionMonitor.h" -#include "PalEventQueue.h" +#include "ble/common/BLERoles.h" +#include "ble/common/BLETypes.h" +#include "ble/gap/AdvertisingDataBuilder.h" +#include "ble/gap/AdvertisingDataSimpleBuilder.h" +#include "ble/gap/ConnectionParameters.h" +#include "ble/gap/ScanParameters.h" +#include "ble/gap/AdvertisingParameters.h" +#include "ble/gap/Events.h" + +#include "source/pal/PalGap.h" +#include "source/pal/PalConnectionMonitor.h" #include "ble/Gap.h" namespace ble { class PalGenericAccessService; + class PalSecurityManager; + class PalGap; + +class PalEventQueue; + +namespace impl { + class BLEInstanceBase; class Gap : - public ble::interface::Gap, - public PalConnectionMonitor, - public PalGapEventHandler -{ + public ble::PalConnectionMonitor, + public PalGapEventHandler { friend PalConnectionMonitor; friend PalGapEventHandler; friend PalGap; - friend BLEInstanceBase; + friend impl::BLEInstanceBase; + + using EventHandler = ::ble::Gap::EventHandler; + using GapShutdownCallback_t = ::ble::Gap::GapShutdownCallback_t; + using GapShutdownCallbackChain_t = ::ble::Gap::GapShutdownCallbackChain_t ; public: + using PreferredConnectionParams_t = ::ble::Gap::PreferredConnectionParams_t ; + /** * Default peripheral privacy configuration. */ @@ -98,6 +105,7 @@ class Gap : ); ble_error_t destroyAdvertisingSet(advertising_handle_t handle); + #endif // BLE_FEATURE_EXTENDED_ADVERTISING ble_error_t setAdvertisingParameters( @@ -124,6 +132,7 @@ class Gap : ble_error_t stopAdvertising(advertising_handle_t handle); bool isAdvertisingActive(advertising_handle_t handle); + #endif // BLE_ROLE_BROADCASTER #if BLE_ROLE_BROADCASTER @@ -146,6 +155,7 @@ class Gap : ble_error_t stopPeriodicAdvertising(advertising_handle_t handle); bool isPeriodicAdvertisingActive(advertising_handle_t handle); + #endif // BLE_ROLE_BROADCASTER #endif // BLE_FEATURE_PERIODIC_ADVERTISING @@ -161,6 +171,7 @@ class Gap : ); ble_error_t stopScan(); + #endif // BLE_ROLE_OBSERVER #if BLE_ROLE_OBSERVER @@ -198,6 +209,7 @@ class Gap : ble_error_t clearPeriodicAdvertiserList(); uint8_t getMaxPeriodicAdvertiserListSize(); + #endif // BLE_ROLE_OBSERVER #endif // BLE_FEATURE_PERIODIC_ADVERTISING @@ -210,6 +222,7 @@ class Gap : ); ble_error_t cancelConnect(); + #endif // BLE_ROLE_CENTRAL #if BLE_FEATURE_CONNECTABLE @@ -246,6 +259,7 @@ class Gap : connection_handle_t connectionHandle, local_disconnection_reason_t reason ); + #endif // BLE_FEATURE_CONNECTABLE #if BLE_FEATURE_PHY_MANAGEMENT @@ -262,6 +276,7 @@ class Gap : const phy_set_t *rxPhys, coded_symbol_per_bit_t codedSymbol ); + #endif // BLE_FEATURE_PHY_MANAGEMENT #if BLE_FEATURE_PRIVACY @@ -277,6 +292,7 @@ class Gap : ble_error_t getPeripheralPrivacyConfiguration( peripheral_privacy_configuration_t *configuration ); + #endif // BLE_ROLE_BROADCASTER #if BLE_ROLE_OBSERVER @@ -288,12 +304,13 @@ class Gap : ble_error_t getCentralPrivacyConfiguration( central_privacy_configuration_t *configuration ); + #endif // BLE_ROLE_OBSERVER #endif // BLE_FEATURE_PRIVACY #if BLE_FEATURE_WHITELIST - uint8_t getMaxWhitelistSize(void) const; + uint8_t getMaxWhitelistSize() const; ble_error_t getWhitelist(whitelist_t &whitelist) const; @@ -307,26 +324,25 @@ class Gap : ); static ble_error_t getRandomAddressType( - const ble::address_t address, + ble::address_t address, ble::random_address_type_t *addressType ); - ble_error_t reset(void); + ble_error_t reset(); void onShutdown(const GapShutdownCallback_t &callback); - template - void onShutdown(T *objPtr, void (T::*memberPtr)(const Gap *)); - GapShutdownCallbackChain_t &onShutdown(); #if !defined(DOXYGEN_ONLY) + /* * API reserved for the controller driver to set the random static address. * Setting a new random static address while the controller is operating is * forbidden by the Bluetooth specification. */ - ble_error_t setRandomStaticAddress(const ble::address_t& address); + ble_error_t setRandomStaticAddress(const ble::address_t &address); + #endif // !defined(DOXYGEN_ONLY) /* ===================================================================== */ @@ -335,13 +351,14 @@ class Gap : private: /* Disallow copy and assignment. */ Gap(const Gap &); - Gap& operator=(const Gap &); + + Gap &operator=(const Gap &); Gap( - PalEventQueue &event_queue, - PalGap &pal_gap, - PalGenericAccessService &generic_access_service, - PalSecurityManager &pal_sm + ble::PalEventQueue &event_queue, + ble::PalGap &pal_gap, + ble::PalGenericAccessService &generic_access_service, + ble::PalSecurityManager &pal_sm ); ~Gap(); @@ -410,20 +427,20 @@ class Gap : connection_handle_t connection_handle, phy_t tx_phy, phy_t rx_phy - ); + ) override; void on_data_length_change( connection_handle_t connection_handle, uint16_t tx_size, uint16_t rx_size - ); + ) override; void on_phy_update_complete( hci_error_code_t hci_status, connection_handle_t connection_handle, phy_t tx_phy, phy_t rx_phy - ); + ) override; void on_enhanced_connection_complete( hci_error_code_t status, @@ -437,7 +454,7 @@ class Gap : uint16_t connection_latency, uint16_t supervision_timeout, clock_accuracy_t master_clock_accuracy - ); + ) override; void on_extended_advertising_report( advertising_event_t event_type, @@ -453,7 +470,7 @@ class Gap : const ble::address_t &direct_address, uint8_t data_length, const uint8_t *data - ); + ) override; void on_periodic_advertising_sync_established( hci_error_code_t error, @@ -464,7 +481,7 @@ class Gap : phy_t advertiser_phy, uint16_t periodic_advertising_interval, clock_accuracy_t clock_accuracy - ); + ) override; void on_periodic_advertising_report( sync_handle_t sync_handle, @@ -473,22 +490,22 @@ class Gap : advertising_data_status_t data_status, uint8_t data_length, const uint8_t *data - ); + ) override; - void on_periodic_advertising_sync_loss(sync_handle_t sync_handle); + void on_periodic_advertising_sync_loss(sync_handle_t sync_handle) override; void on_advertising_set_terminated( hci_error_code_t status, advertising_handle_t advertising_handle, connection_handle_t connection_handle, uint8_t number_of_completed_extended_advertising_events - ); + ) override; void on_scan_request_received( advertising_handle_t advertising_handle, connection_peer_address_type_t scanner_address_type, const ble::address_t &address - ); + ) override; void on_connection_update_complete( hci_error_code_t status, @@ -496,7 +513,7 @@ class Gap : uint16_t connection_interval, uint16_t connection_latency, uint16_t supervision_timeout - ); + ) override; void on_remote_connection_parameter( connection_handle_t connection_handle, @@ -504,9 +521,10 @@ class Gap : uint16_t connection_interval_max, uint16_t connection_latency, uint16_t supervision_timeout - ); + ) override; + + void on_scan_timeout() override; - void on_scan_timeout(); void process_legacy_scan_timeout(); private: @@ -598,6 +616,7 @@ class Gap : bool _user_manage_connection_parameter_requests : 1; }; +} // namespace impl } // namespace ble #endif //IMPL_GAP_GAP_H diff --git a/connectivity/FEATURE_BLE/libraries/ble-api-implementation/source/GattClientImpl.cpp b/connectivity/FEATURE_BLE/source/generic/GattClientImpl.cpp similarity index 82% rename from connectivity/FEATURE_BLE/libraries/ble-api-implementation/source/GattClientImpl.cpp rename to connectivity/FEATURE_BLE/source/generic/GattClientImpl.cpp index 78921ecfa45..51330588a19 100644 --- a/connectivity/FEATURE_BLE/libraries/ble-api-implementation/source/GattClientImpl.cpp +++ b/connectivity/FEATURE_BLE/source/generic/GattClientImpl.cpp @@ -16,21 +16,22 @@ * limitations under the License. */ -#include "BLERoles.h" +#include "ble/common/BLERoles.h" #if BLE_FEATURE_GATT_CLIENT -#include -#include +#include +#include -#include "ble/internal/AttServerMessage.h" -#include "ble/common/ble/DiscoveredService.h" -#include "ble/common/ble/DiscoveredCharacteristic.h" -#include "ble/GattClient.h" -#include "ble/common/ble/blecommon.h" -#include "ble/internal/BLEInstanceBase.h" +#include "ble/BLE.h" #include "ble/SecurityManager.h" -#include +#include "ble/gatt/DiscoveredService.h" +#include "ble/gatt/DiscoveredCharacteristic.h" +#include "ble/common/blecommon.h" + +#include "source/generic/GattClientImpl.h" +#include "source/pal/AttServerMessage.h" +#include "source/BLEInstanceBase.h" using ble::AttServerMessage; using ble::AttReadResponse; @@ -53,6 +54,14 @@ using ble::AttFindInformationResponse; #define MAC_COUNTER_LENGTH 4 namespace ble { +namespace impl { + +namespace { +static constexpr auto GATT_OP_SIGNED_WRITE_CMD = ble::GattClient::GATT_OP_SIGNED_WRITE_CMD; +static constexpr auto GATT_OP_WRITE_CMD = ble::GattClient::GATT_OP_WRITE_CMD; +static constexpr auto GATT_OP_WRITE_REQ = ble::GattClient::GATT_OP_WRITE_REQ; +} + /* * Type of procedures which can be launched by the client. @@ -74,19 +83,21 @@ struct GattClient::ProcedureControlBlock { * Base constructor for procedure control block. */ ProcedureControlBlock(procedure_type_t type, connection_handle_t handle) : - type(type), connection_handle(handle), next(nullptr) { } + type(type), connection_handle(handle), next(nullptr) + { + } - virtual ~ProcedureControlBlock() { } + virtual ~ProcedureControlBlock() = default; /* * Entry point of the control block stack machine. */ - virtual void handle(GattClient* client, const AttServerMessage& message) = 0; + virtual void handle(GattClient *client, const AttServerMessage &message) = 0; /* * Function call in case of timeout */ - virtual void handle_timeout_error(GattClient* client) = 0; + virtual void handle_timeout_error(GattClient *client) = 0; /** * Function called when the procedure is aborted @@ -95,7 +106,7 @@ struct GattClient::ProcedureControlBlock { procedure_type_t type; connection_handle_t connection_handle; - ProcedureControlBlock* next; + ProcedureControlBlock *next; }; @@ -103,7 +114,7 @@ struct GattClient::ProcedureControlBlock { * Procedure control block for the discovery process. */ -struct GattClient::DiscoveryControlBlock : public ProcedureControlBlock { +struct GattClient::DiscoveryControlBlock final : public ProcedureControlBlock { using ProcedureControlBlock::connection_handle; DiscoveryControlBlock( @@ -118,50 +129,55 @@ struct GattClient::DiscoveryControlBlock : public ProcedureControlBlock { matching_service_uuid(matching_service_uuid), matching_characteristic_uuid(matching_characteristic_uuid), services_discovered(nullptr), - done(false) { + done(false) + { } - virtual ~DiscoveryControlBlock() { - while(services_discovered) { - service_t* tmp = services_discovered->next; + ~DiscoveryControlBlock() final + { + while (services_discovered) { + service_t *tmp = services_discovered->next; delete services_discovered; services_discovered = tmp; } } - virtual void handle_timeout_error(GattClient* client) { + void handle_timeout_error(GattClient *client) final + { terminate(client); } - virtual void abort(GattClient *client) { + void abort(GattClient *client) final + { terminate(client); } - virtual void handle(GattClient* client, const AttServerMessage& message) { + void handle(GattClient *client, const AttServerMessage &message) final + { // if end of discovery has been requested, ends it immediately if (done) { terminate(client); return; } - switch(message.opcode) { + switch (message.opcode) { case AttributeOpcode::READ_BY_GROUP_TYPE_RESPONSE: handle_service_discovered( - client, static_cast(message) + client, static_cast(message) ); - break; + break; case AttributeOpcode::FIND_BY_VALUE_TYPE_RESPONSE: handle_service_discovered( - client, static_cast(message) + client, static_cast(message) ); break; case AttributeOpcode::READ_BY_TYPE_RESPONSE: handle_characteristic_discovered( - client, static_cast(message) + client, static_cast(message) ); break; case AttributeOpcode::ERROR_RESPONSE: { - const AttErrorResponse& error = static_cast(message); + const auto &error = static_cast(message); if (error.error_code != AttErrorResponse::ATTRIBUTE_NOT_FOUND) { terminate(client); return; @@ -187,7 +203,8 @@ struct GattClient::DiscoveryControlBlock : public ProcedureControlBlock { } template - void handle_service_discovered(GattClient* client, const Response& response) { + void handle_service_discovered(GattClient *client, const Response &response) + { if (!response.size()) { terminate(client); return; @@ -204,7 +221,7 @@ struct GattClient::DiscoveryControlBlock : public ProcedureControlBlock { discovered_service.setup(uuid, start_handle, end_handle); service_callback(&discovered_service); } else { - service_t* discovered_service = new (std::nothrow) service_t( + auto *discovered_service = new(std::nothrow) service_t( start_handle, end_handle, uuid ); @@ -230,7 +247,8 @@ struct GattClient::DiscoveryControlBlock : public ProcedureControlBlock { } } - void start_characteristic_discovery(GattClient* client) { + void start_characteristic_discovery(GattClient *client) + { if (!services_discovered) { terminate(client); return; @@ -261,12 +279,13 @@ struct GattClient::DiscoveryControlBlock : public ProcedureControlBlock { ); } - void handle_characteristic_discovered(GattClient* client, const AttReadByTypeResponse& response) { + void handle_characteristic_discovered(GattClient *client, const AttReadByTypeResponse &response) + { for (size_t i = 0; i < response.size(); ++i) { if (last_characteristic.is_valid() == false) { last_characteristic.set_last_handle(response[i].handle - 1); if (matching_characteristic_uuid == UUID() - || last_characteristic.getUUID() == matching_characteristic_uuid) { + || last_characteristic.getUUID() == matching_characteristic_uuid) { characteristic_callback(&last_characteristic); } } @@ -294,7 +313,8 @@ struct GattClient::DiscoveryControlBlock : public ProcedureControlBlock { } } - void handle_all_characteristics_discovered(GattClient* client) { + void handle_all_characteristics_discovered(GattClient *client) + { if (last_characteristic.is_valid() == false) { if (matching_characteristic_uuid == UUID() || matching_characteristic_uuid == last_characteristic.getUUID()) { @@ -303,7 +323,7 @@ struct GattClient::DiscoveryControlBlock : public ProcedureControlBlock { } } - service_t* old = services_discovered; + service_t *old = services_discovered; services_discovered = services_discovered->next; delete old; @@ -314,7 +334,8 @@ struct GattClient::DiscoveryControlBlock : public ProcedureControlBlock { } } - void terminate(GattClient* client) { + void terminate(GattClient *client) + { // unknown error, terminate the procedure immediately client->remove_control_block(this); connection_handle_t handle = connection_handle; @@ -322,23 +343,28 @@ struct GattClient::DiscoveryControlBlock : public ProcedureControlBlock { client->on_termination(handle); } - uint16_t get_start_handle(const AttReadByGroupTypeResponse::attribute_data_t& data) { + uint16_t get_start_handle(const AttReadByGroupTypeResponse::attribute_data_t &data) + { return data.group_range.begin; } - uint16_t get_start_handle(const attribute_handle_range_t& range) { + uint16_t get_start_handle(const attribute_handle_range_t &range) + { return range.begin; } - uint16_t get_end_handle(const AttReadByGroupTypeResponse::attribute_data_t& data) { + uint16_t get_end_handle(const AttReadByGroupTypeResponse::attribute_data_t &data) + { return data.group_range.end; } - uint16_t get_end_handle(const attribute_handle_range_t& range) { + uint16_t get_end_handle(const attribute_handle_range_t &range) + { return range.end; } - UUID get_uuid(const AttReadByGroupTypeResponse::attribute_data_t& data) { + UUID get_uuid(const AttReadByGroupTypeResponse::attribute_data_t &data) + { if (data.value.size() == 2) { return UUID(data.value[0] | data.value[1] << 8); } else { @@ -346,31 +372,37 @@ struct GattClient::DiscoveryControlBlock : public ProcedureControlBlock { } } - UUID get_uuid(const attribute_handle_range_t& range) { + UUID get_uuid(const attribute_handle_range_t &range) + { return matching_service_uuid; } struct service_t { - service_t(uint16_t begin, uint16_t end, const UUID& uuid) : - begin(begin), end(end), uuid(uuid), next(nullptr) { } + service_t(uint16_t begin, uint16_t end, const UUID &uuid) : + begin(begin), end(end), uuid(uuid), next(nullptr) + { + } + uint16_t begin; uint16_t end; UUID uuid; - service_t* next; + service_t *next; }; struct characteristic_t : DiscoveredCharacteristic { - characteristic_t() : DiscoveredCharacteristic() { + characteristic_t() : DiscoveredCharacteristic() + { lastHandle = 0x0001; } characteristic_t( - GattClient* client, + GattClient *client, connection_handle_t connection_handle, uint16_t decl_handle, const Span value - ) : DiscoveredCharacteristic() { - gattc = client; + ) : DiscoveredCharacteristic() + { + gattc = &ble::BLE::Instance().gattClient(); uuid = get_uuid(value); props = get_properties(value); declHandle = decl_handle; @@ -379,7 +411,8 @@ struct GattClient::DiscoveryControlBlock : public ProcedureControlBlock { connHandle = connection_handle; } - static UUID get_uuid(const Span& value) { + static UUID get_uuid(const Span &value) + { if (value.size() == 5) { return UUID(value[3] | (value[4] << 8)); } else { @@ -387,39 +420,44 @@ struct GattClient::DiscoveryControlBlock : public ProcedureControlBlock { } } - static DiscoveredCharacteristic::Properties_t get_properties(const Span& value) { + static DiscoveredCharacteristic::Properties_t get_properties(const Span &value) + { uint8_t raw_properties = value[0]; DiscoveredCharacteristic::Properties_t result; result._broadcast = (raw_properties & (1 << 0)) ? true : false; result._read = (raw_properties & (1 << 1)) ? true : false; - result._writeWoResp = (raw_properties & (1 << 2)) ? true : false; - result._write = (raw_properties & (1 << 3)) ? true : false; - result._notify = (raw_properties & (1 << 4)) ? true : false; - result._indicate = (raw_properties & (1 << 5)) ? true : false; - result._authSignedWrite = (raw_properties & (1 << 6)) ? true : false; + result._writeWoResp = (raw_properties & (1 << 2)) ? true : false; + result._write = (raw_properties & (1 << 3)) ? true : false; + result._notify = (raw_properties & (1 << 4)) ? true : false; + result._indicate = (raw_properties & (1 << 5)) ? true : false; + result._authSignedWrite = (raw_properties & (1 << 6)) ? true : false; return result; } - static uint16_t get_value_handle(const Span& value) { + static uint16_t get_value_handle(const Span &value) + { return value[1] | (value[2] << 8); } - void set_last_handle(uint16_t last_handle) { + void set_last_handle(uint16_t last_handle) + { lastHandle = last_handle; } - bool is_valid() const { + bool is_valid() const + { return lastHandle != 0x0000; } }; - void insert_service(service_t* service) { + void insert_service(service_t *service) + { if (services_discovered == nullptr) { services_discovered = service; return; } - service_t* current = services_discovered; + service_t *current = services_discovered; while (current->next) { current = current->next; } @@ -430,30 +468,32 @@ struct GattClient::DiscoveryControlBlock : public ProcedureControlBlock { ServiceDiscovery::CharacteristicCallback_t characteristic_callback; UUID matching_service_uuid; UUID matching_characteristic_uuid; - service_t* services_discovered; + service_t *services_discovered; characteristic_t last_characteristic; bool done; }; - -struct GattClient::ReadControlBlock : public ProcedureControlBlock { +struct GattClient::ReadControlBlock final : public ProcedureControlBlock { using ProcedureControlBlock::connection_handle; ReadControlBlock( connection_handle_t connection_handle, uint16_t attribute_handle, uint16_t offset ) : ProcedureControlBlock(READ_PROCEDURE, connection_handle), attribute_handle(attribute_handle), - offset(offset), current_offset(offset), data(nullptr) { + offset(offset), current_offset(offset), data(nullptr) + { } - virtual ~ReadControlBlock() { + ~ReadControlBlock() final + { if (data != nullptr) { free(data); } } - virtual void handle_timeout_error(GattClient* client) { + void handle_timeout_error(GattClient *client) final + { GattReadCallbackParams response = { connection_handle, attribute_handle, @@ -465,7 +505,8 @@ struct GattClient::ReadControlBlock : public ProcedureControlBlock { terminate(client, response); } - virtual void abort(GattClient *client) { + void abort(GattClient *client) final + { GattReadCallbackParams response = { connection_handle, attribute_handle, @@ -477,24 +518,26 @@ struct GattClient::ReadControlBlock : public ProcedureControlBlock { terminate(client, response); } - void terminate(GattClient* client, const GattReadCallbackParams& response) { + void terminate(GattClient *client, const GattReadCallbackParams &response) + { client->remove_control_block(this); client->processReadResponse(&response); delete this; } - virtual void handle(GattClient* client, const AttServerMessage& message) { - switch(message.opcode) { + void handle(GattClient *client, const AttServerMessage &message) final + { + switch (message.opcode) { case AttributeOpcode::ERROR_RESPONSE: - handle_error(client, static_cast(message)); + handle_error(client, static_cast(message)); break; case AttributeOpcode::READ_RESPONSE: - handle_read_response(client, static_cast(message)); + handle_read_response(client, static_cast(message)); break; case AttributeOpcode::READ_BLOB_RESPONSE: - handle_read_response(client, static_cast(message)); + handle_read_response(client, static_cast(message)); break; default: { @@ -514,7 +557,8 @@ struct GattClient::ReadControlBlock : public ProcedureControlBlock { } template - void handle_read_response(GattClient* client, const ResponseType& read_response) { + void handle_read_response(GattClient *client, const ResponseType &read_response) + { uint16_t mtu_size = client->get_mtu(connection_handle); // end of responses ? @@ -542,7 +586,7 @@ struct GattClient::ReadControlBlock : public ProcedureControlBlock { terminate(client, response); } else { // allocation which will contain the response data plus the next one. - data = (uint8_t*) realloc(data, (current_offset - offset) + ((mtu_size - 1) * 2)); + data = (uint8_t *) realloc(data, (current_offset - offset) + ((mtu_size - 1) * 2)); if (data == nullptr) { GattReadCallbackParams response = { connection_handle, @@ -578,7 +622,8 @@ struct GattClient::ReadControlBlock : public ProcedureControlBlock { } } - void handle_error(GattClient* client, const AttErrorResponse& error) { + void handle_error(GattClient *client, const AttErrorResponse &error) + { ble_error_t status = BLE_ERROR_UNSPECIFIED; switch (error.error_code) { @@ -626,14 +671,14 @@ struct GattClient::ReadControlBlock : public ProcedureControlBlock { uint16_t attribute_handle; uint16_t offset; uint16_t current_offset; - uint8_t* data; + uint8_t *data; }; /* * Control block for the write process */ -struct GattClient::WriteControlBlock : public ProcedureControlBlock { +struct GattClient::WriteControlBlock final : public ProcedureControlBlock { using ProcedureControlBlock::connection_handle; WriteControlBlock( @@ -643,14 +688,17 @@ struct GattClient::WriteControlBlock : public ProcedureControlBlock { uint16_t write_length ) : ProcedureControlBlock(WRITE_PROCEDURE, connection_handle), attribute_handle(attribute_handle), write_length(write_length), offset(0), data(data), - prepare_success(false), status(BLE_ERROR_INITIALIZATION_INCOMPLETE), error_code(0xFF) { + prepare_success(false), status(BLE_ERROR_INITIALIZATION_INCOMPLETE), error_code(0xFF) + { } - virtual ~WriteControlBlock() { + ~WriteControlBlock() final + { free(data); } - virtual void handle_timeout_error(GattClient* client) { + void handle_timeout_error(GattClient *client) final + { GattWriteCallbackParams response = { connection_handle, attribute_handle, @@ -661,7 +709,8 @@ struct GattClient::WriteControlBlock : public ProcedureControlBlock { terminate(client, response); } - virtual void abort(GattClient *client) { + void abort(GattClient *client) final + { GattWriteCallbackParams response = { connection_handle, attribute_handle, @@ -672,13 +721,15 @@ struct GattClient::WriteControlBlock : public ProcedureControlBlock { terminate(client, response); } - void terminate(GattClient* client, const GattWriteCallbackParams& response) { + void terminate(GattClient *client, const GattWriteCallbackParams &response) + { client->remove_control_block(this); client->processWriteResponse(&response); delete this; } - virtual void handle(GattClient* client, const AttServerMessage& message) { + void handle(GattClient *client, const AttServerMessage &message) final + { switch(message.opcode) { case AttributeOpcode::ERROR_RESPONSE: handle_error(client, static_cast(message)); @@ -710,7 +761,8 @@ struct GattClient::WriteControlBlock : public ProcedureControlBlock { } } - void handle_write_response(GattClient* client, const AttWriteResponse& write_response) { + void handle_write_response(GattClient* client, const AttWriteResponse& write_response) + { GattWriteCallbackParams response = { connection_handle, attribute_handle, @@ -722,7 +774,8 @@ struct GattClient::WriteControlBlock : public ProcedureControlBlock { terminate(client, response); } - void handle_prepare_write_response(GattClient* client, const AttPrepareWriteResponse& write_response) { + void handle_prepare_write_response(GattClient* client, const AttPrepareWriteResponse& write_response) + { ble_error_t err = BLE_ERROR_UNSPECIFIED; offset += write_response.partial_value.size(); uint16_t data_left = write_length - offset; /* offset is guaranteed to be less of equal to write_length */ @@ -749,7 +802,8 @@ struct GattClient::WriteControlBlock : public ProcedureControlBlock { } } - void handle_execute_write_response(GattClient* client, const AttExecuteWriteResponse& execute_response) { + void handle_execute_write_response(GattClient* client, const AttExecuteWriteResponse& execute_response) + { if (prepare_success) { status = BLE_ERROR_NONE; error_code = 0x00; @@ -759,14 +813,15 @@ struct GattClient::WriteControlBlock : public ProcedureControlBlock { connection_handle, attribute_handle, GattWriteCallbackParams::OP_WRITE_REQ, - status, + static_cast(status), error_code }; terminate(client, response); } - void clear_prepare_queue(GattClient* client, ble_error_t s, uint8_t e) { + void clear_prepare_queue(GattClient* client, ble_error_t s, uint8_t e) + { prepare_success = false; status = s; error_code = e; @@ -787,25 +842,18 @@ struct GattClient::WriteControlBlock : public ProcedureControlBlock { } } - void handle_error(GattClient* client, const AttErrorResponse& error) { + void handle_error(GattClient* client, const AttErrorResponse& error) + { ble_error_t status = BLE_ERROR_UNSPECIFIED; switch (error.error_code) { case AttErrorResponse::INVALID_HANDLE: - status = BLE_ERROR_INVALID_PARAM; - break; case AttErrorResponse::INVALID_ATTRIBUTE_VALUE_LENGTH: status = BLE_ERROR_INVALID_PARAM; break; case AttErrorResponse::INSUFFICIENT_AUTHORIZATION: - status = BLE_ERROR_INVALID_STATE; - break; case AttErrorResponse::INSUFFICIENT_AUTHENTICATION: - status = BLE_ERROR_INVALID_STATE; - break; case AttErrorResponse::INSUFFICIENT_ENCRYPTION_KEY_SIZE: - status = BLE_ERROR_INVALID_STATE; - break; case AttErrorResponse::INSUFFICIENT_ENCRYPTION: status = BLE_ERROR_INVALID_STATE; break; @@ -845,24 +893,26 @@ struct GattClient::WriteControlBlock : public ProcedureControlBlock { * Control block for the descriptor discovery process */ -struct GattClient::DescriptorDiscoveryControlBlock : public ProcedureControlBlock { +struct GattClient::DescriptorDiscoveryControlBlock final : public ProcedureControlBlock { using ProcedureControlBlock::connection_handle; DescriptorDiscoveryControlBlock( - const DiscoveredCharacteristic& characteristic, - const CharacteristicDescriptorDiscovery::DiscoveryCallback_t& discoveryCallback, - const CharacteristicDescriptorDiscovery::TerminationCallback_t& terminationCallback + const DiscoveredCharacteristic &characteristic, + const CharacteristicDescriptorDiscovery::DiscoveryCallback_t &discoveryCallback, + const CharacteristicDescriptorDiscovery::TerminationCallback_t &terminationCallback ) : ProcedureControlBlock(DESCRIPTOR_DISCOVERY_PROCEDURE, characteristic.getConnectionHandle()), characteristic(characteristic), discovery_cb(discoveryCallback), termination_cb(terminationCallback), next_handle(characteristic.getValueHandle() + 1), - done(false) { + done(false) + { } - virtual ~DescriptorDiscoveryControlBlock() { } + ~DescriptorDiscoveryControlBlock() final = default; - ble_error_t start(GattClient* client) { + ble_error_t start(GattClient *client) + { return client->_pal_client.discover_characteristics_descriptors( connection_handle, attribute_handle_range( @@ -872,27 +922,30 @@ struct GattClient::DescriptorDiscoveryControlBlock : public ProcedureControlBloc ); } - virtual void handle_timeout_error(GattClient* client) { + void handle_timeout_error(GattClient *client) final + { terminate(client, BLE_ERROR_UNSPECIFIED); } - virtual void abort(GattClient *client) { + void abort(GattClient *client) final + { terminate(client, BLE_ERROR_INVALID_STATE); } - virtual void handle(GattClient* client, const AttServerMessage& message) { + void handle(GattClient *client, const AttServerMessage &message) final + { if (done) { terminate(client, BLE_ERROR_NONE); return; } - switch(message.opcode) { + switch (message.opcode) { case AttributeOpcode::ERROR_RESPONSE: - handle_error(client, static_cast(message)); + handle_error(client, static_cast(message)); return; case AttributeOpcode::FIND_INFORMATION_RESPONSE: - handle_response(client, static_cast(message)); + handle_response(client, static_cast(message)); return; default: @@ -900,7 +953,8 @@ struct GattClient::DescriptorDiscoveryControlBlock : public ProcedureControlBloc } } - void handle_error(GattClient* client, const AttErrorResponse& error) { + void handle_error(GattClient *client, const AttErrorResponse &error) + { if (error.error_code == AttErrorResponse::ATTRIBUTE_NOT_FOUND) { terminate(client, BLE_ERROR_NONE); } else { @@ -908,10 +962,11 @@ struct GattClient::DescriptorDiscoveryControlBlock : public ProcedureControlBloc } } - void handle_response(GattClient* client, const AttFindInformationResponse& response) { + void handle_response(GattClient *client, const AttFindInformationResponse &response) + { for (size_t i = 0; i < response.size(); ++i) { DiscoveredCharacteristicDescriptor descriptor( - client, connection_handle, response[i].handle, response[i].uuid + &ble::BLE::Instance().gattClient(), connection_handle, response[i].handle, response[i].uuid ); CharacteristicDescriptorDiscovery::DiscoveryCallbackParams_t params = { characteristic, @@ -936,7 +991,8 @@ struct GattClient::DescriptorDiscoveryControlBlock : public ProcedureControlBloc } } - void terminate(GattClient* client, ble_error_t status, uint8_t error_code = 0x00) { + void terminate(GattClient *client, ble_error_t status, uint8_t error_code = 0x00) + { client->remove_control_block(this); CharacteristicDescriptorDiscovery::TerminationCallbackParams_t params = { characteristic, @@ -955,7 +1011,7 @@ struct GattClient::DescriptorDiscoveryControlBlock : public ProcedureControlBloc }; -GattClient::GattClient(PalGattClient& pal_client) : +GattClient::GattClient(PalGattClient &pal_client) : eventHandler(nullptr), _pal_client(pal_client), _termination_callback(), @@ -963,7 +1019,8 @@ GattClient::GattClient(PalGattClient& pal_client) : _signing_event_handler(nullptr), #endif control_blocks(nullptr), - _is_reseting(false) { + _is_reseting(false) +{ _pal_client.when_server_message_received( mbed::callback(this, &GattClient::on_server_message_received) ); @@ -978,8 +1035,8 @@ ble_error_t GattClient::launchServiceDiscovery( connection_handle_t connection_handle, ServiceDiscovery::ServiceCallback_t service_callback, ServiceDiscovery::CharacteristicCallback_t characteristic_callback, - const UUID& matching_service_uuid, - const UUID& matching_characteristic_uuid + const UUID &matching_service_uuid, + const UUID &matching_characteristic_uuid ) { // verify that there is no other procedures going on this connection @@ -993,7 +1050,7 @@ ble_error_t GattClient::launchServiceDiscovery( return BLE_ERROR_NONE; } - DiscoveryControlBlock* discovery_pcb = new(std::nothrow) DiscoveryControlBlock( + auto *discovery_pcb = new(std::nothrow) DiscoveryControlBlock( connection_handle, service_callback, characteristic_callback, @@ -1048,8 +1105,19 @@ ble_error_t GattClient::discoverServices( ); } -bool GattClient::isServiceDiscoveryActive() const { - ProcedureControlBlock* pcb = control_blocks; +ble_error_t GattClient::discoverServices( + ble::connection_handle_t connectionHandle, + ServiceDiscovery::ServiceCallback_t callback, + GattAttribute::Handle_t startHandle, + GattAttribute::Handle_t endHandle +) +{ + return BLE_ERROR_NOT_IMPLEMENTED; +} + +bool GattClient::isServiceDiscoveryActive() const +{ + ProcedureControlBlock *pcb = control_blocks; while (pcb) { if (pcb->type == COMPLETE_DISCOVERY_PROCEDURE) { @@ -1064,10 +1132,10 @@ bool GattClient::isServiceDiscoveryActive() const { void GattClient::terminateServiceDiscovery() { - ProcedureControlBlock* pcb = control_blocks; + ProcedureControlBlock *pcb = control_blocks; while (pcb) { if (pcb->type == COMPLETE_DISCOVERY_PROCEDURE) { - static_cast(pcb)->done = true; + static_cast(pcb)->done = true; } pcb = pcb->next; } @@ -1077,14 +1145,15 @@ void GattClient::terminateServiceDiscovery() ble_error_t GattClient::read( connection_handle_t connection_handle, GattAttribute::Handle_t attribute_handle, - uint16_t offset) const + uint16_t offset +) const { // verify that there is no other procedures going on this connection if (_is_reseting || get_control_block(connection_handle)) { return BLE_ERROR_INVALID_STATE; } - ReadControlBlock* read_pcb = new(std::nothrow) ReadControlBlock( + auto *read_pcb = new(std::nothrow) ReadControlBlock( connection_handle, attribute_handle, offset @@ -1122,9 +1191,9 @@ ble_error_t GattClient::write( connection_handle_t connection_handle, GattAttribute::Handle_t attribute_handle, size_t length, - const uint8_t* value -) const { - // verify that there is no other procedures going on this connection + const uint8_t *value +) const +{ if (_is_reseting || get_control_block(connection_handle)) { return BLE_ERROR_INVALID_STATE; } @@ -1136,7 +1205,7 @@ ble_error_t GattClient::write( if (cmd == GATT_OP_SIGNED_WRITE_CMD) { ble::link_encryption_t encryption(ble::link_encryption_t::NOT_ENCRYPTED); // FIXME: use security manager or a template if applicable - SecurityManager &sm = createBLEInstance()->getSecurityManager(); + ble::SecurityManager &sm = createBLEInstance()->getSecurityManager(); ble_error_t status = sm.getLinkEncryption(connection_handle, &encryption); if (status == BLE_ERROR_NONE && (encryption == link_encryption_t::ENCRYPTED || @@ -1147,7 +1216,6 @@ ble_error_t GattClient::write( } } #endif // BLE_FEATURE_SIGNING - if (cmd == GATT_OP_WRITE_CMD) { if (length > (uint16_t) (mtu - WRITE_HEADER_LENGTH)) { return BLE_ERROR_PARAM_OUT_OF_RANGE; @@ -1173,18 +1241,18 @@ ble_error_t GattClient::write( } return status; #endif // BLE_FEATURE_SIGNING - } else if (cmd == GattClient::GATT_OP_WRITE_REQ) { - uint8_t* data = nullptr; + } else if (cmd == GATT_OP_WRITE_REQ) { + uint8_t *data = nullptr; if (length > (uint16_t) (mtu - WRITE_HEADER_LENGTH)) { - data = (uint8_t*) malloc(length); + data = (uint8_t *) malloc(length); if (data == nullptr) { return BLE_ERROR_NO_MEM; } memcpy(data, value, length); } - WriteControlBlock* write_pcb = new (std::nothrow) WriteControlBlock( + auto *write_pcb = new(std::nothrow) WriteControlBlock( connection_handle, attribute_handle, data, @@ -1235,9 +1303,9 @@ void GattClient::onServiceDiscoveryTermination( ble_error_t GattClient::discoverCharacteristicDescriptors( - const DiscoveredCharacteristic& characteristic, - const CharacteristicDescriptorDiscovery::DiscoveryCallback_t& discoveryCallback, - const CharacteristicDescriptorDiscovery::TerminationCallback_t& terminationCallback + const DiscoveredCharacteristic &characteristic, + const CharacteristicDescriptorDiscovery::DiscoveryCallback_t &discoveryCallback, + const CharacteristicDescriptorDiscovery::TerminationCallback_t &terminationCallback ) { // verify that there is no other procedures going on this connection @@ -1256,7 +1324,7 @@ ble_error_t GattClient::discoverCharacteristicDescriptors( return BLE_ERROR_NONE; } - DescriptorDiscoveryControlBlock* discovery_pcb = + auto *discovery_pcb = new(std::nothrow) DescriptorDiscoveryControlBlock( characteristic, discoveryCallback, @@ -1281,13 +1349,14 @@ ble_error_t GattClient::discoverCharacteristicDescriptors( bool GattClient::isCharacteristicDescriptorDiscoveryActive( - const DiscoveredCharacteristic& characteristic -) const { - ProcedureControlBlock* pcb = control_blocks; + const DiscoveredCharacteristic &characteristic +) const +{ + ProcedureControlBlock *pcb = control_blocks; while (pcb) { if (pcb->type == DESCRIPTOR_DISCOVERY_PROCEDURE && - static_cast(pcb)->characteristic == characteristic) { + static_cast(pcb)->characteristic == characteristic) { return true; } pcb = pcb->next; @@ -1298,15 +1367,14 @@ bool GattClient::isCharacteristicDescriptorDiscoveryActive( void GattClient::terminateCharacteristicDescriptorDiscovery( - const DiscoveredCharacteristic& characteristic + const DiscoveredCharacteristic &characteristic ) { - ProcedureControlBlock* pcb = control_blocks; + ProcedureControlBlock *pcb = control_blocks; while (pcb) { if (pcb->type == DESCRIPTOR_DISCOVERY_PROCEDURE) { - DescriptorDiscoveryControlBlock* dpcb = - static_cast(pcb); + auto *dpcb = static_cast(pcb); if (dpcb->characteristic == characteristic) { dpcb->done = true; return; @@ -1327,10 +1395,10 @@ ble_error_t GattClient::negotiateAttMtu( } -ble_error_t GattClient::reset(void) +ble_error_t GattClient::reset() { /* Notify that the instance is about to shut down. */ - shutdownCallChain.call(this); + shutdownCallChain.call(&ble::BLE::Instance().gattClient()); shutdownCallChain.clear(); onDataReadCallbackChain.clear(); @@ -1357,6 +1425,7 @@ void GattClient::set_signing_event_handler( { _signing_event_handler = signing_event_handler; } + #endif // BLE_FEATURE_SIGNING @@ -1389,7 +1458,6 @@ void GattClient::on_write_command_sent( } - void GattClient::on_termination(connection_handle_t connection_handle) { if (_termination_callback) { @@ -1400,10 +1468,10 @@ void GattClient::on_termination(connection_handle_t connection_handle) void GattClient::on_server_message_received( connection_handle_t connection_handle, - const AttServerMessage& message + const AttServerMessage &message ) { - switch(message.opcode) { + switch (message.opcode) { case AttributeOpcode::ERROR_RESPONSE: case AttributeOpcode::EXCHANGE_MTU_RESPONSE: case AttributeOpcode::FIND_INFORMATION_RESPONSE: @@ -1433,10 +1501,10 @@ void GattClient::on_server_message_received( void GattClient::on_server_response( connection_handle_t connection, - const AttServerMessage& message + const AttServerMessage &message ) { - ProcedureControlBlock* pcb = get_control_block(connection); + ProcedureControlBlock *pcb = get_control_block(connection); if (pcb == nullptr) { return; } @@ -1445,7 +1513,7 @@ void GattClient::on_server_response( } -void GattClient::on_server_event(connection_handle_t connection, const AttServerMessage& message) +void GattClient::on_server_event(connection_handle_t connection, const AttServerMessage &message) { GattHVXCallbackParams callbacks_params = { (connection_handle_t) connection, 0 @@ -1453,8 +1521,8 @@ void GattClient::on_server_event(connection_handle_t connection, const AttServer switch (message.opcode) { case AttributeOpcode::HANDLE_VALUE_NOTIFICATION: { - const AttHandleValueNotification& notification = - static_cast(message); + const auto ¬ification = + static_cast(message); callbacks_params.handle = notification.attribute_handle; callbacks_params.type = BLE_HVX_NOTIFICATION; callbacks_params.len = notification.attribute_value.size(); @@ -1462,8 +1530,8 @@ void GattClient::on_server_event(connection_handle_t connection, const AttServer } break; case AttributeOpcode::HANDLE_VALUE_INDICATION: { - const AttHandleValueIndication& indication = - static_cast(message); + const auto &indication = + static_cast(message); callbacks_params.handle = indication.attribute_handle; callbacks_params.type = BLE_HVX_INDICATION; callbacks_params.len = indication.attribute_value.size(); @@ -1480,7 +1548,7 @@ void GattClient::on_server_event(connection_handle_t connection, const AttServer void GattClient::on_transaction_timeout(connection_handle_t connection) { - ProcedureControlBlock* pcb = get_control_block(connection); + ProcedureControlBlock *pcb = get_control_block(connection); if (pcb == nullptr) { return; } @@ -1489,10 +1557,10 @@ void GattClient::on_transaction_timeout(connection_handle_t connection) } -typename GattClient::ProcedureControlBlock* +typename GattClient::ProcedureControlBlock * GattClient::get_control_block(connection_handle_t connection) { - ProcedureControlBlock* it = control_blocks; + ProcedureControlBlock *it = control_blocks; while (it && it->connection_handle != connection) { it = it->next; } @@ -1500,9 +1568,10 @@ GattClient::get_control_block(connection_handle_t connection) } -const typename GattClient::ProcedureControlBlock* -GattClient::get_control_block(connection_handle_t connection) const { - ProcedureControlBlock* it = control_blocks; +const typename GattClient::ProcedureControlBlock * +GattClient::get_control_block(connection_handle_t connection) const +{ + ProcedureControlBlock *it = control_blocks; while (it && it->connection_handle != connection) { it = it->next; } @@ -1510,13 +1579,14 @@ GattClient::get_control_block(connection_handle_t connection) const { } -void GattClient::insert_control_block(ProcedureControlBlock* cb) const { +void GattClient::insert_control_block(ProcedureControlBlock *cb) const +{ if (control_blocks == nullptr) { control_blocks = cb; return; } - ProcedureControlBlock* current = control_blocks; + ProcedureControlBlock *current = control_blocks; while (current->next) { current = current->next; } @@ -1524,7 +1594,8 @@ void GattClient::insert_control_block(ProcedureControlBlock* cb) const { } -void GattClient::remove_control_block(ProcedureControlBlock* cb) const { +void GattClient::remove_control_block(ProcedureControlBlock *cb) const +{ if (control_blocks == nullptr) { return; } @@ -1534,7 +1605,7 @@ void GattClient::remove_control_block(ProcedureControlBlock* cb) const { return; } - ProcedureControlBlock* current = control_blocks; + ProcedureControlBlock *current = control_blocks; while (current->next && current->next != cb) { current = current->next; } @@ -1548,9 +1619,10 @@ void GattClient::remove_control_block(ProcedureControlBlock* cb) const { } -uint16_t GattClient::get_mtu(connection_handle_t connection) const { +uint16_t GattClient::get_mtu(connection_handle_t connection) const +{ uint16_t result = 23; - if(_pal_client.get_mtu_size((connection_handle_t) connection, result) != BLE_ERROR_NONE) { + if (_pal_client.get_mtu_size((connection_handle_t) connection, result) != BLE_ERROR_NONE) { result = 23; } return result; @@ -1575,7 +1647,7 @@ void GattClient::onDataRead(ReadCallback_t callback) /** * @see GattClient::onDataRead */ -GattClient::ReadCallbackChain_t& GattClient::onDataRead() +GattClient::ReadCallbackChain_t &GattClient::onDataRead() { return onDataReadCallbackChain; } @@ -1591,7 +1663,7 @@ void GattClient::onDataWritten(WriteCallback_t callback) /** * @see GattClient::onDataWritten */ -GattClient::WriteCallbackChain_t& GattClient::onDataWritten() +GattClient::WriteCallbackChain_t &GattClient::onDataWritten() { return onDataWriteCallbackChain; } @@ -1607,7 +1679,7 @@ void GattClient::onHVX(HVXCallback_t callback) /** * @see GattClient::onShutdown */ -void GattClient::onShutdown(const GattClientShutdownCallback_t& callback) +void GattClient::onShutdown(const GattClientShutdownCallback_t &callback) { shutdownCallChain.add(callback); } @@ -1615,16 +1687,7 @@ void GattClient::onShutdown(const GattClientShutdownCallback_t& callback) /** * @see GattClient::onShutdown */ -template -void GattClient::onShutdown(T *objPtr, void (T::*memberPtr)(const GattClient *)) -{ - shutdownCallChain.add(objPtr, memberPtr); -} - -/** - * @see GattClient::onShutdown - */ -GattClient::GattClientShutdownCallbackChain_t& GattClient::onShutdown() +GattClient::GattClientShutdownCallbackChain_t &GattClient::onShutdown() { return shutdownCallChain; } @@ -1632,7 +1695,7 @@ GattClient::GattClientShutdownCallbackChain_t& GattClient::onShutdown() /** * @see GattClient::onHVX */ -GattClient::HVXCallbackChain_t& GattClient::onHVX() +GattClient::HVXCallbackChain_t &GattClient::onHVX() { return onHVXCallbackChain; } @@ -1663,6 +1726,7 @@ void GattClient::processHVXEvent(const GattHVXCallbackParams *params) } } +} // namespace impl } // namespace ble #endif // BLE_FEATURE_GATT_SERVER diff --git a/connectivity/FEATURE_BLE/libraries/ble-api-implementation/include/ble/internal/GattClientImpl.h b/connectivity/FEATURE_BLE/source/generic/GattClientImpl.h similarity index 71% rename from connectivity/FEATURE_BLE/libraries/ble-api-implementation/include/ble/internal/GattClientImpl.h rename to connectivity/FEATURE_BLE/source/generic/GattClientImpl.h index 9a3c9cd8b1b..bf13e13e6ec 100644 --- a/connectivity/FEATURE_BLE/libraries/ble-api-implementation/include/ble/internal/GattClientImpl.h +++ b/connectivity/FEATURE_BLE/source/generic/GattClientImpl.h @@ -19,34 +19,49 @@ #ifndef IMPL_GATT_CLIENT_H__ #define IMPL_GATT_CLIENT_H__ -#include "CallChainOfFunctionPointersWithContext.h" +#include "ble/BLE.h" + +#include "ble/common/CallChainOfFunctionPointersWithContext.h" #include -#include "ble/common/ble/blecommon.h" -#include "ble/common/ble/GattAttribute.h" -#include "ble/common/ble/ServiceDiscovery.h" -#include "ble/common/ble/CharacteristicDescriptorDiscovery.h" -#include "ble/common/ble/GattCallbackParamTypes.h" -#include "ble/internal/PalGattClient.h" -#include "ble/internal/PalSigningMonitor.h" +#include "ble/common/blecommon.h" +#include "ble/gatt/GattAttribute.h" +#include "ble/gatt/ServiceDiscovery.h" +#include "ble/gatt/CharacteristicDescriptorDiscovery.h" +#include "ble/gatt/GattCallbackParamTypes.h" +#include "source/pal/PalGattClient.h" +#include "source/pal/PalSigningMonitor.h" #include "ble/GattClient.h" namespace ble { +class BLEInstanceBase; + +namespace impl { + class GattClient : - public ble::interface::GattClient, public PalSigningMonitor, - public PalGattClientEventHandler -{ + public PalGattClientEventHandler { friend PalSigningMonitor; friend BLEInstanceBase; public: + using EventHandler = ble::GattClient::EventHandler; + using WriteOp_t = ble::GattClient::WriteOp_t; + using HVXCallback_t = ble::GattClient::HVXCallback_t ; + using GattClientShutdownCallback_t = ble::GattClient::GattClientShutdownCallback_t ; + using GattClientShutdownCallbackChain_t = ble::GattClient::GattClientShutdownCallbackChain_t ; + using HVXCallbackChain_t = ble::GattClient::HVXCallbackChain_t ; + using ReadCallbackChain_t = ble::GattClient::ReadCallbackChain_t ; + using WriteCallbackChain_t = ble::GattClient::WriteCallbackChain_t ; + + + void setEventHandler(EventHandler *handler); ble_error_t launchServiceDiscovery( ble::connection_handle_t connectionHandle, - ServiceDiscovery::ServiceCallback_t sc = NULL, - ServiceDiscovery::CharacteristicCallback_t cc = NULL, + ServiceDiscovery::ServiceCallback_t sc = nullptr, + ServiceDiscovery::CharacteristicCallback_t cc = nullptr, const UUID &matchingServiceUUID = UUID::ShortUUIDBytes_t(BLE_UUID_UNKNOWN), const UUID &matchingCharacteristicUUIDIn = UUID::ShortUUIDBytes_t(BLE_UUID_UNKNOWN) ); @@ -86,28 +101,28 @@ class GattClient : void onDataRead(ReadCallback_t callback); - ReadCallbackChain_t& onDataRead(); + ReadCallbackChain_t &onDataRead(); void onDataWritten(WriteCallback_t callback); - WriteCallbackChain_t& onDataWritten(); + WriteCallbackChain_t &onDataWritten(); void onServiceDiscoveryTermination( ServiceDiscovery::TerminationCallback_t callback ); ble_error_t discoverCharacteristicDescriptors( - const DiscoveredCharacteristic& characteristic, - const CharacteristicDescriptorDiscovery::DiscoveryCallback_t& discoveryCallback, - const CharacteristicDescriptorDiscovery::TerminationCallback_t& terminationCallback + const DiscoveredCharacteristic &characteristic, + const CharacteristicDescriptorDiscovery::DiscoveryCallback_t &discoveryCallback, + const CharacteristicDescriptorDiscovery::TerminationCallback_t &terminationCallback ); bool isCharacteristicDescriptorDiscoveryActive( - const DiscoveredCharacteristic& characteristic + const DiscoveredCharacteristic &characteristic ) const; void terminateCharacteristicDescriptorDiscovery( - const DiscoveredCharacteristic& characteristic + const DiscoveredCharacteristic &characteristic ); ble_error_t negotiateAttMtu(ble::connection_handle_t connection); @@ -122,14 +137,11 @@ class GattClient : */ void onHVX(HVXCallback_t callback); - void onShutdown(const GattClientShutdownCallback_t& callback); - - template - void onShutdown(T *objPtr, void (T::*memberPtr)(const GattClient *)); + void onShutdown(const GattClientShutdownCallback_t &callback); - GattClientShutdownCallbackChain_t& onShutdown(); + GattClientShutdownCallbackChain_t &onShutdown(); - HVXCallbackChain_t& onHVX(); + HVXCallbackChain_t &onHVX(); ble_error_t reset(void); @@ -144,7 +156,8 @@ class GattClient : private: /* Disallow copy and assignment. */ GattClient(const GattClient &); - GattClient& operator=(const GattClient &); + + GattClient &operator=(const GattClient &); /* ===================================================================== */ /* private implementation follows */ @@ -153,7 +166,7 @@ class GattClient : /** * @see ble::PalSigningMonitor::set_signing_event_handler */ - void set_signing_event_handler(PalSigningMonitorEventHandler *signing_event_handler); + void set_signing_event_handler(PalSigningMonitorEventHandler *signing_event_handler) override; /** * @see PalGattClient::EventHandler::on_att_mtu_change @@ -161,7 +174,7 @@ class GattClient : void on_att_mtu_change( ble::connection_handle_t connection_handle, uint16_t att_mtu_size - ); + ) override; /** * @see PalGattClient::EventHandler::on_write_command_sent @@ -170,7 +183,7 @@ class GattClient : ble::connection_handle_t connection_handle, ble::attribute_handle_t attribute_handle, uint8_t status - ); + ) override; private: struct ProcedureControlBlock; @@ -179,15 +192,22 @@ class GattClient : struct WriteControlBlock; struct DescriptorDiscoveryControlBlock; - ProcedureControlBlock* get_control_block(connection_handle_t connection); - const ProcedureControlBlock* get_control_block(connection_handle_t connection) const; - void insert_control_block(ProcedureControlBlock* cb) const; - void remove_control_block(ProcedureControlBlock* cb) const; + ProcedureControlBlock *get_control_block(connection_handle_t connection); + + const ProcedureControlBlock *get_control_block(connection_handle_t connection) const; + + void insert_control_block(ProcedureControlBlock *cb) const; + + void remove_control_block(ProcedureControlBlock *cb) const; void on_termination(connection_handle_t connection_handle); - void on_server_message_received(connection_handle_t, const AttServerMessage&); - void on_server_response(connection_handle_t, const AttServerMessage&); - void on_server_event(connection_handle_t, const AttServerMessage&); + + void on_server_message_received(connection_handle_t, const AttServerMessage &); + + void on_server_response(connection_handle_t, const AttServerMessage &); + + void on_server_event(connection_handle_t, const AttServerMessage &); + void on_transaction_timeout(connection_handle_t); uint16_t get_mtu(connection_handle_t connection) const; @@ -222,21 +242,22 @@ class GattClient : */ GattClientShutdownCallbackChain_t shutdownCallChain; - PalGattClient& _pal_client; + PalGattClient &_pal_client; ServiceDiscovery::TerminationCallback_t _termination_callback; - PalSigningMonitorEventHandler* _signing_event_handler; - mutable ProcedureControlBlock* control_blocks; + PalSigningMonitorEventHandler *_signing_event_handler; + mutable ProcedureControlBlock *control_blocks; bool _is_reseting; private: /** * Create a PalGattClient from a PalGattClient */ - GattClient(PalGattClient& pal_client); + GattClient(PalGattClient &pal_client); - ~GattClient() { } + ~GattClient() = default; }; +} // namespace impl } // namespace ble #endif /* ifndef IMPL_GATT_CLIENT_H__ */ diff --git a/connectivity/FEATURE_BLE/include/ble/common/ble/GattServerEvents.h b/connectivity/FEATURE_BLE/source/generic/GattServerEvents.h similarity index 100% rename from connectivity/FEATURE_BLE/include/ble/common/ble/GattServerEvents.h rename to connectivity/FEATURE_BLE/source/generic/GattServerEvents.h diff --git a/connectivity/FEATURE_BLE/source/KVStoreSecurityDb.cpp b/connectivity/FEATURE_BLE/source/generic/KVStoreSecurityDb.cpp similarity index 99% rename from connectivity/FEATURE_BLE/source/KVStoreSecurityDb.cpp rename to connectivity/FEATURE_BLE/source/generic/KVStoreSecurityDb.cpp index c1a5f2ce836..28db9388819 100644 --- a/connectivity/FEATURE_BLE/source/KVStoreSecurityDb.cpp +++ b/connectivity/FEATURE_BLE/source/generic/KVStoreSecurityDb.cpp @@ -18,7 +18,7 @@ #if BLE_SECURITY_DATABASE_KVSTORE -#include "ble/internal/KVStoreSecurityDb.h" +#include "KVStoreSecurityDb.h" namespace ble { diff --git a/connectivity/FEATURE_BLE/include/ble/internal/KVStoreSecurityDb.h b/connectivity/FEATURE_BLE/source/generic/KVStoreSecurityDb.h similarity index 99% rename from connectivity/FEATURE_BLE/include/ble/internal/KVStoreSecurityDb.h rename to connectivity/FEATURE_BLE/source/generic/KVStoreSecurityDb.h index 0f0dfe6516d..fa4a2bfb463 100644 --- a/connectivity/FEATURE_BLE/include/ble/internal/KVStoreSecurityDb.h +++ b/connectivity/FEATURE_BLE/source/generic/KVStoreSecurityDb.h @@ -24,7 +24,7 @@ #include "kvstore_global_api.h" #include "mbed_error.h" -#include "ble/internal/SecurityDb.h" +#include "SecurityDb.h" #define STR_EXPAND(tok) #tok #define STR(tok) STR_EXPAND(tok) diff --git a/connectivity/FEATURE_BLE/include/ble/internal/MemorySecurityDb.h b/connectivity/FEATURE_BLE/source/generic/MemorySecurityDb.h similarity index 73% rename from connectivity/FEATURE_BLE/include/ble/internal/MemorySecurityDb.h rename to connectivity/FEATURE_BLE/source/generic/MemorySecurityDb.h index 37ad010dec3..25cd90883a8 100644 --- a/connectivity/FEATURE_BLE/include/ble/internal/MemorySecurityDb.h +++ b/connectivity/FEATURE_BLE/source/generic/MemorySecurityDb.h @@ -19,7 +19,7 @@ #ifndef GENERIC_MEMORY_SECURITY_DB_H_ #define GENERIC_MEMORY_SECURITY_DB_H_ -#include "ble/internal/SecurityDb.h" +#include "SecurityDb.h" namespace ble { @@ -27,7 +27,7 @@ namespace ble { class MemorySecurityDb : public SecurityDb { private: struct entry_t { - entry_t() { }; + entry_t() = default; SecurityDistributionFlags_t flags; SecurityEntryKeys_t local_keys; SecurityEntryKeys_t peer_keys; @@ -42,21 +42,21 @@ class MemorySecurityDb : public SecurityDb { public: MemorySecurityDb() : SecurityDb() { } - virtual ~MemorySecurityDb() { } + ~MemorySecurityDb() override = default; - virtual SecurityDistributionFlags_t* get_distribution_flags( + SecurityDistributionFlags_t* get_distribution_flags( entry_handle_t db_handle - ) { + ) override { return reinterpret_cast(db_handle); } /* local keys */ /* set */ - virtual void set_entry_local_ltk( + void set_entry_local_ltk( entry_handle_t db_handle, const ltk_t <k - ) { + ) override { entry_t *entry = as_entry(db_handle); if (entry) { entry->flags.ltk_sent = true; @@ -64,11 +64,11 @@ class MemorySecurityDb : public SecurityDb { } } - virtual void set_entry_local_ediv_rand( + void set_entry_local_ediv_rand( entry_handle_t db_handle, const ediv_t &ediv, const rand_t &rand - ) { + ) override { entry_t *entry = as_entry(db_handle); if (entry) { entry->local_keys.ediv = ediv; @@ -80,10 +80,10 @@ class MemorySecurityDb : public SecurityDb { /* set */ - virtual void set_entry_peer_ltk( + void set_entry_peer_ltk( entry_handle_t db_handle, const ltk_t <k - ) { + ) override { entry_t *entry = as_entry(db_handle); if (entry) { entry->peer_keys.ltk = ltk; @@ -91,11 +91,11 @@ class MemorySecurityDb : public SecurityDb { } } - virtual void set_entry_peer_ediv_rand( + void set_entry_peer_ediv_rand( entry_handle_t db_handle, const ediv_t &ediv, const rand_t &rand - ) { + ) override { entry_t *entry = as_entry(db_handle); if (entry) { entry->peer_keys.ediv = ediv; @@ -103,10 +103,10 @@ class MemorySecurityDb : public SecurityDb { } } - virtual void set_entry_peer_irk( + void set_entry_peer_irk( entry_handle_t db_handle, const irk_t &irk - ) { + ) override { entry_t *entry = as_entry(db_handle); if (entry) { entry->peer_identity.irk = irk; @@ -114,11 +114,11 @@ class MemorySecurityDb : public SecurityDb { } } - virtual void set_entry_peer_bdaddr( + void set_entry_peer_bdaddr( entry_handle_t db_handle, bool address_is_public, const address_t &peer_address - ) { + ) override { entry_t *entry = as_entry(db_handle); if (entry) { entry->peer_identity.identity_address = peer_address; @@ -126,10 +126,10 @@ class MemorySecurityDb : public SecurityDb { } } - virtual void set_entry_peer_csrk( + void set_entry_peer_csrk( entry_handle_t db_handle, const csrk_t &csrk - ) { + ) override { entry_t *entry = as_entry(db_handle); if (entry) { entry->flags.csrk_stored = true; @@ -137,10 +137,10 @@ class MemorySecurityDb : public SecurityDb { } } - virtual void set_entry_peer_sign_counter( + void set_entry_peer_sign_counter( entry_handle_t db_handle, sign_count_t sign_counter - ) { + ) override { entry_t *entry = as_entry(db_handle); if (entry) { entry->peer_signing.counter = sign_counter; @@ -148,40 +148,40 @@ class MemorySecurityDb : public SecurityDb { } private: - virtual uint8_t get_entry_count() { + uint8_t get_entry_count() override { return BLE_SECURITY_DATABASE_MAX_ENTRIES; } - virtual SecurityDistributionFlags_t* get_entry_handle_by_index(uint8_t index) { + SecurityDistributionFlags_t* get_entry_handle_by_index(uint8_t index) override { if (index < BLE_SECURITY_DATABASE_MAX_ENTRIES) { return &_entries[index].flags; } else { - return NULL; + return nullptr; } } - virtual void reset_entry(entry_handle_t db_entry) { - entry_t *entry = reinterpret_cast(db_entry); + void reset_entry(entry_handle_t db_entry) override{ + auto *entry = reinterpret_cast(db_entry); *entry = entry_t(); } - virtual SecurityEntryIdentity_t* read_in_entry_peer_identity(entry_handle_t db_entry) { - entry_t *entry = reinterpret_cast(db_entry); + SecurityEntryIdentity_t* read_in_entry_peer_identity(entry_handle_t db_entry) override { + auto *entry = reinterpret_cast(db_entry); return &entry->peer_identity; }; - virtual SecurityEntryKeys_t* read_in_entry_peer_keys(entry_handle_t db_entry) { - entry_t *entry = reinterpret_cast(db_entry); + SecurityEntryKeys_t* read_in_entry_peer_keys(entry_handle_t db_entry) override { + auto *entry = reinterpret_cast(db_entry); return &entry->peer_keys; }; - virtual SecurityEntryKeys_t* read_in_entry_local_keys(entry_handle_t db_entry) { - entry_t *entry = reinterpret_cast(db_entry); + SecurityEntryKeys_t* read_in_entry_local_keys(entry_handle_t db_entry) override { + auto *entry = reinterpret_cast(db_entry); return &entry->local_keys; }; - virtual SecurityEntrySigning_t* read_in_entry_peer_signing(entry_handle_t db_entry) { - entry_t *entry = reinterpret_cast(db_entry); + SecurityEntrySigning_t* read_in_entry_peer_signing(entry_handle_t db_entry) override { + auto *entry = reinterpret_cast(db_entry); return &entry->peer_signing; }; diff --git a/connectivity/FEATURE_BLE/include/ble/internal/SecurityDb.h b/connectivity/FEATURE_BLE/source/generic/SecurityDb.h similarity index 98% rename from connectivity/FEATURE_BLE/include/ble/internal/SecurityDb.h rename to connectivity/FEATURE_BLE/source/generic/SecurityDb.h index cd20c07ceca..e6a24e709a2 100644 --- a/connectivity/FEATURE_BLE/include/ble/internal/SecurityDb.h +++ b/connectivity/FEATURE_BLE/source/generic/SecurityDb.h @@ -19,11 +19,10 @@ #ifndef GENERIC_SECURITY_MANAGER_DB_H__ #define GENERIC_SECURITY_MANAGER_DB_H__ -#include +#include #include "platform/Callback.h" -#include "ble/common/ble/GapTypes.h" -#include "ble/common/ble/BLETypes.h" +#include "ble/common/BLETypes.h" #include "ble/Gap.h" namespace ble { @@ -128,7 +127,7 @@ class SecurityDb { WhitelistDbCb_t; SecurityDb() : _local_sign_counter(0) { }; - virtual ~SecurityDb() { }; + virtual ~SecurityDb() = default; /** * Return immediately security flags associated to a db entry. @@ -344,7 +343,7 @@ class SecurityDb { Span& identity_list ) { size_t count = 0; - for (size_t i = 0; i < get_entry_count() && count < identity_list.size(); ++i) { + for (size_t i = 0; i < get_entry_count() && count < (size_t) identity_list.size(); ++i) { entry_handle_t db_handle = get_entry_handle_by_index(i); SecurityDistributionFlags_t* flags = get_distribution_flags(db_handle); @@ -487,7 +486,7 @@ class SecurityDb { return flags; } - return NULL; + return nullptr; } /** @@ -536,7 +535,7 @@ class SecurityDb { } } - return NULL; + return nullptr; } /** @@ -705,7 +704,7 @@ class SecurityDb { */ virtual SecurityDistributionFlags_t* get_free_entry_flags() { /* get a free one if available */ - SecurityDistributionFlags_t* match = NULL; + SecurityDistributionFlags_t* match = nullptr; for (size_t i = 0; i < get_entry_count(); i++) { entry_handle_t db_handle = get_entry_handle_by_index(i); SecurityDistributionFlags_t* flags = get_distribution_flags(db_handle); diff --git a/connectivity/FEATURE_BLE/libraries/ble-api-implementation/source/SecurityManagerImpl.cpp b/connectivity/FEATURE_BLE/source/generic/SecurityManagerImpl.cpp similarity index 96% rename from connectivity/FEATURE_BLE/libraries/ble-api-implementation/source/SecurityManagerImpl.cpp rename to connectivity/FEATURE_BLE/source/generic/SecurityManagerImpl.cpp index 9e2ea53a886..fd2b3fe7ad3 100644 --- a/connectivity/FEATURE_BLE/libraries/ble-api-implementation/source/SecurityManagerImpl.cpp +++ b/connectivity/FEATURE_BLE/source/generic/SecurityManagerImpl.cpp @@ -16,13 +16,15 @@ * limitations under the License. */ -#include "BLERoles.h" +#include "ble/BLE.h" +#include "ble/common/BLERoles.h" -#include "ble/SecurityManager.h" -#include "ble/internal/PalSecurityManager.h" -#include "ble/internal/MemorySecurityDb.h" -#include "ble/internal/FileSecurityDb.h" -#include "ble/internal/KVStoreSecurityDb.h" +#include "source/pal/PalSecurityManager.h" + +#include "source/generic/SecurityManagerImpl.h" +#include "source/generic/MemorySecurityDb.h" +#include "source/generic/FileSecurityDb.h" +#include "source/generic/KVStoreSecurityDb.h" using ble::advertising_peer_address_type_t; using ble::AuthenticationMask; @@ -30,6 +32,33 @@ using ble::KeyDistribution; using ble::connection_peer_address_type_t; namespace ble { +namespace impl { + +namespace { +constexpr auto SECURITY_MODE_ENCRYPTION_OPEN_LINK = + ble::SecurityManager::SECURITY_MODE_ENCRYPTION_OPEN_LINK; + +constexpr auto SECURITY_MODE_ENCRYPTION_NO_MITM = + ble::SecurityManager::SECURITY_MODE_ENCRYPTION_NO_MITM; + +constexpr auto SECURITY_MODE_ENCRYPTION_WITH_MITM = + ble::SecurityManager::SECURITY_MODE_ENCRYPTION_WITH_MITM; + +constexpr auto SECURITY_MODE_SIGNED_NO_MITM = + ble::SecurityManager::SECURITY_MODE_SIGNED_NO_MITM; + +constexpr auto SECURITY_MODE_SIGNED_WITH_MITM = + ble::SecurityManager::SECURITY_MODE_SIGNED_WITH_MITM; + +using SecurityCompletionStatus_t = ble::SecurityManager::SecurityCompletionStatus_t; + +constexpr auto SEC_STATUS_TIMEOUT = + ble::SecurityManager::SEC_STATUS_TIMEOUT; + +constexpr auto SEC_STATUS_SUCCESS = + ble::SecurityManager::SEC_STATUS_SUCCESS; + +} /* Implements PalSecurityManager */ @@ -126,8 +155,8 @@ ble_error_t SecurityManager::setDatabaseFilepath( if (!_db) return BLE_ERROR_INITIALIZATION_INCOMPLETE; /* operation only allowed with no connections active */ - for (size_t i = 0; i < MAX_CONTROL_BLOCKS; i++) { - if (_control_blocks[i].connected) { + for (auto & _control_block : _control_blocks) { + if (_control_block.connected) { return BLE_ERROR_OPERATION_NOT_PERMITTED; } } @@ -145,14 +174,14 @@ ble_error_t SecurityManager::setDatabaseFilepath( } -ble_error_t SecurityManager::reset(void) +ble_error_t SecurityManager::reset() { delete _db; _db = nullptr; _pal.reset(); /* Notify that the instance is about to shutdown */ - shutdownCallChain.call(this); + shutdownCallChain.call(&ble::BLE::Instance().securityManager()); shutdownCallChain.clear(); eventHandler = &defaultEventHandler; @@ -955,7 +984,7 @@ ble_error_t SecurityManager::init_resolving_list() /* match the resolving list to the currently stored set of IRKs */ uint8_t resolving_list_capacity = _pal.read_resolving_list_capacity(); - SecurityEntryIdentity_t* identity_list_p = + auto* identity_list_p = new (std::nothrow) SecurityEntryIdentity_t[resolving_list_capacity]; if (identity_list_p) { @@ -1894,7 +1923,7 @@ void SecurityManager::on_ltk_request( SecurityManager::ControlBlock_t::ControlBlock_t() : connection(0), - db_entry(0), + db_entry(nullptr), local_address(), connected(false), authenticated(false), @@ -1932,9 +1961,9 @@ typename SecurityManager::ControlBlock_t* SecurityManager::acquire_control_block(connection_handle_t connection) { /* grab the first disconnected slot*/ - for (size_t i = 0; i < MAX_CONTROL_BLOCKS; i++) { - if (!_control_blocks[i].connected) { - ControlBlock_t* cb = &_control_blocks[i]; + for (auto & control_block : _control_blocks) { + if (!control_block.connected) { + ControlBlock_t* cb = &control_block; cb->connected = true; cb->connection = connection; return cb; @@ -1950,11 +1979,11 @@ SecurityManager::get_control_block( connection_handle_t connection ) { - for (size_t i = 0; i < MAX_CONTROL_BLOCKS; i++) { - if (!_control_blocks[i].connected) { + for (auto & cb : _control_blocks) { + if (!cb.connected) { continue; - } else if (connection == _control_blocks[i].connection) { - return &_control_blocks[i]; + } else if (connection == cb.connection) { + return &cb; } } return nullptr; @@ -1967,8 +1996,8 @@ SecurityManager::get_control_block( ) { MBED_ASSERT(_db); - for (size_t i = 0; i < MAX_CONTROL_BLOCKS; i++) { - ControlBlock_t *cb = &_control_blocks[i]; + for (auto & control_block : _control_blocks) { + ControlBlock_t *cb = &control_block; if (cb->connected) { SecurityDistributionFlags_t* flags = _db->get_distribution_flags(cb->db_entry); if (flags && (flags->peer_address == peer_address)) { @@ -1985,11 +2014,11 @@ SecurityManager::get_control_block( SecurityDb::entry_handle_t db_entry ) { - for (size_t i = 0; i < MAX_CONTROL_BLOCKS; i++) { - if (!_control_blocks[i].connected) { + for (auto & cb : _control_blocks) { + if (!cb.connected) { continue; - } else if (db_entry == _control_blocks[i].db_entry) { - return &_control_blocks[i]; + } else if (db_entry == cb.db_entry) { + return &cb; } } return nullptr; @@ -2026,4 +2055,5 @@ void SecurityManager::setSecurityManagerEventHandler(EventHandler* handler) } } +} /* namespace impl */ } /* namespace ble */ diff --git a/connectivity/FEATURE_BLE/libraries/ble-api-implementation/include/ble/internal/SecurityManagerImpl.h b/connectivity/FEATURE_BLE/source/generic/SecurityManagerImpl.h similarity index 78% rename from connectivity/FEATURE_BLE/libraries/ble-api-implementation/include/ble/internal/SecurityManagerImpl.h rename to connectivity/FEATURE_BLE/source/generic/SecurityManagerImpl.h index a8f26e3c62a..d159880f89e 100644 --- a/connectivity/FEATURE_BLE/libraries/ble-api-implementation/include/ble/internal/SecurityManagerImpl.h +++ b/connectivity/FEATURE_BLE/source/generic/SecurityManagerImpl.h @@ -19,54 +19,66 @@ #ifndef IMPL_SECURITY_MANAGER_H_ #define IMPL_SECURITY_MANAGER_H_ -#include -#include "CallChainOfFunctionPointersWithContext.h" +#include + #include "platform/Callback.h" -#include "ble/common/ble/BLETypes.h" -#include "ble/common/ble/blecommon.h" #include "ble/Gap.h" - -#include "ble/common/ble/GapTypes.h" -#include "ble/common/ble/BLETypes.h" -#include "ble/internal/SecurityDb.h" -#include "ble/internal/PalConnectionMonitor.h" -#include "ble/internal/PalSigningMonitor.h" -#include "ble/internal/PalSecurityManager.h" #include "ble/SecurityManager.h" +#include "ble/common/CallChainOfFunctionPointersWithContext.h" +#include "ble/common/BLETypes.h" +#include "ble/common/blecommon.h" +#include "ble/common/BLETypes.h" + +#include "source/pal/GapTypes.h" +#include "source/pal/PalConnectionMonitor.h" +#include "source/pal/PalSigningMonitor.h" +#include "source/pal/PalSecurityManager.h" + +#include "source/generic/SecurityDb.h" + + namespace ble { +class PalGenericAccessService; -class BLEInstanceBase; +namespace impl { class SecurityManager : - public ble::interface::SecurityManager, public ble::PalSecurityManagerEventHandler, public ble::PalConnectionMonitorEventHandler, - public ble::PalSigningMonitorEventHandler -{ + public ble::PalSigningMonitorEventHandler { friend class ble::PalConnectionMonitorEventHandler; - friend BLEInstanceBase; + friend PalGenericAccessService; friend PalSecurityManager; + using SecurityIOCapabilities_t = ble::SecurityManager::SecurityIOCapabilities_t; + using SecurityMode_t = ble::SecurityManager::SecurityMode_t; + using SecurityManagerShutdownCallback_t = ble::SecurityManager::SecurityManagerShutdownCallback_t; + using SecurityManagerShutdownCallbackChain_t = ble::SecurityManager::SecurityManagerShutdownCallbackChain_t; + using EventHandler = ble::SecurityManager::EventHandler; + using Passkey_t = ble::SecurityManager::Passkey_t ; + + static auto constexpr IO_CAPS_NONE = ble::SecurityManager::IO_CAPS_NONE; + public: //////////////////////////////////////////////////////////////////////////// // SM lifecycle management // ble_error_t init( - bool enableBonding = true, - bool requireMITM = true, - SecurityIOCapabilities_t iocaps = IO_CAPS_NONE, - const Passkey_t passkey = NULL, - bool signing = true, - const char *dbFilepath = NULL + bool enableBonding = true, + bool requireMITM = true, + SecurityIOCapabilities_t iocaps = IO_CAPS_NONE, + const Passkey_t passkey = nullptr, + bool signing = true, + const char *dbFilepath = nullptr ); - ble_error_t setDatabaseFilepath(const char *dbFilepath = NULL); + ble_error_t setDatabaseFilepath(const char *dbFilepath = nullptr); - ble_error_t reset(void); + ble_error_t reset(); ble_error_t preserveBondingStateOnReset(bool enable); @@ -74,7 +86,7 @@ class SecurityManager : // List management // - ble_error_t purgeAllBondingState(void); + ble_error_t purgeAllBondingState(); ble_error_t generateWhitelistFromBondTable(::ble::whitelist_t *whitelist) const; @@ -115,6 +127,7 @@ class SecurityManager : #if BLE_FEATURE_SIGNING ble_error_t enableSigning(ble::connection_handle_t connectionHandle, bool enabled = true); + #endif // BLE_FEATURE_SIGNING ble_error_t setHintFutureRoleReversal(bool enable = true); @@ -156,7 +169,11 @@ class SecurityManager : ble_error_t legacyPairingOobReceived(const ble::address_t *address, const ble::oob_tk_t *tk); - ble_error_t oobReceived(const ble::address_t *address, const ble::oob_lesc_value_t *random, const ble::oob_confirm_t *confirm); + ble_error_t oobReceived( + const ble::address_t *address, + const ble::oob_lesc_value_t *random, + const ble::oob_confirm_t *confirm + ); //////////////////////////////////////////////////////////////////////////// // Keys @@ -175,14 +192,14 @@ class SecurityManager : /* Event callback handlers. */ public: - void onShutdown(const SecurityManagerShutdownCallback_t& callback); + void onShutdown(const SecurityManagerShutdownCallback_t &callback); - template + template void onShutdown(T *objPtr, void (T::*memberPtr)(const SecurityManager *)); - SecurityManagerShutdownCallbackChain_t& onShutdown(); + SecurityManagerShutdownCallbackChain_t &onShutdown(); - void setSecurityManagerEventHandler(EventHandler* handler); + void setSecurityManagerEventHandler(EventHandler *handler); /* ===================================================================== */ /* private implementation follows */ @@ -230,26 +247,26 @@ class SecurityManager : AuthenticationMask authentication, KeyDistribution initiator_dist, KeyDistribution responder_dist - ); + ) override; /** @copydoc PalSecurityManager::on_pairing_error */ void on_pairing_error( connection_handle_t connection, pairing_failure_t error - ); + ) override; /** @copydoc PalSecurityManager::on_pairing_timed_out */ void on_pairing_timed_out( connection_handle_t connection - ); + ) override; /** @copydoc PalSecurityManager::on_pairing_completed */ void on_pairing_completed( connection_handle_t connection - ); + ) override; //////////////////////////////////////////////////////////////////////////// // Security @@ -259,31 +276,31 @@ class SecurityManager : */ void on_valid_mic_timeout( connection_handle_t connection - ); + ) override; /** @copydoc PalSecurityManager::on_signed_write_received */ void on_signed_write_received( connection_handle_t connection, uint32_t sign_coutner - ); + ) override; /** @copydoc PalSecurityManager::on_signed_write_verification_failure */ void on_signed_write_verification_failure( connection_handle_t connection - ); + ) override; /** @copydoc PalSecurityManager::on_signed_write */ - void on_signed_write(); + void on_signed_write() override; /** @copydoc PalSecurityManager::on_slave_security_request */ void on_slave_security_request( connection_handle_t connection, AuthenticationMask authentication - ); + ) override; //////////////////////////////////////////////////////////////////////////// // Encryption @@ -294,13 +311,13 @@ class SecurityManager : void on_link_encryption_result( connection_handle_t connection, link_encryption_t result - ); + ) override; /** @copydoc PalSecurityManager::on_link_encryption_request_timed_out */ void on_link_encryption_request_timed_out( connection_handle_t connection - ); + ) override; //////////////////////////////////////////////////////////////////////////// // MITM @@ -311,45 +328,45 @@ class SecurityManager : void on_passkey_display( connection_handle_t connection, passkey_num_t passkey - ); + ) override; /** @copydoc PalSecurityManager::on_keypress_notification */ void on_keypress_notification( connection_handle_t connection, ble::Keypress_t keypress - ); + ) override; /** @copydoc PalSecurityManager::on_passkey_request */ void on_passkey_request( connection_handle_t connection - ); + ) override; /** @copydoc PalSecurityManager::on_confirmation_request */ void on_confirmation_request( connection_handle_t connection - ); + ) override; /** @copydoc PalSecurityManager::on_secure_connections_oob_request */ void on_secure_connections_oob_request( connection_handle_t connection - ); + ) override; /** @copydoc PalSecurityManager::on_legacy_pairing_oob_request */ void on_legacy_pairing_oob_request( connection_handle_t connection - ); + ) override; /** @copydoc PalSecurityManager::on_secure_connections_oob_generated */ void on_secure_connections_oob_generated( const oob_lesc_value_t &random, const oob_confirm_t &confirm - ); + ) override; //////////////////////////////////////////////////////////////////////////// // Keys @@ -360,14 +377,14 @@ class SecurityManager : void on_secure_connections_ltk_generated( connection_handle_t connection, const ltk_t <k - ); + ) override; /** @copydoc PalSecurityManager::on_keys_distributed_ltk */ void on_keys_distributed_ltk( connection_handle_t connection, const ltk_t <k - ); + ) override; /** @copydoc PalSecurityManager::on_keys_distributed_ediv_rand */ @@ -375,14 +392,14 @@ class SecurityManager : connection_handle_t connection, const ediv_t &ediv, const rand_t &rand - ); + ) override; /** @copydoc PalSecurityManager::on_keys_distributed_local_ltk */ void on_keys_distributed_local_ltk( connection_handle_t connection, const ltk_t <k - ); + ) override; /** @copydoc PalSecurityManager::on_keys_distributed_local_ediv_rand */ @@ -390,14 +407,14 @@ class SecurityManager : connection_handle_t connection, const ediv_t &ediv, const rand_t &rand - ); + ) override; /** @copydoc PalSecurityManager::on_keys_distributed_irk */ void on_keys_distributed_irk( connection_handle_t connection, const irk_t &irk - ); + ) override; /** @copydoc PalSecurityManager::on_keys_distributed_bdaddr */ @@ -405,14 +422,14 @@ class SecurityManager : connection_handle_t connection, advertising_peer_address_type_t peer_address_type, const address_t &peer_identity_address - ); + ) override; /** @copydoc PalSecurityManager::on_keys_distributed_csrk */ void on_keys_distributed_csrk( connection_handle_t connection, const csrk_t &csrk - ); + ) override; /** @copydoc PalSecurityManager::on_ltk_requeston_ltk_request */ @@ -420,35 +437,31 @@ class SecurityManager : connection_handle_t connection, const ediv_t &ediv, const rand_t &rand - ); + ) override; /** @copydoc PalSecurityManager::on_ltk_requeston_ltk_request */ void on_ltk_request( connection_handle_t connection - ); + ) override; /* end implements PalSecurityManager::EventHandler */ -private: - /* Disallow copy and assignment. */ - SecurityManager(const SecurityManager &); - SecurityManager& operator=(const SecurityManager &); - +public: SecurityManager( - PalSecurityManager &palImpl, - PalConnectionMonitor &connMonitorImpl, - PalSigningMonitor &signingMonitorImpl - ) : _pal(palImpl), + ble::PalSecurityManager &palImpl, + ble::PalConnectionMonitor &connMonitorImpl, + ble::PalSigningMonitor &signingMonitorImpl + ) : eventHandler(nullptr), + _pal(palImpl), _connection_monitor(connMonitorImpl), _signing_monitor(signingMonitorImpl), - _db(NULL), + _db(nullptr), _default_authentication(0), _default_key_distribution(KeyDistribution::KEY_DISTRIBUTION_ALL), _pairing_authorisation_required(false), _legacy_pairing_allowed(true), - _master_sends_keys(false), - eventHandler(NULL) + _master_sends_keys(false) { eventHandler = &defaultEventHandler; _pal.set_event_handler(this); @@ -464,13 +477,19 @@ class SecurityManager : delete _db; } +private: + /* Disallow copy and assignment. */ + SecurityManager(const SecurityManager &); + + SecurityManager &operator=(const SecurityManager &); + //////////////////////////////////////////////////////////////////////////// // Helper functions // private: - ble_error_t init_database(const char *db_path = NULL); + ble_error_t init_database(const char *db_path = nullptr); ble_error_t init_resolving_list(); @@ -493,12 +512,12 @@ class SecurityManager : void enable_encryption_cb( ble::SecurityDb::entry_handle_t entry, - const SecurityEntryKeys_t* entryKeys + const SecurityEntryKeys_t *entryKeys ); void set_ltk_cb( SecurityDb::entry_handle_t entry, - const SecurityEntryKeys_t* entryKeys + const SecurityEntryKeys_t *entryKeys ); void return_csrk_cb( @@ -527,20 +546,20 @@ class SecurityManager : address_t peer_address, own_address_type_t local_address_type, address_t local_address - ); + ) override; void on_disconnected( connection_handle_t connection, disconnection_reason_t reason - ); + ) override; void on_security_entry_retrieved( SecurityDb::entry_handle_t entry, - const SecurityEntryIdentity_t* identity + const SecurityEntryIdentity_t *identity ); void on_identity_list_retrieved( - Span& identity_list, + Span &identity_list, size_t count ); @@ -548,16 +567,23 @@ class SecurityManager : struct ControlBlock_t { ControlBlock_t(); - KeyDistribution get_initiator_key_distribution() { + KeyDistribution get_initiator_key_distribution() + { return KeyDistribution(initiator_key_distribution); }; - KeyDistribution get_responder_key_distribution() { + + KeyDistribution get_responder_key_distribution() + { return KeyDistribution(responder_key_distribution); }; - void set_initiator_key_distribution(KeyDistribution mask) { + + void set_initiator_key_distribution(KeyDistribution mask) + { initiator_key_distribution = mask.value(); }; - void set_responder_key_distribution(KeyDistribution mask) { + + void set_responder_key_distribution(KeyDistribution mask) + { responder_key_distribution = mask.value(); }; @@ -567,46 +593,46 @@ class SecurityManager : address_t local_address; /**< address used for connection, possibly different from identity */ private: - uint8_t initiator_key_distribution:4; - uint8_t responder_key_distribution:4; + uint8_t initiator_key_distribution: 4; + uint8_t responder_key_distribution: 4; public: - uint8_t connected:1; - uint8_t authenticated:1; /**< have we turned encryption on during this connection */ - uint8_t is_master:1; + uint8_t connected: 1; + uint8_t authenticated: 1; /**< have we turned encryption on during this connection */ + uint8_t is_master: 1; - uint8_t encryption_requested:1; - uint8_t encryption_failed:1; - uint8_t encrypted:1; - uint8_t signing_requested:1; - uint8_t signing_override_default:1; + uint8_t encryption_requested: 1; + uint8_t encryption_failed: 1; + uint8_t encrypted: 1; + uint8_t signing_requested: 1; + uint8_t signing_override_default: 1; - uint8_t mitm_requested:1; - uint8_t mitm_performed:1; /**< keys exchange will have MITM protection */ + uint8_t mitm_requested: 1; + uint8_t mitm_performed: 1; /**< keys exchange will have MITM protection */ - uint8_t attempt_oob:1; - uint8_t oob_mitm_protection:1; - uint8_t oob_present:1; - uint8_t legacy_pairing_oob_request_pending:1; + uint8_t attempt_oob: 1; + uint8_t oob_mitm_protection: 1; + uint8_t oob_present: 1; + uint8_t legacy_pairing_oob_request_pending: 1; - uint8_t csrk_failures:2; + uint8_t csrk_failures: 2; }; /* list management */ - ControlBlock_t* acquire_control_block(connection_handle_t connection); + ControlBlock_t *acquire_control_block(connection_handle_t connection); - ControlBlock_t* get_control_block(connection_handle_t connection); + ControlBlock_t *get_control_block(connection_handle_t connection); - ControlBlock_t* get_control_block(const address_t &peer_address); + ControlBlock_t *get_control_block(const address_t &peer_address); - ControlBlock_t* get_control_block(SecurityDb::entry_handle_t db_entry); + ControlBlock_t *get_control_block(SecurityDb::entry_handle_t db_entry); - void release_control_block(ControlBlock_t* entry); + void release_control_block(ControlBlock_t *entry); private: SecurityManagerShutdownCallbackChain_t shutdownCallChain; - EventHandler* eventHandler; - EventHandler defaultEventHandler; + EventHandler *eventHandler; + EventHandler defaultEventHandler; PalSecurityManager &_pal; PalConnectionMonitor &_connection_monitor; @@ -634,6 +660,7 @@ class SecurityManager : ControlBlock_t _control_blocks[MAX_CONTROL_BLOCKS]; }; +} // namespace impl } // ble #endif /*IMPL_SECURITY_MANAGER_H_*/ diff --git a/connectivity/FEATURE_BLE/libraries/ble-api-implementation/mbed_lib.json b/connectivity/FEATURE_BLE/source/generic/mbed_lib.json similarity index 100% rename from connectivity/FEATURE_BLE/libraries/ble-api-implementation/mbed_lib.json rename to connectivity/FEATURE_BLE/source/generic/mbed_lib.json diff --git a/connectivity/FEATURE_BLE/include/ble/internal/AttServerMessage.h b/connectivity/FEATURE_BLE/source/pal/AttServerMessage.h similarity index 98% rename from connectivity/FEATURE_BLE/include/ble/internal/AttServerMessage.h rename to connectivity/FEATURE_BLE/source/pal/AttServerMessage.h index a60fe28b0dd..9a804e81eb2 100644 --- a/connectivity/FEATURE_BLE/include/ble/internal/AttServerMessage.h +++ b/connectivity/FEATURE_BLE/source/pal/AttServerMessage.h @@ -19,8 +19,8 @@ #ifndef BLE_PAL_ATT_SERVER_MESSAGE_H_ #define BLE_PAL_ATT_SERVER_MESSAGE_H_ -#include "ble/common/ble/BLETypes.h" -#include "ble/common/ble/UUID.h" +#include "ble/common/BLETypes.h" +#include "ble/common/UUID.h" namespace ble { @@ -323,7 +323,7 @@ struct AttFindInformationResponse : public AttServerMessage { /** * virtual destructor to overide if the sub class needs it. */ - virtual ~AttFindInformationResponse() { } + virtual ~AttFindInformationResponse() = default; /** * Returns the number of information_data_t present in the response. @@ -366,7 +366,7 @@ struct AttFindByTypeValueResponse : public AttServerMessage { /** * virtual destructor to overide if the sub class needs it. */ - virtual ~AttFindByTypeValueResponse() { } + virtual ~AttFindByTypeValueResponse() = default; /** * Returns the number of attribute_handle_range_t present in the response. @@ -414,7 +414,7 @@ struct AttReadByTypeResponse : public AttServerMessage { /** * virtual destructor to overide if the sub class needs it. */ - virtual ~AttReadByTypeResponse() { } + virtual ~AttReadByTypeResponse() = default; /** * Return the number of attribute_data_t presents in the response. @@ -602,7 +602,7 @@ struct AttReadByGroupTypeResponse : public AttServerMessage { /** * virtual destructor to overide if the sub class needs it. */ - virtual ~AttReadByGroupTypeResponse() { } + virtual ~AttReadByGroupTypeResponse() = default; /** * Return the number of attribute_data_t present in the response. diff --git a/connectivity/FEATURE_BLE/include/ble/common/ble/GapEvents.h b/connectivity/FEATURE_BLE/source/pal/GapEvents.h similarity index 99% rename from connectivity/FEATURE_BLE/include/ble/common/ble/GapEvents.h rename to connectivity/FEATURE_BLE/source/pal/GapEvents.h index 0b9cca27a74..000c47e9836 100644 --- a/connectivity/FEATURE_BLE/include/ble/common/ble/GapEvents.h +++ b/connectivity/FEATURE_BLE/source/pal/GapEvents.h @@ -19,8 +19,8 @@ #ifndef BLE_PAL_GAP_MESSAGE_H_ #define BLE_PAL_GAP_MESSAGE_H_ -#include "ble/common/ble/GapTypes.h" -#include "ble/common/ble/BLETypes.h" +#include "GapTypes.h" +#include "ble/common/BLETypes.h" namespace ble { @@ -314,7 +314,7 @@ struct GapAdvertisingReportEvent : public GapEvent { GapAdvertisingReportEvent() : GapEvent(GapEventType::ADVERTISING_REPORT) { } - virtual ~GapAdvertisingReportEvent() { } + virtual ~GapAdvertisingReportEvent() = default; /** * Count of advertising in this event. diff --git a/connectivity/FEATURE_BLE/include/ble/common/ble/GapTypes.h b/connectivity/FEATURE_BLE/source/pal/GapTypes.h similarity index 99% rename from connectivity/FEATURE_BLE/include/ble/common/ble/GapTypes.h rename to connectivity/FEATURE_BLE/source/pal/GapTypes.h index ae0d66514da..8248b4bdb5e 100644 --- a/connectivity/FEATURE_BLE/include/ble/common/ble/GapTypes.h +++ b/connectivity/FEATURE_BLE/source/pal/GapTypes.h @@ -21,8 +21,8 @@ #include -#include "ble/common/ble/BLETypes.h" -#include "ble/common/ble/SafeEnum.h" +#include "ble/common/BLETypes.h" +#include "ble/common/SafeEnum.h" namespace ble { diff --git a/connectivity/FEATURE_BLE/include/ble/internal/PalAttClient.h b/connectivity/FEATURE_BLE/source/pal/PalAttClient.h similarity index 98% rename from connectivity/FEATURE_BLE/include/ble/internal/PalAttClient.h rename to connectivity/FEATURE_BLE/source/pal/PalAttClient.h index 946bbb8049c..cdc5921e3dd 100644 --- a/connectivity/FEATURE_BLE/include/ble/internal/PalAttClient.h +++ b/connectivity/FEATURE_BLE/source/pal/PalAttClient.h @@ -21,13 +21,12 @@ #include "platform/Callback.h" -#include "ble/common/ble/UUID.h" -#include "ble/common/ble/BLETypes.h" -#include "ble/common/ble/blecommon.h" -#include "ble/internal/AttServerMessage.h" +#include "ble/common/UUID.h" +#include "ble/common/BLETypes.h" +#include "ble/common/blecommon.h" +#include "AttServerMessage.h" namespace ble { -namespace interface { /** * Send attribute protocol requests to an ATT server. It also handle reception @@ -627,11 +626,6 @@ class PalAttClient { ) = 0; }; -} // namespace interface } // namespace ble -/* This includes the concrete class implementation, to provide a an alternative BLE PAL implementation - * disable Cordio and place your header in a path with the same structure */ -#include "ble/internal/PalAttClientImpl.h" - #endif /* BLE_PAL_ATTCLIENT_H_ */ diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/source/PalGattClientImpl.cpp b/connectivity/FEATURE_BLE/source/pal/PalAttClientToGattClient.cpp similarity index 74% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/source/PalGattClientImpl.cpp rename to connectivity/FEATURE_BLE/source/pal/PalAttClientToGattClient.cpp index e55e8fa4f54..6fe57930429 100644 --- a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/source/PalGattClientImpl.cpp +++ b/connectivity/FEATURE_BLE/source/pal/PalAttClientToGattClient.cpp @@ -16,31 +16,32 @@ * limitations under the License. */ -#include "ble/internal/PalGattClient.h" -#include "ble/internal/PalAttClient.h" +#include "source/pal/PalGattClient.h" +#include "source/pal/PalAttClient.h" +#include "source/pal/PalAttClientToGattClient.h" namespace ble { -PalGattClient::PalGattClient(PalAttClient& client) : _event_handler(nullptr), _client(client) +PalAttClientToGattClient::PalAttClientToGattClient(PalAttClient& client) : _event_handler(nullptr), _client(client) { _client.when_server_message_received( - mbed::callback(this, &PalGattClient::on_server_event) + mbed::callback(this, &PalAttClientToGattClient::on_server_event) ); _client.when_transaction_timeout( mbed::callback( - this, &PalGattClient::on_transaction_timeout + this, &PalAttClientToGattClient::on_transaction_timeout ) ); } -ble_error_t PalGattClient::exchange_mtu(connection_handle_t connection) +ble_error_t PalAttClientToGattClient::exchange_mtu(connection_handle_t connection) { return _client.exchange_mtu_request(connection); } -ble_error_t PalGattClient::get_mtu_size( +ble_error_t PalAttClientToGattClient::get_mtu_size( connection_handle_t connection_handle, uint16_t& mtu_size ) @@ -49,7 +50,7 @@ ble_error_t PalGattClient::get_mtu_size( } -ble_error_t PalGattClient::discover_primary_service( +ble_error_t PalAttClientToGattClient::discover_primary_service( connection_handle_t connection, attribute_handle_t discovery_range_begining ) @@ -62,7 +63,7 @@ ble_error_t PalGattClient::discover_primary_service( } -ble_error_t PalGattClient::discover_primary_service_by_service_uuid( +ble_error_t PalAttClientToGattClient::discover_primary_service_by_service_uuid( connection_handle_t connection_handle, attribute_handle_t discovery_range_begining, const UUID& uuid @@ -80,7 +81,7 @@ ble_error_t PalGattClient::discover_primary_service_by_service_uuid( } -ble_error_t PalGattClient::find_included_service( +ble_error_t PalAttClientToGattClient::find_included_service( connection_handle_t connection_handle, attribute_handle_range_t service_range ) @@ -93,7 +94,7 @@ ble_error_t PalGattClient::find_included_service( } -ble_error_t PalGattClient::discover_characteristics_of_a_service( +ble_error_t PalAttClientToGattClient::discover_characteristics_of_a_service( connection_handle_t connection_handle, attribute_handle_range_t discovery_range ) @@ -106,7 +107,7 @@ ble_error_t PalGattClient::discover_characteristics_of_a_service( } -ble_error_t PalGattClient::discover_characteristics_descriptors( +ble_error_t PalAttClientToGattClient::discover_characteristics_descriptors( connection_handle_t connection_handle, attribute_handle_range_t descriptors_discovery_range ) @@ -118,7 +119,7 @@ ble_error_t PalGattClient::discover_characteristics_descriptors( } -ble_error_t PalGattClient::read_attribute_value( +ble_error_t PalAttClientToGattClient::read_attribute_value( connection_handle_t connection_handle, attribute_handle_t attribute_handle ) @@ -130,7 +131,7 @@ ble_error_t PalGattClient::read_attribute_value( } -ble_error_t PalGattClient::read_using_characteristic_uuid( +ble_error_t PalAttClientToGattClient::read_using_characteristic_uuid( connection_handle_t connection_handle, attribute_handle_range_t read_range, const UUID& uuid @@ -144,7 +145,7 @@ ble_error_t PalGattClient::read_using_characteristic_uuid( } -ble_error_t PalGattClient::read_attribute_blob( +ble_error_t PalAttClientToGattClient::read_attribute_blob( connection_handle_t connection_handle, attribute_handle_t attribute_handle, uint16_t offset @@ -158,7 +159,7 @@ ble_error_t PalGattClient::read_attribute_blob( } -ble_error_t PalGattClient::read_multiple_characteristic_values( +ble_error_t PalAttClientToGattClient::read_multiple_characteristic_values( connection_handle_t connection_handle, const Span& characteristic_value_handles ) @@ -170,7 +171,7 @@ ble_error_t PalGattClient::read_multiple_characteristic_values( } -ble_error_t PalGattClient::write_without_response( +ble_error_t PalAttClientToGattClient::write_without_response( connection_handle_t connection_handle, attribute_handle_t characteristic_value_handle, const Span& value @@ -184,7 +185,7 @@ ble_error_t PalGattClient::write_without_response( } -ble_error_t PalGattClient::signed_write_without_response( +ble_error_t PalAttClientToGattClient::signed_write_without_response( connection_handle_t connection_handle, attribute_handle_t characteristic_value_handle, const Span& value @@ -198,7 +199,7 @@ ble_error_t PalGattClient::signed_write_without_response( } -ble_error_t PalGattClient::write_attribute( +ble_error_t PalAttClientToGattClient::write_attribute( connection_handle_t connection_handle, attribute_handle_t attribute_handle, const Span& value @@ -212,7 +213,7 @@ ble_error_t PalGattClient::write_attribute( } -ble_error_t PalGattClient::queue_prepare_write( +ble_error_t PalAttClientToGattClient::queue_prepare_write( connection_handle_t connection_handle, attribute_handle_t characteristic_value_handle, const Span& value, @@ -228,7 +229,7 @@ ble_error_t PalGattClient::queue_prepare_write( } -ble_error_t PalGattClient::execute_write_queue( +ble_error_t PalAttClientToGattClient::execute_write_queue( connection_handle_t connection_handle, bool execute ) @@ -237,13 +238,13 @@ ble_error_t PalGattClient::execute_write_queue( } -ble_error_t PalGattClient::initialize() +ble_error_t PalAttClientToGattClient::initialize() { return _client.initialize(); } -ble_error_t PalGattClient::terminate() +ble_error_t PalAttClientToGattClient::terminate() { return _client.initialize(); } diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/include/ble/internal/PalGattClientImpl.h b/connectivity/FEATURE_BLE/source/pal/PalAttClientToGattClient.h similarity index 91% rename from connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/include/ble/internal/PalGattClientImpl.h rename to connectivity/FEATURE_BLE/source/pal/PalAttClientToGattClient.h index 51dc108c268..bb843760e67 100644 --- a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/include/ble/internal/PalGattClientImpl.h +++ b/connectivity/FEATURE_BLE/source/pal/PalAttClientToGattClient.h @@ -19,7 +19,7 @@ #ifndef BLE_PAL_ATTCLIENTTOGATTCLIENTADAPTER_H_ #define BLE_PAL_ATTCLIENTTOGATTCLIENTADAPTER_H_ -#include "ble/internal/PalGattClient.h" +#include "source/pal/PalGattClient.h" namespace ble { @@ -31,7 +31,7 @@ class PalAttClient; * This class let vendors define their abstraction layer in term of an PalAttClient * and adapt any PalAttClient into a PalGattClient. */ -class PalGattClient : public interface::PalGattClient { +class PalAttClientToGattClient : public PalGattClient { public: static const uint16_t END_ATTRIBUTE_HANDLE = 0xFFFF; static const uint16_t SERVICE_TYPE_UUID = 0x2800; @@ -42,12 +42,12 @@ class PalGattClient : public interface::PalGattClient { * Construct an instance of PalGattClient from an instance of PalAttClient. * @param client The client to adapt. */ - PalGattClient(PalAttClient& client); + PalAttClientToGattClient(PalAttClient& client); /** * @see ble::PalGattClient::exchange_mtu */ - ble_error_t exchange_mtu(connection_handle_t connection); + ble_error_t exchange_mtu(connection_handle_t connection) override; /** * @see ble::PalGattClient::get_mtu_size @@ -55,7 +55,7 @@ class PalGattClient : public interface::PalGattClient { ble_error_t get_mtu_size( connection_handle_t connection_handle, uint16_t& mtu_size - ); + ) override; /** * @see ble::PalGattClient::discover_primary_service @@ -63,7 +63,7 @@ class PalGattClient : public interface::PalGattClient { ble_error_t discover_primary_service( connection_handle_t connection, attribute_handle_t discovery_range_begining - ); + ) override; /** * @see ble::PalGattClient::discover_primary_service_by_service_uuid @@ -72,7 +72,7 @@ class PalGattClient : public interface::PalGattClient { connection_handle_t connection_handle, attribute_handle_t discovery_range_begining, const UUID& uuid - ); + ) override; /** * @see ble::PalGattClient::find_included_service @@ -80,7 +80,7 @@ class PalGattClient : public interface::PalGattClient { ble_error_t find_included_service( connection_handle_t connection_handle, attribute_handle_range_t service_range - ); + ) override; /** * @see ble::PalGattClient::discover_characteristics_of_a_service @@ -88,7 +88,7 @@ class PalGattClient : public interface::PalGattClient { ble_error_t discover_characteristics_of_a_service( connection_handle_t connection_handle, attribute_handle_range_t discovery_range - ); + ) override; /** * @see ble::PalGattClient::discover_characteristics_descriptors @@ -96,7 +96,7 @@ class PalGattClient : public interface::PalGattClient { ble_error_t discover_characteristics_descriptors( connection_handle_t connection_handle, attribute_handle_range_t descriptors_discovery_range - ); + ) override; /** * @see ble::PalGattClient::read_attribute_value @@ -104,7 +104,7 @@ class PalGattClient : public interface::PalGattClient { ble_error_t read_attribute_value( connection_handle_t connection_handle, attribute_handle_t attribute_handle - ); + ) override; /** * @see ble::PalGattClient::read_using_characteristic_uuid @@ -113,7 +113,7 @@ class PalGattClient : public interface::PalGattClient { connection_handle_t connection_handle, attribute_handle_range_t read_range, const UUID& uuid - ); + ) override; /** * @see ble::PalGattClient::read_attribute_blob @@ -122,7 +122,7 @@ class PalGattClient : public interface::PalGattClient { connection_handle_t connection_handle, attribute_handle_t attribute_handle, uint16_t offset - ); + ) override; /** * @see ble::PalGattClient::read_multiple_characteristic_values @@ -130,7 +130,7 @@ class PalGattClient : public interface::PalGattClient { ble_error_t read_multiple_characteristic_values( connection_handle_t connection_handle, const Span& characteristic_value_handles - ); + ) override; /** * @see ble::PalGattClient::write_without_response @@ -139,7 +139,7 @@ class PalGattClient : public interface::PalGattClient { connection_handle_t connection_handle, attribute_handle_t characteristic_value_handle, const Span& value - ); + ) override; /** * @see ble::PalGattClient::signed_write_without_response @@ -148,7 +148,7 @@ class PalGattClient : public interface::PalGattClient { connection_handle_t connection_handle, attribute_handle_t characteristic_value_handle, const Span& value - ); + ) override; /** * @see ble::PalGattClient::write_attribute @@ -157,7 +157,7 @@ class PalGattClient : public interface::PalGattClient { connection_handle_t connection_handle, attribute_handle_t attribute_handle, const Span& value - ); + ) override; /** * @see ble::PalGattClient::queue_prepare_write @@ -167,7 +167,7 @@ class PalGattClient : public interface::PalGattClient { attribute_handle_t characteristic_value_handle, const Span& value, uint16_t offset - ); + ) override; /** * @see ble::PalGattClient::execute_write_queue @@ -175,49 +175,47 @@ class PalGattClient : public interface::PalGattClient { ble_error_t execute_write_queue( connection_handle_t connection_handle, bool execute - ); + ) override; /** * @see ble::PalGattClient::initialize */ - ble_error_t initialize(); + ble_error_t initialize() override; /** * @see ble::PalGattClient::terminate */ - ble_error_t terminate(); - + ble_error_t terminate() override; /** * @see ble::PalGattClient::when_server_message_received */ void when_server_message_received( mbed::Callback cb - ) { + ) override { _server_message_cb = cb; } - /** * @see ble::PalGattClient::when_transaction_timeout */ void when_transaction_timeout( mbed::Callback cb - ) { + ) override { _transaction_timeout_cb = cb; } /** * @see ble::PalGattClient::set_event_handler */ - void set_event_handler(PalGattClientEventHandler* event_handler) { + void set_event_handler(PalGattClientEventHandler* event_handler) override { _event_handler = event_handler; } /** * @see ble::PalGattClient::get_event_handler */ - PalGattClientEventHandler* get_event_handler() { + PalGattClientEventHandler* get_event_handler() override { return _event_handler; } diff --git a/connectivity/FEATURE_BLE/include/ble/internal/PalConnectionMonitor.h b/connectivity/FEATURE_BLE/source/pal/PalConnectionMonitor.h similarity index 98% rename from connectivity/FEATURE_BLE/include/ble/internal/PalConnectionMonitor.h rename to connectivity/FEATURE_BLE/source/pal/PalConnectionMonitor.h index 37644a386d2..f4c7afed9e6 100644 --- a/connectivity/FEATURE_BLE/include/ble/internal/PalConnectionMonitor.h +++ b/connectivity/FEATURE_BLE/source/pal/PalConnectionMonitor.h @@ -20,7 +20,7 @@ #define MBED_BLE_CONNECTION_EVENT_MONITOR #include "ble/Gap.h" -#include "ble/common/ble/BLETypes.h" +#include "ble/common/BLETypes.h" namespace ble { diff --git a/connectivity/FEATURE_BLE/include/ble/internal/PalEventQueue.h b/connectivity/FEATURE_BLE/source/pal/PalEventQueue.h similarity index 87% rename from connectivity/FEATURE_BLE/include/ble/internal/PalEventQueue.h rename to connectivity/FEATURE_BLE/source/pal/PalEventQueue.h index b33e213c265..e5fbb4cd6da 100644 --- a/connectivity/FEATURE_BLE/include/ble/internal/PalEventQueue.h +++ b/connectivity/FEATURE_BLE/source/pal/PalEventQueue.h @@ -22,7 +22,6 @@ #include "platform/Callback.h" namespace ble { -namespace interface { /** * Simple interface which allow upper layer to post an event into the event @@ -55,11 +54,6 @@ class PalEventQueue { virtual bool post(const mbed::Callback& event) = 0; }; -} // namespace interface } // namespace ble -/* This includes the concrete class implementation, to provide a an alternative BLE PAL implementation - * disable Cordio and place your header in a path with the same structure */ -#include "ble/internal/PalEventQueueImpl.h" - #endif /* BLE_PAL_EVENT_QUEUE_H_ */ diff --git a/connectivity/FEATURE_BLE/include/ble/internal/PalGap.h b/connectivity/FEATURE_BLE/source/pal/PalGap.h similarity index 99% rename from connectivity/FEATURE_BLE/include/ble/internal/PalGap.h rename to connectivity/FEATURE_BLE/source/pal/PalGap.h index c602bb8bcbc..53d6b28a8ec 100644 --- a/connectivity/FEATURE_BLE/include/ble/internal/PalGap.h +++ b/connectivity/FEATURE_BLE/source/pal/PalGap.h @@ -21,11 +21,9 @@ #include "platform/Callback.h" -#include "ble/common/ble/GapTypes.h" -#include "ble/common/ble/GapEvents.h" -#include "ble/common/ble/blecommon.h" - -#include "dm_api.h" +#include "source/pal/GapTypes.h" +#include "source/pal/GapEvents.h" +#include "ble/common/blecommon.h" namespace ble { @@ -243,7 +241,6 @@ struct PalGapEventHandler { ) = 0; }; -namespace interface { /** * Adaptation interface for the GAP layer. * @@ -1631,12 +1628,6 @@ class PalGap { virtual PalGapEventHandler *get_event_handler() = 0; }; -} // namespace interface } // namespace ble - -/* This includes the concrete class implementation, to provide a an alternative BLE PAL implementation - * disable Cordio and place your header in a path with the same structure */ -#include "ble/internal/PalGapImpl.h" - #endif /* BLE_PAL_GAP_H_ */ diff --git a/connectivity/FEATURE_BLE/include/ble/internal/PalGattClient.h b/connectivity/FEATURE_BLE/source/pal/PalGattClient.h similarity index 98% rename from connectivity/FEATURE_BLE/include/ble/internal/PalGattClient.h rename to connectivity/FEATURE_BLE/source/pal/PalGattClient.h index 5f8ee934ad4..c9a11d2b60c 100644 --- a/connectivity/FEATURE_BLE/include/ble/internal/PalGattClient.h +++ b/connectivity/FEATURE_BLE/source/pal/PalGattClient.h @@ -21,10 +21,10 @@ #include "platform/Callback.h" -#include "ble/common/ble/UUID.h" -#include "ble/common/ble/BLETypes.h" -#include "ble/common/ble/blecommon.h" -#include "ble/internal/AttServerMessage.h" +#include "ble/common/UUID.h" +#include "ble/common/BLETypes.h" +#include "ble/common/blecommon.h" +#include "AttServerMessage.h" namespace ble { @@ -60,8 +60,6 @@ struct PalGattClientEventHandler { ) = 0; }; - -namespace interface { /** * Adaptation layer for a GATT client. * @@ -627,11 +625,6 @@ class PalGattClient { virtual PalGattClientEventHandler* get_event_handler() = 0; }; -} // namespace interface } // namespace ble -/* This includes the concrete class implementation, to provide a an alternative BLE PAL implementation - * disable Cordio and place your header in a path with the same structure */ -#include "ble/internal/PalGattClientImpl.h" - #endif /* BLE_PAL_GATT_CLIENT_H_ */ diff --git a/connectivity/FEATURE_BLE/include/ble/internal/PalGenericAccessService.h b/connectivity/FEATURE_BLE/source/pal/PalGenericAccessService.h similarity index 85% rename from connectivity/FEATURE_BLE/include/ble/internal/PalGenericAccessService.h rename to connectivity/FEATURE_BLE/source/pal/PalGenericAccessService.h index edc44dea19d..e6302037630 100644 --- a/connectivity/FEATURE_BLE/include/ble/internal/PalGenericAccessService.h +++ b/connectivity/FEATURE_BLE/source/pal/PalGenericAccessService.h @@ -19,13 +19,12 @@ #ifndef BLE_PAL_GENERIC_ACCESS_SERVICE_H_ #define BLE_PAL_GENERIC_ACCESS_SERVICE_H_ -#include "ble/common/ble/GapTypes.h" -#include "ble/common/ble/BLETypes.h" -#include "ble/common/ble/blecommon.h" +#include "GapTypes.h" +#include "ble/common/BLETypes.h" +#include "ble/common/blecommon.h" #include "ble/Gap.h" namespace ble { -namespace interface { /** * Manage state of the GAP service exposed by the GATT server. @@ -70,11 +69,6 @@ struct PalGenericAccessService { ) = 0; }; -} // namespace interface } // namespace ble -/* This includes the concrete class implementation, to provide a an alternative BLE PAL implementation - * disable Cordio and place your header in a path with the same structure */ -#include "ble/internal/PalGenericAccessServiceImpl.h" - #endif /* BLE_PAL_GENERIC_ACCESS_SERVICE_H_ */ diff --git a/connectivity/FEATURE_BLE/include/ble/internal/PalSecurityManager.h b/connectivity/FEATURE_BLE/source/pal/PalSecurityManager.h similarity index 98% rename from connectivity/FEATURE_BLE/include/ble/internal/PalSecurityManager.h rename to connectivity/FEATURE_BLE/source/pal/PalSecurityManager.h index 26fac4bce9d..4a1906ee724 100644 --- a/connectivity/FEATURE_BLE/include/ble/internal/PalSecurityManager.h +++ b/connectivity/FEATURE_BLE/source/pal/PalSecurityManager.h @@ -22,8 +22,9 @@ #include "platform/Callback.h" #include "platform/NonCopyable.h" -#include "ble/common/ble/BLETypes.h" -#include "ble/common/ble/GapTypes.h" +#include "ble/common/blecommon.h" +#include "ble/common/BLETypes.h" +#include "source/pal/GapTypes.h" #include "wsf_types.h" #include "wsf_os.h" @@ -528,7 +529,6 @@ class PalSecurityManagerEventHandler { ) = 0; }; -namespace interface { /** * Adaptation layer of the Security Manager. */ @@ -1026,11 +1026,6 @@ class PalSecurityManager { virtual PalSecurityManagerEventHandler* get_event_handler() = 0; }; -} /* namespace interface */ } /* namespace ble */ -/* This includes the concrete class implementation, to provide a an alternative BLE PAL implementation - * disable Cordio and place your header in a path with the same structure */ -#include "ble/internal/PalSecurityManagerImpl.h" - #endif /* MBED_OS_FEATURES_FEATURE_BLE_BLE_PAL_PALSM_H_ */ diff --git a/connectivity/FEATURE_BLE/include/ble/internal/PalSigningMonitor.h b/connectivity/FEATURE_BLE/source/pal/PalSigningMonitor.h similarity index 83% rename from connectivity/FEATURE_BLE/include/ble/internal/PalSigningMonitor.h rename to connectivity/FEATURE_BLE/source/pal/PalSigningMonitor.h index a851b066938..e4836be1690 100644 --- a/connectivity/FEATURE_BLE/include/ble/internal/PalSigningMonitor.h +++ b/connectivity/FEATURE_BLE/source/pal/PalSigningMonitor.h @@ -19,7 +19,7 @@ #ifndef MBED_BLE_SIGNING_EVENT_MONITOR #define MBED_BLE_SIGNING_EVENT_MONITOR -#include "ble/common/ble/BLETypes.h" +#include "ble/common/BLETypes.h" namespace ble { @@ -58,7 +58,6 @@ class PalSigningMonitorEventHandler { }; }; -namespace interface { /** * Implemented by classes that need to be notified of signing events. * Notification is done by calling functions in the passed in event handler @@ -70,14 +69,9 @@ class PalSigningMonitor { * * @param[in] signing_event_handler Event handler being registered. */ - void set_signing_event_handler(PalSigningMonitorEventHandler *signing_event_handler); + virtual void set_signing_event_handler(PalSigningMonitorEventHandler *signing_event_handler) = 0; }; -} // namespace interface } // namespace ble -/* This includes the concrete class implementation, to provide a an alternative BLE PAL implementation - * disable Cordio and place your header in a path with the same structure */ -#include "ble/internal/PalSigningMonitorImpl.h" - #endif /* MBED_BLE_SIGNING_EVENT_MONITOR */ diff --git a/connectivity/FEATURE_BLE/include/ble/internal/PalSimpleAttServerMessage.h b/connectivity/FEATURE_BLE/source/pal/PalSimpleAttServerMessage.h similarity index 93% rename from connectivity/FEATURE_BLE/include/ble/internal/PalSimpleAttServerMessage.h rename to connectivity/FEATURE_BLE/source/pal/PalSimpleAttServerMessage.h index 183303cd879..b40921bb0ec 100644 --- a/connectivity/FEATURE_BLE/include/ble/internal/PalSimpleAttServerMessage.h +++ b/connectivity/FEATURE_BLE/source/pal/PalSimpleAttServerMessage.h @@ -19,7 +19,7 @@ #ifndef BLE_PAL_SIMPLEATTSERVERMESSAGE_H_ #define BLE_PAL_SIMPLEATTSERVERMESSAGE_H_ -#include "ble/internal/AttServerMessage.h" +#include "AttServerMessage.h" namespace ble { @@ -53,14 +53,14 @@ struct PalSimpleAttFindInformationResponse : public AttFindInformationResponse { /** * @see ble::AttFindInformationResponse::size */ - virtual size_t size() const { + size_t size() const override { return _information_data.size() / _item_size; } /** * @see ble::AttFindInformationResponse::operator[] */ - virtual information_data_t operator[](size_t index) const { + information_data_t operator[](size_t index) const override { const uint8_t* item = &_information_data[index * _item_size]; information_data_t result; @@ -105,14 +105,14 @@ struct PalSimpleAttFindByTypeValueResponse : public AttFindByTypeValueResponse { /** * @see ble::AttFindByTypeValueResponse::size */ - virtual std::size_t size() const { + std::size_t size() const override { return _handles.size() / item_size; } /** * @see ble::AttFindByTypeValueResponse::operator[] */ - virtual attribute_handle_range_t operator[](size_t index) const { + attribute_handle_range_t operator[](size_t index) const override { attribute_handle_range_t result; const uint8_t* item = &_handles[index * item_size]; memcpy(&result.begin, item, sizeof(result.begin)); @@ -147,14 +147,14 @@ struct PalSimpleAttReadByTypeResponse : public AttReadByTypeResponse { /** * @see ble::AttReadByTypeResponse::size */ - virtual size_t size() const { + size_t size() const override { return _attribute_data.size() / _element_size; } /** * @see ble::AttReadByTypeResponse::operator[] */ - virtual attribute_data_t operator[](size_t index) const { + attribute_data_t operator[](size_t index) const override { const uint8_t* item = &_attribute_data[index * _element_size]; uint16_t handle; memcpy(&handle, item, sizeof(handle)); @@ -196,14 +196,14 @@ struct PalSimpleAttReadByGroupTypeResponse : public AttReadByGroupTypeResponse { /** * @see ble::AttReadByGroupTypeResponse::size */ - virtual size_t size() const { + size_t size() const override { return _attribute_data.size() / _element_size; } /** * @see ble::AttReadByGroupTypeResponse::operator[] */ - virtual attribute_data_t operator[](size_t index) const { + attribute_data_t operator[](size_t index) const override { const uint8_t* item = &_attribute_data[index * _element_size]; uint16_t begin; uint16_t end; diff --git a/connectivity/drivers/ble/FEATURE_BLE/COMPONENT_BlueNRG_MS/BlueNrgMsHCIDriver.cpp b/connectivity/drivers/ble/FEATURE_BLE/COMPONENT_BlueNRG_MS/BlueNrgMsHCIDriver.cpp index 8676c15fbae..e978b8379f3 100644 --- a/connectivity/drivers/ble/FEATURE_BLE/COMPONENT_BlueNRG_MS/BlueNrgMsHCIDriver.cpp +++ b/connectivity/drivers/ble/FEATURE_BLE/COMPONENT_BlueNRG_MS/BlueNrgMsHCIDriver.cpp @@ -27,9 +27,8 @@ #include "platform/mbed_wait_api.h" // FEATURE_BLE/targets/TARGET_CORDIO -#include "BLEInstanceBase.h" -#include "CordioHCIDriver.h" -#include "CordioHCITransportDriver.h" +#include "ble/driver/CordioHCIDriver.h" +#include "ble/driver/CordioHCITransportDriver.h" #include "hci_api.h" #include "hci_cmd.h" #include "hci_core.h" diff --git a/connectivity/drivers/ble/FEATURE_BLE/COMPONENT_CYW43XXX/CyH4TransportDriver.h b/connectivity/drivers/ble/FEATURE_BLE/COMPONENT_CYW43XXX/CyH4TransportDriver.h index 86c83fdd490..0f90e884b85 100644 --- a/connectivity/drivers/ble/FEATURE_BLE/COMPONENT_CYW43XXX/CyH4TransportDriver.h +++ b/connectivity/drivers/ble/FEATURE_BLE/COMPONENT_CYW43XXX/CyH4TransportDriver.h @@ -21,7 +21,7 @@ #if (DEVICE_SERIAL && DEVICE_SERIAL_FC) || defined(DOXYGEN_ONLY) #include -#include "CordioHCITransportDriver.h" +#include "ble/driver/CordioHCITransportDriver.h" #include "drivers/DigitalInOut.h" #include "cyhal_uart.h" diff --git a/connectivity/drivers/ble/FEATURE_BLE/COMPONENT_CYW43XXX/HCIDriver.cpp b/connectivity/drivers/ble/FEATURE_BLE/COMPONENT_CYW43XXX/HCIDriver.cpp index 4494bcd113f..1e339546e50 100644 --- a/connectivity/drivers/ble/FEATURE_BLE/COMPONENT_CYW43XXX/HCIDriver.cpp +++ b/connectivity/drivers/ble/FEATURE_BLE/COMPONENT_CYW43XXX/HCIDriver.cpp @@ -16,15 +16,19 @@ */ #include -#include "BLEInstanceBase.h" -#include "CordioHCIDriver.h" +#include "ble/driver/CordioHCIDriver.h" #include "hci_api.h" #include "hci_cmd.h" #include "hci_core.h" +#include "dm_api.h" #include "bstream.h" #include #include "hci_mbed_os_adaptation.h" #include "CyH4TransportDriver.h" +#include "platform/mbed_power_mgmt.h" +#include "rtos/ThisThread.h" + +using namespace std::chrono_literals; extern const int brcm_patch_ram_length; extern const uint8_t brcm_patchram_buf[]; @@ -522,7 +526,7 @@ class HCIDriver : public CordioHCIDriver { } PinName bt_power_name; - DigitalInOut bt_power; + mbed::DigitalInOut bt_power; bool is_powersave_enabled; uint8_t host_wake_irq; diff --git a/connectivity/drivers/ble/FEATURE_BLE/COMPONENT_CYW43XXX/TARGET_PSOC6/cy_bt_cordio_cfg.cpp b/connectivity/drivers/ble/FEATURE_BLE/COMPONENT_CYW43XXX/TARGET_PSOC6/cy_bt_cordio_cfg.cpp index 4133531f87c..e4fcd387941 100644 --- a/connectivity/drivers/ble/FEATURE_BLE/COMPONENT_CYW43XXX/TARGET_PSOC6/cy_bt_cordio_cfg.cpp +++ b/connectivity/drivers/ble/FEATURE_BLE/COMPONENT_CYW43XXX/TARGET_PSOC6/cy_bt_cordio_cfg.cpp @@ -24,8 +24,7 @@ *******************************************************************************/ #include -#include "BLEInstanceBase.h" -#include "CordioHCIDriver.h" +#include "ble/driver/CordioHCIDriver.h" #include "hci_api.h" #include "hci_cmd.h" #include "hci_core.h" diff --git a/connectivity/drivers/ble/FEATURE_BLE/TARGET_CY8C63XX/Psoc6BLE.cpp b/connectivity/drivers/ble/FEATURE_BLE/TARGET_CY8C63XX/Psoc6BLE.cpp index c89bc5ad4ea..ac024153090 100644 --- a/connectivity/drivers/ble/FEATURE_BLE/TARGET_CY8C63XX/Psoc6BLE.cpp +++ b/connectivity/drivers/ble/FEATURE_BLE/TARGET_CY8C63XX/Psoc6BLE.cpp @@ -19,7 +19,7 @@ #include "hci_api.h" #include "bstream.h" -#include "driver/CordioHCIDriver.h" +#include "ble/driver/CordioHCIDriver.h" #include "drivers/IPCPipeTransportDriver.h" #include "psoc6_utils.h" diff --git a/connectivity/drivers/ble/FEATURE_BLE/TARGET_CY8C63XX/drivers/IPCPipeTransportDriver.h b/connectivity/drivers/ble/FEATURE_BLE/TARGET_CY8C63XX/drivers/IPCPipeTransportDriver.h index 6a60f8df496..092a475a4f2 100644 --- a/connectivity/drivers/ble/FEATURE_BLE/TARGET_CY8C63XX/drivers/IPCPipeTransportDriver.h +++ b/connectivity/drivers/ble/FEATURE_BLE/TARGET_CY8C63XX/drivers/IPCPipeTransportDriver.h @@ -22,7 +22,7 @@ #include #include "mbed.h" -#include "CordioHCITransportDriver.h" +#include "ble/driver/CordioHCITransportDriver.h" namespace ble { diff --git a/connectivity/drivers/ble/FEATURE_BLE/TARGET_NORDIC/TARGET_NORDIC_CORDIO/TARGET_NRF5x/NRFCordioHCIDriver.cpp b/connectivity/drivers/ble/FEATURE_BLE/TARGET_NORDIC/TARGET_NORDIC_CORDIO/TARGET_NRF5x/NRFCordioHCIDriver.cpp index 61cc2c674cc..36237322400 100644 --- a/connectivity/drivers/ble/FEATURE_BLE/TARGET_NORDIC/TARGET_NORDIC_CORDIO/TARGET_NRF5x/NRFCordioHCIDriver.cpp +++ b/connectivity/drivers/ble/FEATURE_BLE/TARGET_NORDIC/TARGET_NORDIC_CORDIO/TARGET_NRF5x/NRFCordioHCIDriver.cpp @@ -327,8 +327,8 @@ void NRFCordioHCIDriver::do_initialize() /* Load address from nRF configuration. */ uint64_t address_int = (((uint64_t)NRF_FICR->DEVICEADDR[0]) << 0) | (((uint64_t)NRF_FICR->DEVICEADDR[1]) << 32); - unsigned int i = 0; - while (i++ < BDA_ADDR_LEN) { + + for (unsigned int i = 0; i < BDA_ADDR_LEN; ++i) { bd_addr[i] = address_int >> (i * 8); } diff --git a/connectivity/drivers/ble/FEATURE_BLE/TARGET_NORDIC/TARGET_NORDIC_CORDIO/TARGET_NRF5x/NRFCordioHCIDriver.h b/connectivity/drivers/ble/FEATURE_BLE/TARGET_NORDIC/TARGET_NORDIC_CORDIO/TARGET_NRF5x/NRFCordioHCIDriver.h index 4c14429c39a..bd490cbdfe0 100644 --- a/connectivity/drivers/ble/FEATURE_BLE/TARGET_NORDIC/TARGET_NORDIC_CORDIO/TARGET_NRF5x/NRFCordioHCIDriver.h +++ b/connectivity/drivers/ble/FEATURE_BLE/TARGET_NORDIC/TARGET_NORDIC_CORDIO/TARGET_NRF5x/NRFCordioHCIDriver.h @@ -17,7 +17,7 @@ #ifndef NRF_CORDIO_HCI_DRIVER_H_ #define NRF_CORDIO_HCI_DRIVER_H_ -#include "CordioHCIDriver.h" +#include "ble/driver/CordioHCIDriver.h" namespace ble { diff --git a/connectivity/drivers/ble/FEATURE_BLE/TARGET_NORDIC/TARGET_NORDIC_CORDIO/TARGET_NRF5x/NRFCordioHCITransportDriver.cpp b/connectivity/drivers/ble/FEATURE_BLE/TARGET_NORDIC/TARGET_NORDIC_CORDIO/TARGET_NRF5x/NRFCordioHCITransportDriver.cpp index f4becdec259..7f116e95607 100644 --- a/connectivity/drivers/ble/FEATURE_BLE/TARGET_NORDIC/TARGET_NORDIC_CORDIO/TARGET_NRF5x/NRFCordioHCITransportDriver.cpp +++ b/connectivity/drivers/ble/FEATURE_BLE/TARGET_NORDIC/TARGET_NORDIC_CORDIO/TARGET_NRF5x/NRFCordioHCITransportDriver.cpp @@ -28,7 +28,7 @@ #include #include "NRFCordioHCITransportDriver.h" -#include "CordioHCITransportDriver.h" +#include "ble/driver/CordioHCITransportDriver.h" using namespace ble; diff --git a/connectivity/drivers/ble/FEATURE_BLE/TARGET_NORDIC/TARGET_NORDIC_CORDIO/TARGET_NRF5x/NRFCordioHCITransportDriver.h b/connectivity/drivers/ble/FEATURE_BLE/TARGET_NORDIC/TARGET_NORDIC_CORDIO/TARGET_NRF5x/NRFCordioHCITransportDriver.h index 0377037cdc7..d0a3be13047 100644 --- a/connectivity/drivers/ble/FEATURE_BLE/TARGET_NORDIC/TARGET_NORDIC_CORDIO/TARGET_NRF5x/NRFCordioHCITransportDriver.h +++ b/connectivity/drivers/ble/FEATURE_BLE/TARGET_NORDIC/TARGET_NORDIC_CORDIO/TARGET_NRF5x/NRFCordioHCITransportDriver.h @@ -17,7 +17,7 @@ #ifndef NRF_CORDIO_HCI_TRANSPORT_DRIVER_H_ #define NRF_CORDIO_HCI_TRANSPORT_DRIVER_H_ -#include "CordioHCITransportDriver.h" +#include "ble/driver/CordioHCITransportDriver.h" namespace ble { diff --git a/connectivity/drivers/ble/FEATURE_BLE/TARGET_STM32WB/HCIDriver.cpp b/connectivity/drivers/ble/FEATURE_BLE/TARGET_STM32WB/HCIDriver.cpp index a57caa348df..345f8db96d7 100644 --- a/connectivity/drivers/ble/FEATURE_BLE/TARGET_STM32WB/HCIDriver.cpp +++ b/connectivity/drivers/ble/FEATURE_BLE/TARGET_STM32WB/HCIDriver.cpp @@ -17,10 +17,9 @@ */ #include -#include "ble/common/ble/blecommon.h" -#include "BLEInstanceBase.h" -#include "CordioHCIDriver.h" -#include "CordioHCITransportDriver.h" +#include "ble/common/blecommon.h" +#include "ble/driver/CordioHCIDriver.h" +#include "ble/driver/CordioHCITransportDriver.h" #include "mbed.h" #include "hci_api.h" #include "hci_cmd.h" diff --git a/doxyfile_options b/doxyfile_options index 24132312211..a4475a2857b 100644 --- a/doxyfile_options +++ b/doxyfile_options @@ -853,14 +853,13 @@ EXCLUDE_PATTERNS = */tools/* \ */nanostack-libservice/* \ */mbed-client-randlib/* \ */nanostack/sal-stack-nanostack-eventloop/* \ - */ble/generic/* \ - */ble/pal/* \ */connectivity/drivers/802.15.4_RF/* \ */components/wifi/* \ */UNITTESTS/* \ */connectivity/cellular/framework/AT/* \ */connectivity/cellular/framework/device/* \ - */connectivity/cellular/framework/common/* + */connectivity/cellular/framework/common/* \ + */FEATURE_BLE/source/* # The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names # (namespaces, classes, functions, etc.) that should be excluded from the diff --git a/doxygen_options.json b/doxygen_options.json index 178689d5ce8..62d6f8189f8 100644 --- a/doxygen_options.json +++ b/doxygen_options.json @@ -10,7 +10,7 @@ "EXPAND_AS_DEFINED": "", "SKIP_FUNCTION_MACROS": "NO", "STRIP_CODE_COMMENTS": "NO", - "EXCLUDE_PATTERNS": "*/tools/* */targets/* */connectivity/mbedtls/* */features/unsupported/* */BUILD/* */rtos/TARGET_CORTEX/rtx*/* */cmsis/* */features/lwipstack/* */nanostack/sal-stack-nanostack/* */nanostack/coap-service/* */ble/generic/* */ble/pal/* */mbed-trace/* */mbed-coap/* */nanostack-libservice/* */mbed-client-randlib/* */nanostack/sal-stack-nanostack-eventloop/* */connectivity/drivers/802.15.4_RF/* */components/wifi/* */features/nfc/stack/* */UNITTESTS/* */features/cryptocell/*", + "EXCLUDE_PATTERNS": "*/tools/* */targets/* */connectivity/mbedtls/* */features/unsupported/* */BUILD/* */rtos/TARGET_CORTEX/rtx*/* */cmsis/* */features/lwipstack/* */nanostack/sal-stack-nanostack/* */nanostack/coap-service/* */mbed-trace/* */mbed-coap/* */nanostack-libservice/* */mbed-client-randlib/* */nanostack/sal-stack-nanostack-eventloop/* */connectivity/drivers/802.15.4_RF/* */components/wifi/* */features/nfc/stack/* */UNITTESTS/* */features/cryptocell/* */FEATURE_BLE/source/*", "ALPHABETICAL_INDEX": "NO", "CASE_SENSE_NAMES": "NO", "DOT_MULTI_TARGETS": "YES",