Merge pull request #13475 from pan-/ble-remove-user-facing-abstraction

Ble remove user facing abstraction
pull/13579/head
Martin Kojtal 2020-09-09 15:13:01 +01:00 committed by GitHub
commit c99ff74928
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
343 changed files with 3484 additions and 1922 deletions

View File

@ -19,20 +19,20 @@
#ifndef MBED_BLE_H__ #ifndef MBED_BLE_H__
#define MBED_BLE_H__ #define MBED_BLE_H__
#include "FunctionPointerWithContext.h"
#include "platform/mbed_error.h" #include "platform/mbed_error.h"
#include "platform/mbed_assert.h" #include "platform/mbed_assert.h"
#include "platform/mbed_toolchain.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/Gap.h"
#include "ble/GattClient.h" #include "ble/GattClient.h"
#include "ble/GattServer.h" #include "ble/GattServer.h"
#include "ble/SecurityManager.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 */ /* Forward declaration for the implementation class */
namespace ble { namespace ble {
@ -154,6 +154,10 @@ public:
*/ */
static const InstanceID_t NUM_INSTANCES = 1; 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. * Get a reference to the BLE singleton.
* *
@ -164,16 +168,6 @@ public:
*/ */
static BLE &Instance(); 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. * Get a reference to the BLE singleton corresponding to a given interface.
* *
@ -203,7 +197,7 @@ public:
*/ */
MBED_DEPRECATED_SINCE("mbed-os-6.3.0", "BLE singleton supports one instance. You may create multiple" MBED_DEPRECATED_SINCE("mbed-os-6.3.0", "BLE singleton supports one instance. You may create multiple"
"instances by using the constructor.") "instances by using the constructor.")
InstanceID_t getInstanceID(void) const InstanceID_t getInstanceID() const
{ {
return DEFAULT_INSTANCE; return DEFAULT_INSTANCE;
} }
@ -309,7 +303,7 @@ public:
* @attention This should be called before using anything else in the BLE * @attention This should be called before using anything else in the BLE
* API. * API.
*/ */
ble_error_t init(InitializationCompleteCallback_t completion_cb = NULL) ble_error_t init(InitializationCompleteCallback_t completion_cb = nullptr)
{ {
FunctionPointerWithContext<InitializationCompleteCallbackContext *> callback(completion_cb); FunctionPointerWithContext<InitializationCompleteCallbackContext *> callback(completion_cb);
return initImplementation(callback); return initImplementation(callback);
@ -341,7 +335,7 @@ public:
* @note The application should set up a callback to signal completion of * @note The application should set up a callback to signal completion of
* initialization when using init(). * initialization when using init().
*/ */
bool hasInitialized(void) const; bool hasInitialized() const;
/** /**
* Shut down the underlying stack, and reset state of this BLE instance. * Shut down the underlying stack, and reset state of this BLE instance.
@ -353,7 +347,7 @@ public:
* GAP state. This API offers a way to repopulate the GATT database with new * GAP state. This API offers a way to repopulate the GATT database with new
* services and characteristics. * services and characteristics.
*/ */
ble_error_t shutdown(void); ble_error_t shutdown();
/** /**
* This call allows the application to get the BLE stack version information. * This call allows the application to get the BLE stack version information.
@ -362,7 +356,7 @@ public:
* *
* @note The BLE API owns the string returned. * @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 * Accessor to Gap. All Gap-related functionality requires going through
@ -455,6 +449,16 @@ public:
private: private:
friend class ble::BLEInstanceBase; 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]. * Implementation of init() [internal to BLE_API].
* *
@ -465,11 +469,6 @@ private:
FunctionPointerWithContext<InitializationCompleteCallbackContext *> callback FunctionPointerWithContext<InitializationCompleteCallbackContext *> callback
); );
private:
// Prevent copy construction and copy assignment of BLE.
BLE(const BLE &);
BLE &operator=(const BLE &);
private: private:
ble::BLEInstanceBase &transport; /* The device-specific backend */ ble::BLEInstanceBase &transport; /* The device-specific backend */
OnEventsToProcessCallback_t whenEventsToProcess; OnEventsToProcessCallback_t whenEventsToProcess;
@ -480,7 +479,7 @@ private:
using ble::BLE; using ble::BLE;
/** /**
* @namespace ble Entry namespace for all %BLE API definitions. * @namespace ble Entry namespace for all BLE API definitions.
*/ */
/** /**

View File

@ -19,28 +19,27 @@
#ifndef BLE_GAP_GAP_H #ifndef BLE_GAP_GAP_H
#define BLE_GAP_GAP_H #define BLE_GAP_GAP_H
#include "CallChainOfFunctionPointersWithContext.h" #include "ble/common/CallChainOfFunctionPointersWithContext.h"
#include <algorithm> #include "ble/common/BLERoles.h"
#include "ble/common/BLETypes.h"
#include "drivers/LowPowerTimeout.h" #include "ble/gap/AdvertisingDataBuilder.h"
#include "drivers/LowPowerTicker.h" #include "ble/gap/AdvertisingDataParser.h"
#include "platform/mbed_error.h" #include "ble/gap/AdvertisingDataSimpleBuilder.h"
#include "ble/gap/AdvertisingDataTypes.h"
#include "ble/common/ble/BLERoles.h" #include "ble/gap/AdvertisingParameters.h"
#include "ble/common/ble/BLETypes.h" #include "ble/gap/ConnectionParameters.h"
#include "ble/common/ble/gap/AdvertisingDataBuilder.h" #include "ble/gap/ScanParameters.h"
#include "ble/common/ble/gap/AdvertisingDataParser.h" #include "ble/gap/Events.h"
#include "ble/common/ble/gap/AdvertisingDataSimpleBuilder.h" #include "ble/gap/Types.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"
namespace ble { namespace ble {
class PalGenericAccessService;
#if !defined(DOXYGEN_ONLY)
namespace impl {
class Gap;
}
#endif // !defined(DOXYGEN_ONLY)
/** /**
* @addtogroup ble * @addtogroup ble
@ -280,9 +279,6 @@ class PalGenericAccessService;
* PHY and of any changes to PHYs which may be triggered autonomously by the * PHY and of any changes to PHYs which may be triggered autonomously by the
* controller or by the peer. * controller or by the peer.
*/ */
#if !defined(DOXYGEN_ONLY)
namespace interface {
#endif // !defined(DOXYGEN_ONLY)
class Gap { class Gap {
public: public:
/** /**
@ -547,9 +543,7 @@ public:
* Prevent polymorphic deletion and avoid unnecessary virtual destructor * Prevent polymorphic deletion and avoid unnecessary virtual destructor
* as the Gap class will never delete the instance it contains. * as the Gap class will never delete the instance it contains.
*/ */
~EventHandler() ~EventHandler() = default;
{
}
}; };
/** /**
@ -1314,7 +1308,7 @@ public:
* *
* @return Maximum size of the whitelist. * @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, * Get the Link Layer to use the internal whitelist when scanning,
@ -1377,7 +1371,7 @@ public:
* the address in input was not identifiable as a random address. * the address in input was not identifiable as a random address.
*/ */
static ble_error_t getRandomAddressType( static ble_error_t getRandomAddressType(
const ble::address_t address, ble::address_t address,
ble::random_address_type_t *addressType ble::random_address_type_t *addressType
); );
@ -1399,7 +1393,7 @@ public:
* @note Currently, a call to reset() does not reset the advertising and * @note Currently, a call to reset() does not reset the advertising and
* scan parameters to default values. * scan parameters to default values.
*/ */
ble_error_t reset(void); ble_error_t reset();
/** /**
* Register a Gap shutdown event handler. * Register a Gap shutdown event handler.
@ -1421,7 +1415,9 @@ public:
* @param[in] memberPtr Shutdown event handler to register. * @param[in] memberPtr Shutdown event handler to register.
*/ */
template<typename T> template<typename T>
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. * Access the callchain of shutdown event handler.
@ -1435,6 +1431,17 @@ public:
GapShutdownCallbackChain_t &onShutdown(); GapShutdownCallbackChain_t &onShutdown();
#if !defined(DOXYGEN_ONLY) #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. * API reserved for the controller driver to set the random static address.
* Setting a new random static address while the controller is operating is * Setting a new random static address while the controller is operating is
@ -1442,6 +1449,9 @@ public:
*/ */
ble_error_t setRandomStaticAddress(const ble::address_t& address); ble_error_t setRandomStaticAddress(const ble::address_t& address);
#endif // !defined(DOXYGEN_ONLY) #endif // !defined(DOXYGEN_ONLY)
private:
impl::Gap* impl;
}; };
/** /**
@ -1449,15 +1459,8 @@ public:
* @} * @}
*/ */
#if !defined(DOXYGEN_ONLY)
} // namespace interface
#endif // !defined(DOXYGEN_ONLY)
} // namespace ble } // 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. */ /** @deprecated Use the namespaced ble::Gap instead of the global Gap. */
using ble::Gap; using ble::Gap;

View File

@ -21,19 +21,24 @@
#define MBED_GATT_CLIENT_H__ #define MBED_GATT_CLIENT_H__
#include "CallChainOfFunctionPointersWithContext.h" #include "ble/common/CallChainOfFunctionPointersWithContext.h"
#include <algorithm> #include "ble/common/blecommon.h"
#include "ble/common/ble/blecommon.h" #include "ble/gatt/GattAttribute.h"
#include "ble/common/ble/GattAttribute.h" #include "ble/gatt/ServiceDiscovery.h"
#include "ble/common/ble/ServiceDiscovery.h" #include "ble/gatt/CharacteristicDescriptorDiscovery.h"
#include "ble/common/ble/CharacteristicDescriptorDiscovery.h" #include "ble/gatt/GattCallbackParamTypes.h"
#include "ble/common/ble/GattCallbackParamTypes.h" #include "ble/gatt/DiscoveredService.h"
#include "ble/common/ble/DiscoveredService.h" #include "ble/gatt/DiscoveredCharacteristic.h"
#include "ble/common/ble/DiscoveredCharacteristic.h"
namespace ble { namespace ble {
#if !defined(DOXYGEN_ONLY)
namespace impl {
class GattClient;
}
#endif // !defined(DOXYGEN_ONLY)
/** /**
* @addtogroup ble * @addtogroup ble
* @{ * @{
@ -89,9 +94,6 @@ namespace ble {
* indicate properties are set. The client discovers that descriptor * indicate properties are set. The client discovers that descriptor
* if it intends to register to server initiated events. * if it intends to register to server initiated events.
*/ */
#if !defined(DOXYGEN_ONLY)
namespace interface {
#endif // !defined(DOXYGEN_ONLY)
class GattClient { class GattClient {
public: public:
/** /**
@ -118,9 +120,7 @@ public:
* Prevent polymorphic deletion and avoid unnecessary virtual destructor * Prevent polymorphic deletion and avoid unnecessary virtual destructor
* as the GattClient class will never delete the instance it contains. * as the GattClient class will never delete the instance it contains.
*/ */
~EventHandler() ~EventHandler() = default;
{
}
}; };
/** /**
@ -233,7 +233,7 @@ public:
* specific subclass. * specific subclass.
*/ */
~GattClient() { } ~GattClient() = default;
/** /**
* Launch the service and characteristic discovery procedure of a GATT server * Launch the service and characteristic discovery procedure of a GATT server
@ -287,8 +287,8 @@ public:
*/ */
ble_error_t launchServiceDiscovery( ble_error_t launchServiceDiscovery(
ble::connection_handle_t connectionHandle, ble::connection_handle_t connectionHandle,
ServiceDiscovery::ServiceCallback_t sc = NULL, ServiceDiscovery::ServiceCallback_t sc = nullptr,
ServiceDiscovery::CharacteristicCallback_t cc = NULL, ServiceDiscovery::CharacteristicCallback_t cc = nullptr,
const UUID &matchingServiceUUID = UUID::ShortUUIDBytes_t(BLE_UUID_UNKNOWN), const UUID &matchingServiceUUID = UUID::ShortUUIDBytes_t(BLE_UUID_UNKNOWN),
const UUID &matchingCharacteristicUUIDIn = UUID::ShortUUIDBytes_t(BLE_UUID_UNKNOWN) const UUID &matchingCharacteristicUUIDIn = UUID::ShortUUIDBytes_t(BLE_UUID_UNKNOWN)
); );
@ -366,7 +366,7 @@ public:
* *
* @return true if service discovery procedure is active and false otherwise. * @return true if service discovery procedure is active and false otherwise.
*/ */
bool isServiceDiscoveryActive(void) const; bool isServiceDiscoveryActive() const;
/** /**
* Terminate all ongoing service discovery procedures. * Terminate all ongoing service discovery procedures.
@ -374,7 +374,7 @@ public:
* It results in an invocation of the service discovery termination handler * It results in an invocation of the service discovery termination handler
* registered with onServiceDiscoveryTermination(). * registered with onServiceDiscoveryTermination().
*/ */
void terminateServiceDiscovery(void); void terminateServiceDiscovery();
/** /**
* Initiate the read procedure of an attribute handle. * Initiate the read procedure of an attribute handle.
@ -625,7 +625,10 @@ public:
* available. * available.
*/ */
template <typename T> template <typename T>
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. * Get the callchain of shutdown event handlers.
@ -649,7 +652,6 @@ public:
*/ */
HVXCallbackChain_t& onHVX(); HVXCallbackChain_t& onHVX();
/** /**
* Reset the state of the GattClient instance. * Reset the state of the GattClient instance.
* *
@ -667,7 +669,7 @@ public:
* *
* @return BLE_ERROR_NONE on success. * @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. */ /* Entry points for the underlying stack to report events back to the user. */
@ -703,6 +705,15 @@ public:
* registered handlers. * registered handlers.
*/ */
void processHVXEvent(const GattHVXCallbackParams *params); 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 @@ public:
* @} * @}
*/ */
#if !defined(DOXYGEN_ONLY)
} // namespace interface
#endif // !defined(DOXYGEN_ONLY)
} // namespace ble } // 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. */ /** @deprecated Use the namespaced ble::GattClient instead of the global GattClient. */
using ble::GattClient; using ble::GattClient;

