BLE: Clang tidy on public headers.

pull/13475/head
Vincent Coubard 2020-08-21 23:25:48 +01:00
parent 0baa92d70c
commit 7cbc0e38a4
35 changed files with 199 additions and 205 deletions

View File

@ -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.
* *
@ -193,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;
} }
@ -299,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);
@ -331,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.
@ -343,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.
@ -352,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
@ -465,11 +469,6 @@ private:
FunctionPointerWithContext<InitializationCompleteCallbackContext *> callback FunctionPointerWithContext<InitializationCompleteCallbackContext *> callback
); );
private:
// Prevent copy construction and copy assignment of BLE.
BLE(const BLE &) = delete;
BLE &operator=(const BLE &) = delete;
private: private:
ble::BLEInstanceBase &transport; /* The device-specific backend */ ble::BLEInstanceBase &transport; /* The device-specific backend */
OnEventsToProcessCallback_t whenEventsToProcess; OnEventsToProcessCallback_t whenEventsToProcess;

View File

@ -549,9 +549,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;
{
}
}; };
/** /**
@ -1316,7 +1314,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,
@ -1379,7 +1377,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
); );
@ -1401,7 +1399,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.

View File

@ -120,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;
{
}
}; };
/** /**
@ -235,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
@ -289,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)
); );
@ -368,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.
@ -376,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.
@ -627,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.
@ -668,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. */

View File

@ -126,9 +126,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;
{
}
}; };
/** /**
@ -224,7 +222,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.

View File

@ -19,7 +19,7 @@
#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 "ble/common/CallChainOfFunctionPointersWithContext.h" #include "ble/common/CallChainOfFunctionPointersWithContext.h"
#include "platform/Callback.h" #include "platform/Callback.h"
@ -421,9 +421,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 +455,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 +471,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 +486,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 +509,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 +868,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.

View File

@ -19,9 +19,9 @@
#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 "ble/common/SafeEnum.h" #include "ble/common/SafeEnum.h"
#include "platform/Span.h" #include "platform/Span.h"
@ -872,7 +872,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,7 +19,7 @@
#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 "ble/common/FunctionPointerWithContext.h" #include "ble/common/FunctionPointerWithContext.h"
#include "ble/common/SafeBool.h" #include "ble/common/SafeBool.h"
@ -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,7 +19,7 @@
#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 "ble/common/SafeBool.h" #include "ble/common/SafeBool.h"
/** /**
@ -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,9 +19,9 @@
#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/blecommon.h" #include "ble/common/blecommon.h"
@ -250,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) {
} }
@ -283,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;
} }
@ -294,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;
@ -310,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;
} }
@ -321,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

@ -17,8 +17,8 @@
#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 <BLETypes.h>
// FIXME: make this invisible! // FIXME: make this invisible!
#include "wsf_buf.h" #include "wsf_buf.h"
@ -74,7 +74,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,7 +19,7 @@
#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 "mbed.h"
#include "driver/CordioHCITransportDriver.h" #include "driver/CordioHCITransportDriver.h"
@ -47,22 +47,22 @@ 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();

View File

@ -19,9 +19,9 @@
#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/UUID.h" #include "ble/common/UUID.h"

View File

@ -19,7 +19,7 @@
#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/gap/AdvertisingDataTypes.h" #include "ble/gap/AdvertisingDataTypes.h"

View File

@ -68,7 +68,7 @@ public:
/** /**
* Construct a AdvertisingDataSimpleBuilder * Construct a AdvertisingDataSimpleBuilder
*/ */
AdvertisingDataSimpleBuilder() : _builder(_buffer) AdvertisingDataSimpleBuilder() : _builder(_buffer), _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

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

@ -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,7 +19,7 @@
#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/blecommon.h" #include "ble/common/blecommon.h"
#include "ble/common/BLETypes.h" #include "ble/common/BLETypes.h"

View File

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

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

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

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

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

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

@ -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);
} }

View File

@ -478,7 +478,7 @@ ble_error_t Gap::getAddress(
ble_error_t Gap::getRandomAddressType( ble_error_t Gap::getRandomAddressType(
const ble::address_t address, ble::address_t address,
ble::random_address_type_t *addressType ble::random_address_type_t *addressType
) )
{ {