Represents the LE central role. Used to scan and connect to peripherals. More...
#include <central2.h>
Classes | |
struct | ScanFilter |
class | ScanHandle |
Represents an ongoing LE scan. More... | |
struct | ScanOptions |
Parameters used during a scan. More... | |
struct | ScanResult |
Public Types | |
enum class | ScanType : uint8_t { kPassive , kActiveUsePublicAddress , kActiveUseRandomAddress , kActiveUseResolvablePrivateAddress } |
enum class | ConnectError : uint8_t { kUnknownPeer , kInvalidOptions , kAlreadyExists , kCouldNotBeEstablished } |
Possible errors returned by Connect . More... | |
enum class | StartScanError : uint8_t { kScanInProgress , kInvalidParameters , kInternal } |
using | ConnectResult = pw::expected< Connection2::Ptr, ConnectError > |
The result type returned by Connect(). | |
using | ScanStartResult = pw::expected< ScanHandle::Ptr, StartScanError > |
The result type returned by Scan(). | |
Public Member Functions | |
virtual async2::OnceReceiver< ConnectResult > | Connect (PeerId peer_id, Connection2::ConnectionOptions options)=0 |
virtual async2::OnceReceiver< ScanStartResult > | Scan (const ScanOptions &options)=0 |
Represents the LE central role. Used to scan and connect to peripherals.
|
strong |
Possible errors returned by Connect
.
|
strong |
|
strong |
|
pure virtual |
Connect to the peer with the given identifier.
The returned Connection2
represents the client's interest in the LE connection to the peer. Destroying all Connection2
instances for a peer will disconnect from the peer.
The Connection
will be closed by the system if the connection to the peer is lost or an error occurs, as indicated by Connection.OnError
.
peer_id | Identifier of the peer to initiate a connection to. |
options | Options used to configure the connection. |
Possible errors are documented in ConnectError
.
|
pure virtual |
Scans for nearby LE peripherals and broadcasters. The lifetime of the scan session is tied to the returned ScanHandle
object in ScanStartResult
. Once a scan is started, ScanHandle::PendResult
can be called to get scan results. Only 1 scan may be active at a time.
options | Options used to configure the scan session. These options are suggestions only, and the implementation may use different parameters to meet power or radio requirements. |
ScanHandle
object if the scan successfully starts, or a ScanError
otherwise. ScanHandle::PendResult
can be called to get ScanResult
s for LE peers that satisfy the filters indicated in options
. The initial results may report recently discovered peers. Subsequent results will be reported only when peers have been scanned or updated since the last call. Implemented in pw::bluetooth_sapphire::Central.