mirror of https://github.com/ARMmbed/mbed-os.git
Merge pull request #13475 from pan-/ble-remove-user-facing-abstraction
Ble remove user facing abstractionpull/13579/head
commit
c99ff74928
|
|
@ -19,20 +19,20 @@
|
|||
#ifndef MBED_BLE_H__
|
||||
#define MBED_BLE_H__
|
||||
|
||||
#include "FunctionPointerWithContext.h"
|
||||
#include "platform/mbed_error.h"
|
||||
#include "platform/mbed_assert.h"
|
||||
#include "platform/mbed_toolchain.h"
|
||||
|
||||
#include "ble/common/ble/BLERoles.h"
|
||||
#include "ble/common/ble/BLETypes.h"
|
||||
#include "ble/common/ble/blecommon.h"
|
||||
|
||||
#include "ble/Gap.h"
|
||||
#include "ble/GattClient.h"
|
||||
#include "ble/GattServer.h"
|
||||
#include "ble/SecurityManager.h"
|
||||
|
||||
#include "ble/common/BLERoles.h"
|
||||
#include "ble/common/BLETypes.h"
|
||||
#include "ble/common/blecommon.h"
|
||||
#include "ble/common/FunctionPointerWithContext.h"
|
||||
|
||||
/* Forward declaration for the implementation class */
|
||||
|
||||
namespace ble {
|
||||
|
|
@ -154,6 +154,10 @@ public:
|
|||
*/
|
||||
static const InstanceID_t NUM_INSTANCES = 1;
|
||||
|
||||
// Prevent copy construction and copy assignment of BLE.
|
||||
BLE(const BLE &) = delete;
|
||||
BLE &operator=(const BLE &) = delete;
|
||||
|
||||
/**
|
||||
* Get a reference to the BLE singleton.
|
||||
*
|
||||
|
|
@ -164,16 +168,6 @@ public:
|
|||
*/
|
||||
static BLE &Instance();
|
||||
|
||||
/**
|
||||
* Constructor for a handle to a BLE instance (the BLE stack). BLE handles
|
||||
* are thin wrappers around a transport object (that is, ptr. to
|
||||
* ble::BLEInstanceBase).
|
||||
*
|
||||
* @param[in] transport Ble transport used for the BLE instance.
|
||||
* @note Cordio supports only one instance.
|
||||
*/
|
||||
BLE(ble::BLEInstanceBase &transport);
|
||||
|
||||
/**
|
||||
* Get a reference to the BLE singleton corresponding to a given interface.
|
||||
*
|
||||
|
|
@ -203,7 +197,7 @@ public:
|
|||
*/
|
||||
MBED_DEPRECATED_SINCE("mbed-os-6.3.0", "BLE singleton supports one instance. You may create multiple"
|
||||
"instances by using the constructor.")
|
||||
InstanceID_t getInstanceID(void) const
|
||||
InstanceID_t getInstanceID() const
|
||||
{
|
||||
return DEFAULT_INSTANCE;
|
||||
}
|
||||
|
|
@ -309,7 +303,7 @@ public:
|
|||
* @attention This should be called before using anything else in the BLE
|
||||
* API.
|
||||
*/
|
||||
ble_error_t init(InitializationCompleteCallback_t completion_cb = NULL)
|
||||
ble_error_t init(InitializationCompleteCallback_t completion_cb = nullptr)
|
||||
{
|
||||
FunctionPointerWithContext<InitializationCompleteCallbackContext *> callback(completion_cb);
|
||||
return initImplementation(callback);
|
||||
|
|
@ -341,7 +335,7 @@ public:
|
|||
* @note The application should set up a callback to signal completion of
|
||||
* initialization when using init().
|
||||
*/
|
||||
bool hasInitialized(void) const;
|
||||
bool hasInitialized() const;
|
||||
|
||||
/**
|
||||
* Shut down the underlying stack, and reset state of this BLE instance.
|
||||
|
|
@ -353,7 +347,7 @@ public:
|
|||
* GAP state. This API offers a way to repopulate the GATT database with new
|
||||
* services and characteristics.
|
||||
*/
|
||||
ble_error_t shutdown(void);
|
||||
ble_error_t shutdown();
|
||||
|
||||
/**
|
||||
* This call allows the application to get the BLE stack version information.
|
||||
|
|
@ -362,7 +356,7 @@ public:
|
|||
*
|
||||
* @note The BLE API owns the string returned.
|
||||
*/
|
||||
const char *getVersion(void);
|
||||
const char *getVersion();
|
||||
|
||||
/**
|
||||
* Accessor to Gap. All Gap-related functionality requires going through
|
||||
|
|
@ -455,6 +449,16 @@ public:
|
|||
private:
|
||||
friend class ble::BLEInstanceBase;
|
||||
|
||||
/**
|
||||
* Constructor for a handle to a BLE instance (the BLE stack). BLE handles
|
||||
* are thin wrappers around a transport object (that is, ptr. to
|
||||
* ble::BLEInstanceBase).
|
||||
*
|
||||
* @param[in] transport Ble transport used for the BLE instance.
|
||||
* @note Cordio supports only one instance.
|
||||
*/
|
||||
BLE(ble::BLEInstanceBase &transport);
|
||||
|
||||
/**
|
||||
* Implementation of init() [internal to BLE_API].
|
||||
*
|
||||
|
|
@ -465,11 +469,6 @@ private:
|
|||
FunctionPointerWithContext<InitializationCompleteCallbackContext *> callback
|
||||
);
|
||||
|
||||
private:
|
||||
// Prevent copy construction and copy assignment of BLE.
|
||||
BLE(const BLE &);
|
||||
BLE &operator=(const BLE &);
|
||||
|
||||
private:
|
||||
ble::BLEInstanceBase &transport; /* The device-specific backend */
|
||||
OnEventsToProcessCallback_t whenEventsToProcess;
|
||||
|
|
@ -480,7 +479,7 @@ private:
|
|||
|
||||
using ble::BLE;
|
||||
/**
|
||||
* @namespace ble Entry namespace for all %BLE API definitions.
|
||||
* @namespace ble Entry namespace for all BLE API definitions.
|
||||
*/
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -19,28 +19,27 @@
|
|||
#ifndef BLE_GAP_GAP_H
|
||||
#define BLE_GAP_GAP_H
|
||||
|
||||
#include "CallChainOfFunctionPointersWithContext.h"
|
||||
#include "ble/common/CallChainOfFunctionPointersWithContext.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "drivers/LowPowerTimeout.h"
|
||||
#include "drivers/LowPowerTicker.h"
|
||||
#include "platform/mbed_error.h"
|
||||
|
||||
#include "ble/common/ble/BLERoles.h"
|
||||
#include "ble/common/ble/BLETypes.h"
|
||||
#include "ble/common/ble/gap/AdvertisingDataBuilder.h"
|
||||
#include "ble/common/ble/gap/AdvertisingDataParser.h"
|
||||
#include "ble/common/ble/gap/AdvertisingDataSimpleBuilder.h"
|
||||
#include "ble/common/ble/gap/AdvertisingDataTypes.h"
|
||||
#include "ble/common/ble/gap/AdvertisingParameters.h"
|
||||
#include "ble/common/ble/gap/ConnectionParameters.h"
|
||||
#include "ble/common/ble/gap/Events.h"
|
||||
#include "ble/common/ble/gap/ScanParameters.h"
|
||||
#include "ble/common/ble/gap/Types.h"
|
||||
#include "ble/common/BLERoles.h"
|
||||
#include "ble/common/BLETypes.h"
|
||||
#include "ble/gap/AdvertisingDataBuilder.h"
|
||||
#include "ble/gap/AdvertisingDataParser.h"
|
||||
#include "ble/gap/AdvertisingDataSimpleBuilder.h"
|
||||
#include "ble/gap/AdvertisingDataTypes.h"
|
||||
#include "ble/gap/AdvertisingParameters.h"
|
||||
#include "ble/gap/ConnectionParameters.h"
|
||||
#include "ble/gap/ScanParameters.h"
|
||||
#include "ble/gap/Events.h"
|
||||
#include "ble/gap/Types.h"
|
||||
|
||||
namespace ble {
|
||||
class PalGenericAccessService;
|
||||
|
||||
#if !defined(DOXYGEN_ONLY)
|
||||
namespace impl {
|
||||
class Gap;
|
||||
}
|
||||
#endif // !defined(DOXYGEN_ONLY)
|
||||
|
||||
/**
|
||||
* @addtogroup ble
|
||||
|
|
@ -280,9 +279,6 @@ class PalGenericAccessService;
|
|||
* PHY and of any changes to PHYs which may be triggered autonomously by the
|
||||
* controller or by the peer.
|
||||
*/
|
||||
#if !defined(DOXYGEN_ONLY)
|
||||
namespace interface {
|
||||
#endif // !defined(DOXYGEN_ONLY)
|
||||
class Gap {
|
||||
public:
|
||||
/**
|
||||
|
|
@ -547,9 +543,7 @@ public:
|
|||
* Prevent polymorphic deletion and avoid unnecessary virtual destructor
|
||||
* as the Gap class will never delete the instance it contains.
|
||||
*/
|
||||
~EventHandler()
|
||||
{
|
||||
}
|
||||
~EventHandler() = default;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -1314,7 +1308,7 @@ public:
|
|||
*
|
||||
* @return Maximum size of the whitelist.
|
||||
*/
|
||||
uint8_t getMaxWhitelistSize(void) const;
|
||||
uint8_t getMaxWhitelistSize() const;
|
||||
|
||||
/**
|
||||
* Get the Link Layer to use the internal whitelist when scanning,
|
||||
|
|
@ -1377,7 +1371,7 @@ public:
|
|||
* the address in input was not identifiable as a random address.
|
||||
*/
|
||||
static ble_error_t getRandomAddressType(
|
||||
const ble::address_t address,
|
||||
ble::address_t address,
|
||||
ble::random_address_type_t *addressType
|
||||
);
|
||||
|
||||
|
|
@ -1399,7 +1393,7 @@ public:
|
|||
* @note Currently, a call to reset() does not reset the advertising and
|
||||
* scan parameters to default values.
|
||||
*/
|
||||
ble_error_t reset(void);
|
||||
ble_error_t reset();
|
||||
|
||||
/**
|
||||
* Register a Gap shutdown event handler.
|
||||
|
|
@ -1421,7 +1415,9 @@ public:
|
|||
* @param[in] memberPtr Shutdown event handler to register.
|
||||
*/
|
||||
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.
|
||||
|
|
@ -1435,6 +1431,17 @@ public:
|
|||
GapShutdownCallbackChain_t &onShutdown();
|
||||
|
||||
#if !defined(DOXYGEN_ONLY)
|
||||
/*
|
||||
* Constructor from the private implementation.
|
||||
*/
|
||||
Gap(impl::Gap* impl) : impl(impl) {}
|
||||
|
||||
/*
|
||||
* Restrict copy and move.
|
||||
*/
|
||||
Gap(const Gap&) = delete;
|
||||
Gap& operator=(const Gap&) = delete;
|
||||
|
||||
/*
|
||||
* API reserved for the controller driver to set the random static address.
|
||||
* Setting a new random static address while the controller is operating is
|
||||
|
|
@ -1442,6 +1449,9 @@ public:
|
|||
*/
|
||||
ble_error_t setRandomStaticAddress(const ble::address_t& address);
|
||||
#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
|
||||
|
||||
/* This includes the concrete class implementation, to provide a an alternative API implementation
|
||||
* disable ble-api-implementation and place your header in a path with the same structure */
|
||||
#include "ble/internal/GapImpl.h"
|
||||
|
||||
/** @deprecated Use the namespaced ble::Gap instead of the global Gap. */
|
||||
using ble::Gap;
|
||||
|
||||
|
|
|
|||
|
|
@ -21,19 +21,24 @@
|
|||
|
||||
#define MBED_GATT_CLIENT_H__
|
||||
|
||||
#include "CallChainOfFunctionPointersWithContext.h"
|
||||
#include <algorithm>
|
||||
#include "ble/common/CallChainOfFunctionPointersWithContext.h"
|
||||
#include "ble/common/blecommon.h"
|
||||
|
||||
#include "ble/common/ble/blecommon.h"
|
||||
#include "ble/common/ble/GattAttribute.h"
|
||||
#include "ble/common/ble/ServiceDiscovery.h"
|
||||
#include "ble/common/ble/CharacteristicDescriptorDiscovery.h"
|
||||
#include "ble/common/ble/GattCallbackParamTypes.h"
|
||||
#include "ble/common/ble/DiscoveredService.h"
|
||||
#include "ble/common/ble/DiscoveredCharacteristic.h"
|
||||
#include "ble/gatt/GattAttribute.h"
|
||||
#include "ble/gatt/ServiceDiscovery.h"
|
||||
#include "ble/gatt/CharacteristicDescriptorDiscovery.h"
|
||||
#include "ble/gatt/GattCallbackParamTypes.h"
|
||||
#include "ble/gatt/DiscoveredService.h"
|
||||
#include "ble/gatt/DiscoveredCharacteristic.h"
|
||||
|
||||
namespace ble {
|
||||
|
||||
#if !defined(DOXYGEN_ONLY)
|
||||
namespace impl {
|
||||
class GattClient;
|
||||
}
|
||||
#endif // !defined(DOXYGEN_ONLY)
|
||||
|
||||
/**
|
||||
* @addtogroup ble
|
||||
* @{
|
||||
|
|
@ -89,9 +94,6 @@ namespace ble {
|
|||
* indicate properties are set. The client discovers that descriptor
|
||||
* if it intends to register to server initiated events.
|
||||
*/
|
||||
#if !defined(DOXYGEN_ONLY)
|
||||
namespace interface {
|
||||
#endif // !defined(DOXYGEN_ONLY)
|
||||
class GattClient {
|
||||
public:
|
||||
/**
|
||||
|
|
@ -118,9 +120,7 @@ public:
|
|||
* Prevent polymorphic deletion and avoid unnecessary virtual destructor
|
||||
* as the GattClient class will never delete the instance it contains.
|
||||
*/
|
||||
~EventHandler()
|
||||
{
|
||||
}
|
||||
~EventHandler() = default;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -233,7 +233,7 @@ public:
|
|||
* specific subclass.
|
||||
*/
|
||||
|
||||
~GattClient() { }
|
||||
~GattClient() = default;
|
||||
|
||||
/**
|
||||
* Launch the service and characteristic discovery procedure of a GATT server
|
||||
|
|
@ -287,8 +287,8 @@ public:
|
|||
*/
|
||||
ble_error_t launchServiceDiscovery(
|
||||
ble::connection_handle_t connectionHandle,
|
||||
ServiceDiscovery::ServiceCallback_t sc = NULL,
|
||||
ServiceDiscovery::CharacteristicCallback_t cc = NULL,
|
||||
ServiceDiscovery::ServiceCallback_t sc = nullptr,
|
||||
ServiceDiscovery::CharacteristicCallback_t cc = nullptr,
|
||||
const UUID &matchingServiceUUID = UUID::ShortUUIDBytes_t(BLE_UUID_UNKNOWN),
|
||||
const UUID &matchingCharacteristicUUIDIn = UUID::ShortUUIDBytes_t(BLE_UUID_UNKNOWN)
|
||||
);
|
||||
|
|
@ -366,7 +366,7 @@ public:
|
|||
*
|
||||
* @return true if service discovery procedure is active and false otherwise.
|
||||
*/
|
||||
bool isServiceDiscoveryActive(void) const;
|
||||
bool isServiceDiscoveryActive() const;
|
||||
|
||||
/**
|
||||
* Terminate all ongoing service discovery procedures.
|
||||
|
|
@ -374,7 +374,7 @@ public:
|
|||
* It results in an invocation of the service discovery termination handler
|
||||
* registered with onServiceDiscoveryTermination().
|
||||
*/
|
||||
void terminateServiceDiscovery(void);
|
||||
void terminateServiceDiscovery();
|
||||
|
||||
/**
|
||||
* Initiate the read procedure of an attribute handle.
|
||||
|
|
@ -625,7 +625,10 @@ public:
|
|||
* available.
|
||||
*/
|
||||
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.
|
||||
|
|
@ -649,7 +652,6 @@ public:
|
|||
*/
|
||||
HVXCallbackChain_t& onHVX();
|
||||
|
||||
|
||||
/**
|
||||
* Reset the state of the GattClient instance.
|
||||
*
|
||||
|
|
@ -667,7 +669,7 @@ public:
|
|||
*
|
||||
* @return BLE_ERROR_NONE on success.
|
||||
*/
|
||||
ble_error_t reset(void);
|
||||
ble_error_t reset();
|
||||
|
||||
/* Entry points for the underlying stack to report events back to the user. */
|
||||
|
||||
|
|
@ -703,6 +705,15 @@ public:
|
|||
* registered handlers.
|
||||
*/
|
||||
void processHVXEvent(const GattHVXCallbackParams *params);
|
||||
|
||||
#if !defined(DOXYGEN_ONLY)
|
||||
GattClient(impl::GattClient* impl) : impl(impl) { }
|
||||
GattClient(const GattClient&) = delete;
|
||||
GattClient& operator=(const GattClient&) = delete;
|
||||
#endif // !defined(DOXYGEN_ONLY)
|
||||
|
||||
private:
|
||||
impl::GattClient *impl;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -711,15 +722,8 @@ public:
|
|||
* @}
|
||||
*/
|
||||
|
||||
#if !defined(DOXYGEN_ONLY)
|
||||
} // namespace interface
|
||||
#endif // !defined(DOXYGEN_ONLY)
|
||||
} // namespace ble
|
||||
|
||||
/* This includes the concrete class implementation, to provide a an alternative API implementation
|
||||
* disable ble-api-implementation and place your header in a path with the same structure */
|
||||
#include "ble/internal/GattClientImpl.h"
|
||||
|
||||
/** @deprecated Use the namespaced ble::GattClient instead of the global GattClient. */
|
||||
using ble::GattClient;
|
||||
|
||||
|
|
|
|||
|
|
@ -20,19 +20,22 @@
|
|||
#ifndef MBED_GATT_SERVER_H__
|
||||
#define MBED_GATT_SERVER_H__
|
||||
|
||||
#include "CallChainOfFunctionPointersWithContext.h"
|
||||
#include "ble/common/CallChainOfFunctionPointersWithContext.h"
|
||||
#include "ble/common/blecommon.h"
|
||||
|
||||
#include "ble/common/ble/GattService.h"
|
||||
#include "ble/common/ble/GattAttribute.h"
|
||||
#include "ble/common/ble/GattServerEvents.h"
|
||||
#include "ble/common/ble/GattCallbackParamTypes.h"
|
||||
|
||||
#include "ble/common/ble/blecommon.h"
|
||||
#include "ble/Gap.h"
|
||||
#include "SecurityManager.h"
|
||||
#include "ble/gatt/GattService.h"
|
||||
#include "ble/gatt/GattAttribute.h"
|
||||
#include "ble/gatt/GattCallbackParamTypes.h"
|
||||
|
||||
namespace ble {
|
||||
|
||||
#if !defined(DOXYGEN_ONLY)
|
||||
namespace impl {
|
||||
class GattServer;
|
||||
}
|
||||
#endif // !defined(DOXYGEN_ONLY)
|
||||
|
||||
|
||||
/**
|
||||
* @addtogroup ble
|
||||
* @{
|
||||
|
|
@ -94,9 +97,6 @@ namespace ble {
|
|||
* Characteristic Value Notification and Characteristic Value Indication when
|
||||
* the nature of the server initiated is not relevant.
|
||||
*/
|
||||
#if !defined(DOXYGEN_ONLY)
|
||||
namespace interface {
|
||||
#endif // !defined(DOXYGEN_ONLY)
|
||||
class GattServer {
|
||||
public:
|
||||
/**
|
||||
|
|
@ -123,9 +123,7 @@ public:
|
|||
* Prevent polymorphic deletion and avoid unnecessary virtual destructor
|
||||
* as the GattServer class will never delete the instance it contains.
|
||||
*/
|
||||
~EventHandler()
|
||||
{
|
||||
}
|
||||
~EventHandler() = default;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -221,7 +219,7 @@ public:
|
|||
*
|
||||
* @return BLE_ERROR_NONE on success.
|
||||
*/
|
||||
ble_error_t reset(void);
|
||||
ble_error_t reset();
|
||||
|
||||
/**
|
||||
* Add a service declaration to the local attribute server table.
|
||||
|
|
@ -415,7 +413,10 @@ public:
|
|||
* function.
|
||||
*/
|
||||
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.
|
||||
|
|
@ -448,7 +449,10 @@ public:
|
|||
void onDataWritten(
|
||||
T *objPtr,
|
||||
void (T::*memberPtr)(const GattWriteCallbackParams *context)
|
||||
);
|
||||
)
|
||||
{
|
||||
onDataWritten({objPtr, memberPtr});
|
||||
}
|
||||
|
||||
/**
|
||||
* Access the callchain of data written event handlers.
|
||||
|
|
@ -495,7 +499,10 @@ public:
|
|||
ble_error_t onDataRead(
|
||||
T *objPtr,
|
||||
void (T::*memberPtr)(const GattReadCallbackParams *context)
|
||||
);
|
||||
)
|
||||
{
|
||||
return onDataRead({objPtr, memberPtr});
|
||||
}
|
||||
|
||||
/**
|
||||
* Access the callchain of data read event handlers.
|
||||
|
|
@ -537,7 +544,10 @@ public:
|
|||
* function.
|
||||
*/
|
||||
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.
|
||||
|
|
@ -578,72 +588,14 @@ public:
|
|||
*/
|
||||
void onConfirmationReceived(EventCallback_t callback);
|
||||
|
||||
/* Entry points for the underlying stack to report events back to the user. */
|
||||
protected:
|
||||
/**
|
||||
* Helper function that notifies all registered handlers of an occurrence
|
||||
* of a data written event.
|
||||
*
|
||||
* @attention Vendor implementation must invoke this function after one of
|
||||
* the GattServer attributes has been written.
|
||||
*
|
||||
* @param[in] params The data written parameters passed to the registered
|
||||
* handlers.
|
||||
*/
|
||||
void handleDataWrittenEvent(const GattWriteCallbackParams *params);
|
||||
#if !defined(DOXYGEN_ONLY)
|
||||
GattServer(impl::GattServer* impl) : impl(impl) {}
|
||||
GattServer(const GattServer&) = delete;
|
||||
GattServer& operator=(const GattServer&) = delete;
|
||||
#endif // !defined(DOXYGEN_ONLY)
|
||||
|
||||
/**
|
||||
* Helper function that notifies all registered handlers of an occurrence
|
||||
* of a data read event.
|
||||
*
|
||||
* @attention Vendor implementation must invoke this function after one of
|
||||
* the GattServer attributes has been read.
|
||||
*
|
||||
* @param[in] params The data read parameters passed to the registered
|
||||
* handlers.
|
||||
*/
|
||||
void handleDataReadEvent(const GattReadCallbackParams *params);
|
||||
|
||||
/**
|
||||
* Helper function that notifies the registered handler of an occurrence
|
||||
* of updates enabled, updates disabled or confirmation received events.
|
||||
*
|
||||
* @attention Vendor implementation must invoke this function when a client
|
||||
* subscribes to characteristic updates, unsubscribes from characteristic
|
||||
* updates or a notification confirmation has been received.
|
||||
*
|
||||
* @param[in] type The type of event that occurred.
|
||||
* @param[in] attributeHandle The handle of the attribute concerned by the
|
||||
* event.
|
||||
*/
|
||||
void handleEvent(
|
||||
GattServerEvents::gattEvent_e type,
|
||||
GattAttribute::Handle_t attributeHandle
|
||||
);
|
||||
|
||||
/**
|
||||
* Helper function that notifies all registered handlers of an occurrence
|
||||
* of a data sent event.
|
||||
*
|
||||
* @attention Vendor implementation must invoke this function after the
|
||||
* emission of a notification or an indication.
|
||||
*
|
||||
* @param[in] count Number of packets sent.
|
||||
*/
|
||||
void handleDataSentEvent(unsigned count);
|
||||
|
||||
/**
|
||||
* Get preferred connection paramters.
|
||||
*
|
||||
*/
|
||||
Gap::PreferredConnectionParams_t getPreferredConnectionParams();
|
||||
|
||||
/**
|
||||
* Set preferred connection parameters.
|
||||
*
|
||||
* @param[in] params Preferred connection parameter values to set.
|
||||
*/
|
||||
void setPreferredConnectionParams(const Gap::PreferredConnectionParams_t& params);
|
||||
private:
|
||||
impl::GattServer *impl;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -652,15 +604,8 @@ protected:
|
|||
* @}
|
||||
*/
|
||||
|
||||
#if !defined(DOXYGEN_ONLY)
|
||||
} // namespace interface
|
||||
#endif // !defined(DOXYGEN_ONLY)
|
||||
} // ble
|
||||
|
||||
/* This includes the concrete class implementation, to provide a an alternative API implementation
|
||||
* disable ble-api-implementation and place your header in a path with the same structure */
|
||||
#include "ble/internal/GattServerImpl.h"
|
||||
|
||||
/** @deprecated Use the namespaced ble::GattServer instead of the global GattServer. */
|
||||
using ble::GattServer;
|
||||
|
||||
|
|
|
|||
|
|
@ -19,20 +19,20 @@
|
|||
#ifndef BLE_SECURITY_MANAGER_H_
|
||||
#define BLE_SECURITY_MANAGER_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include "CallChainOfFunctionPointersWithContext.h"
|
||||
#include "platform/Callback.h"
|
||||
#include <cstdint>
|
||||
|
||||
#include "ble/common/ble/BLETypes.h"
|
||||
#include "ble/common/ble/blecommon.h"
|
||||
|
||||
#include "ble/common/ble/BLETypes.h"
|
||||
#include "ble/internal/SecurityDb.h"
|
||||
#include "ble/internal/PalConnectionMonitor.h"
|
||||
#include "ble/internal/PalSecurityManager.h"
|
||||
#include "ble/common/BLETypes.h"
|
||||
#include "ble/common/blecommon.h"
|
||||
#include "ble/common/CallChainOfFunctionPointersWithContext.h"
|
||||
|
||||
namespace ble {
|
||||
|
||||
#if !defined(DOXYGEN_ONLY)
|
||||
namespace impl {
|
||||
class SecurityManager;
|
||||
}
|
||||
#endif // !defined(DOXYGEN_ONLY)
|
||||
|
||||
/**
|
||||
* Overview
|
||||
*
|
||||
|
|
@ -186,9 +186,6 @@ namespace ble {
|
|||
* @endverbatim
|
||||
*
|
||||
*/
|
||||
#if !defined(DOXYGEN_ONLY)
|
||||
namespace interface {
|
||||
#endif // !defined(DOXYGEN_ONLY)
|
||||
class SecurityManager
|
||||
{
|
||||
public:
|
||||
|
|
@ -421,9 +418,7 @@ public:
|
|||
* Prevent polymorphic deletion and avoid unnecessary virtual destructor
|
||||
* as the SecurityManager class will never delete the instance it contains.
|
||||
*/
|
||||
~EventHandler()
|
||||
{
|
||||
}
|
||||
~EventHandler() = default;
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
@ -457,9 +452,9 @@ public:
|
|||
bool enableBonding = true,
|
||||
bool requireMITM = true,
|
||||
SecurityIOCapabilities_t iocaps = IO_CAPS_NONE,
|
||||
const Passkey_t passkey = NULL,
|
||||
const Passkey_t passkey = nullptr,
|
||||
bool signing = true,
|
||||
const char *dbFilepath = NULL
|
||||
const char *dbFilepath = nullptr
|
||||
);
|
||||
|
||||
/**
|
||||
|
|
@ -473,7 +468,7 @@ public:
|
|||
*
|
||||
* @return BLE_ERROR_NONE on success.
|
||||
*/
|
||||
ble_error_t setDatabaseFilepath(const char *dbFilepath = NULL);
|
||||
ble_error_t setDatabaseFilepath(const char *dbFilepath = nullptr);
|
||||
|
||||
/**
|
||||
* Notify all registered onShutdown callbacks that the SecurityManager is
|
||||
|
|
@ -488,7 +483,7 @@ public:
|
|||
*
|
||||
* @return BLE_ERROR_NONE on success.
|
||||
*/
|
||||
ble_error_t reset(void);
|
||||
ble_error_t reset();
|
||||
|
||||
/**
|
||||
* Normally all bonding information is lost when device is reset, this requests that the stack
|
||||
|
|
@ -511,7 +506,7 @@ public:
|
|||
* @retval BLE_ERROR_INVALID_STATE If the API is called without module initialization or
|
||||
* application registration.
|
||||
*/
|
||||
ble_error_t purgeAllBondingState(void);
|
||||
ble_error_t purgeAllBondingState();
|
||||
|
||||
/**
|
||||
* Create a list of addresses from all peers in the bond table and generate
|
||||
|
|
@ -870,7 +865,10 @@ public:
|
|||
void onShutdown(const SecurityManagerShutdownCallback_t& callback);
|
||||
|
||||
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.
|
||||
|
|
@ -894,18 +892,18 @@ public:
|
|||
/** For backwards compatibility. This enum is now in BLETypes.h
|
||||
* @deprecated use the enum in ble namespace */
|
||||
typedef ble::Keypress_t Keypress_t;
|
||||
|
||||
SecurityManager(impl::SecurityManager* impl) : impl(impl) {}
|
||||
SecurityManager(const SecurityManager&) = delete;
|
||||
SecurityManager& operator=(const SecurityManager&) = delete;
|
||||
#endif // !defined(DOXYGEN_ONLY)
|
||||
|
||||
private:
|
||||
impl::SecurityManager *impl;
|
||||
};
|
||||
|
||||
#if !defined(DOXYGEN_ONLY)
|
||||
} // namespace interface
|
||||
#endif // !defined(DOXYGEN_ONLY)
|
||||
} // ble
|
||||
|
||||
/* This includes the concrete class implementation, to provide a an alternative API implementation
|
||||
* disable ble-api-implementation and place your header in a path with the same structure */
|
||||
#include "ble/internal/SecurityManagerImpl.h"
|
||||
|
||||
/** @deprecated Use the namespaced ble::SecurityManager instead of the global SecurityManager. */
|
||||
using ble::SecurityManager;
|
||||
|
||||
|
|
|
|||
|
|
@ -19,13 +19,14 @@
|
|||
#ifndef BLE_TYPES_H_
|
||||
#define BLE_TYPES_H_
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include "SafeEnum.h"
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
|
||||
#include "platform/Span.h"
|
||||
|
||||
#include "ble/common/ble/gap/Types.h"
|
||||
#include "ble/common/SafeEnum.h"
|
||||
#include "ble/gap/Types.h"
|
||||
|
||||
/**
|
||||
* @addtogroup ble
|
||||
|
|
@ -872,7 +873,7 @@ struct whitelist_t {
|
|||
* @post type is equal to PUBLIC and the address value is equal to
|
||||
* 00:00:00:00:00:00
|
||||
*/
|
||||
entry_t(void) : type(), address() { }
|
||||
entry_t() : type(), address() { }
|
||||
|
||||
/**
|
||||
* Type of the peer address.
|
||||
|
|
@ -19,7 +19,7 @@
|
|||
#ifndef BLE_COMMON_BOUNDED_H_
|
||||
#define BLE_COMMON_BOUNDED_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include <cstdint>
|
||||
|
||||
namespace ble {
|
||||
|
||||
|
|
@ -47,9 +47,9 @@ struct Bounded {
|
|||
Bounded(Rep v) : _value(v)
|
||||
{
|
||||
if (v < Min) {
|
||||
_value = v;
|
||||
_value = Min;
|
||||
} else if (v > Max) {
|
||||
_value = v;
|
||||
_value = Max;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -19,9 +19,9 @@
|
|||
#ifndef MBED_CALLCHAIN_OF_FUNCTION_POINTERS_WITH_CONTEXT_H
|
||||
#define MBED_CALLCHAIN_OF_FUNCTION_POINTERS_WITH_CONTEXT_H
|
||||
|
||||
#include <string.h>
|
||||
#include "FunctionPointerWithContext.h"
|
||||
#include "SafeBool.h"
|
||||
#include <cstring>
|
||||
#include "ble/common/FunctionPointerWithContext.h"
|
||||
#include "ble/common/SafeBool.h"
|
||||
|
||||
/**
|
||||
* @addtogroup ble
|
||||
|
|
@ -96,6 +96,14 @@ public:
|
|||
*/
|
||||
CallChainOfFunctionPointersWithContext() : chainHead(NULL) { }
|
||||
|
||||
/* Disallow copy constructor and assignment operators. */
|
||||
CallChainOfFunctionPointersWithContext(
|
||||
const CallChainOfFunctionPointersWithContext&
|
||||
) = delete;
|
||||
CallChainOfFunctionPointersWithContext &operator=(
|
||||
const CallChainOfFunctionPointersWithContext&
|
||||
) = delete;
|
||||
|
||||
/**
|
||||
* Destruction of the callchain.
|
||||
*/
|
||||
|
|
@ -186,7 +194,7 @@ public:
|
|||
/**
|
||||
* Remove all functions registered in the chain.
|
||||
*/
|
||||
void clear(void)
|
||||
void clear()
|
||||
{
|
||||
pFunctionPointerWithContext_t fptr = chainHead;
|
||||
while (fptr) {
|
||||
|
|
@ -203,7 +211,7 @@ public:
|
|||
*
|
||||
* @return true if the callchain is not empty and false otherwise.
|
||||
*/
|
||||
bool hasCallbacksAttached(void) const
|
||||
bool hasCallbacksAttached() const
|
||||
{
|
||||
return (chainHead != NULL);
|
||||
}
|
||||
|
|
@ -324,16 +332,6 @@ private:
|
|||
* const from an external standpoint.
|
||||
*/
|
||||
mutable pFunctionPointerWithContext_t currentCalled;
|
||||
|
||||
|
||||
/* Disallow copy constructor and assignment operators. */
|
||||
private:
|
||||
CallChainOfFunctionPointersWithContext(
|
||||
const CallChainOfFunctionPointersWithContext&
|
||||
);
|
||||
CallChainOfFunctionPointersWithContext &operator=(
|
||||
const CallChainOfFunctionPointersWithContext&
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -19,8 +19,8 @@
|
|||
#ifndef BLE_COMMON_DURATION_H_
|
||||
#define BLE_COMMON_DURATION_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
#include "platform/mbed_assert.h"
|
||||
#include "platform/mbed_chrono.h"
|
||||
|
||||
|
|
@ -155,7 +155,7 @@ struct Duration {
|
|||
* @param other_ms The Duration in millisecond to convert.
|
||||
*/
|
||||
template<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))
|
||||
{
|
||||
}
|
||||
|
|
@ -19,8 +19,8 @@
|
|||
#ifndef MBED_FUNCTIONPOINTER_WITH_CONTEXT_H
|
||||
#define MBED_FUNCTIONPOINTER_WITH_CONTEXT_H
|
||||
|
||||
#include <string.h>
|
||||
#include "SafeBool.h"
|
||||
#include <cstring>
|
||||
#include "ble/common/SafeBool.h"
|
||||
|
||||
/**
|
||||
* @file
|
||||
|
|
@ -106,6 +106,10 @@ public:
|
|||
*/
|
||||
FunctionPointerWithContext &operator=(const FunctionPointerWithContext &that)
|
||||
{
|
||||
if (&that == this) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
_memberFunctionAndPointer = that._memberFunctionAndPointer;
|
||||
_caller = that._caller;
|
||||
_next = NULL;
|
||||
|
|
@ -222,7 +226,7 @@ public:
|
|||
* @return A pointer to the next FunctionPointerWithContext instance in the
|
||||
* chain.
|
||||
*/
|
||||
pFunctionPointerWithContext_t getNext(void) const
|
||||
pFunctionPointerWithContext_t getNext() const
|
||||
{
|
||||
return _next;
|
||||
}
|
||||
|
|
@ -19,8 +19,8 @@
|
|||
#ifndef BLE_SAFE_ENUM_H_
|
||||
#define BLE_SAFE_ENUM_H_
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
namespace ble {
|
||||
|
||||
|
|
@ -19,12 +19,12 @@
|
|||
#ifndef MBED_UUID_H__
|
||||
#define MBED_UUID_H__
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <algorithm>
|
||||
|
||||
#include "ble/common/ble/blecommon.h"
|
||||
#include "ble/common/blecommon.h"
|
||||
|
||||
/**
|
||||
* @file
|
||||
|
|
@ -235,6 +235,13 @@ public:
|
|||
memcpy(baseUUID, source.baseUUID, LENGTH_OF_LONG_UUID);
|
||||
}
|
||||
|
||||
/**
|
||||
* UUID copy assignment.
|
||||
*
|
||||
* @param[in] source The UUID to copy.
|
||||
*/
|
||||
UUID& operator=(const UUID &source) = default;
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
*
|
||||
|
|
@ -243,7 +250,7 @@ public:
|
|||
* @post shortOrLong() returns the value UUID_TYPE_SHORT.
|
||||
* @post getShortUUID() returns the value BLE_UUID_UNKNOWN.
|
||||
*/
|
||||
UUID(void) :
|
||||
UUID() :
|
||||
type(UUID_TYPE_SHORT),
|
||||
shortUUID(BLE_UUID_UNKNOWN) {
|
||||
}
|
||||
|
|
@ -276,7 +283,7 @@ public:
|
|||
* @return UUID_TYPE_SHORT if the UUID is 16-bit wide.
|
||||
* @return UUID_TYPE_LONG if the UUID is 128-bit wide.
|
||||
*/
|
||||
UUID_Type_t shortOrLong(void) const
|
||||
UUID_Type_t shortOrLong() const
|
||||
{
|
||||
return type;
|
||||
}
|
||||
|
|
@ -287,7 +294,7 @@ public:
|
|||
* @return A pointer to an uint16_t object if the UUID is 16 bits long.
|
||||
* @return A pointer to an array of 16 bytes if the UUID is 128 bits long.
|
||||
*/
|
||||
const uint8_t *getBaseUUID(void) const
|
||||
const uint8_t *getBaseUUID() const
|
||||
{
|
||||
if (type == UUID_TYPE_SHORT) {
|
||||
return (const uint8_t*)&shortUUID;
|
||||
|
|
@ -303,7 +310,7 @@ public:
|
|||
*
|
||||
* @return The value of the shortened UUID.
|
||||
*/
|
||||
ShortUUIDBytes_t getShortUUID(void) const
|
||||
ShortUUIDBytes_t getShortUUID() const
|
||||
{
|
||||
return shortUUID;
|
||||
}
|
||||
|
|
@ -314,7 +321,7 @@ public:
|
|||
* @return sizeof(ShortUUIDBytes_t) if the UUID type is UUID_TYPE_SHORT.
|
||||
* @return LENGTH_OF_LONG_UUID if the UUID type is UUID_TYPE_LONG.
|
||||
*/
|
||||
uint8_t getLen(void) const
|
||||
uint8_t getLen() const
|
||||
{
|
||||
return ((type == UUID_TYPE_SHORT) ?
|
||||
sizeof(ShortUUIDBytes_t) :
|
||||
|
|
@ -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"
|
||||
|
|
@ -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"
|
||||
|
|
@ -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"
|
||||
|
|
@ -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"
|
||||
|
|
@ -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"
|
||||
|
|
@ -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"
|
||||
|
|
@ -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"
|
||||
|
|
@ -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"
|
||||
|
|
@ -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"
|
||||
|
|
@ -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"
|
||||
|
|
@ -16,20 +16,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef IMPL_PAL_SIGNING_MONITOR_H_
|
||||
#define IMPL_PAL_SIGNING_MONITOR_H_
|
||||
/* for backwards compatibility */
|
||||
#warning "please include ble/gatt/GattCharacteristic.h directly"
|
||||
#include "ble/gatt/GattCharacteristic.h"
|
||||
|
||||
#include "ble/internal/PalSigningMonitor.h"
|
||||
|
||||
namespace ble {
|
||||
|
||||
class SecurityManager;
|
||||
|
||||
class PalSigningMonitor : public interface::PalSigningMonitor {
|
||||
public:
|
||||
void set_signing_event_handler(SecurityManager *handler);
|
||||
};
|
||||
|
||||
} // ble
|
||||
|
||||
#endif // CORDIO_PAL_SIGNING_MONITOR_H_
|
||||
|
|
@ -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"
|
||||
|
|
@ -16,20 +16,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "ble/internal/PalSigningMonitor.h"
|
||||
#include "ble/internal/BLEInstanceBase.h"
|
||||
#include "ble/GattClient.h"
|
||||
/* for backwards compatibility */
|
||||
#warning "please include ble/common/SafeBool.h directly"
|
||||
#include "ble/common/SafeBool.h"
|
||||
|
||||
namespace ble {
|
||||
|
||||
void PalSigningMonitor::set_signing_event_handler(SecurityManager *handler)
|
||||
{
|
||||
#if BLE_FEATURE_GATT_CLIENT
|
||||
BLEInstanceBase::deviceInstance().getGattClient().set_signing_event_handler(handler);
|
||||
#endif // BLE_FEATURE_GATT_CLIENT
|
||||
#if BLE_FEATURE_GATT_SERVER
|
||||
BLEInstanceBase::deviceInstance().getGattServer().set_signing_event_handler(handler);
|
||||
#endif // BLE_FEATURE_GATT_SERVER
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -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"
|
||||
|
||||
|
|
@ -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"
|
||||
|
|
@ -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"
|
||||
|
|
@ -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"
|
||||
|
|
@ -17,13 +17,15 @@
|
|||
#ifndef IMPL_HCI_DRIVER_H_
|
||||
#define IMPL_HCI_DRIVER_H_
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <BLETypes.h>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include "platform/Callback.h"
|
||||
#include "ble/common/BLETypes.h"
|
||||
#include "ble/driver/CordioHCITransportDriver.h"
|
||||
#include "ble/common/blecommon.h"
|
||||
|
||||
// FIXME: make this invisible!
|
||||
#include "wsf_buf.h"
|
||||
#include "CordioHCITransportDriver.h"
|
||||
#include "ble/common/ble/blecommon.h"
|
||||
#include "mbed.h"
|
||||
|
||||
namespace ble {
|
||||
|
||||
|
|
@ -73,7 +75,7 @@ public:
|
|||
/**
|
||||
* Driver destructor
|
||||
*/
|
||||
virtual ~CordioHCIDriver() { }
|
||||
virtual ~CordioHCIDriver() = default;
|
||||
|
||||
/**
|
||||
* Return the set of memory pool which will be used by the Cordio stack
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
#ifndef IMPL_HCI_TRANSPORT_DRIVER_H_
|
||||
#define IMPL_HCI_TRANSPORT_DRIVER_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include <cstdint>
|
||||
|
||||
namespace ble {
|
||||
|
||||
|
|
@ -34,7 +34,7 @@ public:
|
|||
/**
|
||||
* Driver destructor.
|
||||
*/
|
||||
virtual ~CordioHCITransportDriver() { }
|
||||
virtual ~CordioHCITransportDriver() = default;
|
||||
|
||||
/**
|
||||
* Inialization of the transport.
|
||||
|
|
@ -19,9 +19,9 @@
|
|||
|
||||
#if (DEVICE_SERIAL && DEVICE_SERIAL_FC) || defined(DOXYGEN_ONLY)
|
||||
|
||||
#include <stdint.h>
|
||||
#include "mbed.h"
|
||||
#include "CordioHCITransportDriver.h"
|
||||
#include <cstdint>
|
||||
#include "drivers/UnbufferedSerial.h"
|
||||
#include "ble/driver/CordioHCITransportDriver.h"
|
||||
|
||||
namespace ble {
|
||||
|
||||
|
|
@ -47,29 +47,29 @@ public:
|
|||
/**
|
||||
* Destructor
|
||||
*/
|
||||
virtual ~H4TransportDriver() { }
|
||||
~H4TransportDriver() override = default;
|
||||
|
||||
/**
|
||||
* @see CordioHCITransportDriver::initialize
|
||||
*/
|
||||
virtual void initialize();
|
||||
void initialize() override;
|
||||
|
||||
/**
|
||||
* @see CordioHCITransportDriver::terminate
|
||||
*/
|
||||
virtual void terminate();
|
||||
void terminate() override;
|
||||
|
||||
/**
|
||||
* @see CordioHCITransportDriver::write
|
||||
*/
|
||||
virtual uint16_t write(uint8_t type, uint16_t len, uint8_t *pData);
|
||||
uint16_t write(uint8_t type, uint16_t len, uint8_t *pData) override;
|
||||
|
||||
private:
|
||||
void on_controller_irq();
|
||||
|
||||
// Use UnbufferedSerial as we don't require locking primitives.
|
||||
// We access the peripheral in interrupt context.
|
||||
UnbufferedSerial uart;
|
||||
mbed::UnbufferedSerial uart;
|
||||
PinName cts;
|
||||
PinName rts;
|
||||
};
|
||||
|
|
@ -25,7 +25,7 @@ in the future with an implementation of the H5 interface. However, there is no
|
|||
plan to provide the SDIO implementation at the moment.
|
||||
|
||||
This interface is defined in the header file
|
||||
[CordioHCITransportDriver.h](../driver/CordioHCITransportDriver.h)
|
||||
[CordioHCITransportDriver.h](../CordioHCITransportDriver.h)
|
||||
|
||||
## CordioHCIDriver
|
||||
|
||||
|
|
@ -35,10 +35,10 @@ The responsibilities of this driver are:
|
|||
* Handle the reset/startup sequence of the Bluetooth controller.
|
||||
|
||||
This interface is defined in the header file
|
||||
[CordioHCIDriver.h](../driver/CordioHCIDriver.h)
|
||||
[CordioHCIDriver.h](../CordioHCIDriver.h)
|
||||
|
||||
A partial implementation is present in the file
|
||||
[CordioHCIDriver.cpp](../driver/CordioHCIDriver.cpp). It defines the function
|
||||
[CordioHCIDriver.cpp](../../../../source/cordio/driver/CordioHCIDriver.cpp). It defines the function
|
||||
delivering memory to the stack and a complete reset sequence. However, it does
|
||||
not define any initialization for the Bluetooth controller, this part being
|
||||
specific to the controller used.
|
||||
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
|
|
@ -19,16 +19,16 @@
|
|||
#ifndef MBED_GAP_ADVERTISING_DATA_H__
|
||||
#define MBED_GAP_ADVERTISING_DATA_H__
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <cstdlib>
|
||||
#include "platform/NonCopyable.h"
|
||||
|
||||
#include "ble/common/ble/UUID.h"
|
||||
#include "ble/common/ble/BLETypes.h"
|
||||
#include "ble/common/ble/blecommon.h"
|
||||
#include "ble/common/ble/gap/AdvertisingDataTypes.h"
|
||||
#include "ble/common/ble/gap/Types.h"
|
||||
#include "ble/common/UUID.h"
|
||||
#include "ble/common/BLETypes.h"
|
||||
#include "ble/common/blecommon.h"
|
||||
#include "ble/gap/AdvertisingDataTypes.h"
|
||||
#include "ble/gap/Types.h"
|
||||
|
||||
namespace ble {
|
||||
|
||||
|
|
@ -19,10 +19,10 @@
|
|||
#ifndef BLE_GAP_ADVERTISINGDATAPARSER_H
|
||||
#define BLE_GAP_ADVERTISINGDATAPARSER_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <cstdint>
|
||||
#include "platform/Span.h"
|
||||
|
||||
#include "ble/common/ble/gap/AdvertisingDataTypes.h"
|
||||
#include "ble/gap/AdvertisingDataTypes.h"
|
||||
|
||||
namespace ble {
|
||||
|
||||
|
|
@ -70,7 +70,7 @@ public:
|
|||
*/
|
||||
bool hasNext() const
|
||||
{
|
||||
if (position >= data.size()) {
|
||||
if (position >= (size_t) data.size()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -79,7 +79,7 @@ public:
|
|||
return false;
|
||||
}
|
||||
|
||||
if (position + current_length() >= data.size()) {
|
||||
if (position + current_length() >= (size_t) data.size()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -21,8 +21,8 @@
|
|||
|
||||
#include "platform/Span.h"
|
||||
|
||||
#include "ble/common/ble/UUID.h"
|
||||
#include "ble/common/ble/gap/AdvertisingDataBuilder.h"
|
||||
#include "ble/common/UUID.h"
|
||||
#include "ble/gap/AdvertisingDataBuilder.h"
|
||||
|
||||
namespace ble {
|
||||
|
||||
|
|
@ -68,7 +68,7 @@ public:
|
|||
/**
|
||||
* Construct a AdvertisingDataSimpleBuilder
|
||||
*/
|
||||
AdvertisingDataSimpleBuilder() : _builder(_buffer)
|
||||
AdvertisingDataSimpleBuilder() : _buffer(), _builder(_buffer)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -200,7 +200,7 @@ public:
|
|||
*
|
||||
* @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);
|
||||
MBED_ASSERT(res == BLE_ERROR_NONE);
|
||||
|
|
@ -19,7 +19,7 @@
|
|||
#ifndef BLE_GAP_ADVERTISINGDATATYPES_H
|
||||
#define BLE_GAP_ADVERTISINGDATATYPES_H
|
||||
|
||||
#include "ble/common/ble/SafeEnum.h"
|
||||
#include "ble/common/SafeEnum.h"
|
||||
|
||||
namespace ble {
|
||||
|
||||
|
|
@ -180,7 +180,7 @@ struct adv_data_flags_t {
|
|||
|
||||
adv_data_flags_t &setGeneralDiscoverable(bool enable = true)
|
||||
{
|
||||
_value &= ~0x03;
|
||||
_value &= ~0x03U;
|
||||
if (enable) {
|
||||
_value |= LE_GENERAL_DISCOVERABLE;
|
||||
}
|
||||
|
|
@ -189,7 +189,7 @@ struct adv_data_flags_t {
|
|||
|
||||
adv_data_flags_t &setLimitedDiscoverable(bool enable = true)
|
||||
{
|
||||
_value &= ~0x03;
|
||||
_value &= ~0x03U;
|
||||
if (enable) {
|
||||
_value |= LE_LIMITED_DISCOVERABLE;
|
||||
}
|
||||
|
|
@ -223,27 +223,27 @@ struct adv_data_flags_t {
|
|||
return *this;
|
||||
}
|
||||
|
||||
bool getGeneralDiscoverable()
|
||||
bool getGeneralDiscoverable() const
|
||||
{
|
||||
return _value & LE_GENERAL_DISCOVERABLE;
|
||||
}
|
||||
|
||||
bool getlimitedDiscoverable()
|
||||
bool getlimitedDiscoverable() const
|
||||
{
|
||||
return _value & LE_LIMITED_DISCOVERABLE;
|
||||
}
|
||||
|
||||
bool getBrEdrNotSupported()
|
||||
bool getBrEdrNotSupported() const
|
||||
{
|
||||
return _value & BREDR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
bool getSimultaneousLeBredrC()
|
||||
bool getSimultaneousLeBredrC() const
|
||||
{
|
||||
return _value & SIMULTANEOUS_LE_BREDR_C;
|
||||
}
|
||||
|
||||
bool getSimultaneousLeBredrH()
|
||||
bool getSimultaneousLeBredrH() const
|
||||
{
|
||||
return _value & SIMULTANEOUS_LE_BREDR_H;
|
||||
}
|
||||
|
|
@ -253,7 +253,7 @@ struct adv_data_flags_t {
|
|||
_value = 0;
|
||||
}
|
||||
|
||||
uint8_t value()
|
||||
uint8_t value() const
|
||||
{
|
||||
return _value;
|
||||
}
|
||||
|
|
@ -21,9 +21,9 @@
|
|||
|
||||
#include <algorithm>
|
||||
|
||||
#include "ble/common/ble/BLETypes.h"
|
||||
#include "ble/common/ble/blecommon.h"
|
||||
#include "ble/common/ble/SafeEnum.h"
|
||||
#include "ble/common/BLETypes.h"
|
||||
#include "ble/common/blecommon.h"
|
||||
#include "ble/common/SafeEnum.h"
|
||||
|
||||
namespace ble {
|
||||
|
||||
|
|
@ -19,9 +19,9 @@
|
|||
#ifndef MBED_EXTENDED_CONNECT_PARAMETERS_H__
|
||||
#define MBED_EXTENDED_CONNECT_PARAMETERS_H__
|
||||
|
||||
#include "mbed_assert.h"
|
||||
#include "platform/mbed_assert.h"
|
||||
|
||||
#include "ble/common/ble/BLETypes.h"
|
||||
#include "ble/common/BLETypes.h"
|
||||
|
||||
namespace ble {
|
||||
|
||||
|
|
@ -429,7 +429,7 @@ private:
|
|||
return index;
|
||||
}
|
||||
|
||||
uint8_t phyToIndex(phy_t phy) const
|
||||
static uint8_t phyToIndex(phy_t phy)
|
||||
{
|
||||
uint8_t index;
|
||||
switch (phy.value()) {
|
||||
|
|
@ -19,8 +19,8 @@
|
|||
#ifndef BLE_GAP_EVENTS_H
|
||||
#define BLE_GAP_EVENTS_H
|
||||
|
||||
#include "ble/common/ble/blecommon.h"
|
||||
#include "ble/common/ble/BLETypes.h"
|
||||
#include "ble/common/blecommon.h"
|
||||
#include "ble/common/BLETypes.h"
|
||||
|
||||
namespace ble {
|
||||
|
||||
|
|
@ -19,10 +19,10 @@
|
|||
#ifndef 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/ble/BLETypes.h"
|
||||
#include "ble/common/blecommon.h"
|
||||
#include "ble/common/BLETypes.h"
|
||||
|
||||
namespace ble {
|
||||
|
||||
|
|
@ -19,9 +19,9 @@
|
|||
#ifndef BLE_GAP_TYPES_H
|
||||
#define BLE_GAP_TYPES_H
|
||||
|
||||
#include "ble/common/ble/Duration.h"
|
||||
#include "ble/common/ble/Bounded.h"
|
||||
#include "ble/common/ble/SafeEnum.h"
|
||||
#include "ble/common/Duration.h"
|
||||
#include "ble/common/Bounded.h"
|
||||
#include "ble/common/SafeEnum.h"
|
||||
|
||||
namespace ble {
|
||||
|
||||
|
|
@ -19,7 +19,7 @@
|
|||
#ifndef MBED_CHARACTERISTIC_DESCRIPTOR_DISCOVERY_H__
|
||||
#define MBED_CHARACTERISTIC_DESCRIPTOR_DISCOVERY_H__
|
||||
|
||||
#include "FunctionPointerWithContext.h"
|
||||
#include "ble/common/FunctionPointerWithContext.h"
|
||||
|
||||
class DiscoveredCharacteristic; // forward declaration
|
||||
class DiscoveredCharacteristicDescriptor; // forward declaration
|
||||
|
|
@ -19,11 +19,11 @@
|
|||
#ifndef MBED_DISCOVERED_CHARACTERISTIC_H__
|
||||
#define MBED_DISCOVERED_CHARACTERISTIC_H__
|
||||
|
||||
#include "ble/common/ble/UUID.h"
|
||||
#include "ble/common/ble/GattAttribute.h"
|
||||
#include "ble/common/ble/GattCallbackParamTypes.h"
|
||||
#include "ble/common/ble/CharacteristicDescriptorDiscovery.h"
|
||||
#include "ble/common/ble/DiscoveredCharacteristicDescriptor.h"
|
||||
#include "ble/common/UUID.h"
|
||||
#include "ble/gatt/GattAttribute.h"
|
||||
#include "ble/gatt/GattCallbackParamTypes.h"
|
||||
#include "ble/gatt/CharacteristicDescriptorDiscovery.h"
|
||||
#include "ble/gatt/DiscoveredCharacteristicDescriptor.h"
|
||||
|
||||
namespace ble {
|
||||
class GattClient;
|
||||
|
|
@ -155,7 +155,7 @@ public:
|
|||
*
|
||||
* @see _broadcast
|
||||
*/
|
||||
bool broadcast(void) const
|
||||
bool broadcast() const
|
||||
{
|
||||
return _broadcast;
|
||||
}
|
||||
|
|
@ -168,7 +168,7 @@ public:
|
|||
*
|
||||
* @see _read
|
||||
*/
|
||||
bool read(void) const
|
||||
bool read() const
|
||||
{
|
||||
return _read;
|
||||
}
|
||||
|
|
@ -181,7 +181,7 @@ public:
|
|||
*
|
||||
* @see _writeWoResp
|
||||
*/
|
||||
bool writeWoResp(void) const
|
||||
bool writeWoResp() const
|
||||
{
|
||||
return _writeWoResp;
|
||||
}
|
||||
|
|
@ -194,7 +194,7 @@ public:
|
|||
*
|
||||
* @see _write
|
||||
*/
|
||||
bool write(void) const
|
||||
bool write() const
|
||||
{
|
||||
return _write;
|
||||
}
|
||||
|
|
@ -211,7 +211,7 @@ public:
|
|||
*
|
||||
* @see _notify
|
||||
*/
|
||||
bool notify(void) const
|
||||
bool notify() const
|
||||
{
|
||||
return _notify;
|
||||
}
|
||||
|
|
@ -228,7 +228,7 @@ public:
|
|||
*
|
||||
* @see _indicate
|
||||
*/
|
||||
bool indicate(void) const
|
||||
bool indicate() const
|
||||
{
|
||||
return _indicate;
|
||||
}
|
||||
|
|
@ -239,7 +239,7 @@ public:
|
|||
* @return true if the characteristic accepts authenticated signed write
|
||||
* and false otherwise.
|
||||
*/
|
||||
bool authSignedWrite(void) const
|
||||
bool authSignedWrite() const
|
||||
{
|
||||
return _authSignedWrite;
|
||||
}
|
||||
|
|
@ -447,7 +447,7 @@ public:
|
|||
*
|
||||
* @return The UUID of this characteristic.
|
||||
*/
|
||||
const UUID &getUUID(void) const
|
||||
const UUID &getUUID() const
|
||||
{
|
||||
return uuid;
|
||||
}
|
||||
|
|
@ -457,7 +457,7 @@ public:
|
|||
*
|
||||
* @return The set of properties of this characteristic.
|
||||
*/
|
||||
const Properties_t &getProperties(void) const
|
||||
const Properties_t &getProperties() const
|
||||
{
|
||||
return props;
|
||||
}
|
||||
|
|
@ -477,7 +477,7 @@ public:
|
|||
*
|
||||
* @return the declaration handle of this characteristic.
|
||||
*/
|
||||
GattAttribute::Handle_t getDeclHandle(void) const
|
||||
GattAttribute::Handle_t getDeclHandle() const
|
||||
{
|
||||
return declHandle;
|
||||
}
|
||||
|
|
@ -489,7 +489,7 @@ public:
|
|||
*
|
||||
* @return The handle to access the value of this characteristic.
|
||||
*/
|
||||
GattAttribute::Handle_t getValueHandle(void) const
|
||||
GattAttribute::Handle_t getValueHandle() const
|
||||
{
|
||||
return valueHandle;
|
||||
}
|
||||
|
|
@ -510,7 +510,7 @@ public:
|
|||
*
|
||||
* @note This function is public for informative purposes.
|
||||
*/
|
||||
GattAttribute::Handle_t getLastHandle(void) const
|
||||
GattAttribute::Handle_t getLastHandle() const
|
||||
{
|
||||
return lastHandle;
|
||||
}
|
||||
|
|
@ -583,7 +583,7 @@ public:
|
|||
|
||||
public:
|
||||
DiscoveredCharacteristic() :
|
||||
gattc(NULL),
|
||||
gattc(nullptr),
|
||||
uuid(UUID::ShortUUIDBytes_t(0)),
|
||||
props(),
|
||||
declHandle(GattAttribute::INVALID_HANDLE),
|
||||
|
|
@ -19,10 +19,10 @@
|
|||
#ifndef MBED_DISCOVERED_CHARACTERISTIC_DESCRIPTOR_H__
|
||||
#define MBED_DISCOVERED_CHARACTERISTIC_DESCRIPTOR_H__
|
||||
|
||||
#include "ble/common/ble/UUID.h"
|
||||
#include "ble/Gap.h"
|
||||
#include "ble/common/ble/GattAttribute.h"
|
||||
#include "ble/common/ble/CharacteristicDescriptorDiscovery.h"
|
||||
#include "ble/common/UUID.h"
|
||||
#include "ble/gatt/GattAttribute.h"
|
||||
#include "ble/gatt/CharacteristicDescriptorDiscovery.h"
|
||||
|
||||
namespace ble {
|
||||
class GattClient;
|
||||
|
|
@ -124,7 +124,7 @@ public:
|
|||
*
|
||||
* @return UUID of this descriptor.
|
||||
*/
|
||||
const UUID& getUUID(void) const
|
||||
const UUID& getUUID() const
|
||||
{
|
||||
return _uuid;
|
||||
}
|
||||
|
|
@ -19,8 +19,8 @@
|
|||
#ifndef MBED_DISCOVERED_SERVICE_H__
|
||||
#define MBED_DISCOVERED_SERVICE_H__
|
||||
|
||||
#include "ble/common/ble/UUID.h"
|
||||
#include "ble/common/ble/GattAttribute.h"
|
||||
#include "ble/common/UUID.h"
|
||||
#include "ble/gatt/GattAttribute.h"
|
||||
|
||||
/**
|
||||
* @addtogroup ble
|
||||
|
|
@ -57,7 +57,7 @@ public:
|
|||
*
|
||||
* @return A reference to the UUID of the discovered service.
|
||||
*/
|
||||
const UUID &getUUID(void) const
|
||||
const UUID &getUUID() const
|
||||
{
|
||||
return uuid;
|
||||
}
|
||||
|
|
@ -67,7 +67,7 @@ public:
|
|||
*
|
||||
* @return A reference to the start handle.
|
||||
*/
|
||||
const GattAttribute::Handle_t& getStartHandle(void) const
|
||||
const GattAttribute::Handle_t& getStartHandle() const
|
||||
{
|
||||
return startHandle;
|
||||
}
|
||||
|
|
@ -77,7 +77,7 @@ public:
|
|||
*
|
||||
* @return A reference to the end handle.
|
||||
*/
|
||||
const GattAttribute::Handle_t& getEndHandle(void) const
|
||||
const GattAttribute::Handle_t& getEndHandle() const
|
||||
{
|
||||
return endHandle;
|
||||
}
|
||||
|
|
@ -95,6 +95,9 @@ public:
|
|||
endHandle(GattAttribute::INVALID_HANDLE) {
|
||||
}
|
||||
|
||||
DiscoveredService(const DiscoveredService &) = delete;
|
||||
DiscoveredService operator=(const DiscoveredService &) = delete;
|
||||
|
||||
/**
|
||||
* Set information about the discovered service.
|
||||
*
|
||||
|
|
@ -108,7 +111,7 @@ public:
|
|||
* peer's GATT server.
|
||||
*/
|
||||
void setup(
|
||||
UUID uuidIn,
|
||||
const UUID& uuidIn,
|
||||
GattAttribute::Handle_t startHandleIn,
|
||||
GattAttribute::Handle_t endHandleIn
|
||||
) {
|
||||
|
|
@ -153,10 +156,6 @@ public:
|
|||
uuid.setupLong(longUUID, order);
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
DiscoveredService(const DiscoveredService &);
|
||||
|
||||
private:
|
||||
/**
|
||||
* UUID of the service.
|
||||
|
|
@ -19,8 +19,8 @@
|
|||
#ifndef MBED_GATT_ATTRIBUTE_H__
|
||||
#define MBED_GATT_ATTRIBUTE_H__
|
||||
|
||||
#include "ble/common/ble/UUID.h"
|
||||
#include "ble/common/ble/BLETypes.h"
|
||||
#include "ble/common/UUID.h"
|
||||
#include "ble/common/BLETypes.h"
|
||||
|
||||
/**
|
||||
* @addtogroup ble
|
||||
|
|
@ -113,7 +113,7 @@ public:
|
|||
*/
|
||||
GattAttribute(
|
||||
const UUID &uuid,
|
||||
uint8_t *valuePtr = NULL,
|
||||
uint8_t *valuePtr = nullptr,
|
||||
uint16_t len = 0,
|
||||
uint16_t maxLen = 0,
|
||||
bool hasVariableLen = true
|
||||
|
|
@ -129,6 +129,9 @@ public:
|
|||
_write_security(Security_t::NONE) {
|
||||
}
|
||||
|
||||
GattAttribute(const GattAttribute &) = delete;
|
||||
GattAttribute& operator=(const GattAttribute &) = delete;
|
||||
|
||||
public:
|
||||
/**
|
||||
* Get the attribute's handle in the ATT table.
|
||||
|
|
@ -138,7 +141,7 @@ public:
|
|||
*
|
||||
* @return The attribute's handle.
|
||||
*/
|
||||
Handle_t getHandle(void) const
|
||||
Handle_t getHandle() const
|
||||
{
|
||||
return _handle;
|
||||
}
|
||||
|
|
@ -150,7 +153,7 @@ public:
|
|||
*
|
||||
* @return The attribute.
|
||||
*/
|
||||
const UUID &getUUID(void) const
|
||||
const UUID &getUUID() const
|
||||
{
|
||||
return _uuid;
|
||||
}
|
||||
|
|
@ -160,7 +163,7 @@ public:
|
|||
*
|
||||
* @return The current length of the attribute value.
|
||||
*/
|
||||
uint16_t getLength(void) const
|
||||
uint16_t getLength() const
|
||||
{
|
||||
return _len;
|
||||
}
|
||||
|
|
@ -170,7 +173,7 @@ public:
|
|||
*
|
||||
* The maximum length of the attribute value.
|
||||
*/
|
||||
uint16_t getMaxLength(void) const
|
||||
uint16_t getMaxLength() const
|
||||
{
|
||||
return _lenMax;
|
||||
}
|
||||
|
|
@ -182,7 +185,7 @@ public:
|
|||
*
|
||||
* @return A pointer to the current length of the attribute value.
|
||||
*/
|
||||
uint16_t *getLengthPtr(void)
|
||||
uint16_t *getLengthPtr()
|
||||
{
|
||||
return &_len;
|
||||
}
|
||||
|
|
@ -205,7 +208,7 @@ public:
|
|||
*
|
||||
* @return A pointer to the attribute value.
|
||||
*/
|
||||
uint8_t *getValuePtr(void)
|
||||
uint8_t *getValuePtr()
|
||||
{
|
||||
return _valuePtr;
|
||||
}
|
||||
|
|
@ -216,7 +219,7 @@ public:
|
|||
* @return true if the attribute value has a variable length and false
|
||||
* otherwise.
|
||||
*/
|
||||
bool hasVariableLength(void) const
|
||||
bool hasVariableLength() const
|
||||
{
|
||||
return _hasVariableLen;
|
||||
}
|
||||
|
|
@ -234,7 +237,7 @@ public:
|
|||
* Indicate if a client is allowed to read the attribute.
|
||||
* @return true if a client is allowed to read the attribute.
|
||||
*/
|
||||
bool isReadAllowed(void) const
|
||||
bool isReadAllowed() const
|
||||
{
|
||||
return _read_allowed;
|
||||
}
|
||||
|
|
@ -270,7 +273,7 @@ public:
|
|||
* Indicate if a client is allowed to write the attribute.
|
||||
* @return true if a client is allowed to write the attribute.
|
||||
*/
|
||||
bool isWriteAllowed(void) const
|
||||
bool isWriteAllowed() const
|
||||
{
|
||||
return _write_allowed;
|
||||
}
|
||||
|
|
@ -343,11 +346,6 @@ private:
|
|||
* Security applied to the write operation.
|
||||
*/
|
||||
uint8_t _write_security: Security_t::size;
|
||||
|
||||
private:
|
||||
/* Disallow copy and assignment. */
|
||||
GattAttribute(const GattAttribute &);
|
||||
GattAttribute& operator=(const GattAttribute &);
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "CallChainOfFunctionPointersWithContext.h"
|
||||
#include "ble/common/CallChainOfFunctionPointersWithContext.h"
|
||||
|
||||
#ifndef MBED_BLE_GATT_CALLBACK_PARAM_TYPES_H__
|
||||
#define MBED_BLE_GATT_CALLBACK_PARAM_TYPES_H__
|
||||
|
|
@ -19,10 +19,10 @@
|
|||
#ifndef __GATT_CHARACTERISTIC_H__
|
||||
#define __GATT_CHARACTERISTIC_H__
|
||||
|
||||
#include "FunctionPointerWithContext.h"
|
||||
#include "ble/common/FunctionPointerWithContext.h"
|
||||
|
||||
#include "ble/common/ble/GattAttribute.h"
|
||||
#include "ble/common/ble/GattCallbackParamTypes.h"
|
||||
#include "ble/gatt/GattAttribute.h"
|
||||
#include "ble/gatt/GattCallbackParamTypes.h"
|
||||
|
||||
/**
|
||||
* @addtogroup ble
|
||||
|
|
@ -1384,7 +1384,7 @@ public:
|
|||
* @param[in] hasVariableLen Flag that indicates if the attribute's value
|
||||
* length can change throughout time.
|
||||
*
|
||||
* @note If valuePtr is NULL, length is equal to 0 and the characteristic
|
||||
* @note If valuePtr is nullptr, length is equal to 0 and the characteristic
|
||||
* is readable, then that particular characteristic may be considered
|
||||
* optional and dropped while instantiating the service with the underlying
|
||||
* BLE stack.
|
||||
|
|
@ -1398,11 +1398,11 @@ public:
|
|||
*/
|
||||
GattCharacteristic(
|
||||
const UUID &uuid,
|
||||
uint8_t *valuePtr = NULL,
|
||||
uint8_t *valuePtr = nullptr,
|
||||
uint16_t len = 0,
|
||||
uint16_t maxLen = 0,
|
||||
uint8_t props = BLE_GATT_CHAR_PROPERTIES_NONE,
|
||||
GattAttribute *descriptors[] = NULL,
|
||||
GattAttribute *descriptors[] = nullptr,
|
||||
unsigned numDescriptors = 0,
|
||||
bool hasVariableLen = true
|
||||
) : _valueAttribute(uuid, valuePtr, len, maxLen, hasVariableLen),
|
||||
|
|
@ -1426,6 +1426,9 @@ public:
|
|||
#endif // BLE_FEATURE_SECURITY
|
||||
}
|
||||
|
||||
GattCharacteristic(const GattCharacteristic &) = delete;
|
||||
GattCharacteristic& operator=(const GattCharacteristic &) = delete;
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
|
|
@ -1639,7 +1642,7 @@ public:
|
|||
* @return A GattAuthCallbackReply_t value indicating whether authorization
|
||||
* is granted.
|
||||
*
|
||||
* @note If the read request is approved and params->data remains NULL, then
|
||||
* @note If the read request is approved and params->data remains nullptr, then
|
||||
* the current characteristic value is used in the read response payload.
|
||||
*
|
||||
* @note If the read is approved, the event handler can specify an outgoing
|
||||
|
|
@ -1687,7 +1690,7 @@ public:
|
|||
* @note The underlying BLE stack assigns the attribute handle when the
|
||||
* enclosing service is added.
|
||||
*/
|
||||
GattAttribute::Handle_t getValueHandle(void) const
|
||||
GattAttribute::Handle_t getValueHandle() const
|
||||
{
|
||||
return getValueAttribute().getHandle();
|
||||
}
|
||||
|
|
@ -1699,7 +1702,7 @@ public:
|
|||
*
|
||||
* @return The characteristic's properties.
|
||||
*/
|
||||
uint8_t getProperties(void) const
|
||||
uint8_t getProperties() const
|
||||
{
|
||||
return _properties;
|
||||
}
|
||||
|
|
@ -1709,7 +1712,7 @@ public:
|
|||
*
|
||||
* @return The total number of descriptors.
|
||||
*/
|
||||
uint8_t getDescriptorCount(void) const
|
||||
uint8_t getDescriptorCount() const
|
||||
{
|
||||
return _descriptorCount;
|
||||
}
|
||||
|
|
@ -1746,12 +1749,12 @@ public:
|
|||
* @param[in] index The index of the descriptor to get.
|
||||
*
|
||||
* @return A pointer the requested descriptor if @p index is within the
|
||||
* range of the descriptor array or NULL otherwise.
|
||||
* range of the descriptor array or nullptr otherwise.
|
||||
*/
|
||||
GattAttribute *getDescriptor(uint8_t index)
|
||||
{
|
||||
if (index >= _descriptorCount) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return _descriptors[index];
|
||||
|
|
@ -1799,11 +1802,6 @@ private:
|
|||
* receive updates
|
||||
*/
|
||||
uint8_t _update_security: SecurityRequirement_t::size;
|
||||
|
||||
private:
|
||||
/* Disallow copy and assignment. */
|
||||
GattCharacteristic(const GattCharacteristic &);
|
||||
GattCharacteristic& operator=(const GattCharacteristic &);
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -1834,7 +1832,7 @@ public:
|
|||
const UUID &uuid,
|
||||
T *valuePtr,
|
||||
uint8_t additionalProperties = BLE_GATT_CHAR_PROPERTIES_NONE,
|
||||
GattAttribute *descriptors[] = NULL,
|
||||
GattAttribute *descriptors[] = nullptr,
|
||||
unsigned numDescriptors = 0
|
||||
) : GattCharacteristic(
|
||||
uuid,
|
||||
|
|
@ -1877,7 +1875,7 @@ public:
|
|||
const UUID &uuid,
|
||||
T *valuePtr,
|
||||
uint8_t additionalProperties = BLE_GATT_CHAR_PROPERTIES_NONE,
|
||||
GattAttribute *descriptors[] = NULL,
|
||||
GattAttribute *descriptors[] = nullptr,
|
||||
unsigned numDescriptors = 0
|
||||
) : GattCharacteristic(
|
||||
uuid,
|
||||
|
|
@ -1919,7 +1917,7 @@ public:
|
|||
const UUID &uuid,
|
||||
T *valuePtr,
|
||||
uint8_t additionalProperties = BLE_GATT_CHAR_PROPERTIES_NONE,
|
||||
GattAttribute *descriptors[] = NULL,
|
||||
GattAttribute *descriptors[] = nullptr,
|
||||
unsigned numDescriptors = 0
|
||||
) : GattCharacteristic(
|
||||
uuid,
|
||||
|
|
@ -1962,7 +1960,7 @@ public:
|
|||
const UUID &uuid,
|
||||
T valuePtr[NUM_ELEMENTS],
|
||||
uint8_t additionalProperties = BLE_GATT_CHAR_PROPERTIES_NONE,
|
||||
GattAttribute *descriptors[] = NULL,
|
||||
GattAttribute *descriptors[] = nullptr,
|
||||
unsigned numDescriptors = 0
|
||||
) : GattCharacteristic(
|
||||
uuid,
|
||||
|
|
@ -2006,7 +2004,7 @@ public:
|
|||
const UUID &uuid,
|
||||
T valuePtr[NUM_ELEMENTS],
|
||||
uint8_t additionalProperties = BLE_GATT_CHAR_PROPERTIES_NONE,
|
||||
GattAttribute *descriptors[] = NULL,
|
||||
GattAttribute *descriptors[] = nullptr,
|
||||
unsigned numDescriptors = 0
|
||||
) : GattCharacteristic(
|
||||
uuid,
|
||||
|
|
@ -2051,7 +2049,7 @@ public:
|
|||
const UUID &uuid,
|
||||
T valuePtr[NUM_ELEMENTS],
|
||||
uint8_t additionalProperties = BLE_GATT_CHAR_PROPERTIES_NONE,
|
||||
GattAttribute *descriptors[] = NULL,
|
||||
GattAttribute *descriptors[] = nullptr,
|
||||
unsigned numDescriptors = 0
|
||||
) : GattCharacteristic(
|
||||
uuid,
|
||||
|
|
@ -19,8 +19,8 @@
|
|||
#ifndef MBED_GATT_SERVICE_H__
|
||||
#define MBED_GATT_SERVICE_H__
|
||||
|
||||
#include "ble/common/ble/UUID.h"
|
||||
#include "ble/common/ble/GattCharacteristic.h"
|
||||
#include "ble/common/UUID.h"
|
||||
#include "ble/gatt/GattCharacteristic.h"
|
||||
|
||||
/**
|
||||
* @addtogroup ble
|
||||
|
|
@ -164,7 +164,7 @@ public:
|
|||
*
|
||||
* @return A reference to the service's UUID.
|
||||
*/
|
||||
const UUID &getUUID(void) const
|
||||
const UUID &getUUID() const
|
||||
{
|
||||
return _primaryServiceID;
|
||||
}
|
||||
|
|
@ -174,7 +174,7 @@ public:
|
|||
*
|
||||
* @return The service's handle.
|
||||
*/
|
||||
uint16_t getHandle(void) const
|
||||
uint16_t getHandle() const
|
||||
{
|
||||
return _handle;
|
||||
}
|
||||
|
|
@ -184,7 +184,7 @@ public:
|
|||
*
|
||||
* @return The total number of characteristics within this service.
|
||||
*/
|
||||
uint8_t getCharacteristicCount(void) const
|
||||
uint8_t getCharacteristicCount() const
|
||||
{
|
||||
return _characteristicCount;
|
||||
}
|
||||
|
|
@ -211,7 +211,7 @@ public:
|
|||
GattCharacteristic *getCharacteristic(uint8_t index)
|
||||
{
|
||||
if (index >= _characteristicCount) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return _characteristics[index];
|
||||
|
|
@ -19,9 +19,9 @@
|
|||
#ifndef MBED_BLE_SERVICE_DISOVERY_H__
|
||||
#define MBED_BLE_SERVICE_DISOVERY_H__
|
||||
|
||||
#include "ble/common/ble/blecommon.h"
|
||||
#include "ble/common/ble/UUID.h"
|
||||
#include "ble/common/ble/GattAttribute.h"
|
||||
#include "ble/common/blecommon.h"
|
||||
#include "ble/common/UUID.h"
|
||||
#include "ble/gatt/GattAttribute.h"
|
||||
|
||||
class DiscoveredService;
|
||||
class DiscoveredCharacteristic;
|
||||
|
|
@ -138,21 +138,21 @@ public:
|
|||
* BLE_ERROR_NONE if service discovery is launched successfully; else an appropriate error.
|
||||
*/
|
||||
virtual ble_error_t launch(ble::connection_handle_t connectionHandle,
|
||||
ServiceCallback_t sc = NULL,
|
||||
CharacteristicCallback_t cc = NULL,
|
||||
ServiceCallback_t sc = nullptr,
|
||||
CharacteristicCallback_t cc = nullptr,
|
||||
const UUID &matchingServiceUUID = UUID::ShortUUIDBytes_t(BLE_UUID_UNKNOWN),
|
||||
const UUID &matchingCharacteristicUUIDIn = UUID::ShortUUIDBytes_t(BLE_UUID_UNKNOWN)) = 0;
|
||||
|
||||
/**
|
||||
* Check whether service-discovery is currently active.
|
||||
*/
|
||||
virtual bool isActive(void) const = 0;
|
||||
virtual bool isActive() const = 0;
|
||||
|
||||
/**
|
||||
* Terminate an ongoing service discovery. This should result in an
|
||||
* invocation of the TerminationCallback if service discovery is active.
|
||||
*/
|
||||
virtual void terminate(void) = 0;
|
||||
virtual void terminate() = 0;
|
||||
|
||||
/**
|
||||
* Set up a callback to be invoked when service discovery is terminated.
|
||||
|
|
@ -170,12 +170,12 @@ public:
|
|||
*
|
||||
* @return BLE_ERROR_NONE on success.
|
||||
*/
|
||||
virtual ble_error_t reset(void) {
|
||||
virtual ble_error_t reset() {
|
||||
connHandle = 0;
|
||||
matchingServiceUUID = UUID::ShortUUIDBytes_t(BLE_UUID_UNKNOWN);
|
||||
serviceCallback = NULL;
|
||||
serviceCallback = nullptr;
|
||||
matchingCharacteristicUUID = UUID::ShortUUIDBytes_t(BLE_UUID_UNKNOWN);
|
||||
characteristicCallback = NULL;
|
||||
characteristicCallback = nullptr;
|
||||
|
||||
return BLE_ERROR_NONE;
|
||||
}
|
||||
|
|
@ -86,7 +86,7 @@ public:
|
|||
GattService batteryService(
|
||||
GattService::UUID_BATTERY_SERVICE,
|
||||
charTable,
|
||||
sizeof(charTable) / sizeof(GattCharacteristic *)
|
||||
sizeof(charTable) / sizeof(charTable[0])
|
||||
);
|
||||
|
||||
ble.gattServer().addService(batteryService);
|
||||
|
|
|
|||
|
|
@ -53,42 +53,42 @@ public:
|
|||
* The device's software version.
|
||||
*/
|
||||
DeviceInformationService(BLE &_ble,
|
||||
const char *manufacturersName = NULL,
|
||||
const char *modelNumber = NULL,
|
||||
const char *serialNumber = NULL,
|
||||
const char *hardwareRevision = NULL,
|
||||
const char *firmwareRevision = NULL,
|
||||
const char *softwareRevision = NULL) :
|
||||
const char *manufacturersName = nullptr,
|
||||
const char *modelNumber = nullptr,
|
||||
const char *serialNumber = nullptr,
|
||||
const char *hardwareRevision = nullptr,
|
||||
const char *firmwareRevision = nullptr,
|
||||
const char *softwareRevision = nullptr) :
|
||||
ble(_ble),
|
||||
manufacturersNameStringCharacteristic(GattCharacteristic::UUID_MANUFACTURER_NAME_STRING_CHAR,
|
||||
(uint8_t *)manufacturersName,
|
||||
(manufacturersName != NULL) ? strlen(manufacturersName) : 0, /* Min length */
|
||||
(manufacturersName != NULL) ? strlen(manufacturersName) : 0, /* Max length */
|
||||
(manufacturersName != nullptr) ? strlen(manufacturersName) : 0, /* Min length */
|
||||
(manufacturersName != nullptr) ? strlen(manufacturersName) : 0, /* Max length */
|
||||
GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ),
|
||||
modelNumberStringCharacteristic(GattCharacteristic::UUID_MODEL_NUMBER_STRING_CHAR,
|
||||
(uint8_t *)modelNumber,
|
||||
(modelNumber != NULL) ? strlen(modelNumber) : 0, /* Min length */
|
||||
(modelNumber != NULL) ? strlen(modelNumber) : 0, /* Max length */
|
||||
(modelNumber != nullptr) ? strlen(modelNumber) : 0, /* Min length */
|
||||
(modelNumber != nullptr) ? strlen(modelNumber) : 0, /* Max length */
|
||||
GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ),
|
||||
serialNumberStringCharacteristic(GattCharacteristic::UUID_SERIAL_NUMBER_STRING_CHAR,
|
||||
(uint8_t *)serialNumber,
|
||||
(serialNumber != NULL) ? strlen(serialNumber) : 0, /* Min length */
|
||||
(serialNumber != NULL) ? strlen(serialNumber) : 0, /* Max length */
|
||||
(serialNumber != nullptr) ? strlen(serialNumber) : 0, /* Min length */
|
||||
(serialNumber != nullptr) ? strlen(serialNumber) : 0, /* Max length */
|
||||
GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ),
|
||||
hardwareRevisionStringCharacteristic(GattCharacteristic::UUID_HARDWARE_REVISION_STRING_CHAR,
|
||||
(uint8_t *)hardwareRevision,
|
||||
(hardwareRevision != NULL) ? strlen(hardwareRevision) : 0, /* Min length */
|
||||
(hardwareRevision != NULL) ? strlen(hardwareRevision) : 0, /* Max length */
|
||||
(hardwareRevision != nullptr) ? strlen(hardwareRevision) : 0, /* Min length */
|
||||
(hardwareRevision != nullptr) ? strlen(hardwareRevision) : 0, /* Max length */
|
||||
GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ),
|
||||
firmwareRevisionStringCharacteristic(GattCharacteristic::UUID_FIRMWARE_REVISION_STRING_CHAR,
|
||||
(uint8_t *)firmwareRevision,
|
||||
(firmwareRevision != NULL) ? strlen(firmwareRevision) : 0, /* Min length */
|
||||
(firmwareRevision != NULL) ? strlen(firmwareRevision) : 0, /* Max length */
|
||||
(firmwareRevision != nullptr) ? strlen(firmwareRevision) : 0, /* Min length */
|
||||
(firmwareRevision != nullptr) ? strlen(firmwareRevision) : 0, /* Max length */
|
||||
GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ),
|
||||
softwareRevisionStringCharacteristic(GattCharacteristic::UUID_SOFTWARE_REVISION_STRING_CHAR,
|
||||
(uint8_t *)softwareRevision,
|
||||
(softwareRevision != NULL) ? strlen(softwareRevision) : 0, /* Min length */
|
||||
(softwareRevision != NULL) ? strlen(softwareRevision) : 0, /* Max length */
|
||||
(softwareRevision != nullptr) ? strlen(softwareRevision) : 0, /* Min length */
|
||||
(softwareRevision != nullptr) ? strlen(softwareRevision) : 0, /* Max length */
|
||||
GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ)
|
||||
{
|
||||
static bool serviceAdded = false; /* We only add the information service once. */
|
||||
|
|
@ -103,7 +103,7 @@ public:
|
|||
&firmwareRevisionStringCharacteristic,
|
||||
&softwareRevisionStringCharacteristic};
|
||||
GattService deviceInformationService(GattService::UUID_DEVICE_INFORMATION_SERVICE, charTable,
|
||||
sizeof(charTable) / sizeof(GattCharacteristic *));
|
||||
sizeof(charTable) / sizeof(charTable[0]));
|
||||
|
||||
ble.gattServer().addService(deviceInformationService);
|
||||
serviceAdded = true;
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ public:
|
|||
&pressureCharacteristic,
|
||||
&temperatureCharacteristic };
|
||||
|
||||
GattService environmentalService(GattService::UUID_ENVIRONMENTAL_SERVICE, charTable, sizeof(charTable) / sizeof(GattCharacteristic *));
|
||||
GattService environmentalService(GattService::UUID_ENVIRONMENTAL_SERVICE, charTable, sizeof(charTable) / sizeof(charTable[0]));
|
||||
|
||||
ble.gattServer().addService(environmentalService);
|
||||
serviceAdded = true;
|
||||
|
|
@ -97,9 +97,9 @@ public:
|
|||
private:
|
||||
BLE& ble;
|
||||
|
||||
TemperatureType_t temperature;
|
||||
HumidityType_t humidity;
|
||||
PressureType_t pressure;
|
||||
TemperatureType_t temperature{};
|
||||
HumidityType_t humidity{};
|
||||
PressureType_t pressure{};
|
||||
|
||||
ReadOnlyGattCharacteristic<TemperatureType_t> temperatureCharacteristic;
|
||||
ReadOnlyGattCharacteristic<HumidityType_t> humidityCharacteristic;
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ public:
|
|||
tempLocation(GattCharacteristic::UUID_TEMPERATURE_TYPE_CHAR, &_location) {
|
||||
|
||||
GattCharacteristic *hrmChars[] = {&tempMeasurement, &tempLocation, };
|
||||
GattService hrmService(GattService::UUID_HEALTH_THERMOMETER_SERVICE, hrmChars, sizeof(hrmChars) / sizeof(GattCharacteristic *));
|
||||
GattService hrmService(GattService::UUID_HEALTH_THERMOMETER_SERVICE, hrmChars, sizeof(hrmChars) / sizeof(hrmChars[0]));
|
||||
|
||||
ble.gattServer().addService(hrmService);
|
||||
}
|
||||
|
|
@ -116,11 +116,11 @@ private:
|
|||
memcpy(&bytes[OFFSET_OF_VALUE], &temp_ieee11073, sizeof(float));
|
||||
}
|
||||
|
||||
uint8_t *getPointer(void) {
|
||||
uint8_t *getPointer() {
|
||||
return bytes;
|
||||
}
|
||||
|
||||
const uint8_t *getPointer(void) const {
|
||||
const uint8_t *getPointer() const {
|
||||
return bytes;
|
||||
}
|
||||
|
||||
|
|
@ -130,7 +130,7 @@ private:
|
|||
* @param temperature The temperature as a float.
|
||||
* @return The temperature in 11073-20601 FLOAT-Type format.
|
||||
*/
|
||||
uint32_t quick_ieee11073_from_float(float temperature) {
|
||||
static uint32_t quick_ieee11073_from_float(float temperature) {
|
||||
uint8_t exponent = 0xFE; //Exponent is -2
|
||||
uint32_t mantissa = (uint32_t)(temperature * 100);
|
||||
|
||||
|
|
|
|||
|
|
@ -161,7 +161,7 @@ protected:
|
|||
/**
|
||||
* Construct and add to the GattServer the heart rate service.
|
||||
*/
|
||||
void setupService(void) {
|
||||
void setupService() {
|
||||
GattCharacteristic *charTable[] = {
|
||||
&hrmRate,
|
||||
&hrmLocation
|
||||
|
|
@ -169,7 +169,7 @@ protected:
|
|||
GattService hrmService(
|
||||
GattService::UUID_HEART_RATE_SERVICE,
|
||||
charTable,
|
||||
sizeof(charTable) / sizeof(GattCharacteristic*)
|
||||
sizeof(charTable) / sizeof(charTable[0])
|
||||
);
|
||||
|
||||
ble.gattServer().addService(hrmService);
|
||||
|
|
@ -204,17 +204,17 @@ protected:
|
|||
}
|
||||
}
|
||||
|
||||
uint8_t *getPointer(void)
|
||||
uint8_t *getPointer()
|
||||
{
|
||||
return valueBytes;
|
||||
}
|
||||
|
||||
const uint8_t *getPointer(void) const
|
||||
const uint8_t *getPointer() const
|
||||
{
|
||||
return valueBytes;
|
||||
}
|
||||
|
||||
unsigned getNumValueBytes(void) const
|
||||
unsigned getNumValueBytes() const
|
||||
{
|
||||
if (valueBytes[FLAGS_BYTE_INDEX] & VALUE_FORMAT_FLAG) {
|
||||
return 1 + sizeof(uint16_t);
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ public:
|
|||
}
|
||||
|
||||
GattCharacteristic *charTable[] = {&alertLevelChar};
|
||||
GattService linkLossService(GattService::UUID_LINK_LOSS_SERVICE, charTable, sizeof(charTable) / sizeof(GattCharacteristic *));
|
||||
GattService linkLossService(GattService::UUID_LINK_LOSS_SERVICE, charTable, sizeof(charTable) / sizeof(charTable[0]));
|
||||
|
||||
ble.gattServer().addService(linkLossService);
|
||||
serviceAdded = true;
|
||||
|
|
@ -95,7 +95,7 @@ protected:
|
|||
}
|
||||
}
|
||||
|
||||
virtual void onDisconnectionComplete(const ble::DisconnectionCompleteEvent &) {
|
||||
void onDisconnectionComplete(const ble::DisconnectionCompleteEvent &) override {
|
||||
if (alertLevel != NO_ALERT) {
|
||||
callback(alertLevel);
|
||||
}
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue