Pigweed
 
Loading...
Searching...
No Matches
pw::bluetooth_sapphire::Central Class Referencefinal

Must only be constructed and destroyed on the Bluetooth thread. More...

#include <central.h>

Inheritance diagram for pw::bluetooth_sapphire::Central:
pw::bluetooth::low_energy::Central2

Public Member Functions

 Central (bt::gap::Adapter::WeakPtr adapter, pw::async::Dispatcher &dispatcher, pw::multibuf::MultiBufAllocator &allocator)
 
async2::OnceReceiver< ConnectResultConnect (pw::bluetooth::PeerId peer_id, bluetooth::low_energy::Connection2::ConnectionOptions options) override
 
async2::OnceReceiver< ScanStartResultScan (const ScanOptions &options) override
 
- Public Member Functions inherited from pw::bluetooth::low_energy::Central2
virtual async2::OnceReceiver< ConnectResultConnect (PeerId peer_id, Connection2::ConnectionOptions options)=0
 
virtual async2::OnceReceiver< ScanStartResultScan (const ScanOptions &options)=0
 

Static Public Member Functions

static pw::sync::Mutexlock ()
 

Static Public Attributes

static constexpr uint8_t kMaxScanResultsQueueSize = 10
 

Additional Inherited Members

- Public Types inherited from pw::bluetooth::low_energy::Central2
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().
 

Detailed Description

Must only be constructed and destroyed on the Bluetooth thread.

Constructor & Destructor Documentation

◆ Central()

pw::bluetooth_sapphire::Central::Central ( bt::gap::Adapter::WeakPtr  adapter,
pw::async::Dispatcher dispatcher,
pw::multibuf::MultiBufAllocator allocator 
)

Must only be constructed on the Bluetooth thread.

Parameters
allocatorThe allocator to use for advertising data buffers.

Member Function Documentation

◆ Scan()

async2::OnceReceiver< ScanStartResult > pw::bluetooth_sapphire::Central::Scan ( const ScanOptions options)
overridevirtual

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.

Parameters
optionsOptions used to configure the scan session. These options are suggestions only, and the implementation may use different parameters to meet power or radio requirements.
Returns
Returns a ScanHandle object if the scan successfully starts, or a ScanError otherwise. ScanHandle::PendResult can be called to get ScanResults 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.

Implements pw::bluetooth::low_energy::Central2.


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