Skip to main content

BleController

Struct BleController 

Source
pub struct BleController { /* private fields */ }
Expand description

A BLE HAP controller: holds the long-term controller identity used for pairing and verification.

Implementations§

Source§

impl BleController

Source

pub fn new(keypair: ControllerKeypair) -> Self

Create a controller from a long-term identity.

Source

pub fn generate(id: String) -> Self

Generate a fresh controller identity with the given pairing id.

Source

pub fn keypair(&self) -> &ControllerKeypair

The controller’s pairing identity.

Source

pub async fn pair( &self, gatt: Arc<dyn GattConnection>, _accessory: &DiscoveredBleAccessory, setup_code: &str, ) -> Result<Paired>

Pair with a discovered accessory: run Pair Setup, then Pair Verify, then build the attribute database. Returns a Paired containing the ready accessory handle, the persisted AccessoryPairing, and initial broadcast material.

§Errors

Propagates connection, pairing, and model errors.

Source

pub async fn connect( &self, gatt: Arc<dyn GattConnection>, pairing: &AccessoryPairing, broadcast: Option<BleBroadcastState>, ) -> Result<BleAccessory>

Connect to an already-paired accessory via Pair Verify, then build the DB.

broadcast is optional previously-persisted broadcast state. Its gsn seeds last_gsn so the accessory handle does not re-emit already-seen events after a restart. The key in broadcast is the previously-persisted one — Pair Verify derives a fresh per-session broadcast key, which becomes the accessory’s current key.

§NOTE

Decrypting pre-connect broadcasts with the persisted key (vs the fresh per-session key derived here) is a documented follow-up task — the fresh key covers forward broadcasts.

§Errors

Propagates connection, verify, and model errors.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.