20#ifndef MBED_GATT_SERVER_H__
21#define MBED_GATT_SERVER_H__
23#include "platform/mbed_toolchain.h"
25#include "ble/common/CallChainOfFunctionPointersWithContext.h"
26#include "ble/common/blecommon.h"
28#include "ble/gatt/GattService.h"
29#include "ble/gatt/GattAttribute.h"
30#include "ble/gatt/GattCallbackParamTypes.h"
34#if !defined(DOXYGEN_ONLY)
122 (void)connectionHandle;
199 MBED_DEPRECATED_SINCE(
"mbed-os-6.11.0",
"This event is never triggered. Indication triggers onDataSent"
200 "when confirmation is received.")
414 const uint8_t *value,
416 bool localOnly =
false
446 const uint8_t *value,
448 bool localOnly =
false
511 "been replaced by GattServer::setEventHandler. Use that function instead.")
523 template <typename T>
526 void onDataSent(T *objPtr,
void (T::*memberPtr)(
unsigned count))
537 "been replaced by GattServer::setEventHandler. Use that function instead.")
562 template <typename T>
585 "been replaced by GattServer::setEventHandler. Use that function instead.")
618 template <typename T>
641 "been replaced by GattServer::setEventHandler. Use that function instead.")
672 template <typename T>
692 "been replaced by GattServer::setEventHandler. Use that function instead.")
724 "been replaced by an event handler. Indication confirmation triggers"
728#if !defined(DOXYGEN_ONLY)
729 GattServer(impl::GattServer* impl) : impl(impl) {}
735 impl::GattServer *impl;
Function like object hosting a list of FunctionPointerWithContext.
Function like object adapter over freestanding and member functions.
ble::attribute_handle_t Handle_t
Representation of an attribute handle.
Representation of a GattServer characteristic.
Representation of a GattServer service.
Construct and operates a GATT server.
CallChainOfFunctionPointersWithContext< const GattServer * > GattServerShutdownCallbackChain_t
Callchain of GattServerShutdownCallback_t.
void onUpdatesEnabled(EventCallback_t callback)
Set up an event handler that monitors subscription to characteristic updates.
FunctionPointerWithContext< unsigned > DataSentCallback_t
Event handler invoked when the server has sent data to a client.
bool isOnDataReadAvailable() const
Indicate if the underlying stack emit events when an attribute is read by a client.
FunctionPointerWithContext< GattAttribute::Handle_t > EventCallback_t
Event handler that handles subscription to characteristic updates, unsubscription from characteristic...
void onConfirmationReceived(EventCallback_t callback)
Set up an event handler that monitors notification acknowledgment.
CallChainOfFunctionPointersWithContext< unsigned > DataSentCallbackChain_t
Callchain of DataSentCallback_t objects.
DataSentCallbackChain_t & onDataSent()
Access the callchain of data sent event handlers.
FunctionPointerWithContext< const GattServer * > GattServerShutdownCallback_t
Event handler invoked when the GattServer is reset.
ble_error_t areUpdatesEnabled(ble::connection_handle_t connectionHandle, const GattCharacteristic &characteristic, bool *enabledP)
Determine if an identified client has subscribed to notifications or indications of a given character...
ble_error_t areUpdatesEnabled(const GattCharacteristic &characteristic, bool *enabledP)
Determine if one of the connected clients has subscribed to notifications or indications of the chara...
void setEventHandler(EventHandler *handler)
Assign the event handler implementation that will be used by the module to signal events back to the ...
FunctionPointerWithContext< const GattReadCallbackParams * > DataReadCallback_t
Event handler invoked when the client has read an attribute of the server.
ble_error_t reset()
Shut down the GattServer instance.
CallChainOfFunctionPointersWithContext< const GattReadCallbackParams * > DataReadCallbackChain_t
Callchain of DataReadCallback_t.
void onUpdatesDisabled(EventCallback_t callback)
Set up an event handler that monitors unsubscription from characteristic updates.
FunctionPointerWithContext< const GattWriteCallbackParams * > DataWrittenCallback_t
Event handler invoked when the client has written an attribute of the server.
ble_error_t write(GattAttribute::Handle_t attributeHandle, const uint8_t *value, uint16_t size, bool localOnly=false)
Update the value of an attribute present in the local GATT server.
CallChainOfFunctionPointersWithContext< const GattWriteCallbackParams * > DataWrittenCallbackChain_t
Callchain of DataWrittenCallback_t objects.
ble_error_t read(ble::connection_handle_t connectionHandle, GattAttribute::Handle_t attributeHandle, uint8_t *buffer, uint16_t *lengthP)
Read the value of an attribute present in the local GATT server.
ble_error_t write(ble::connection_handle_t connectionHandle, GattAttribute::Handle_t attributeHandle, const uint8_t *value, uint16_t size, bool localOnly=false)
Update the value of an attribute present in the local GATT server.
ble_error_t read(GattAttribute::Handle_t attributeHandle, uint8_t buffer[], uint16_t *lengthP)
Read the value of an attribute present in the local GATT server.
DataReadCallbackChain_t & onDataRead()
Access the callchain of data read event handlers.
ble_error_t addService(GattService &service)
Add a service declaration to the local attribute server table.
GattServerShutdownCallbackChain_t & onShutdown()
Access the callchain of shutdown event handlers.
DataWrittenCallbackChain_t & onDataWritten()
Access the callchain of data written event handlers.
ble_error_t
Error codes for the BLE API.
Entry namespace for all BLE API definitions.
uintptr_t connection_handle_t
Opaque reference to a connection.
Gatt Data Sent Attribute related events.
GATT Read event definition.
Gatt Updates Changed Attribute related events.
GATT Write event definition.
Definition of the general handler of GattServer related events.
virtual void onShutdown(const GattServer &server)
Function invoked when the GattServer instance is about to be shut down.
~EventHandler()=default
Prevent polymorphic deletion and avoid unnecessary virtual destructor as the GattServer class will ne...
virtual void onDataWritten(const GattWriteCallbackParams ¶ms)
Function invoked when a client writes an attribute.
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...
virtual void onDataRead(const GattReadCallbackParams ¶ms)
Function invoked when a client reads an attribute.
virtual void onConfirmationReceived(const GattConfirmationReceivedCallbackParams ¶ms)
Event not used.
virtual void onDataSent(const GattDataSentCallbackParams ¶ms)
Function invoked when the server has sent data to a client.
virtual void onUpdatesDisabled(const GattUpdatesDisabledCallbackParams ¶ms)
Function invoked when the client has unsubscribed from characteristic updates.
virtual void onUpdatesEnabled(const GattUpdatesEnabledCallbackParams ¶ms)
Function invoked when the client has subscribed to characteristic updates.