Reference#

pw_bluetooth_sapphire: Battle-tested Bluetooth with rock-solid reliability

C++ API reference#

class Peripheral : public pw::bluetooth::low_energy::Peripheral2#

Must only be constructed and destroyed on the Bluetooth thread.

Public Functions

Peripheral(bt::gap::Adapter::WeakPtr adapter, pw::async::Dispatcher &dispatcher)#

Must only be constructed on the Bluetooth thread.

~Peripheral() override#

Must only be destroyed on the Bluetooth thread.

virtual async2::OnceReceiver<AdvertiseResult> Advertise(const AdvertisingParameters &parameters) override#

Thread safe. The AdvertisedPeripheral2 returned on success is thread safe.

class Central : public pw::bluetooth::low_energy::Central2#

Must only be constructed and destroyed on the Bluetooth thread.

Public Functions

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

Must only be constructed on the Bluetooth thread.

Parameters:

allocator – The allocator to use for advertising data buffers.

virtual async2::OnceReceiver<ScanStartResult> Scan(ScanOptions options) override#

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:

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.

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.