View File

@ -20,19 +20,22 @@
#ifndef MBED_GATT_SERVER_H__ #ifndef MBED_GATT_SERVER_H__
#define 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/gatt/GattService.h"
#include "ble/common/ble/GattAttribute.h" #include "ble/gatt/GattAttribute.h"
#include "ble/common/ble/GattServerEvents.h" #include "ble/gatt/GattCallbackParamTypes.h"
#include "ble/common/ble/GattCallbackParamTypes.h"
#include "ble/common/ble/blecommon.h"
#include "ble/Gap.h"
#include "SecurityManager.h"
namespace ble { namespace ble {
#if !defined(DOXYGEN_ONLY)
namespace impl {
class GattServer;
}
#endif // !defined(DOXYGEN_ONLY)
/** /**
* @addtogroup ble * @addtogroup ble
* @{ * @{
@ -94,9 +97,6 @@ namespace ble {
* Characteristic Value Notification and Characteristic Value Indication when * Characteristic Value Notification and Characteristic Value Indication when
* the nature of the server initiated is not relevant. * the nature of the server initiated is not relevant.
*/ */
#if !defined(DOXYGEN_ONLY)
namespace interface {
#endif // !defined(DOXYGEN_ONLY)
class GattServer { class GattServer {
public: public:
/** /**
@ -123,9 +123,7 @@ public:
* Prevent polymorphic deletion and avoid unnecessary virtual destructor * Prevent polymorphic deletion and avoid unnecessary virtual destructor
* as the GattServer class will never delete the instance it contains. * as the GattServer class will never delete the instance it contains.
*/ */
~EventHandler() ~EventHandler() = default;
{
}
}; };
/** /**
@ -221,7 +219,7 @@ public:
* *
* @return BLE_ERROR_NONE on success. * @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. * Add a service declaration to the local attribute server table.
@ -415,7 +413,10 @@ public:
* function. * function.
*/ */
template <typename T> template <typename T>
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. * Access the callchain of data sent event handlers.
@ -448,7 +449,10 @@ public:
void onDataWritten( void onDataWritten(
T *objPtr, T *objPtr,
void (T::*memberPtr)(const GattWriteCallbackParams *context) void (T::*memberPtr)(const GattWriteCallbackParams *context)
); )
{
onDataWritten({objPtr, memberPtr});
}
/** /**
* Access the callchain of data written event handlers. * Access the callchain of data written event handlers.
@ -495,7 +499,10 @@ public:
ble_error_t onDataRead( ble_error_t onDataRead(
T *objPtr, T *objPtr,
void (T::*memberPtr)(const GattReadCallbackParams *context) void (T::*memberPtr)(const GattReadCallbackParams *context)
); )
{
return onDataRead({objPtr, memberPtr});
}
/** /**
* Access the callchain of data read event handlers. * Access the callchain of data read event handlers.
@ -537,7 +544,10 @@ public:
* function. * function.
*/ */
template <typename T> template <typename T>
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. * Access the callchain of shutdown event handlers.
@ -578,72 +588,14 @@ public:
*/ */
void onConfirmationReceived(EventCallback_t callback); void onConfirmationReceived(EventCallback_t callback);
/* Entry points for the underlying stack to report events back to the user. */ #if !defined(DOXYGEN_ONLY)
protected: GattServer(impl::GattServer* impl) : impl(impl) {}
/** GattServer(const GattServer&) = delete;
* Helper function that notifies all registered handlers of an occurrence GattServer& operator=(const GattServer&) = delete;
* of a data written event. #endif // !defined(DOXYGEN_ONLY)
*
* @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);
/** private:
* Helper function that notifies all registered handlers of an occurrence impl::GattServer *impl;
* 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();
/**
* Set preferred connection parameters.
*
* @param[in] params Preferred connection parameter values to set.
*/
void setPreferredConnectionParams(const Gap::PreferredConnectionParams_t& params);
}; };
/** /**
@ -652,15 +604,8 @@ protected:
* @} * @}
*/ */
#if !defined(DOXYGEN_ONLY)
} // namespace interface
#endif // !defined(DOXYGEN_ONLY)
} // ble } // 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. */ /** @deprecated Use the namespaced ble::GattServer instead of the global GattServer. */
using ble::GattServer; using ble::GattServer;

View File

@ -19,20 +19,20 @@
#ifndef BLE_SECURITY_MANAGER_H_ #ifndef BLE_SECURITY_MANAGER_H_
#define BLE_SECURITY_MANAGER_H_ #define BLE_SECURITY_MANAGER_H_
#include <stdint.h> #include <cstdint>
#include "CallChainOfFunctionPointersWithContext.h"
#include "platform/Callback.h"
#include "ble/common/ble/BLETypes.h" #include "ble/common/BLETypes.h"
#include "ble/common/ble/blecommon.h" #include "ble/common/blecommon.h"
#include "ble/common/CallChainOfFunctionPointersWithContext.h"
#include "ble/common/ble/BLETypes.h"
#include "ble/internal/SecurityDb.h"
#include "ble/internal/PalConnectionMonitor.h"
#include "ble/internal/PalSecurityManager.h"
namespace ble { namespace ble {
#if !defined(DOXYGEN_ONLY)
namespace impl {
class SecurityManager;
}
#endif // !defined(DOXYGEN_ONLY)
/** /**
* Overview * Overview
* *
@ -186,9 +186,6 @@ namespace ble {
* @endverbatim * @endverbatim
* *
*/ */
#if !defined(DOXYGEN_ONLY)
namespace interface {
#endif // !defined(DOXYGEN_ONLY)
class SecurityManager class SecurityManager
{ {
public: public:
@ -421,9 +418,7 @@ public:
* Prevent polymorphic deletion and avoid unnecessary virtual destructor * Prevent polymorphic deletion and avoid unnecessary virtual destructor
* as the SecurityManager class will never delete the instance it contains. * as the SecurityManager class will never delete the instance it contains.
*/ */
~EventHandler() ~EventHandler() = default;
{
}
}; };
/* /*
@ -457,9 +452,9 @@ public:
bool enableBonding = true, bool enableBonding = true,
bool requireMITM = true, bool requireMITM = true,
SecurityIOCapabilities_t iocaps = IO_CAPS_NONE, SecurityIOCapabilities_t iocaps = IO_CAPS_NONE,
const Passkey_t passkey = NULL, const Passkey_t passkey = nullptr,
bool signing = true, bool signing = true,
const char *dbFilepath = NULL const char *dbFilepath = nullptr
); );
/** /**
@ -473,7 +468,7 @@ public:
* *
* @return BLE_ERROR_NONE on success. * @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 * Notify all registered onShutdown callbacks that the SecurityManager is
@ -488,7 +483,7 @@ public:
* *
* @return BLE_ERROR_NONE on success. * @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 * Normally all bonding information is lost when device is reset, this requests that the stack
@ -511,7 +506,7 @@ public:
* @retval BLE_ERROR_INVALID_STATE If the API is called without module initialization or * @retval BLE_ERROR_INVALID_STATE If the API is called without module initialization or
* application registration. * 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 * Create a list of addresses from all peers in the bond table and generate
@ -870,7 +865,10 @@ public:
void onShutdown(const SecurityManagerShutdownCallback_t& callback); void onShutdown(const SecurityManagerShutdownCallback_t& callback);
template <typename T> template <typename T>
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. * Provide access to the callchain of shutdown event callbacks.
@ -894,18 +892,18 @@ public:
/** For backwards compatibility. This enum is now in BLETypes.h /** For backwards compatibility. This enum is now in BLETypes.h
* @deprecated use the enum in ble namespace */ * @deprecated use the enum in ble namespace */
typedef ble::Keypress_t Keypress_t; 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) #endif // !defined(DOXYGEN_ONLY)
private:
impl::SecurityManager *impl;
}; };
#if !defined(DOXYGEN_ONLY)
} // namespace interface
#endif // !defined(DOXYGEN_ONLY)
} // ble } // 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. */ /** @deprecated Use the namespaced ble::SecurityManager instead of the global SecurityManager. */
using ble::SecurityManager; using ble::SecurityManager;

View File

