Pigweed
 
Loading...
Searching...
No Matches
pw::bluetooth::low_energy::Connection2 Class Referenceabstract

#include <connection2.h>

Classes

struct  ConnectionOptions
 Represents parameters that are set on a per-connection basis. More...
 
struct  ConnectionParameters
 Actual connection parameters returned by the controller. More...
 
struct  ConnectL2capParameters
 
struct  RequestedConnectionParameters
 

Public Types

enum class  ConnectionParameterUpdateError : uint8_t { kFailure , kInvalidParameters , kRejected }
 Possible errors when updating the connection parameters.
 
enum class  DisconnectReason : uint8_t { kFailure , kRemoteUserTerminatedConnection , kConnectionTimeout }
 Possible reasons a connection was disconnected. More...
 
using Ptr = internal::RaiiPtr< Connection2, &Connection2::Release >
 

Public Member Functions

virtual ~Connection2 ()=default
 
virtual async2::Poll< DisconnectReasonPendDisconnect (async2::Context &cx)=0
 
virtual gatt::Client2GattClient ()=0
 
virtual uint16_t AttMtu ()=0
 
virtual async2::Poll< uint16_t > PendAttMtuChange (async2::Context &cx)=0
 
virtual ConnectionParameters Parameters ()=0
 Returns the current connection parameters.
 
virtual async2::OnceReceiver< pw::expected< void, ConnectionParameterUpdateError > > RequestParameterUpdate (RequestedConnectionParameters parameters)=0
 
virtual async2::OnceReceiver< pw::Result< Channel::Ptr > > ConnectL2cap (ConnectL2capParameters parameters)=0
 

Private Member Functions

virtual void Release ()=0
 

Detailed Description

Class that represents a connection to a peer. This can be used to interact with GATT services and establish LE L2CAP channels.

The lifetime of this object is tied to that of the LE connection it represents. Destroying the object results in a disconnection.

Member Typedef Documentation

◆ Ptr

Movable Connection2 smart pointer. When Connection::Ptr is destroyed the Connection2 will disconnect automatically.

Member Enumeration Documentation

◆ DisconnectReason

Possible reasons a connection was disconnected.

Enumerator
kConnectionTimeout 

This usually indicates that the link supervision timeout expired.

Constructor & Destructor Documentation

◆ ~Connection2()

virtual pw::bluetooth::low_energy::Connection2::~Connection2 ( )
virtualdefault

If a disconnection has not occurred, destroying this object will result in disconnection.

Member Function Documentation

◆ AttMtu()

virtual uint16_t pw::bluetooth::low_energy::Connection2::AttMtu ( )
pure virtual

Returns the current ATT Maximum Transmission Unit. By subtracting ATT headers from the MTU, the maximum payload size of messages can be calculated.

◆ ConnectL2cap()

virtual async2::OnceReceiver< pw::Result< Channel::Ptr > > pw::bluetooth::low_energy::Connection2::ConnectL2cap ( ConnectL2capParameters  parameters)
pure virtual

Connect to an L2CAP LE connection-oriented channel.

Parameters
parametersThe parameters to configure the channel with.
Returns
The result of the connection procedure. On success, contains a Channel that can be used to exchange data.

◆ GattClient()

virtual gatt::Client2 * pw::bluetooth::low_energy::Connection2::GattClient ( )
pure virtual

Returns a GATT client to the connected peer that is valid for the lifetime of this Connection2 object. Connection2 is considered alive as long as PendDisconnect() returns pending and the object hasn't been destroyed.

◆ PendAttMtuChange()

virtual async2::Poll< uint16_t > pw::bluetooth::low_energy::Connection2::PendAttMtuChange ( async2::Context cx)
pure virtual

Returns Pending until the ATT MTU changes, at which point cx will be awoken. Returns Ready with the new ATT MTU once the ATT MTU has been changed. The ATT MTU can only be changed once.

◆ PendDisconnect()

virtual async2::Poll< DisconnectReason > pw::bluetooth::low_energy::Connection2::PendDisconnect ( async2::Context cx)
pure virtual

Returns Ready after the peer disconnects or there is a connection error that caused a disconnection. Awakens cx on disconnect.

◆ Release()

virtual void pw::bluetooth::low_energy::Connection2::Release ( )
privatepure virtual

Request to destroy this connection. This method is called by the ~Connection2Ptr() when it goes out of scope, the API client should never call this method.

◆ RequestParameterUpdate()

virtual async2::OnceReceiver< pw::expected< void, ConnectionParameterUpdateError > > pw::bluetooth::low_energy::Connection2::RequestParameterUpdate ( RequestedConnectionParameters  parameters)
pure virtual

Requests an update to the connection parameters.

Returns
Asynchronously returns the result of the request.

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