20#ifndef MBED_GATT_CLIENT_H__
22#define MBED_GATT_CLIENT_H__
24#include "ble/common/CallChainOfFunctionPointersWithContext.h"
25#include "ble/common/blecommon.h"
27#include "ble/gatt/GattAttribute.h"
28#include "ble/gatt/ServiceDiscovery.h"
29#include "ble/gatt/CharacteristicDescriptorDiscovery.h"
30#include "ble/gatt/GattCallbackParamTypes.h"
31#include "ble/gatt/DiscoveredService.h"
32#include "ble/gatt/DiscoveredCharacteristic.h"
36#if !defined(DOXYGEN_ONLY)
117 (void)connectionHandle;
629 template <
typename T>
711#if !defined(DOXYGEN_ONLY)
712 GattClient(impl::GattClient* impl) : impl(impl) { }
718 impl::GattClient *impl;
Function like object hosting a list of FunctionPointerWithContext.
Representation of a characteristic discovered.
Function like object adapter over freestanding and member functions.
ble::attribute_handle_t Handle_t
Representation of an attribute handle.
Representation of a Universally Unique Identifier (UUID).
uint16_t ShortUUIDBytes_t
Type for a 16-bit UUID.
Define procedures required for interacting with a distant GATT server.
ble_error_t discoverServices(ble::connection_handle_t connectionHandle, ServiceDiscovery::ServiceCallback_t callback, GattAttribute::Handle_t startHandle, GattAttribute::Handle_t endHandle)
Launch the service discovery procedure of a GATT server peer.
FunctionPointerWithContext< const GattClient * > GattClientShutdownCallback_t
Shutdown event handler.
void terminateCharacteristicDescriptorDiscovery(const DiscoveredCharacteristic &characteristic)
Terminate an ongoing characteristic descriptor discovery procedure.
CallChainOfFunctionPointersWithContext< const GattWriteCallbackParams * > WriteCallbackChain_t
Callchain of attribute write event handlers.
void onHVX(HVXCallback_t callback)
Register an handler for Handle Value Notification/Indication events.
ble_error_t negotiateAttMtu(ble::connection_handle_t connection)
Trigger MTU negotiation.
void onServiceDiscoveryTermination(ServiceDiscovery::TerminationCallback_t callback)
Register a service discovery termination event handler.
FunctionPointerWithContext< const GattReadCallbackParams * > ReadCallback_t
Attribute read event handler.
void onDataRead(ble::ReadCallback_t callback)
Register an attribute read event handler.
CallChainOfFunctionPointersWithContext< const GattHVXCallbackParams * > HVXCallbackChain_t
Callchain of handle value notification/indication event handlers.
void processReadResponse(const GattReadCallbackParams *params)
Forward an attribute read event to all registered handlers.
ble::WriteCallbackChain_t & onDataWritten()
Get the callchain of attribute write event handlers.
void onShutdown(T *objPtr, void(T::*memberPtr)(const GattClient *))
Register a shutdown event handler.
ble_error_t discoverServices(ble::connection_handle_t connectionHandle, ServiceDiscovery::ServiceCallback_t callback, const UUID &matchingServiceUUID=UUID::ShortUUIDBytes_t(BLE_UUID_UNKNOWN))
Launch the service discovery procedure of a GATT server peer.
FunctionPointerWithContext< const GattHVXCallbackParams * > HVXCallback_t
Handle value notification/indication event handler.
WriteOp_t
GATT write operations.
@ GATT_OP_SIGNED_WRITE_CMD
Signed Write command.
@ GATT_OP_WRITE_CMD
Write command.
@ GATT_OP_WRITE_REQ
Write request.
ble_error_t discoverCharacteristicDescriptors(const DiscoveredCharacteristic &characteristic, const CharacteristicDescriptorDiscovery::DiscoveryCallback_t &discoveryCallback, const CharacteristicDescriptorDiscovery::TerminationCallback_t &terminationCallback)
Initiate the descriptor discovery procedure for a given characteristic.
bool isCharacteristicDescriptorDiscoveryActive(const DiscoveredCharacteristic &characteristic) const
Query status of the descriptor discovery procedure for a given characteristic.
FunctionPointerWithContext< const GattWriteCallbackParams * > WriteCallback_t
Attribute write event handler.ble::WriteCallback_t.
void onShutdown(const GattClientShutdownCallback_t &callback)
Register a shutdown event handler.
void setEventHandler(EventHandler *handler)
Assign the event handler implementation that will be used by the module to signal events back to the ...
ble::ReadCallbackChain_t & onDataRead()
Get the callchain of attribute read event handlers.
CallChainOfFunctionPointersWithContext< const GattReadCallbackParams * > ReadCallbackChain_t
Callchain of attribute read event handlers.
ble_error_t reset()
Reset the state of the GattClient instance.
GattClientShutdownCallbackChain_t & onShutdown()
Get the callchain of shutdown event handlers.
void processHVXEvent(const GattHVXCallbackParams *params)
Forward a handle value notification or indication event to all registered handlers.
bool isServiceDiscoveryActive() const
Check if the service discovery procedure is currently active.
void onDataWritten(ble::WriteCallback_t callback)
Register an attribute write event handler.
ble_error_t read(ble::connection_handle_t connHandle, GattAttribute::Handle_t attributeHandle, uint16_t offset) const
Initiate the read procedure of an attribute handle.
CallChainOfFunctionPointersWithContext< const GattClient * > GattClientShutdownCallbackChain_t
Callchain of shutdown event handlers.
ble_error_t write(GattClient::WriteOp_t cmd, ble::connection_handle_t connHandle, GattAttribute::Handle_t attributeHandle, size_t length, const uint8_t *value) const
Initiate a write procedure on an attribute value.
void terminateServiceDiscovery()
Terminate all ongoing service discovery procedures.
HVXCallbackChain_t & onHVX()
provide access to the callchain of HVX callbacks.
void processWriteResponse(const GattWriteCallbackParams *params)
Forward an attribute written event to all registered handlers.
ble_error_t launchServiceDiscovery(ble::connection_handle_t connectionHandle, 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))
Launch the service and characteristic discovery procedure of a GATT server peer.
ble_error_t
Error codes for the BLE API.
@ BLE_UUID_UNKNOWN
Reserved UUID.
Entry namespace for all BLE API definitions.
uintptr_t connection_handle_t
Opaque reference to a connection.
Handle Value Notification/Indication event.
GATT Read event definition.
GATT Write event definition.
Definition of the general handler of GattClient related events.
~EventHandler()=default
Prevent polymorphic deletion and avoid unnecessary virtual destructor as the GattClient class will ne...
virtual void onAttMtuChange(ble::connection_handle_t connectionHandle, uint16_t attMtuSize)
Function invoked when the connections changes the ATT_MTU which controls the maximum size of an attri...