Pigweed
 
Loading...
Searching...
No Matches
pw::bluetooth::gatt::LocalServiceDelegate2 Class Referenceabstract

#include <server2.h>

Public Member Functions

virtual void OnError (Error error)=0
 
virtual void CharacteristicConfiguration (PeerId peer_id, Handle handle, bool notify, bool indicate)=0
 
virtual async2::OnceReceiver< pw::expected< multibuf::MultiBuf, Error > > ReadValue (PeerId peer_id, Handle handle, uint32_t offset)=0
 
virtual async2::OnceReceiver< pw::expected< void, Error > > WriteValue (PeerId peer_id, Handle handle, uint32_t offset, multibuf::MultiBuf &&value)=0
 
virtual void MtuUpdate (PeerId peer_id, uint16_t mtu)=0
 

Detailed Description

Interface for serving a local GATT service. This is implemented by the API client.

Member Function Documentation

◆ CharacteristicConfiguration()

virtual void pw::bluetooth::gatt::LocalServiceDelegate2::CharacteristicConfiguration ( PeerId  peer_id,
Handle  handle,
bool  notify,
bool  indicate 
)
pure virtual

This notifies the current configuration of a particular characteristic/descriptor for a particular peer. It will be called when the peer GATT client changes the configuration.

The Bluetooth stack maintains the state of each peer's configuration across reconnections. As such, this method will be called with both notify and indicate set to false for each characteristic when a peer disconnects. Also, when a peer reconnects this method will be called again with the persisted state of the newly-connected peer's configuration. However, clients should not rely on this state being persisted indefinitely by the Bluetooth stack.

Parameters
peer_idThe PeerId of the GATT client associated with this particular CCC.
handleThe handle of the characteristic associated with the notify and indicate parameters.
notifyTrue if the client has enabled notifications, false otherwise.
indicateTrue if the client has enabled indications, false otherwise.

◆ MtuUpdate()

virtual void pw::bluetooth::gatt::LocalServiceDelegate2::MtuUpdate ( PeerId  peer_id,
uint16_t  mtu 
)
pure virtual

Called when the MTU of a peer is updated. Also called for peers that are already connected when the server is published.

Notifications and indications must fit in a single packet including both the 3-byte notification/indication header and the user-provided payload. If these are not used, the MTU can be safely ignored as it is intended for use cases where the throughput needs to be optimized.

◆ OnError()

virtual void pw::bluetooth::gatt::LocalServiceDelegate2::OnError ( Error  error)
pure virtual

Called when there is a fatal error related to this service that forces the service to close. LocalServiceDelegate methods will no longer be called. This invalidates the associated LocalService. It is OK to destroy both LocalServiceDelegate and the associated LocalService::Ptr from within this method.

◆ ReadValue()

virtual async2::OnceReceiver< pw::expected< multibuf::MultiBuf, Error > > pw::bluetooth::gatt::LocalServiceDelegate2::ReadValue ( PeerId  peer_id,
Handle  handle,
uint32_t  offset 
)
pure virtual

Called when a peer requests to read the value of a characteristic or descriptor. It is guaranteed that the peer satisfies the permissions associated with this attribute.

Parameters
peer_idThe PeerId of the GATT client making the read request.
handleThe handle of the requested descriptor/characteristic.
offsetThe offset at which to start reading the requested value.
Returns
Returns the value of the characteristic on success, or an Error on failure. The value will be truncated to fit in the MTU if necessary.

◆ WriteValue()

virtual async2::OnceReceiver< pw::expected< void, Error > > pw::bluetooth::gatt::LocalServiceDelegate2::WriteValue ( PeerId  peer_id,
Handle  handle,
uint32_t  offset,
multibuf::MultiBuf &&  value 
)
pure virtual

Called when a peer issues a request to write the value of a characteristic or descriptor. It is guaranteed that the peer satisfies the permissions associated with this attribute.

Parameters
peer_idThe PeerId of the GATT client making the write request.
handleThe handle of the requested descriptor/characteristic.
offsetThe offset at which to start writing the requested value. If the offset is 0, any existing value should be overwritten by the new value. Otherwise, the existing value between offset:(offset + len(value)) should be changed to value.
valueThe new value for the descriptor/characteristic.
Returns
The result of the write.

The documentation for this class was generated from the following file: