pub struct Peripheral { /* private fields */ }Expand description
A local GATT server, published through bluetoothd.
Implementations§
Source§impl Peripheral
impl Peripheral
Sourcepub fn new() -> (Self, Requests)
pub fn new() -> (Self, Requests)
Open the peripheral role, returning the handle and its request stream.
Sourcepub fn with_restoration(_restoration: Restoration) -> (Self, Requests)
pub fn with_restoration(_restoration: Restoration) -> (Self, Requests)
Linux has no state restoration; this is Peripheral::new.
Sourcepub async fn availability(&self) -> Result<(), Availability>
pub async fn availability(&self) -> Result<(), Availability>
Why the peripheral role is not usable, if it is not.
Sourcepub async fn publish(&self, service: Service) -> Result<PublishedService>
pub async fn publish(&self, service: Service) -> Result<PublishedService>
Publish a service into the local GATT database.
The first call registers the application with BlueZ; later ones
re-register it, because GattManager1 has no way to add a service to an
application it has already walked.
Sourcepub fn unpublish_all(&self)
pub fn unpublish_all(&self)
Withdraw every published service.
Sourcepub async fn start_advertising(&self, advertising: Advertising) -> Result<()>
pub async fn start_advertising(&self, advertising: Advertising) -> Result<()>
Start advertising.
Sourcepub fn stop_advertising(&self)
pub fn stop_advertising(&self)
Stop advertising.
pub fn is_advertising(&self) -> bool
Sourcepub async fn publish_l2cap_channel(
&self,
encryption_required: bool,
) -> Result<Psm>
pub async fn publish_l2cap_channel( &self, encryption_required: bool, ) -> Result<Psm>
Listen for LE connection-oriented channels on a PSM the kernel picks.
BlueZ has no D-Bus API for this, so it is an L2CAP socket of our own
(AF_BLUETOOTH/BTPROTO_L2CAP, SOCK_SEQPACKET, LE public address),
which the kernel serves alongside bluetoothd’s GATT. Each central that
opens the PSM arrives as Request::ChannelOpened. Tell centrals the
PSM yourself, typically in a readable characteristic (Apple’s
convention, ABDD3056-28FA-441D-A470-55A75A52553A).
pub async fn unpublish_l2cap_channel(&self, psm: Psm) -> Result<()>
Sourcepub async fn restored_state(&self) -> Option<RestoredPeripheral>
pub async fn restored_state(&self) -> Option<RestoredPeripheral>
Linux preserves nothing across a relaunch.