Pigweed
 
Loading...
Searching...
No Matches
connection2.h
1// Copyright 2024 The Pigweed Authors
2//
3// Licensed under the Apache License, Version 2.0 (the "License"); you may not
4// use this file except in compliance with the License. You may obtain a copy of
5// the License at
6//
7// https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12// License for the specific language governing permissions and limitations under
13// the License.
14#pragma once
15
16#include "pw_async2/dispatcher.h"
17#include "pw_bluetooth/gatt/client2.h"
18#include "pw_bluetooth/internal/raii_ptr.h"
19#include "pw_bluetooth/low_energy/channel.h"
20#include "pw_bluetooth/types.h"
21
22namespace pw::bluetooth::low_energy {
23
30 public:
32 enum class ConnectionParameterUpdateError : uint8_t {
33 kFailure,
34 kInvalidParameters,
35 kRejected,
36 };
37
39 enum class DisconnectReason : uint8_t {
40 kFailure,
41 kRemoteUserTerminatedConnection,
44 };
45
55 uint16_t interval;
56
60 uint16_t latency;
61
69 };
70
82 uint16_t min_interval;
83
92 uint16_t max_interval;
93
97 uint16_t max_latency;
98
106 };
107
115 bool bondable_mode = true;
116
120 std::optional<Uuid> service_filter;
121
124 std::optional<RequestedConnectionParameters> parameters;
125
133 std::optional<uint16_t> att_mtu;
134 };
135
138 Psm psm;
145 };
146
149 virtual ~Connection2() = default;
150
154 async2::Context& cx) = 0;
155
159 virtual gatt::Client2* GattClient() = 0;
160
164 virtual uint16_t AttMtu() = 0;
165
170
173
176 virtual async2::OnceReceiver<
177 pw::expected<void, ConnectionParameterUpdateError>>
179
185 ConnectL2capParameters parameters) = 0;
186
187 private:
191 virtual void Release() = 0;
192
193 public:
196 using Ptr = internal::RaiiPtr<Connection2, &Connection2::Release>;
197};
198
199} // namespace pw::bluetooth::low_energy
Definition: dispatcher_base.h:52
Definition: once_sender.h:41
Definition: poll.h:54
Represents a GATT client that interacts with services on a GATT server.
Definition: client2.h:284
Definition: connection2.h:29
virtual gatt::Client2 * GattClient()=0
virtual ConnectionParameters Parameters()=0
Returns the current connection parameters.
virtual async2::OnceReceiver< pw::Result< Channel::Ptr > > ConnectL2cap(ConnectL2capParameters parameters)=0
virtual async2::Poll< DisconnectReason > PendDisconnect(async2::Context &cx)=0
internal::RaiiPtr< Connection2, &Connection2::Release > Ptr
Definition: connection2.h:196
virtual async2::OnceReceiver< pw::expected< void, ConnectionParameterUpdateError > > RequestParameterUpdate(RequestedConnectionParameters parameters)=0
virtual async2::Poll< uint16_t > PendAttMtuChange(async2::Context &cx)=0
DisconnectReason
Possible reasons a connection was disconnected.
Definition: connection2.h:39
@ kConnectionTimeout
This usually indicates that the link supervision timeout expired.
ConnectionParameterUpdateError
Possible errors when updating the connection parameters.
Definition: connection2.h:32
SecurityRequirements security_requirements
Definition: connection2.h:144
uint16_t max_receive_packet_size
Maximum supported packet size for receiving.
Definition: connection2.h:140
Psm psm
The identifier of the service to connect to.
Definition: connection2.h:138
Represents parameters that are set on a per-connection basis.
Definition: connection2.h:109
std::optional< Uuid > service_filter
Definition: connection2.h:120
std::optional< RequestedConnectionParameters > parameters
Definition: connection2.h:124
std::optional< uint16_t > att_mtu
Definition: connection2.h:133
Actual connection parameters returned by the controller.
Definition: connection2.h:47
uint16_t supervision_timeout
Definition: connection2.h:68
The authentication an encryption requirements for a channel.
Definition: channel.h:30