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

#include <server2.h>

Classes

struct  ValueChangedParameters
 

Public Types

using ValueChangedResult = pw::expected< void, Error >
 
using Ptr = internal::RaiiPtr< LocalService2, &LocalService2::UnpublishService >
 

Public Member Functions

virtual async2::OnceReceiver< ValueChangedResultNotifyValue (ValueChangedParameters &&parameters)=0
 
virtual async2::OnceReceiver< ValueChangedResultIndicateValue (ValueChangedParameters &&parameters)=0
 

Private Member Functions

virtual void UnpublishService ()=0
 

Detailed Description

Interface provided by the backend to interact with a published service. LocalService is valid for the lifetime of a published GATT service. It is used to control the service and send notifications/indications.

Member Typedef Documentation

◆ Ptr

Movable LocalService smart pointer. When the LocalService::Ptr object is destroyed the service will be unpublished.

◆ ValueChangedResult

using pw::bluetooth::gatt::LocalService2::ValueChangedResult = pw::expected<void, Error>

The Result type for a ValueChanged indication or notification message. The error can be locally generated for notifications and either locally or remotely generated for indications.

Member Function Documentation

◆ IndicateValue()

virtual async2::OnceReceiver< ValueChangedResult > pw::bluetooth::gatt::LocalService2::IndicateValue ( ValueChangedParameters &&  parameters)
pure virtual

Sends an indication to peers. Indications should be used instead of notifications when the service does require peer confirmation of the update.

Indications should not be sent to peers which have not enabled indications on a particular characteristic. If they are sent, they will not be propagated and the result_sender will be set to an error condition. The Bluetooth stack will track this configuration for the lifetime of the service.

If any of the peers in parameters.peer_ids fails to confirm the indication within the ATT transaction timeout (30 seconds per Bluetooth 6.0 Vol. 3 Part F 3.3.3), the link between the peer and the local adapter will be closed.

The maximum size of the parameters.value field depends on the MTU negotiated with the peer. A 3-byte header plus the value contents must fit in a packet of MTU bytes.

Parameters
parametersThe parameters associated with the changed characteristic.
Returns
When all the peers listed in parameters.peer_ids have confirmed the indication, the result is returned. If the implementation wishes to receive indication confirmations on a per-peer basis, they should send this event with a single PeerId in parameters.peer_ids. Additional values should not be indicated until this procedure completes.

◆ NotifyValue()

virtual async2::OnceReceiver< ValueChangedResult > pw::bluetooth::gatt::LocalService2::NotifyValue ( ValueChangedParameters &&  parameters)
pure virtual

Sends a notification to peers. Notifications should be used instead of indications when the service does not require peer confirmation of the update.

Notifications should not be sent to peers which have not enabled notifications on a particular characteristic or that have disconnected. If notifications are sent, they will not be propagated and the result_sender will be set to an error condition. The Bluetooth stack will track this configuration for the lifetime of the service.

The maximum size of the parameters.value field depends on the Maximum Transmission Unit (MTU) negotiated with the peer. A 3-byte header plus the value contents must fit in a packet of MTU bytes.

Parameters
parametersThe parameters associated with the changed characteristic.
Returns
The result is returned when the notification has been sent to all peers or an error is produced when trying to send the notification to any of the peers. This value is only set only once when all associated work is done, if the implementation wishes to receive a call on a per-peer basis, they should send this event with a single PeerId in parameters.peer_ids. Additional values should not be notified until this notification completes.

◆ UnpublishService()

virtual void pw::bluetooth::gatt::LocalService2::UnpublishService ( )
privatepure virtual

Unpublish the local service. This method is called by the ~LocalServicePtr() when it goes out of scope, the API client should never call this method.


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