Host-layer Bluetooth Low Energy APIs and utilities. Main docs: https://pigweed.dev/pw_bluetooth.
Typedefs | |
using | pw::bluetooth::gatt::RemoteService2::Ptr = internal::RaiiPtr< RemoteService2, &RemoteService2::Disconnect > |
using | pw::bluetooth::gatt::LocalService2::ValueChangedResult = pw::expected< void, Error > |
using | pw::bluetooth::gatt::LocalService2::Ptr = internal::RaiiPtr< LocalService2, &LocalService2::UnpublishService > |
using | pw::bluetooth::gatt::Server2::PublishServiceResult = pw::expected< LocalService2::Ptr, PublishServiceError > |
The Result passed by PublishService. | |
using | pw::bluetooth::low_energy::Central2::ScanHandle::Ptr = internal::RaiiPtr< ScanHandle, &ScanHandle::Release > |
using | pw::bluetooth::low_energy::Central2::ConnectResult = pw::expected< Connection2::Ptr, ConnectError > |
The result type returned by Connect(). | |
using | pw::bluetooth::low_energy::Central2::ScanStartResult = pw::expected< ScanHandle::Ptr, StartScanError > |
The result type returned by Scan(). | |
using | pw::bluetooth::low_energy::Channel::Ptr = internal::RaiiPtr< Channel, &Channel::Release > |
using | pw::bluetooth::low_energy::ChannelListener::Ptr = internal::RaiiPtr< ChannelListener, &ChannelListener::Release > |
using | pw::bluetooth::low_energy::Connection2::Ptr = internal::RaiiPtr< Connection2, &Connection2::Release > |
using | pw::bluetooth::low_energy::AdvertisedPeripheral2::Ptr = internal::RaiiPtr< AdvertisedPeripheral2, &AdvertisedPeripheral2::Release > |
using | pw::bluetooth::low_energy::Peripheral2::ScanResponse = AdvertisingData |
using | pw::bluetooth::low_energy::Peripheral2::ConnectionOptions = Connection2::ConnectionOptions |
using | pw::bluetooth::low_energy::Peripheral2::AdvertisingProcedure = std::variant< LegacyAdvertising, ExtendedAdvertising > |
using | pw::bluetooth::low_energy::Peripheral2::AdvertiseResult = pw::expected< AdvertisedPeripheral2::Ptr, AdvertiseError > |
Variables | |
Handle | pw::bluetooth::gatt::RemoteService2::ReadValue::handle |
Characteristic or descriptor handle. | |
multibuf::MultiBuf | pw::bluetooth::gatt::RemoteService2::ReadValue::value |
The value of the characteristic or descriptor. | |
bool | pw::bluetooth::gatt::RemoteService2::ReadValue::maybe_truncated |
Handle | pw::bluetooth::gatt::RemoteService2::ReadByTypeResult::handle |
Characteristic or descriptor handle. | |
pw::expected< ReadValue, Error > | pw::bluetooth::gatt::RemoteService2::ReadByTypeResult::result |
uint16_t | pw::bluetooth::gatt::RemoteService2::LongReadOptions::offset = 0 |
uint16_t | pw::bluetooth::gatt::RemoteService2::LongReadOptions::max_bytes = kMaxValueLength |
The maximum number of bytes to read. | |
WriteMode | pw::bluetooth::gatt::RemoteService2::WriteOptions::mode = WriteMode::kDefault |
uint16_t | pw::bluetooth::gatt::RemoteService2::WriteOptions::offset = 0 |
ServiceHandle | pw::bluetooth::gatt::Client2::RemoteServiceInfo::handle |
Uniquely identifies this GATT service. | |
bool | pw::bluetooth::gatt::Client2::RemoteServiceInfo::primary |
Indicates whether this is a primary or secondary service. | |
Uuid | pw::bluetooth::gatt::Client2::RemoteServiceInfo::type |
pw::span< const PeerId > | pw::bluetooth::gatt::LocalService2::ValueChangedParameters::peer_ids |
Handle | pw::bluetooth::gatt::LocalService2::ValueChangedParameters::handle |
The handle of the characteristic value being signaled. | |
multibuf::MultiBuf | pw::bluetooth::gatt::LocalService2::ValueChangedParameters::value |
The new value for the descriptor/characteristic. | |
ServiceHandle | pw::bluetooth::gatt::Server2::LocalServiceInfo::handle |
A unique (within a Server) handle identifying this service. | |
bool | pw::bluetooth::gatt::Server2::LocalServiceInfo::primary |
Indicates whether this is a primary or secondary service. | |
Uuid | pw::bluetooth::gatt::Server2::LocalServiceInfo::type |
span< const Characteristic2 > | pw::bluetooth::gatt::Server2::LocalServiceInfo::characteristics |
The characteristics of this service. | |
span< const ServiceHandle > | pw::bluetooth::gatt::Server2::LocalServiceInfo::includes |
std::optional< Uuid > | pw::bluetooth::low_energy::Central2::ScanFilter::service_uuid |
Filter based on advertised service UUID. | |
std::optional< Uuid > | pw::bluetooth::low_energy::Central2::ScanFilter::service_data_uuid |
Filter based on service data containing the given UUID. | |
std::optional< uint16_t > | pw::bluetooth::low_energy::Central2::ScanFilter::manufacturer_id |
std::optional< bool > | pw::bluetooth::low_energy::Central2::ScanFilter::connectable |
std::optional< std::string_view > | pw::bluetooth::low_energy::Central2::ScanFilter::name |
std::optional< int8_t > | pw::bluetooth::low_energy::Central2::ScanFilter::max_path_loss |
std::optional< Uuid > | pw::bluetooth::low_energy::Central2::ScanFilter::solicitation_uuid |
Require that a peer solicits support for a service UUID. | |
pw::span< const ScanFilter > | pw::bluetooth::low_energy::Central2::ScanOptions::filters |
uint16_t | pw::bluetooth::low_energy::Central2::ScanOptions::interval |
uint16_t | pw::bluetooth::low_energy::Central2::ScanOptions::window |
ScanType | pw::bluetooth::low_energy::Central2::ScanOptions::scan_type |
Phy | pw::bluetooth::low_energy::Central2::ScanOptions::phys = Phy::k1Megabit |
PeerId | pw::bluetooth::low_energy::Central2::ScanResult::peer_id |
Uniquely identifies this peer on the current system. | |
bool | pw::bluetooth::low_energy::Central2::ScanResult::connectable |
std::optional< uint8_t > | pw::bluetooth::low_energy::Central2::ScanResult::rssi |
pw::multibuf::MultiBuf | pw::bluetooth::low_energy::Central2::ScanResult::data |
This contains the advertising data last received from the peer. | |
std::optional< InlineString< 22 > > | pw::bluetooth::low_energy::Central2::ScanResult::name |
chrono::SystemClock::time_point | pw::bluetooth::low_energy::Central2::ScanResult::last_updated |
Timestamp of when the information in this ScanResult was last updated. | |
bool | pw::bluetooth::low_energy::SecurityRequirements::authentication_required |
bool | pw::bluetooth::low_energy::SecurityRequirements::secure_connections_required |
If true, the link must be encrypted with a Secure Connections key. | |
uint16_t | pw::bluetooth::low_energy::ChannelListenerRegistry::ListenParameters::max_receive_size |
Maximum supported payload size (SDU) for receiving. | |
SecurityRequirements | pw::bluetooth::low_energy::ChannelListenerRegistry::ListenParameters::security_requirements |
uint16_t | pw::bluetooth::low_energy::Connection2::ConnectionParameters::interval |
uint16_t | pw::bluetooth::low_energy::Connection2::ConnectionParameters::latency |
uint16_t | pw::bluetooth::low_energy::Connection2::ConnectionParameters::supervision_timeout |
uint16_t | pw::bluetooth::low_energy::Connection2::RequestedConnectionParameters::min_interval |
uint16_t | pw::bluetooth::low_energy::Connection2::RequestedConnectionParameters::max_interval |
uint16_t | pw::bluetooth::low_energy::Connection2::RequestedConnectionParameters::max_latency |
uint16_t | pw::bluetooth::low_energy::Connection2::RequestedConnectionParameters::supervision_timeout |
bool | pw::bluetooth::low_energy::Connection2::ConnectionOptions::bondable_mode = true |
std::optional< Uuid > | pw::bluetooth::low_energy::Connection2::ConnectionOptions::service_filter |
std::optional< RequestedConnectionParameters > | pw::bluetooth::low_energy::Connection2::ConnectionOptions::parameters |
std::optional< uint16_t > | pw::bluetooth::low_energy::Connection2::ConnectionOptions::att_mtu |
Psm | pw::bluetooth::low_energy::Connection2::ConnectL2capParameters::psm |
The identifier of the service to connect to. | |
uint16_t | pw::bluetooth::low_energy::Connection2::ConnectL2capParameters::max_receive_packet_size |
Maximum supported packet size for receiving. | |
SecurityRequirements | pw::bluetooth::low_energy::Connection2::ConnectL2capParameters::security_requirements |
uint16_t | pw::bluetooth::low_energy::Peripheral2::AdvertisingIntervalRange::min = 0x0800 |
Default: 1.28s. | |
uint16_t | pw::bluetooth::low_energy::Peripheral2::AdvertisingIntervalRange::max = 0x0800 |
Default: 1.28s. | |
std::optional< ScanResponse > | pw::bluetooth::low_energy::Peripheral2::LegacyAdvertising::scan_response |
See ScanResponse documentation. | |
std::optional< ConnectionOptions > | pw::bluetooth::low_energy::Peripheral2::LegacyAdvertising::connection_options |
See ConnectionOptions documentation. | |
std::variant< std::monostate, ScanResponse, ConnectionOptions, Anonymous > | pw::bluetooth::low_energy::Peripheral2::ExtendedAdvertising::configuration |
std::optional< int8_t > | pw::bluetooth::low_energy::Peripheral2::ExtendedAdvertising::tx_power |
Phy | pw::bluetooth::low_energy::Peripheral2::ExtendedAdvertising::primary_phy = Phy::k1Megabit |
Phy | pw::bluetooth::low_energy::Peripheral2::ExtendedAdvertising::secondary_phy = Phy::k1Megabit |
AdvertisingData | pw::bluetooth::low_energy::Peripheral2::AdvertisingParameters::data |
AdvertisingIntervalRange | pw::bluetooth::low_energy::Peripheral2::AdvertisingParameters::interval_range |
See AdvertisingIntervalRange documentation. | |
std::optional< Address::Type > | pw::bluetooth::low_energy::Peripheral2::AdvertisingParameters::address_type |
AdvertisingProcedure | pw::bluetooth::low_energy::Peripheral2::AdvertisingParameters::procedure |
If present, the controller will broadcast connectable advertisements which allow peers to initiate connections to the Peripheral. The fields of ConnectionOptions
will configure any connections set up from advertising.
using pw::bluetooth::gatt::RemoteService2::Ptr = internal::RaiiPtr<RemoteService2, &RemoteService2::Disconnect> |
Movable RemoteService2
smart pointer. The remote server will remain connected until the returned RemoteService2::Ptr
is destroyed.
using pw::bluetooth::gatt::LocalService2::Ptr = internal::RaiiPtr<LocalService2, &LocalService2::UnpublishService> |
Movable LocalService smart pointer. When the LocalService::Ptr object is destroyed the service will be unpublished.
using pw::bluetooth::low_energy::Central2::ScanHandle::Ptr = internal::RaiiPtr<ScanHandle, &ScanHandle::Release> |
Movable ScanHandle smart pointer. The controller will continue scanning until the ScanHandle::Ptr is destroyed.
using pw::bluetooth::low_energy::Connection2::Ptr = internal::RaiiPtr<Connection2, &Connection2::Release> |
Movable Connection2
smart pointer. When Connection::Ptr
is destroyed the Connection2
will disconnect automatically.
using pw::bluetooth::low_energy::AdvertisedPeripheral2::Ptr = internal::RaiiPtr<AdvertisedPeripheral2, &AdvertisedPeripheral2::Release> |
Movable AdvertisedPeripheral2
smart pointer. The peripheral will continue advertising until the returned AdvertisedPeripheral::Ptr
is destroyed.
using pw::bluetooth::low_energy::Peripheral2::ScanResponse = AdvertisingData |
The fields that are to be sent in a scan response packet. Clients may use this to send additional data that does not fit inside an advertising packet on platforms that do not support the advertising data length extensions.
If present, advertisements will be configured to be scannable.
using pw::bluetooth::gatt::LocalService2::ValueChangedResult = pw::expected<void, Error> |
The Result type for a ValueChanged indication or notification message. The error can be locally generated for notifications and either locally or remotely generated for indications.
|
strong |
Errors returned by Advertise
.
|
strong |
Possible errors returned by Connect
.
|
strong |
|
strong |
Bitmask of features the controller supports.
Enumerator | |
---|---|
kHciSco | Indicates support for transferring Synchronous Connection-Oriented (SCO) link data over the HCI. Offloaded SCO links may still be supported even if HCI SCO isn't. |
kSetAclPriorityCommand | Indicates support for the Set Acl Priority command. |
kAndroidVendorExtensions | Indicates support for the |
|
strong |
An identifier for a service that accepts connection-oriented channel connections. Referred to as a (simplified) protocol/service multiplexer in the Bluetooth specification.
|
strong |
|
strong |
|
strong |
|
strong |
|
strong |
Represents the supported write modes for writing characteristics & descriptors to the server.
|
pure virtual |
Start advertising continuously as a LE peripheral. If advertising cannot be initiated then result_callback
will be called with an error. Once started, advertising can be stopped by destroying the returned AdvertisedPeripheral::Ptr
.
If the system supports multiple advertising, this may be called as many times as there are advertising slots. To reconfigure an advertisement, first close the original advertisement and then initiate a new advertisement.
parameters | Parameters used while configuring the advertising instance. |
AdvertisedPeripheral2
that models the lifetime of the advertisement. Destroying it will stop advertising. Implemented in pw::bluetooth_sapphire::Peripheral.
|
pure virtual |
Returns the current ATT Maximum Transmission Unit. By subtracting ATT headers from the MTU, the maximum payload size of messages can be calculated.
|
pure virtual |
This notifies the current configuration of a particular characteristic/descriptor for a particular peer. It will be called when the peer GATT client changes the configuration.
The Bluetooth stack maintains the state of each peer's configuration across reconnections. As such, this method will be called with both notify
and indicate
set to false for each characteristic when a peer disconnects. Also, when a peer reconnects this method will be called again with the persisted state of the newly-connected peer's configuration. However, clients should not rely on this state being persisted indefinitely by the Bluetooth stack.
peer_id | The PeerId of the GATT client associated with this particular CCC. |
handle | The handle of the characteristic associated with the notify and indicate parameters. |
notify | True if the client has enabled notifications, false otherwise. |
indicate | True if the client has enabled indications, false otherwise. |
|
pure virtual |
Configure the HCI for a SCO connection with the indicated parameters.
|
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 |
Connect to an L2CAP LE connection-oriented channel.
parameters | The parameters to configure the channel with. |
Channel
that can be used to exchange data.
|
pure virtual |
Connects to a RemoteService2
. Only 1 connection per service is allowed.
handle | The handle of the service to connect to. |
handle
does not correspond to a known service.
|
privatepure virtual |
Disconnect from the remote service. This method is called by the ~RemoteServicePtr() when it goes out of scope, the API client should never call this method.
|
pure virtual |
Asynchronously sends the characteristics in this service, up to Vector::.max_size()
. May perform service discovery if the characteristics are not yet known.
|
pure virtual |
Subscribe to notifications & indications from the characteristic with the given handle
.
Either notifications or indications will be enabled depending on characteristic properties. Indications will be preferred if they are supported. This operation fails if the characteristic does not have the "notify" or "indicate" property.
A write request will be issued to configure the characteristic for notifications/indications if it contains a Client Characteristic Configuration (CCC) descriptor. This method fails if an error occurs while writing to the descriptor.
On success, PendNotification
will return Ready when the peer sends a notification or indication. Indications are automatically confirmed.
Subscriptions can be canceled with StopNotifications
.
handle | the handle of the characteristic to subscribe to. |
handle
is invalid.
|
pure virtual |
Encode the vendor-specific HCI command for a generic type of vendor command, and return the encoded command in a buffer.
parameters | Vendor command to encode. |
|
pure virtual |
Returns a GATT client to the connected peer that is valid for the lifetime of this Connection2
object. Connection2
is considered alive as long as PendDisconnect()
returns pending and the object hasn't been destroyed.
|
pure virtual |
pw::Result< size_t > pw::bluetooth::GetHciHeaderSize | ( | emboss::H4PacketType | type | ) |
Get the size of an Hci Header
type | H4 Packet Type |
embed:rst:leading-asterisk * * .. pw-status-codes:: * * OK: Size of the Hci header * * INVALID_ARGUMENT: An invalid type was provided * *
pw::Result< size_t > pw::bluetooth::GetHciPayloadSize | ( | emboss::H4PacketType | type, |
pw::span< const uint8_t > | hci_header | ||
) |
Get the size of an Hci Payload
type | H4 Packet Type |
hci_header | span holding at least a full header |
embed:rst:leading-asterisk * * .. pw-status-codes:: * * OK: Size of the Hci payload * * INVALID_ARGUMENT: An invalid type was provided * * OUT_OF_RANGE: The span was too small * *
|
pure virtual |
Sends an indication to peers. Indications should be used instead of notifications when the service does require peer confirmation of the update.
Indications should not be sent to peers which have not enabled indications on a particular characteristic. If they are sent, they will not be propagated and the result_sender
will be set to an error condition. The Bluetooth stack will track this configuration for the lifetime of the service.
If any of the peers in parameters.peer_ids
fails to confirm the indication within the ATT transaction timeout (30 seconds per Bluetooth 6.0 Vol. 3 Part F 3.3.3), the link between the peer and the local adapter will be closed.
The maximum size of the parameters.value
field depends on the MTU negotiated with the peer. A 3-byte header plus the value contents must fit in a packet of MTU bytes.
parameters | The parameters associated with the changed characteristic. |
parameters.peer_ids
have confirmed the indication, the result is returned. If the implementation wishes to receive indication confirmations on a per-peer basis, they should send this event with a single PeerId in parameters.peer_ids
. Additional values should not be indicated until this procedure completes.
|
pure virtual |
Initializes the controller interface and starts processing packets. Asynchronously returns the result of initialization.
On success, HCI packets may now be sent and received with this object.
|
pure virtual |
Register a listener for incoming channels. The registry will assign a protocol/service multiplexer value that is unique for the local device, as well as create a ChannelListener
for accepting incoming channels. In the unlikely event that all PSMs have been assigned, this call will fail with RESOURCE_EXHAUSTED
.
Note that the method of service discovery or advertising is defined by the service or protocol, so it is the responsibility of the caller to update the GATT database or other service discovery mechanism.
parameters | Parameters for the local side of the channel. |
ChannelListener
that can be used to receive new channels.
|
pure virtual |
Called when the MTU of a peer is updated. Also called for peers that are already connected when the server is published.
Notifications and indications must fit in a single packet including both the 3-byte notification/indication header and the user-provided payload. If these are not used, the MTU can be safely ignored as it is intended for use cases where the throughput needs to be optimized.
|
pure virtual |
Sends a notification to peers. Notifications should be used instead of indications when the service does not require peer confirmation of the update.
Notifications should not be sent to peers which have not enabled notifications on a particular characteristic or that have disconnected. If notifications are sent, they will not be propagated and the result_sender
will be set to an error condition. The Bluetooth stack will track this configuration for the lifetime of the service.
The maximum size of the parameters.value
field depends on the Maximum Transmission Unit (MTU) negotiated with the peer. A 3-byte header plus the value contents must fit in a packet of MTU bytes.
parameters | The parameters associated with the changed characteristic. |
parameters.peer_ids
. Additional values should not be notified until this notification completes.
|
pure virtual |
Called when there is a fatal error related to this service that forces the service to close. LocalServiceDelegate methods will no longer be called. This invalidates the associated LocalService. It is OK to destroy both LocalServiceDelegate
and the associated LocalService::Ptr
from within this method.
|
pure virtual |
Returns Pending until the ATT MTU changes, at which point cx
will be awoken. Returns Ready with the new ATT MTU once the ATT MTU has been changed. The ATT MTU can only be changed once.
|
pure virtual |
For connectable advertisements, this method returns Ready when an LE central connects to the advertisement.
The returned Connection2 can be used to interact with the peer. It also represents a peripheral's ownership over the connection: the client can drop the object to request a disconnection. Similarly, the Connection2 error handler is called by the system to indicate that the connection to the peer has been lost. While connections are exclusive among peripherals, they may be shared with centrals, preventing disconnections.
After a connection is returned, advertising will be paused until PendConnection()
is called again. This method may return multiple connections over the lifetime of an advertisement.
cx | Awoken when a connection is established. |
|
pure virtual |
Returns Ready after the peer disconnects or there is a connection error that caused a disconnection. Awakens cx
on disconnect.
|
pure virtual |
Returns Ready when fatal errors occur after initialization. After a fatal error, this object is invalid.
|
pure virtual |
Poll for an Error status on this service, waking cx
and returning Ready when there is an error condition. When an error condition is present, any previous RemoteService2
Waker
and OnceReceiver
instances may or may not be woken and all other methods will be no-ops. Only 1 waker can be set at a time (additional calls will replace the existing waker).
|
pure virtual |
After notifications have been enabled with EnableNotifications
, this method can be used to check for notifications. This method will safely return Pending when notifications are disabled.
handle | The handle of the characteristic to await for notifications. |
cx | The Context to awaken when a notification is available. Only one Waker per handle is supported at a time (subsequent calls will overwrite the old Waker). |
|
pure virtual |
Returns the next ScanResult
if available. Otherwise, invokes cx.waker()
when a ScanResult
is available. Only one waker is supported at a time.
embed:rst:leading-asterisk * * .. pw-status-codes:: * * OK: ScanResult was returned. * * CANCELLED: An internal error occurred and the scan was cancelled. * *
|
virtual |
Returns the handles of services that have been removed. Note that handles may be reused, so it is recommended to check for removed services before calling PendServiceUpdate
. This should be called repeatedly until Pending
is returned.
cx | Awoken when a service is removed after Pending is returned. |
|
virtual |
Enumerates existing services found on the peer that this object represents and notifies of modifications to services or new services thereafter. If service discovery hasn't happened yet, it may be started. To further interact with services, clients must obtain a RemoteService2
protocol by calling ConnectToService
.
Ready
with RemoteServiceInfo
when there are services that are updated/modified. This can can be called repeatedly until Pending
is returned to get all previously discovered services.
|
pure virtual |
Returns Ready when advertising has stopped due to a call to StopAdvertising()
or due to error. Awakens cx
on stopping.
embed:rst:leading-asterisk * * .. pw-status-codes:: * * OK: Advertising was stopped successfully after a call to * ``StopAdvertising()``. * * CANCELLED: An internal error occurred and the advertisement was * cancelled. * *
|
pure virtual |
Publishes the service defined by info
and implemented by delegate
so that it is available to all remote peers.
The caller must assign distinct handles to the characteristics and descriptors listed in info
per call to PublishService
(handles can be reused across calls). These identifiers will be used in requests sent to delegate
.
LocalService::Ptr
is returned via result_sender
. When the LocalService::Ptr
is destroyed or an error occurs (LocalServiceDelegate.OnError), the service will be unpublished.
|
pure virtual |
Reads characteristics and descriptors with the specified type. This method is useful for reading values before discovery has completed, thereby reducing latency.
uuid | The UUID of the characteristics/descriptors to read. |
This may fail with the following errors:
kInvalidParameters
: if uuid
refers to an internally reserved descriptor type (e.g. the Client Characteristic Configuration descriptor).kTooManyResults
: More results were read than can fit in the Vector. Consider reading characteristics/descriptors individually after performing discovery.kFailure
: The server returned an error not specific to a single result.
|
pure virtual |
Reads the value of a characteristic.
handle | The handle of the characteristic to be read. |
options | If null, a short read will be performed, which may be truncated to what fits in a single message (at least 22 bytes). If long read options are present, performs a long read with the indicated options. |
handle
is invalid.options
is invalid.
|
pure virtual |
Reads the value of the characteristic descriptor with handle
and returns it in the reply.
handle | The descriptor handle to read. |
options | Options that apply to the read. |
result_sender | Set to a result containing the value of the descriptor on success. |
kInvalidHandle | handle is invalid. |
kInvalidParameters | options is invalid. |
kReadNotPermitted | |
kInsufficient* | The server rejected the request. |
kApplicationError* | An application error was returned by the GATT profile. |
kFailure | The server returned an error not covered by the above errors. |
|
pure virtual |
Called when a peer requests to read the value of a characteristic or descriptor. It is guaranteed that the peer satisfies the permissions associated with this attribute.
peer_id | The PeerId of the GATT client making the read request. |
handle | The handle of the requested descriptor/characteristic. |
offset | The offset at which to start reading the requested value. |
|
privatepure virtual |
Stop the current scan. This method is called by the ~ScanHandlePtr() when it goes out of scope, the API client should never call this method.
|
privatepure virtual |
Custom deleter called when ChannelListener::Ptr
is destroyed. The implementation should free or clean up the memory used by this object. This enables the use of smart pointer semantics while leaving memory management up to the implementation. Calling the virtual destructor or not is up to the implementation.
|
privatepure virtual |
Request to destroy this connection. This method is called by the ~Connection2Ptr() when it goes out of scope, the API client should never call this method.
|
privatepure virtual |
Stop advertising and release memory. This method is called by the ~AdvertisedPeripheralPtr() when it goes out of scope, the API client should never call this method.
|
pure virtual |
Requests an update to the connection parameters.
|
pure virtual |
Releases the resources held by an active SCO connection. This should be called when a SCO connection is closed. No-op if no SCO connection is configured.
|
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.
|
pure virtual |
Requests that advertising be stopped. PendStop()
can be used to wait for advertising to stop (e.g. before starting another advertisement). Destroying this object will also stop advertising, but there will be no way to determine when advertising has stopped. This method is idempotent.
|
pure virtual |
Stops notifications for the characteristic with the given handle
.
handle
is invalid.
|
privatepure virtual |
Unpublish the local service. This method is called by the ~LocalServicePtr() when it goes out of scope, the API client should never call this method.
|
pure virtual |
Writes value
to the characteristic with handle
using the provided options
.
handle | Handle of the characteristic to be written to |
value | The value to be written. |
options | Options that apply to the write. |
handle
is invalid.
|
pure virtual |
Writes value
to the descriptor with handle
using the provided. It is not recommended to send additional writes while a write is already in progress.
handle | Handle of the descriptor to be written to. |
value | The value to be written. |
handle
is invalid.
|
pure virtual |
Called when a peer issues a request to write the value of a characteristic or descriptor. It is guaranteed that the peer satisfies the permissions associated with this attribute.
peer_id | The PeerId of the GATT client making the write request. |
handle | The handle of the requested descriptor/characteristic. |
offset | The offset at which to start writing the requested value. If the offset is 0, any existing value should be overwritten by the new value. Otherwise, the existing value between offset:(offset + len(value)) should be changed to value . |
value | The new value for the descriptor/characteristic. |
|
virtualdefault |
If a disconnection has not occurred, destroying this object will result in disconnection.
std::optional<Address::Type> pw::bluetooth::low_energy::Peripheral2::AdvertisingParameters::address_type |
The type of address to include in advertising packets. If null, the host stack will select an address type. If the address type could not be used (either because of controller error or host configuration), a kFailed
error wil be returned.
std::optional<uint16_t> pw::bluetooth::low_energy::Connection2::ConnectionOptions::att_mtu |
When present, specifies the ATT MTU to request. The actual MTU used may be smaller depending on peer and controller support. If none is specified, the host implementation will select the ATT MTU. Note that an MTU of 247 is the largest that can fit into a single LE data packet with the Data Length Extension.
bool pw::bluetooth::low_energy::SecurityRequirements::authentication_required |
If true, the link must be authenticated with on-path attacker protection. If false, authentication is not required.
bool pw::bluetooth::low_energy::Connection2::ConnectionOptions::bondable_mode = true |
When true, the connection operates in bondable mode. This means pairing will form a bond, or persist across disconnections, if the peer is also in bondable mode. When false, the connection operates in non-bondable mode, which means the local device only allows pairing that does not form a bond.
std::variant<std::monostate, ScanResponse, ConnectionOptions, Anonymous> pw::bluetooth::low_energy::Peripheral2::ExtendedAdvertising::configuration |
Extended advertisements can have a scan response, be connectable, be anonymous, or none of the above. See ScanResponse
, ConnectionOptions
, and Anonymous
documentation.
std::optional<bool> pw::bluetooth::low_energy::Central2::ScanFilter::connectable |
Filter based on whether or not a device is connectable. For example, a client that is only interested in peripherals that it can connect to can set this to true. Similarly a client can scan only for broadcasters by setting this to false.
bool pw::bluetooth::low_energy::Central2::ScanResult::connectable |
Whether or not this peer is connectable. Non-connectable peers are typically in the LE broadcaster role.
AdvertisingData pw::bluetooth::low_energy::Peripheral2::AdvertisingParameters::data |
The fields that will be encoded in the data section of advertising packets.
pw::span<const ScanFilter> pw::bluetooth::low_energy::Central2::ScanOptions::filters |
List of filters for use during a scan. A peripheral that satisfies any of these filters will be reported. At least 1 filter must be specified. While not recommended, clients that require that all peripherals be reported can specify an empty filter. The span memory must only be valid until the call to Scan() ends.
span<const ServiceHandle> pw::bluetooth::gatt::Server2::LocalServiceInfo::includes |
Handles of other services that are included by this service. The included services need to already be published.
uint16_t pw::bluetooth::low_energy::Central2::ScanOptions::interval |
The time interval between scans.
uint16_t pw::bluetooth::low_energy::Connection2::ConnectionParameters::interval |
The connection interval indicates the frequency of link layer connection events over which data channel PDUs can be transmitted. See Core Spec v6, Vol 6, Part B, Section 4.5.1 for more information on the link layer connection events.
uint16_t pw::bluetooth::low_energy::Connection2::ConnectionParameters::latency |
The maximum allowed peripheral connection latency in number of connection events. See Core Spec v5, Vol 6, Part B, Section 4.5.1.
std::optional<uint16_t> pw::bluetooth::low_energy::Central2::ScanFilter::manufacturer_id |
Filter based on a manufacturer identifier present in the manufacturer data. If this filter parameter is set, then the advertising payload must contain manufacturer-specific data with the provided company identifier to satisfy this filter. Manufacturer identifiers can be found at Assigned Numbers.
uint16_t pw::bluetooth::low_energy::Connection2::RequestedConnectionParameters::max_interval |
Maximum value for the connection interval. This shall be greater than or equal to min_interval
. The connection interval indicates the frequency of link layer connection events over which data channel PDUs can be transmitted. See Core Spec v6, Vol 6, Part B, Section 4.5.1 for more information on the link layer connection events.
uint16_t pw::bluetooth::low_energy::Connection2::RequestedConnectionParameters::max_latency |
Maximum peripheral latency for the connection in number of connection events. See Core Spec v6, Vol 6, Part B, Section 4.5.1.
std::optional<int8_t> pw::bluetooth::low_energy::Central2::ScanFilter::max_path_loss |
Filter results based on the path loss of the radio wave. A device that matches this filter must satisfy the following:
max_path_loss
.bool pw::bluetooth::gatt::RemoteService2::ReadValue::maybe_truncated |
True if value
might be truncated (the buffer was completely filled by the server and the read was a short read). ReadCharacteristic
or ReadDescriptor
should be used to read the complete value.
uint16_t pw::bluetooth::low_energy::Connection2::RequestedConnectionParameters::min_interval |
Minimum value for the connection interval. This shall be less than or equal to max_interval
. The connection interval indicates the frequency of link layer connection events over which data channel PDUs can be transmitted. See Core Spec v6, Vol 6, Part B, Section 4.5.1 for more information on the link layer connection events.
WriteMode pw::bluetooth::gatt::RemoteService2::WriteOptions::mode = WriteMode::kDefault |
The mode of the write operation. For descriptors, only WriteMode::kDefault
is supported
std::optional<std::string_view> pw::bluetooth::low_energy::Central2::ScanFilter::name |
Filter results based on a portion of the advertised device name. Substring matches are allowed. The name length must be at most pw::bluetooth::kMaxDeviceNameLength
.
std::optional<InlineString<22> > pw::bluetooth::low_energy::Central2::ScanResult::name |
The name of this peer. The name is often obtained during a scan procedure and can get updated during the name discovery procedure following a connection.
This field is present if the name is known.
uint16_t pw::bluetooth::gatt::RemoteService2::LongReadOptions::offset = 0 |
The byte to start the read at. Must be less than the length of the value.
uint16_t pw::bluetooth::gatt::RemoteService2::WriteOptions::offset = 0 |
Request a write starting at the byte indicated. Must be 0 if mode
is WriteMode.kWithoutResponse
.
std::optional<RequestedConnectionParameters> pw::bluetooth::low_energy::Connection2::ConnectionOptions::parameters |
When present, specifies the initial connection parameters. Otherwise, the connection parameters will be selected by the implementation.
pw::span<const PeerId> pw::bluetooth::gatt::LocalService2::ValueChangedParameters::peer_ids |
The peers peers to signal. The LocalService should respect the Characteristic Configuration associated with a peer+handle when deciding whether to signal it. If empty, all peers which configured the handle are signalled.
Phy pw::bluetooth::low_energy::Central2::ScanOptions::phys = Phy::k1Megabit |
A bitmask of the PHYs to scan with. Only the 1Megabit and LeCoded PHYs are supported.
Phy pw::bluetooth::low_energy::Peripheral2::ExtendedAdvertising::primary_phy = Phy::k1Megabit |
The primary physical layer configuration to advertise with. Can only be 1Megabit or LeCoded PHY. If the PHY is not supported, a kNotSupported
error will be returned.
AdvertisingProcedure pw::bluetooth::low_energy::Peripheral2::AdvertisingParameters::procedure |
Specifies the advertising procedure to use and the parameters specific to that procedure.
pw::expected<ReadValue, Error> pw::bluetooth::gatt::RemoteService2::ReadByTypeResult::result |
The value of the characteristic or descriptor, if it was read successfully, or an error explaining why the value could not be read.
std::optional<uint8_t> pw::bluetooth::low_energy::Central2::ScanResult::rssi |
The last observed signal strength of this peer. This field is only present for a peer that is broadcasting. The RSSI can be stale if the peer has not been advertising.
ScanType pw::bluetooth::low_energy::Central2::ScanOptions::scan_type |
Specifies whether to send scan requests, and if so, what type of address to use in scan requests.
Phy pw::bluetooth::low_energy::Peripheral2::ExtendedAdvertising::secondary_phy = Phy::k1Megabit |
The secondary physical layer configuration to advertise with. Can be any PHY. If the PHY is not supported, a kNotSupported
error will be returned.
SecurityRequirements pw::bluetooth::low_energy::ChannelListenerRegistry::ListenParameters::security_requirements |
The security requirements that must be met before data is exchanged on the channel. If the requirements cannot be met, channel establishment will fail.
SecurityRequirements pw::bluetooth::low_energy::Connection2::ConnectL2capParameters::security_requirements |
The security requirements that must be met before data is exchanged on the channel. If the requirements cannot be met, channel establishment will fail.
std::optional<Uuid> pw::bluetooth::low_energy::Connection2::ConnectionOptions::service_filter |
When present, service discovery performed following the connection is restricted to primary services that match this field. Otherwise, by default all available services are discovered.
uint16_t pw::bluetooth::low_energy::Connection2::ConnectionParameters::supervision_timeout |
This defines the maximum time between two received data packet PDUs before the connection is considered lost. See Core Spec v6, Vol 6, Part B, Section 4.5.2.
uint16_t pw::bluetooth::low_energy::Connection2::RequestedConnectionParameters::supervision_timeout |
This defines the maximum time between two received data packet PDUs before the connection is considered lost. See Core Spec v6, Vol 6, Part B, Section 4.5.2.
std::optional<int8_t> pw::bluetooth::low_energy::Peripheral2::ExtendedAdvertising::tx_power |
The maximum power level to transmit with. Null indicates no preference. Range: -127 to +20 Units: dBm
Uuid pw::bluetooth::gatt::Client2::RemoteServiceInfo::type |
The UUID that identifies the type of this service. There may be multiple services with the same UUID.
Uuid pw::bluetooth::gatt::Server2::LocalServiceInfo::type |
The UUID that identifies the type of this service. There may be multiple services with the same UUID.
uint16_t pw::bluetooth::low_energy::Central2::ScanOptions::window |
The duration of the scan. The window must be less than or equal to the interval.