@ -19,13 +19,14 @@
#ifndef BLE_TYPES_H_ #ifndef BLE_TYPES_H_
#define BLE_TYPES_H_ #define BLE_TYPES_H_
#include <stddef.h> #include <cstddef>
#include <stdint.h> #include <cstdint>
#include <string.h> #include <cstring>
#include "SafeEnum.h"
#include "platform/Span.h" #include "platform/Span.h"
#include "ble/common/ble/gap/Types.h" #include "ble/common/SafeEnum.h"
#include "ble/gap/Types.h"
/** /**
* @addtogroup ble * @addtogroup ble
@ -872,7 +873,7 @@ struct whitelist_t {
* @post type is equal to PUBLIC and the address value is equal to * @post type is equal to PUBLIC and the address value is equal to
* 00:00:00:00:00:00 * 00:00:00:00:00:00
*/ */
entry_t(void) : type(), address() { } entry_t() : type(), address() { }
/** /**
* Type of the peer address. * Type of the peer address.

View File

@ -19,7 +19,7 @@
#ifndef BLE_COMMON_BOUNDED_H_ #ifndef BLE_COMMON_BOUNDED_H_
#define BLE_COMMON_BOUNDED_H_ #define BLE_COMMON_BOUNDED_H_
#include <stdint.h> #include <cstdint>
namespace ble { namespace ble {
@ -47,9 +47,9 @@ struct Bounded {
Bounded(Rep v) : _value(v) Bounded(Rep v) : _value(v)
{ {
if (v < Min) { if (v < Min) {
_value = v; _value = Min;
} else if (v > Max) { } else if (v > Max) {
_value = v; _value = Max;
} }
} }

View File

@ -19,9 +19,9 @@
#ifndef MBED_CALLCHAIN_OF_FUNCTION_POINTERS_WITH_CONTEXT_H #ifndef MBED_CALLCHAIN_OF_FUNCTION_POINTERS_WITH_CONTEXT_H
#define MBED_CALLCHAIN_OF_FUNCTION_POINTERS_WITH_CONTEXT_H #define MBED_CALLCHAIN_OF_FUNCTION_POINTERS_WITH_CONTEXT_H
#include <string.h> #include <cstring>
#include "FunctionPointerWithContext.h" #include "ble/common/FunctionPointerWithContext.h"
#include "SafeBool.h" #include "ble/common/SafeBool.h"
/** /**
* @addtogroup ble * @addtogroup ble
@ -96,6 +96,14 @@ public:
*/ */
CallChainOfFunctionPointersWithContext() : chainHead(NULL) { } CallChainOfFunctionPointersWithContext() : chainHead(NULL) { }
/* Disallow copy constructor and assignment operators. */
CallChainOfFunctionPointersWithContext(
const CallChainOfFunctionPointersWithContext&
) = delete;
CallChainOfFunctionPointersWithContext &operator=(
const CallChainOfFunctionPointersWithContext&
) = delete;
/** /**
* Destruction of the callchain. * Destruction of the callchain.
*/ */
@ -186,7 +194,7 @@ public:
/** /**
* Remove all functions registered in the chain. * Remove all functions registered in the chain.
*/ */
void clear(void) void clear()
{ {
pFunctionPointerWithContext_t fptr = chainHead; pFunctionPointerWithContext_t fptr = chainHead;
while (fptr) { while (fptr) {
@ -203,7 +211,7 @@ public:
* *
* @return true if the callchain is not empty and false otherwise. * @return true if the callchain is not empty and false otherwise.
*/ */
bool hasCallbacksAttached(void) const bool hasCallbacksAttached() const
{ {
return (chainHead != NULL); return (chainHead != NULL);
} }
@ -324,16 +332,6 @@ private:
* const from an external standpoint. * const from an external standpoint.
*/ */
mutable pFunctionPointerWithContext_t currentCalled; mutable pFunctionPointerWithContext_t currentCalled;
/* Disallow copy constructor and assignment operators. */
private:
CallChainOfFunctionPointersWithContext(
const CallChainOfFunctionPointersWithContext&
);
CallChainOfFunctionPointersWithContext &operator=(
const CallChainOfFunctionPointersWithContext&
);
}; };
/** /**

View File

@ -19,8 +19,8 @@
#ifndef BLE_COMMON_DURATION_H_ #ifndef BLE_COMMON_DURATION_H_
#define BLE_COMMON_DURATION_H_ #define BLE_COMMON_DURATION_H_
#include <stdint.h> #include <cstdint>
#include <stddef.h> #include <cstddef>
#include "platform/mbed_assert.h" #include "platform/mbed_assert.h"
#include "platform/mbed_chrono.h" #include "platform/mbed_chrono.h"
@ -155,7 +155,7 @@ struct Duration {
* @param other_ms The Duration in millisecond to convert. * @param other_ms The Duration in millisecond to convert.
*/ */
template<typename OtherRep, typename OtherRange, typename OtherF> template<typename OtherRep, typename OtherRange, typename OtherF>
explicit Duration(Duration<OtherRep, 1000, OtherRange, OtherF> other_ms, void* = NULL) : explicit Duration(Duration<OtherRep, 1000, OtherRange, OtherF> other_ms, void* = nullptr) :
duration(clamp(((other_ms.value() * 1000) + TB - 1) / TB)) duration(clamp(((other_ms.value() * 1000) + TB - 1) / TB))
{ {
} }

View File

@ -19,8 +19,8 @@
#ifndef MBED_FUNCTIONPOINTER_WITH_CONTEXT_H #ifndef MBED_FUNCTIONPOINTER_WITH_CONTEXT_H
#define MBED_FUNCTIONPOINTER_WITH_CONTEXT_H #define MBED_FUNCTIONPOINTER_WITH_CONTEXT_H
#include <string.h> #include <cstring>
#include "SafeBool.h" #include "ble/common/SafeBool.h"
/** /**
* @file * @file
@ -106,6 +106,10 @@ public:
*/ */
FunctionPointerWithContext &operator=(const FunctionPointerWithContext &that) FunctionPointerWithContext &operator=(const FunctionPointerWithContext &that)
{ {
if (&that == this) {
return *this;
}
_memberFunctionAndPointer = that._memberFunctionAndPointer; _memberFunctionAndPointer = that._memberFunctionAndPointer;
_caller = that._caller; _caller = that._caller;
_next = NULL; _next = NULL;
@ -222,7 +226,7 @@ public:
* @return A pointer to the next FunctionPointerWithContext instance in the * @return A pointer to the next FunctionPointerWithContext instance in the
* chain. * chain.
*/ */
pFunctionPointerWithContext_t getNext(void) const pFunctionPointerWithContext_t getNext() const
{ {
return _next; return _next;
} }

View File

@ -19,8 +19,8 @@
#ifndef BLE_SAFE_ENUM_H_ #ifndef BLE_SAFE_ENUM_H_
#define BLE_SAFE_ENUM_H_ #define BLE_SAFE_ENUM_H_
#include <stddef.h> #include <cstddef>
#include <stdint.h> #include <cstdint>
namespace ble { namespace ble {

View File

@ -19,12 +19,12 @@
#ifndef MBED_UUID_H__ #ifndef MBED_UUID_H__
#define MBED_UUID_H__ #define MBED_UUID_H__
#include <stddef.h> #include <cstddef>
#include <stdint.h> #include <cstdint>
#include <string.h> #include <cstring>
#include <algorithm> #include <algorithm>
#include "ble/common/ble/blecommon.h" #include "ble/common/blecommon.h"
/** /**
* @file * @file
@ -235,6 +235,13 @@ public:
memcpy(baseUUID, source.baseUUID, LENGTH_OF_LONG_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. * Default constructor.
* *
@ -243,7 +250,7 @@ public:
* @post shortOrLong() returns the value UUID_TYPE_SHORT. * @post shortOrLong() returns the value UUID_TYPE_SHORT.
* @post getShortUUID() returns the value BLE_UUID_UNKNOWN. * @post getShortUUID() returns the value BLE_UUID_UNKNOWN.
*/ */
UUID(void) : UUID() :
type(UUID_TYPE_SHORT), type(UUID_TYPE_SHORT),
shortUUID(BLE_UUID_UNKNOWN) { shortUUID(BLE_UUID_UNKNOWN) {
} }
@ -276,7 +283,7 @@ public:
* @return UUID_TYPE_SHORT if the UUID is 16-bit wide. * @return UUID_TYPE_SHORT if the UUID is 16-bit wide.
* @return UUID_TYPE_LONG if the UUID is 128-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; return type;
} }
@ -287,7 +294,7 @@ public:
* @return A pointer to an uint16_t object if the UUID is 16 bits long. * @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. * @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) { if (type == UUID_TYPE_SHORT) {
return (const uint8_t*)&shortUUID; return (const uint8_t*)&shortUUID;
@ -303,7 +310,7 @@ public:
* *
* @return The value of the shortened UUID. * @return The value of the shortened UUID.
*/ */
ShortUUIDBytes_t getShortUUID(void) const ShortUUIDBytes_t getShortUUID() const
{ {
return shortUUID; return shortUUID;
} }
@ -314,7 +321,7 @@ public:
* @return sizeof(ShortUUIDBytes_t) if the UUID type is UUID_TYPE_SHORT. * @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. * @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) ? return ((type == UUID_TYPE_SHORT) ?
sizeof(ShortUUIDBytes_t) : sizeof(ShortUUIDBytes_t) :

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -16,20 +16,7 @@
* limitations under the License. * limitations under the License.
*/ */
#ifndef IMPL_PAL_SIGNING_MONITOR_H_ /* for backwards compatibility */
#define IMPL_PAL_SIGNING_MONITOR_H_ #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_

View File

@ -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"

View File

@ -16,20 +16,7 @@
* limitations under the License. * limitations under the License.
*/ */
#include "ble/internal/PalSigningMonitor.h" /* for backwards compatibility */
#include "ble/internal/BLEInstanceBase.h" #warning "please include ble/common/SafeBool.h directly"
#include "ble/GattClient.h" #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
}
}

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -17,13 +17,15 @@
#ifndef IMPL_HCI_DRIVER_H_ #ifndef IMPL_HCI_DRIVER_H_
#define IMPL_HCI_DRIVER_H_ #define IMPL_HCI_DRIVER_H_
#include <stddef.h> #include <cstddef>
#include <stdint.h> #include <cstdint>
#include <BLETypes.h> #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 "wsf_buf.h"
#include "CordioHCITransportDriver.h"
#include "ble/common/ble/blecommon.h"
#include "mbed.h"
namespace ble { namespace ble {
@ -73,7 +75,7 @@ public:
/** /**
* Driver destructor * Driver destructor
*/ */
virtual ~CordioHCIDriver() { } virtual ~CordioHCIDriver() = default;
/** /**
* Return the set of memory pool which will be used by the Cordio stack * Return the set of memory pool which will be used by the Cordio stack

View File

@ -17,7 +17,7 @@
#ifndef IMPL_HCI_TRANSPORT_DRIVER_H_ #ifndef IMPL_HCI_TRANSPORT_DRIVER_H_
#define IMPL_HCI_TRANSPORT_DRIVER_H_ #define IMPL_HCI_TRANSPORT_DRIVER_H_
#include <stdint.h> #include <cstdint>
namespace ble { namespace ble {
@ -34,7 +34,7 @@ public:
/** /**
* Driver destructor. * Driver destructor.
*/ */
virtual ~CordioHCITransportDriver() { } virtual ~CordioHCITransportDriver() = default;
/** /**
* Inialization of the transport. * Inialization of the transport.

View File

@ -19,9 +19,9 @@
#if (DEVICE_SERIAL && DEVICE_SERIAL_FC) || defined(DOXYGEN_ONLY) #if (DEVICE_SERIAL && DEVICE_SERIAL_FC) || defined(DOXYGEN_ONLY)
#include <stdint.h> #include <cstdint>
#include "mbed.h" #include "drivers/UnbufferedSerial.h"
#include "CordioHCITransportDriver.h" #include "ble/driver/CordioHCITransportDriver.h"
namespace ble { namespace ble {
@ -47,29 +47,29 @@ public:
/** /**
* Destructor * Destructor
*/ */
virtual ~H4TransportDriver() { } ~H4TransportDriver() override = default;
/** /**
* @see CordioHCITransportDriver::initialize * @see CordioHCITransportDriver::initialize
*/ */
virtual void initialize(); void initialize() override;
/** /**
* @see CordioHCITransportDriver::terminate * @see CordioHCITransportDriver::terminate
*/ */
virtual void terminate(); void terminate() override;
/** /**
* @see CordioHCITransportDriver::write * @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: private:
void on_controller_irq(); void on_controller_irq();
// Use UnbufferedSerial as we don't require locking primitives. // Use UnbufferedSerial as we don't require locking primitives.
// We access the peripheral in interrupt context. // We access the peripheral in interrupt context.
UnbufferedSerial uart; mbed::UnbufferedSerial uart;
PinName cts; PinName cts;
PinName rts; PinName rts;
}; };

View File

@ -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. plan to provide the SDIO implementation at the moment.
This interface is defined in the header file This interface is defined in the header file
[CordioHCITransportDriver.h](../driver/CordioHCITransportDriver.h) [CordioHCITransportDriver.h](../CordioHCITransportDriver.h)
## CordioHCIDriver ## CordioHCIDriver
@ -35,10 +35,10 @@ The responsibilities of this driver are:
* Handle the reset/startup sequence of the Bluetooth controller. * Handle the reset/startup sequence of the Bluetooth controller.
This interface is defined in the header file 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 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 delivering memory to the stack and a complete reset sequence. However, it does
not define any initialization for the Bluetooth controller, this part being not define any initialization for the Bluetooth controller, this part being
specific to the controller used. specific to the controller used.

View File

@ -19,16 +19,16 @@
#ifndef MBED_GAP_ADVERTISING_DATA_H__ #ifndef MBED_GAP_ADVERTISING_DATA_H__
#define MBED_GAP_ADVERTISING_DATA_H__ #define MBED_GAP_ADVERTISING_DATA_H__
#include <stdint.h> #include <cstdint>
#include <string.h> #include <cstring>
#include <stdlib.h> #include <cstdlib>
#include "platform/NonCopyable.h" #include "platform/NonCopyable.h"
#include "ble/common/ble/UUID.h" #include "ble/common/UUID.h"
#include "ble/common/ble/BLETypes.h" #include "ble/common/BLETypes.h"
#include "ble/common/ble/blecommon.h" #include "ble/common/blecommon.h"
#include "ble/common/ble/gap/AdvertisingDataTypes.h" #include "ble/gap/AdvertisingDataTypes.h"
#include "ble/common/ble/gap/Types.h" #include "ble/gap/Types.h"
namespace ble { namespace ble {

View File

@ -19,10 +19,10 @@
#ifndef BLE_GAP_ADVERTISINGDATAPARSER_H #ifndef BLE_GAP_ADVERTISINGDATAPARSER_H
#define BLE_GAP_ADVERTISINGDATAPARSER_H #define BLE_GAP_ADVERTISINGDATAPARSER_H
#include <stdint.h> #include <cstdint>
#include "platform/Span.h" #include "platform/Span.h"
#include "ble/common/ble/gap/AdvertisingDataTypes.h" #include "ble/gap/AdvertisingDataTypes.h"
namespace ble { namespace ble {
@ -70,7 +70,7 @@ public:
*/ */
bool hasNext() const bool hasNext() const
{ {
if (position >= data.size()) { if (position >= (size_t) data.size()) {
return false; return false;
} }
@ -79,7 +79,7 @@ public:
return false; return false;
} }
if (position + current_length() >= data.size()) { if (position + current_length() >= (size_t) data.size()) {
return false; return false;
} }

View File

@ -21,8 +21,8 @@
#include "platform/Span.h" #include "platform/Span.h"
#include "ble/common/ble/UUID.h" #include "ble/common/UUID.h"
#include "ble/common/ble/gap/AdvertisingDataBuilder.h" #include "ble/gap/AdvertisingDataBuilder.h"
namespace ble { namespace ble {
@ -68,7 +68,7 @@ public:
/** /**
* Construct a AdvertisingDataSimpleBuilder * Construct a AdvertisingDataSimpleBuilder
*/ */
AdvertisingDataSimpleBuilder() : _builder(_buffer) AdvertisingDataSimpleBuilder() : _buffer(), _builder(_buffer)
{ {
} }
@ -200,7 +200,7 @@ public:
* *
* @return A reference to this object. * @return A reference to this object.
*/ */
AdvertisingDataSimpleBuilder &setServiceData(UUID service, mbed::Span<const uint8_t> data) AdvertisingDataSimpleBuilder &setServiceData(const UUID& service, mbed::Span<const uint8_t> data)
{ {
ble_error_t res = _builder.setServiceData(service, data); ble_error_t res = _builder.setServiceData(service, data);
MBED_ASSERT(res == BLE_ERROR_NONE); MBED_ASSERT(res == BLE_ERROR_NONE);

View File

@ -19,7 +19,7 @@
#ifndef BLE_GAP_ADVERTISINGDATATYPES_H #ifndef BLE_GAP_ADVERTISINGDATATYPES_H
#define BLE_GAP_ADVERTISINGDATATYPES_H #define BLE_GAP_ADVERTISINGDATATYPES_H
#include "ble/common/ble/SafeEnum.h" #include "ble/common/SafeEnum.h"
namespace ble { namespace ble {
@ -180,7 +180,7 @@ struct adv_data_flags_t {
adv_data_flags_t &setGeneralDiscoverable(bool enable = true) adv_data_flags_t &setGeneralDiscoverable(bool enable = true)
{ {
_value &= ~0x03; _value &= ~0x03U;
if (enable) { if (enable) {
_value |= LE_GENERAL_DISCOVERABLE; _value |= LE_GENERAL_DISCOVERABLE;
} }
@ -189,7 +189,7 @@ struct adv_data_flags_t {
adv_data_flags_t &setLimitedDiscoverable(bool enable = true) adv_data_flags_t &setLimitedDiscoverable(bool enable = true)
{ {
_value &= ~0x03; _value &= ~0x03U;
if (enable) { if (enable) {
_value |= LE_LIMITED_DISCOVERABLE; _value |= LE_LIMITED_DISCOVERABLE;
} }
@ -223,27 +223,27 @@ struct adv_data_flags_t {
return *this; return *this;
} }
bool getGeneralDiscoverable() bool getGeneralDiscoverable() const
{ {
return _value & LE_GENERAL_DISCOVERABLE; return _value & LE_GENERAL_DISCOVERABLE;
} }
bool getlimitedDiscoverable() bool getlimitedDiscoverable() const
{ {
return _value & LE_LIMITED_DISCOVERABLE; return _value & LE_LIMITED_DISCOVERABLE;
} }
bool getBrEdrNotSupported() bool getBrEdrNotSupported() const
{ {
return _value & BREDR_NOT_SUPPORTED; return _value & BREDR_NOT_SUPPORTED;
} }
bool getSimultaneousLeBredrC() bool getSimultaneousLeBredrC() const
{ {
return _value & SIMULTANEOUS_LE_BREDR_C; return _value & SIMULTANEOUS_LE_BREDR_C;
} }
bool getSimultaneousLeBredrH() bool getSimultaneousLeBredrH() const
{ {
return _value & SIMULTANEOUS_LE_BREDR_H; return _value & SIMULTANEOUS_LE_BREDR_H;
} }
@ -253,7 +253,7 @@ struct adv_data_flags_t {
_value = 0; _value = 0;
} }
uint8_t value() uint8_t value() const
{ {
return _value; return _value;
} }

View File

@ -21,9 +21,9 @@
#include <algorithm> #include <algorithm>
#include "ble/common/ble/BLETypes.h" #include "ble/common/BLETypes.h"
#include "ble/common/ble/blecommon.h" #include "ble/common/blecommon.h"
#include "ble/common/ble/SafeEnum.h" #include "ble/common/SafeEnum.h"
namespace ble { namespace ble {

View File

@ -19,9 +19,9 @@
#ifndef MBED_EXTENDED_CONNECT_PARAMETERS_H__ #ifndef MBED_EXTENDED_CONNECT_PARAMETERS_H__
#define 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 { namespace ble {
@ -429,7 +429,7 @@ private:
return index; return index;
} }
uint8_t phyToIndex(phy_t phy) const static uint8_t phyToIndex(phy_t phy)
{ {
uint8_t index; uint8_t index;
switch (phy.value()) { switch (phy.value()) {

View File

@ -19,8 +19,8 @@
#ifndef BLE_GAP_EVENTS_H #ifndef BLE_GAP_EVENTS_H
#define BLE_GAP_EVENTS_H #define BLE_GAP_EVENTS_H
#include "ble/common/ble/blecommon.h" #include "ble/common/blecommon.h"
#include "ble/common/ble/BLETypes.h" #include "ble/common/BLETypes.h"
namespace ble { namespace ble {

View File

@ -19,10 +19,10 @@
#ifndef MBED_GAP_SCAN_PARAMETERS_H__ #ifndef MBED_GAP_SCAN_PARAMETERS_H__
#define MBED_GAP_SCAN_PARAMETERS_H__ #define MBED_GAP_SCAN_PARAMETERS_H__
#include <stdint.h> #include <cstdint>
#include "ble/common/ble/blecommon.h" #include "ble/common/blecommon.h"
#include "ble/common/ble/BLETypes.h" #include "ble/common/BLETypes.h"
namespace ble { namespace ble {

View File

@ -19,9 +19,9 @@
#ifndef BLE_GAP_TYPES_H #ifndef BLE_GAP_TYPES_H
#define BLE_GAP_TYPES_H #define BLE_GAP_TYPES_H
#include "ble/common/ble/Duration.h" #include "ble/common/Duration.h"
#include "ble/common/ble/Bounded.h" #include "ble/common/Bounded.h"
#include "ble/common/ble/SafeEnum.h" #include "ble/common/SafeEnum.h"
namespace ble { namespace ble {

View File

@ -19,7 +19,7 @@
#ifndef MBED_CHARACTERISTIC_DESCRIPTOR_DISCOVERY_H__ #ifndef MBED_CHARACTERISTIC_DESCRIPTOR_DISCOVERY_H__
#define MBED_CHARACTERISTIC_DESCRIPTOR_DISCOVERY_H__ #define MBED_CHARACTERISTIC_DESCRIPTOR_DISCOVERY_H__
#include "FunctionPointerWithContext.h" #include "ble/common/FunctionPointerWithContext.h"
class DiscoveredCharacteristic; // forward declaration class DiscoveredCharacteristic; // forward declaration
class DiscoveredCharacteristicDescriptor; // forward declaration class DiscoveredCharacteristicDescriptor; // forward declaration

View File

@ -19,11 +19,11 @@
#ifndef MBED_DISCOVERED_CHARACTERISTIC_H__ #ifndef MBED_DISCOVERED_CHARACTERISTIC_H__
#define MBED_DISCOVERED_CHARACTERISTIC_H__ #define MBED_DISCOVERED_CHARACTERISTIC_H__
#include "ble/common/ble/UUID.h" #include "ble/common/UUID.h"
#include "ble/common/ble/GattAttribute.h" #include "ble/gatt/GattAttribute.h"
#include "ble/common/ble/GattCallbackParamTypes.h" #include "ble/gatt/GattCallbackParamTypes.h"
#include "ble/common/ble/CharacteristicDescriptorDiscovery.h" #include "ble/gatt/CharacteristicDescriptorDiscovery.h"
#include "ble/common/ble/DiscoveredCharacteristicDescriptor.h" #include "ble/gatt/DiscoveredCharacteristicDescriptor.h"
namespace ble { namespace ble {
class GattClient; class GattClient;
@ -155,7 +155,7 @@ public:
* *
* @see _broadcast * @see _broadcast
*/ */
bool broadcast(void) const bool broadcast() const
{ {
return _broadcast; return _broadcast;
} }
@ -168,7 +168,7 @@ public:
* *
* @see _read * @see _read
*/ */
bool read(void) const bool read() const
{ {
return _read; return _read;
} }
@ -181,7 +181,7 @@ public:
* *
* @see _writeWoResp * @see _writeWoResp
*/ */
bool writeWoResp(void) const bool writeWoResp() const
{ {
return _writeWoResp; return _writeWoResp;
} }
@ -194,7 +194,7 @@ public:
* *
* @see _write * @see _write
*/ */
bool write(void) const bool write() const
{ {
return _write; return _write;
} }
@ -211,7 +211,7 @@ public:
* *
* @see _notify * @see _notify
*/ */
bool notify(void) const bool notify() const
{ {
return _notify; return _notify;
} }
@ -228,7 +228,7 @@ public:
* *
* @see _indicate * @see _indicate
*/ */
bool indicate(void) const bool indicate() const
{ {
return _indicate; return _indicate;
} }
@ -239,7 +239,7 @@ public:
* @return true if the characteristic accepts authenticated signed write * @return true if the characteristic accepts authenticated signed write
* and false otherwise. * and false otherwise.
*/ */
bool authSignedWrite(void) const bool authSignedWrite() const
{ {
return _authSignedWrite; return _authSignedWrite;
} }
@ -447,7 +447,7 @@ public:
* *
* @return The UUID of this characteristic. * @return The UUID of this characteristic.
*/ */
const UUID &getUUID(void) const const UUID &getUUID() const
{ {
return uuid; return uuid;
} }
@ -457,7 +457,7 @@ public:
* *
* @return The set of properties of this characteristic. * @return The set of properties of this characteristic.
*/ */
const Properties_t &getProperties(void) const const Properties_t &getProperties() const
{ {
return props; return props;
} }
@ -477,7 +477,7 @@ public:
* *
* @return the declaration handle of this characteristic. * @return the declaration handle of this characteristic.
*/ */
GattAttribute::Handle_t getDeclHandle(void) const GattAttribute::Handle_t getDeclHandle() const
{ {
return declHandle; return declHandle;
} }
@ -489,7 +489,7 @@ public:
* *
* @return The handle to access the value of this characteristic. * @return The handle to access the value of this characteristic.
*/ */
GattAttribute::Handle_t getValueHandle(void) const GattAttribute::Handle_t getValueHandle() const
{ {
return valueHandle; return valueHandle;
} }
@ -510,7 +510,7 @@ public:
* *
* @note This function is public for informative purposes. * @note This function is public for informative purposes.
*/ */
GattAttribute::Handle_t getLastHandle(void) const GattAttribute::Handle_t getLastHandle() const
{ {
return lastHandle; return lastHandle;
} }
@ -583,7 +583,7 @@ public:
public: public:
DiscoveredCharacteristic() : DiscoveredCharacteristic() :
gattc(NULL), gattc(nullptr),
uuid(UUID::ShortUUIDBytes_t(0)), uuid(UUID::ShortUUIDBytes_t(0)),
props(), props(),
declHandle(GattAttribute::INVALID_HANDLE), declHandle(GattAttribute::INVALID_HANDLE),

View File

@ -19,10 +19,10 @@
#ifndef MBED_DISCOVERED_CHARACTERISTIC_DESCRIPTOR_H__ #ifndef MBED_DISCOVERED_CHARACTERISTIC_DESCRIPTOR_H__
#define MBED_DISCOVERED_CHARACTERISTIC_DESCRIPTOR_H__ #define MBED_DISCOVERED_CHARACTERISTIC_DESCRIPTOR_H__
#include "ble/common/ble/UUID.h"
#include "ble/Gap.h" #include "ble/Gap.h"
#include "ble/common/ble/GattAttribute.h" #include "ble/common/UUID.h"
#include "ble/common/ble/CharacteristicDescriptorDiscovery.h" #include "ble/gatt/GattAttribute.h"
#include "ble/gatt/CharacteristicDescriptorDiscovery.h"
namespace ble { namespace ble {
class GattClient; class GattClient;
@ -124,7 +124,7 @@ public:
* *
* @return UUID of this descriptor. * @return UUID of this descriptor.
*/ */
const UUID& getUUID(void) const const UUID& getUUID() const
{ {
return _uuid; return _uuid;
} }

View File

@ -19,8 +19,8 @@
#ifndef MBED_DISCOVERED_SERVICE_H__ #ifndef MBED_DISCOVERED_SERVICE_H__
#define MBED_DISCOVERED_SERVICE_H__ #define MBED_DISCOVERED_SERVICE_H__
#include "ble/common/ble/UUID.h" #include "ble/common/UUID.h"
#include "ble/common/ble/GattAttribute.h" #include "ble/gatt/GattAttribute.h"
/** /**
* @addtogroup ble * @addtogroup ble
@ -57,7 +57,7 @@ public:
* *
* @return A reference to the UUID of the discovered service. * @return A reference to the UUID of the discovered service.
*/ */
const UUID &getUUID(void) const const UUID &getUUID() const
{ {
return uuid; return uuid;
} }
@ -67,7 +67,7 @@ public:
* *
* @return A reference to the start handle. * @return A reference to the start handle.
*/ */
const GattAttribute::Handle_t& getStartHandle(void) const const GattAttribute::Handle_t& getStartHandle() const
{ {
return startHandle; return startHandle;
} }
@ -77,7 +77,7 @@ public:
* *
* @return A reference to the end handle. * @return A reference to the end handle.
*/ */
const GattAttribute::Handle_t& getEndHandle(void) const const GattAttribute::Handle_t& getEndHandle() const
{ {
return endHandle; return endHandle;
} }
@ -95,6 +95,9 @@ public:
endHandle(GattAttribute::INVALID_HANDLE) { endHandle(GattAttribute::INVALID_HANDLE) {
} }
DiscoveredService(const DiscoveredService &) = delete;
DiscoveredService operator=(const DiscoveredService &) = delete;
/** /**
* Set information about the discovered service. * Set information about the discovered service.
* *
@ -108,7 +111,7 @@ public:
* peer's GATT server. * peer's GATT server.
*/ */
void setup( void setup(
UUID uuidIn, const UUID& uuidIn,
GattAttribute::Handle_t startHandleIn, GattAttribute::Handle_t startHandleIn,
GattAttribute::Handle_t endHandleIn GattAttribute::Handle_t endHandleIn
) { ) {
@ -153,10 +156,6 @@ public:
uuid.setupLong(longUUID, order); uuid.setupLong(longUUID, order);
} }
private:
DiscoveredService(const DiscoveredService &);
private: private:
/** /**
* UUID of the service. * UUID of the service.

View File

@ -19,8 +19,8 @@
#ifndef MBED_GATT_ATTRIBUTE_H__ #ifndef MBED_GATT_ATTRIBUTE_H__
#define MBED_GATT_ATTRIBUTE_H__ #define MBED_GATT_ATTRIBUTE_H__
#include "ble/common/ble/UUID.h" #include "ble/common/UUID.h"
#include "ble/common/ble/BLETypes.h" #include "ble/common/BLETypes.h"
/** /**
* @addtogroup ble * @addtogroup ble
@ -113,7 +113,7 @@ public:
*/ */
GattAttribute( GattAttribute(
const UUID &uuid, const UUID &uuid,
uint8_t *valuePtr = NULL, uint8_t *valuePtr = nullptr,
uint16_t len = 0, uint16_t len = 0,
uint16_t maxLen = 0, uint16_t maxLen = 0,
bool hasVariableLen = true bool hasVariableLen = true
@ -129,6 +129,9 @@ public:
_write_security(Security_t::NONE) { _write_security(Security_t::NONE) {
} }
GattAttribute(const GattAttribute &) = delete;
GattAttribute& operator=(const GattAttribute &) = delete;
public: public:
/** /**
* Get the attribute's handle in the ATT table. * Get the attribute's handle in the ATT table.
@ -138,7 +141,7 @@ public:
* *
* @return The attribute's handle. * @return The attribute's handle.
*/ */
Handle_t getHandle(void) const Handle_t getHandle() const
{ {
return _handle; return _handle;
} }
@ -150,7 +153,7 @@ public:
* *
* @return The attribute. * @return The attribute.
*/ */
const UUID &getUUID(void) const const UUID &getUUID() const
{ {
return _uuid; return _uuid;
} }
@ -160,7 +163,7 @@ public:
* *
* @return The current length of the attribute value. * @return The current length of the attribute value.
*/ */
uint16_t getLength(void) const uint16_t getLength() const
{ {
return _len; return _len;
} }
@ -170,7 +173,7 @@ public:
* *
* The maximum length of the attribute value. * The maximum length of the attribute value.
*/ */
uint16_t getMaxLength(void) const uint16_t getMaxLength() const
{ {
return _lenMax; return _lenMax;
} }
@ -182,7 +185,7 @@ public:
* *
* @return A pointer to the current length of the attribute value. * @return A pointer to the current length of the attribute value.
*/ */
uint16_t *getLengthPtr(void) uint16_t *getLengthPtr()
{ {
return &_len; return &_len;
} }
@ -205,7 +208,7 @@ public:
* *
* @return A pointer to the attribute value. * @return A pointer to the attribute value.
*/ */
uint8_t *getValuePtr(void) uint8_t *getValuePtr()
{ {
return _valuePtr; return _valuePtr;
} }
@ -216,7 +219,7 @@ public:
* @return true if the attribute value has a variable length and false * @return true if the attribute value has a variable length and false
* otherwise. * otherwise.
*/ */
bool hasVariableLength(void) const bool hasVariableLength() const
{ {
return _hasVariableLen; return _hasVariableLen;
} }
@ -234,7 +237,7 @@ public:
* Indicate if a client is allowed to read the attribute. * Indicate if a client is allowed to read the attribute.
* @return true 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; return _read_allowed;
} }
@ -270,7 +273,7 @@ public:
* Indicate if a client is allowed to write the attribute. * Indicate if a client is allowed to write the attribute.
* @return true 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; return _write_allowed;
} }
@ -343,11 +346,6 @@ private:
* Security applied to the write operation. * Security applied to the write operation.
*/ */
uint8_t _write_security: Security_t::size; uint8_t _write_security: Security_t::size;
private:
/* Disallow copy and assignment. */
GattAttribute(const GattAttribute &);
GattAttribute& operator=(const GattAttribute &);
}; };
/** /**

View File

@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#include "CallChainOfFunctionPointersWithContext.h" #include "ble/common/CallChainOfFunctionPointersWithContext.h"
#ifndef MBED_BLE_GATT_CALLBACK_PARAM_TYPES_H__ #ifndef MBED_BLE_GATT_CALLBACK_PARAM_TYPES_H__
#define MBED_BLE_GATT_CALLBACK_PARAM_TYPES_H__ #define MBED_BLE_GATT_CALLBACK_PARAM_TYPES_H__

View File

@ -19,10 +19,10 @@
#ifndef __GATT_CHARACTERISTIC_H__ #ifndef __GATT_CHARACTERISTIC_H__
#define __GATT_CHARACTERISTIC_H__ #define __GATT_CHARACTERISTIC_H__
#include "FunctionPointerWithContext.h" #include "ble/common/FunctionPointerWithContext.h"
#include "ble/common/ble/GattAttribute.h" #include "ble/gatt/GattAttribute.h"
#include "ble/common/ble/GattCallbackParamTypes.h" #include "ble/gatt/GattCallbackParamTypes.h"
/** /**
* @addtogroup ble * @addtogroup ble
@ -1384,7 +1384,7 @@ public:
* @param[in] hasVariableLen Flag that indicates if the attribute's value * @param[in] hasVariableLen Flag that indicates if the attribute's value
* length can change throughout time. * 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 * is readable, then that particular characteristic may be considered
* optional and dropped while instantiating the service with the underlying * optional and dropped while instantiating the service with the underlying
* BLE stack. * BLE stack.
@ -1398,11 +1398,11 @@ public:
*/ */
GattCharacteristic( GattCharacteristic(
const UUID &uuid, const UUID &uuid,
uint8_t *valuePtr = NULL, uint8_t *valuePtr = nullptr,
uint16_t len = 0, uint16_t len = 0,
uint16_t maxLen = 0, uint16_t maxLen = 0,
uint8_t props = BLE_GATT_CHAR_PROPERTIES_NONE, uint8_t props = BLE_GATT_CHAR_PROPERTIES_NONE,
GattAttribute *descriptors[] = NULL, GattAttribute *descriptors[] = nullptr,
unsigned numDescriptors = 0, unsigned numDescriptors = 0,
bool hasVariableLen = true bool hasVariableLen = true
) : _valueAttribute(uuid, valuePtr, len, maxLen, hasVariableLen), ) : _valueAttribute(uuid, valuePtr, len, maxLen, hasVariableLen),
@ -1426,6 +1426,9 @@ public:
#endif // BLE_FEATURE_SECURITY #endif // BLE_FEATURE_SECURITY
} }
GattCharacteristic(const GattCharacteristic &) = delete;
GattCharacteristic& operator=(const GattCharacteristic &) = delete;
public: public:
/** /**
@ -1639,7 +1642,7 @@ public:
* @return A GattAuthCallbackReply_t value indicating whether authorization * @return A GattAuthCallbackReply_t value indicating whether authorization
* is granted. * 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. * the current characteristic value is used in the read response payload.
* *
* @note If the read is approved, the event handler can specify an outgoing * @note If the read is approved, the event handler can specify an outgoing
@ -1687,7 +1690,7 @@ public:
* @note The underlying BLE stack assigns the attribute handle when the * @note The underlying BLE stack assigns the attribute handle when the
* enclosing service is added. * enclosing service is added.
*/ */
GattAttribute::Handle_t getValueHandle(void) const GattAttribute::Handle_t getValueHandle() const
{ {
return getValueAttribute().getHandle(); return getValueAttribute().getHandle();
} }
@ -1699,7 +1702,7 @@ public:
* *
* @return The characteristic's properties. * @return The characteristic's properties.
*/ */
uint8_t getProperties(void) const uint8_t getProperties() const
{ {
return _properties; return _properties;
} }
@ -1709,7 +1712,7 @@ public:
* *
* @return The total number of descriptors. * @return The total number of descriptors.
*/ */
uint8_t getDescriptorCount(void) const uint8_t getDescriptorCount() const
{ {
return _descriptorCount; return _descriptorCount;
} }
@ -1746,12 +1749,12 @@ public:
* @param[in] index The index of the descriptor to get. * @param[in] index The index of the descriptor to get.
* *
* @return A pointer the requested descriptor if @p index is within the * @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) GattAttribute *getDescriptor(uint8_t index)
{ {
if (index >= _descriptorCount) { if (index >= _descriptorCount) {
return NULL; return nullptr;
} }
return _descriptors[index]; return _descriptors[index];
@ -1799,11 +1802,6 @@ private:
* receive updates * receive updates
*/ */
uint8_t _update_security: SecurityRequirement_t::size; uint8_t _update_security: SecurityRequirement_t::size;
private:
/* Disallow copy and assignment. */
GattCharacteristic(const GattCharacteristic &);
GattCharacteristic& operator=(const GattCharacteristic &);
}; };
/** /**
@ -1834,7 +1832,7 @@ public:
const UUID &uuid, const UUID &uuid,
T *valuePtr, T *valuePtr,
uint8_t additionalProperties = BLE_GATT_CHAR_PROPERTIES_NONE, uint8_t additionalProperties = BLE_GATT_CHAR_PROPERTIES_NONE,
GattAttribute *descriptors[] = NULL, GattAttribute *descriptors[] = nullptr,
unsigned numDescriptors = 0 unsigned numDescriptors = 0
) : GattCharacteristic( ) : GattCharacteristic(
uuid, uuid,
@ -1877,7 +1875,7 @@ public:
const UUID &uuid, const UUID &uuid,
T *valuePtr, T *valuePtr,
uint8_t additionalProperties = BLE_GATT_CHAR_PROPERTIES_NONE, uint8_t additionalProperties = BLE_GATT_CHAR_PROPERTIES_NONE,
GattAttribute *descriptors[] = NULL, GattAttribute *descriptors[] = nullptr,
unsigned numDescriptors = 0 unsigned numDescriptors = 0
) : GattCharacteristic( ) : GattCharacteristic(
uuid, uuid,
@ -1919,7 +1917,7 @@ public:
const UUID &uuid, const UUID &uuid,
T *valuePtr, T *valuePtr,
uint8_t additionalProperties = BLE_GATT_CHAR_PROPERTIES_NONE, uint8_t additionalProperties = BLE_GATT_CHAR_PROPERTIES_NONE,
GattAttribute *descriptors[] = NULL, GattAttribute *descriptors[] = nullptr,
unsigned numDescriptors = 0 unsigned numDescriptors = 0
) : GattCharacteristic( ) : GattCharacteristic(
uuid, uuid,
@ -1962,7 +1960,7 @@ public:
const UUID &uuid, const UUID &uuid,
T valuePtr[NUM_ELEMENTS], T valuePtr[NUM_ELEMENTS],
uint8_t additionalProperties = BLE_GATT_CHAR_PROPERTIES_NONE, uint8_t additionalProperties = BLE_GATT_CHAR_PROPERTIES_NONE,
GattAttribute *descriptors[] = NULL, GattAttribute *descriptors[] = nullptr,
unsigned numDescriptors = 0 unsigned numDescriptors = 0
) : GattCharacteristic( ) : GattCharacteristic(
uuid, uuid,
@ -2006,7 +2004,7 @@ public:
const UUID &uuid, const UUID &uuid,
T valuePtr[NUM_ELEMENTS], T valuePtr[NUM_ELEMENTS],
uint8_t additionalProperties = BLE_GATT_CHAR_PROPERTIES_NONE, uint8_t additionalProperties = BLE_GATT_CHAR_PROPERTIES_NONE,
GattAttribute *descriptors[] = NULL, GattAttribute *descriptors[] = nullptr,
unsigned numDescriptors = 0 unsigned numDescriptors = 0
) : GattCharacteristic( ) : GattCharacteristic(
uuid, uuid,
@ -2051,7 +2049,7 @@ public:
const UUID &uuid, const UUID &uuid,
T valuePtr[NUM_ELEMENTS], T valuePtr[NUM_ELEMENTS],
uint8_t additionalProperties = BLE_GATT_CHAR_PROPERTIES_NONE, uint8_t additionalProperties = BLE_GATT_CHAR_PROPERTIES_NONE,
GattAttribute *descriptors[] = NULL, GattAttribute *descriptors[] = nullptr,
unsigned numDescriptors = 0 unsigned numDescriptors = 0
) : GattCharacteristic( ) : GattCharacteristic(
uuid, uuid,

View File

@ -19,8 +19,8 @@
#ifndef MBED_GATT_SERVICE_H__ #ifndef MBED_GATT_SERVICE_H__
#define MBED_GATT_SERVICE_H__ #define MBED_GATT_SERVICE_H__
#include "ble/common/ble/UUID.h" #include "ble/common/UUID.h"
#include "ble/common/ble/GattCharacteristic.h" #include "ble/gatt/GattCharacteristic.h"
/** /**
* @addtogroup ble * @addtogroup ble
@ -164,7 +164,7 @@ public:
* *
* @return A reference to the service's UUID. * @return A reference to the service's UUID.
*/ */
const UUID &getUUID(void) const const UUID &getUUID() const
{ {
return _primaryServiceID; return _primaryServiceID;
} }
@ -174,7 +174,7 @@ public:
* *
* @return The service's handle. * @return The service's handle.
*/ */
uint16_t getHandle(void) const uint16_t getHandle() const
{ {
return _handle; return _handle;
} }
@ -184,7 +184,7 @@ public:
* *
* @return The total number of characteristics within this service. * @return The total number of characteristics within this service.
*/ */
uint8_t getCharacteristicCount(void) const uint8_t getCharacteristicCount() const
{ {
return _characteristicCount; return _characteristicCount;
} }
@ -211,7 +211,7 @@ public:
GattCharacteristic *getCharacteristic(uint8_t index) GattCharacteristic *getCharacteristic(uint8_t index)
{ {
if (index >= _characteristicCount) { if (index >= _characteristicCount) {
return NULL; return nullptr;
} }
return _characteristics[index]; return _characteristics[index];

View File

@ -19,9 +19,9 @@
#ifndef MBED_BLE_SERVICE_DISOVERY_H__ #ifndef MBED_BLE_SERVICE_DISOVERY_H__
#define MBED_BLE_SERVICE_DISOVERY_H__ #define MBED_BLE_SERVICE_DISOVERY_H__
#include "ble/common/ble/blecommon.h" #include "ble/common/blecommon.h"
#include "ble/common/ble/UUID.h" #include "ble/common/UUID.h"
#include "ble/common/ble/GattAttribute.h" #include "ble/gatt/GattAttribute.h"
class DiscoveredService; class DiscoveredService;
class DiscoveredCharacteristic; class DiscoveredCharacteristic;
@ -138,21 +138,21 @@ public:
* BLE_ERROR_NONE if service discovery is launched successfully; else an appropriate error. * BLE_ERROR_NONE if service discovery is launched successfully; else an appropriate error.
*/ */
virtual ble_error_t launch(ble::connection_handle_t connectionHandle, virtual ble_error_t launch(ble::connection_handle_t connectionHandle,
ServiceCallback_t sc = NULL, ServiceCallback_t sc = nullptr,
CharacteristicCallback_t cc = NULL, CharacteristicCallback_t cc = nullptr,
const UUID &matchingServiceUUID = UUID::ShortUUIDBytes_t(BLE_UUID_UNKNOWN), const UUID &matchingServiceUUID = UUID::ShortUUIDBytes_t(BLE_UUID_UNKNOWN),
const UUID &matchingCharacteristicUUIDIn = UUID::ShortUUIDBytes_t(BLE_UUID_UNKNOWN)) = 0; const UUID &matchingCharacteristicUUIDIn = UUID::ShortUUIDBytes_t(BLE_UUID_UNKNOWN)) = 0;
/** /**
* Check whether service-discovery is currently active. * 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 * Terminate an ongoing service discovery. This should result in an
* invocation of the TerminationCallback if service discovery is active. * 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. * Set up a callback to be invoked when service discovery is terminated.
@ -170,12 +170,12 @@ public:
* *
* @return BLE_ERROR_NONE on success. * @return BLE_ERROR_NONE on success.
*/ */
virtual ble_error_t reset(void) { virtual ble_error_t reset() {
connHandle = 0; connHandle = 0;
matchingServiceUUID = UUID::ShortUUIDBytes_t(BLE_UUID_UNKNOWN); matchingServiceUUID = UUID::ShortUUIDBytes_t(BLE_UUID_UNKNOWN);
serviceCallback = NULL; serviceCallback = nullptr;
matchingCharacteristicUUID = UUID::ShortUUIDBytes_t(BLE_UUID_UNKNOWN); matchingCharacteristicUUID = UUID::ShortUUIDBytes_t(BLE_UUID_UNKNOWN);
characteristicCallback = NULL; characteristicCallback = nullptr;
return BLE_ERROR_NONE; return BLE_ERROR_NONE;
} }

View File

@ -86,7 +86,7 @@ public:
GattService batteryService( GattService batteryService(
GattService::UUID_BATTERY_SERVICE, GattService::UUID_BATTERY_SERVICE,
charTable, charTable,
sizeof(charTable) / sizeof(GattCharacteristic *) sizeof(charTable) / sizeof(charTable[0])
); );
ble.gattServer().addService(batteryService); ble.gattServer().addService(batteryService);

View File

@ -53,42 +53,42 @@ public:
* The device's software version. * The device's software version.
*/ */
DeviceInformationService(BLE &_ble, DeviceInformationService(BLE &_ble,
const char *manufacturersName = NULL, const char *manufacturersName = nullptr,
const char *modelNumber = NULL, const char *modelNumber = nullptr,
const char *serialNumber = NULL, const char *serialNumber = nullptr,
const char *hardwareRevision = NULL, const char *hardwareRevision = nullptr,
const char *firmwareRevision = NULL, const char *firmwareRevision = nullptr,
const char *softwareRevision = NULL) : const char *softwareRevision = nullptr) :
ble(_ble), ble(_ble),
manufacturersNameStringCharacteristic(GattCharacteristic::UUID_MANUFACTURER_NAME_STRING_CHAR, manufacturersNameStringCharacteristic(GattCharacteristic::UUID_MANUFACTURER_NAME_STRING_CHAR,
(uint8_t *)manufacturersName, (uint8_t *)manufacturersName,
(manufacturersName != NULL) ? strlen(manufacturersName) : 0, /* Min length */ (manufacturersName != nullptr) ? strlen(manufacturersName) : 0, /* Min length */
(manufacturersName != NULL) ? strlen(manufacturersName) : 0, /* Max length */ (manufacturersName != nullptr) ? strlen(manufacturersName) : 0, /* Max length */
GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ), GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ),
modelNumberStringCharacteristic(GattCharacteristic::UUID_MODEL_NUMBER_STRING_CHAR, modelNumberStringCharacteristic(GattCharacteristic::UUID_MODEL_NUMBER_STRING_CHAR,
(uint8_t *)modelNumber, (uint8_t *)modelNumber,
(modelNumber != NULL) ? strlen(modelNumber) : 0, /* Min length */ (modelNumber != nullptr) ? strlen(modelNumber) : 0, /* Min length */
(modelNumber != NULL) ? strlen(modelNumber) : 0, /* Max length */ (modelNumber != nullptr) ? strlen(modelNumber) : 0, /* Max length */
GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ), GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ),
serialNumberStringCharacteristic(GattCharacteristic::UUID_SERIAL_NUMBER_STRING_CHAR, serialNumberStringCharacteristic(GattCharacteristic::UUID_SERIAL_NUMBER_STRING_CHAR,
(uint8_t *)serialNumber, (uint8_t *)serialNumber,
(serialNumber != NULL) ? strlen(serialNumber) : 0, /* Min length */ (serialNumber != nullptr) ? strlen(serialNumber) : 0, /* Min length */
(serialNumber != NULL) ? strlen(serialNumber) : 0, /* Max length */ (serialNumber != nullptr) ? strlen(serialNumber) : 0, /* Max length */
GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ), GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ),
hardwareRevisionStringCharacteristic(GattCharacteristic::UUID_HARDWARE_REVISION_STRING_CHAR, hardwareRevisionStringCharacteristic(GattCharacteristic::UUID_HARDWARE_REVISION_STRING_CHAR,
(uint8_t *)hardwareRevision, (uint8_t *)hardwareRevision,
(hardwareRevision != NULL) ? strlen(hardwareRevision) : 0, /* Min length */ (hardwareRevision != nullptr) ? strlen(hardwareRevision) : 0, /* Min length */
(hardwareRevision != NULL) ? strlen(hardwareRevision) : 0, /* Max length */ (hardwareRevision != nullptr) ? strlen(hardwareRevision) : 0, /* Max length */
GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ), GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ),
firmwareRevisionStringCharacteristic(GattCharacteristic::UUID_FIRMWARE_REVISION_STRING_CHAR, firmwareRevisionStringCharacteristic(GattCharacteristic::UUID_FIRMWARE_REVISION_STRING_CHAR,
(uint8_t *)firmwareRevision, (uint8_t *)firmwareRevision,
(firmwareRevision != NULL) ? strlen(firmwareRevision) : 0, /* Min length */ (firmwareRevision != nullptr) ? strlen(firmwareRevision) : 0, /* Min length */
(firmwareRevision != NULL) ? strlen(firmwareRevision) : 0, /* Max length */ (firmwareRevision != nullptr) ? strlen(firmwareRevision) : 0, /* Max length */
GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ), GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ),
softwareRevisionStringCharacteristic(GattCharacteristic::UUID_SOFTWARE_REVISION_STRING_CHAR, softwareRevisionStringCharacteristic(GattCharacteristic::UUID_SOFTWARE_REVISION_STRING_CHAR,
(uint8_t *)softwareRevision, (uint8_t *)softwareRevision,
(softwareRevision != NULL) ? strlen(softwareRevision) : 0, /* Min length */ (softwareRevision != nullptr) ? strlen(softwareRevision) : 0, /* Min length */
(softwareRevision != NULL) ? strlen(softwareRevision) : 0, /* Max length */ (softwareRevision != nullptr) ? strlen(softwareRevision) : 0, /* Max length */
GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ) GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ)
{ {
static bool serviceAdded = false; /* We only add the information service once. */ static bool serviceAdded = false; /* We only add the information service once. */
@ -103,7 +103,7 @@ public:
&firmwareRevisionStringCharacteristic, &firmwareRevisionStringCharacteristic,
&softwareRevisionStringCharacteristic}; &softwareRevisionStringCharacteristic};
GattService deviceInformationService(GattService::UUID_DEVICE_INFORMATION_SERVICE, charTable, GattService deviceInformationService(GattService::UUID_DEVICE_INFORMATION_SERVICE, charTable,
sizeof(charTable) / sizeof(GattCharacteristic *)); sizeof(charTable) / sizeof(charTable[0]));
ble.gattServer().addService(deviceInformationService); ble.gattServer().addService(deviceInformationService);
serviceAdded = true; serviceAdded = true;

View File

@ -58,7 +58,7 @@ public:
&pressureCharacteristic, &pressureCharacteristic,
&temperatureCharacteristic }; &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); ble.gattServer().addService(environmentalService);
serviceAdded = true; serviceAdded = true;
@ -97,9 +97,9 @@ public:
private: private:
BLE& ble; BLE& ble;
TemperatureType_t temperature; TemperatureType_t temperature{};
HumidityType_t humidity; HumidityType_t humidity{};
PressureType_t pressure; PressureType_t pressure{};
ReadOnlyGattCharacteristic<TemperatureType_t> temperatureCharacteristic; ReadOnlyGattCharacteristic<TemperatureType_t> temperatureCharacteristic;
ReadOnlyGattCharacteristic<HumidityType_t> humidityCharacteristic; ReadOnlyGattCharacteristic<HumidityType_t> humidityCharacteristic;

View File

@ -63,7 +63,7 @@ public:
tempLocation(GattCharacteristic::UUID_TEMPERATURE_TYPE_CHAR, &_location) { tempLocation(GattCharacteristic::UUID_TEMPERATURE_TYPE_CHAR, &_location) {
GattCharacteristic *hrmChars[] = {&tempMeasurement, &tempLocation, }; 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); ble.gattServer().addService(hrmService);
} }
@ -116,11 +116,11 @@ private:
memcpy(&bytes[OFFSET_OF_VALUE], &temp_ieee11073, sizeof(float)); memcpy(&bytes[OFFSET_OF_VALUE], &temp_ieee11073, sizeof(float));
} }
uint8_t *getPointer(void) { uint8_t *getPointer() {
return bytes; return bytes;
} }
const uint8_t *getPointer(void) const { const uint8_t *getPointer() const {
return bytes; return bytes;
} }
@ -130,7 +130,7 @@ private:
* @param temperature The temperature as a float. * @param temperature The temperature as a float.
* @return The temperature in 11073-20601 FLOAT-Type format. * @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 uint8_t exponent = 0xFE; //Exponent is -2
uint32_t mantissa = (uint32_t)(temperature * 100); uint32_t mantissa = (uint32_t)(temperature * 100);

View File

@ -161,7 +161,7 @@ protected:
/** /**
* Construct and add to the GattServer the heart rate service. * Construct and add to the GattServer the heart rate service.
*/ */
void setupService(void) { void setupService() {
GattCharacteristic *charTable[] = { GattCharacteristic *charTable[] = {
&hrmRate, &hrmRate,
&hrmLocation &hrmLocation
@ -169,7 +169,7 @@ protected:
GattService hrmService( GattService hrmService(
GattService::UUID_HEART_RATE_SERVICE, GattService::UUID_HEART_RATE_SERVICE,
charTable, charTable,
sizeof(charTable) / sizeof(GattCharacteristic*) sizeof(charTable) / sizeof(charTable[0])
); );
ble.gattServer().addService(hrmService); ble.gattServer().addService(hrmService);
@ -204,17 +204,17 @@ protected:
} }
} }
uint8_t *getPointer(void) uint8_t *getPointer()
{ {
return valueBytes; return valueBytes;
} }
const uint8_t *getPointer(void) const const uint8_t *getPointer() const
{ {
return valueBytes; return valueBytes;
} }
unsigned getNumValueBytes(void) const unsigned getNumValueBytes() const
{ {
if (valueBytes[FLAGS_BYTE_INDEX] & VALUE_FORMAT_FLAG) { if (valueBytes[FLAGS_BYTE_INDEX] & VALUE_FORMAT_FLAG) {
return 1 + sizeof(uint16_t); return 1 + sizeof(uint16_t);

View File

@ -59,7 +59,7 @@ public:
} }
GattCharacteristic *charTable[] = {&alertLevelChar}; 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); ble.gattServer().addService(linkLossService);
serviceAdded = true; serviceAdded = true;
@ -95,7 +95,7 @@ protected:
} }
} }
virtual void onDisconnectionComplete(const ble::DisconnectionCompleteEvent &) { void onDisconnectionComplete(const ble::DisconnectionCompleteEvent &) override {
if (alertLevel != NO_ALERT) { if (alertLevel != NO_ALERT) {
callback(alertLevel); callback(alertLevel);
} }

Some files were not shown because too many files have changed in this diff Show More