17 #ifndef MBED_GATT_CLIENT_H__ 18 #define MBED_GATT_CLIENT_H__ 20 #include "ble/common/StaticInterface.h" 21 #include "ble/GattAttribute.h" 22 #include "ble/ServiceDiscovery.h" 23 #include "ble/CharacteristicDescriptorDiscovery.h" 24 #include "ble/GattCallbackParamTypes.h" 25 #include "ble/CallChainOfFunctionPointersWithContext.h" 26 #include "BleImplementationForward.h" 28 #if !defined(DOXYGEN_ONLY) 88 #if defined(DOXYGEN_ONLY) 92 class GattClient :
public StaticInterface<Impl, GattClient> {
127 eventHandler = handler;
154 GATT_OP_WRITE_REQ = 0x01,
162 GATT_OP_WRITE_CMD = 0x02,
171 GATT_OP_SIGNED_WRITE_CMD = 0x03
328 return launchServiceDiscovery(
329 connectionHandle, callback, NULL, matchingServiceUUID
371 bool isServiceDiscoveryActive(
void)
const;
379 void terminateServiceDiscovery(
void);
477 onDataReadCallbackChain.add(callback);
493 return onDataReadCallbackChain;
509 onDataWriteCallbackChain.add(callback);
525 return onDataWriteCallbackChain;
541 MBED_DEPRECATED(
"Use GattServer::onDataWritten()")
544 onDataWritten(callback);
552 void onServiceDiscoveryTermination(
594 bool isCharacteristicDescriptorDiscoveryActive(
607 void terminateCharacteristicDescriptorDiscovery(
635 onHVXCallbackChain.add(callback);
654 shutdownCallChain.add(callback);
667 template <
typename T>
670 shutdownCallChain.add(objPtr, memberPtr);
684 return shutdownCallChain;
697 return onHVXCallbackChain;
738 const UUID &matchingServiceUUID,
739 const UUID &matchingCharacteristicUUIDIn
742 bool isServiceDiscoveryActive_(
void)
const;
744 void terminateServiceDiscovery_(
void);
762 void onServiceDiscoveryTermination_(
772 bool isCharacteristicDescriptorDiscoveryActive_(
776 void terminateCharacteristicDescriptorDiscovery_(
798 onDataReadCallbackChain(params);
812 onDataWriteCallbackChain(params);
827 if (onHVXCallbackChain) {
828 onHVXCallbackChain(params);
874 #if !defined(DOXYGEN_ONLY) 878 using ble::impl::GattClient;
EventHandler * eventHandler
Event handler provided by the application.
void onDataWritten(WriteCallback_t callback)
Register an attribute write event handler.
HVXCallbackChain_t & onHVX()
provide access to the callchain of HVX callbacks.
FunctionPointerWithContext< const GattHVXCallbackParams * > HVXCallback_t
Handle value notification/indication event handler.
GattClientShutdownCallbackChain_t & onShutdown()
Get the callchain of shutdown event handlers.
uintptr_t connection_handle_t
Opaque reference to a connection.
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.
void setEventHandler(EventHandler *handler)
Assign the event handler implementation that will be used by the module to signal events back to the ...
Representation of a characteristic discovered.
void onHVX(HVXCallback_t callback)
Register an handler for Handle Value Notification/Indication events.
WriteOp_t
GATT write operations.
Handle Value Notification/Indication event.
HVXCallbackChain_t onHVXCallbackChain
Callchain containing all registered event handlers for update events.
CallChainOfFunctionPointersWithContext< const GattReadCallbackParams * > ReadCallbackChain_t
Callchain of attribute read event handlers.
CallChainOfFunctionPointersWithContext< const GattClient * > GattClientShutdownCallbackChain_t
Callchain of shutdown event handlers.
Definition of the general handler of GattClient related events.
WriteCallbackChain_t & onDataWritten()
Get the callchain of attribute write event handlers.
Representation of a Universally Unique Identifier (UUID).
ReadCallbackChain_t & onDataRead()
Get the callchain of attribute read event handlers.
void onShutdown(const GattClientShutdownCallback_t &callback)
Register a shutdown event handler.
Define procedures required for interacting with a distant GATT server.
GattClientShutdownCallbackChain_t shutdownCallChain
Callchain containing all registered event handlers for shutdown events.
ble::attribute_handle_t Handle_t
Representation of an attribute handle.
FunctionPointerWithContext< const GattReadCallbackParams * > ReadCallback_t
Attribute read event handler.
void onShutdown(T *objPtr, void(T::*memberPtr)(const GattClient *))
Register a shutdown event handler.
void onDataRead(ReadCallback_t callback)
Register an attribute read event handler.
void processWriteResponse(const GattWriteCallbackParams *params)
Forward an attribute written event to all registered handlers.
ReadCallbackChain_t onDataReadCallbackChain
Callchain containing all registered event handlers for data read events.
FunctionPointerWithContext< const GattWriteCallbackParams * > WriteCallback_t
Attribute write event handler.
CallChainOfFunctionPointersWithContext< const GattWriteCallbackParams * > WriteCallbackChain_t
Callchain of attribute write event handlers.
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...
GATT Write event definition.
WriteCallbackChain_t onDataWriteCallbackChain
Callchain containing all registered event handlers for data write events.
uint16_t ShortUUIDBytes_t
Type for a 16-bit UUID.
GATT Read event definition.
CallChainOfFunctionPointersWithContext< const GattHVXCallbackParams * > HVXCallbackChain_t
Callchain of handle value notification/indication event handlers.
void processHVXEvent(const GattHVXCallbackParams *params)
Forward a handle value notification or indication event to all registered handlers.
FunctionPointerWithContext< const GattClient * > GattClientShutdownCallback_t
Shutdown event handler.
void processReadResponse(const GattReadCallbackParams *params)
Forward an attribute read event to all registered handlers.
Entry namespace for all BLE API definitions.
ble_error_t
Error codes for the BLE API.