Must only be constructed and destroyed on the Bluetooth thread. More...
#include <central.h>
Public Member Functions | |
Central (bt::gap::Adapter::WeakPtr adapter, pw::async::Dispatcher &dispatcher, pw::multibuf::MultiBufAllocator &allocator) | |
async2::OnceReceiver< ConnectResult > | Connect (pw::bluetooth::PeerId peer_id, bluetooth::low_energy::Connection2::ConnectionOptions options) override |
async2::OnceReceiver< ScanStartResult > | Scan (const ScanOptions &options) override |
![]() | |
virtual async2::OnceReceiver< ConnectResult > | Connect (PeerId peer_id, Connection2::ConnectionOptions options)=0 |
virtual async2::OnceReceiver< ScanStartResult > | Scan (const ScanOptions &options)=0 |
Static Public Member Functions | |
static pw::sync::Mutex & | lock () |
Static Public Attributes | |
static constexpr uint8_t | kMaxScanResultsQueueSize = 10 |
Additional Inherited Members | |
![]() | |
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(). | |
Must only be constructed and destroyed on the Bluetooth thread.
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.
allocator | The allocator to use for advertising data buffers. |
|
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.
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. Implements pw::bluetooth::low_energy::Central2.