[][src]Struct rustable::Bluetooth

pub struct Bluetooth {
    pub verbose: u8,
    pub filter_dest: Option<String>,
    // some fields omitted
}

Bluetooth is created to interact with Bluez over DBus and file descriptors.

Fields

verbose: u8filter_dest: Option<String>

Implementations

impl Bluetooth[src]

pub fn new(dbus_name: &str, blue_path: String) -> Result<Self, Error>[src]

Creates a new Bluetooth and setup a DBus client to interact with Bluez.

pub fn get_path(&self) -> &Path[src]

Gets the path of the DBus client

pub fn add_service(&mut self, service: LocalServiceBase) -> Result<(), Error>[src]

Adds a service to the Bluetooth instance. Once registered with register_application(), this service will be a local service that can be interacted with by remote devices.

If register_application() has already called, the service will not be visible to Bluez (or other devices) until the application in reregistered.

pub fn get_service<T: ToUUID>(&mut self, uuid: T) -> Option<LocalService>[src]

Access a service that has been added to the Bluetooth instance.

pub fn get_device<'c>(&'c mut self, mac: &MAC) -> Option<RemoteDevice<'c>>[src]

Gets a remote device by MAC. The device must be discovered using discover_devices() from bluez, before it can be gotten with this device.

pub fn devices(&self) -> HashSet<MAC>[src]

Gets a HashSet of known devices' MAC addresses.

pub fn start_adv(&mut self, adv: Advertisement) -> Result<u16, (u16, Error)>[src]

Registers an advertisement with Bluez. After a successful call, it will persist until the remove_advertise()/remove_advertise_no_dbus() is called or Bluez releases the advertisement (this is typically done on device connect).

Calls process_requests()

pub fn is_adv_active(&self, index: u16) -> Option<bool>[src]

Checks if an advertisement is still active, or if Bluez has signaled it has ended.

pub fn restart_adv(&mut self, index: u16) -> Result<bool, Error>[src]

Restart an inactive advertisement.

If the advertisement is already active this method, does nothing and returns false. If an advertisement is not active it tries to reregister the advertisement and returns true on success otherwise it returns and Err.

pub fn remove_adv(&mut self, index: u16) -> Result<Advertisement, Error>[src]

Unregisters an advertisement with Bluez. Returns the Advertisement if successful.

Calls process_requests()

pub fn remove_adv_no_dbus(&mut self, index: u16) -> Option<Advertisement>[src]

Removes the advertisement from the Bluetooth instance but does not unregister the advertisement with Bluez. It is recommended that this is not used.

pub fn set_discoverable(&mut self, on: bool) -> Result<(), Error>[src]

Set whether the Bluez controller should be discoverable (true) or not.

Calls process_requests()

pub fn set_power(&mut self, on: bool) -> Result<(), Error>[src]

Set the Bluez controller power on (true) or off.

Calls process_requests()

pub fn register_application(&mut self) -> Result<(), Error>[src]

Registers the local application's GATT services/characteristics (TODO: descriptors) with the Bluez controller.

Calls process_requests()

pub fn unregister_application(&mut self) -> Result<(), Error>[src]

Unimplemented

Unregisters the local GATT services from the Bluez controller.

Calls process_requests()

pub fn process_requests(&mut self) -> Result<(), Error>[src]

Process incoming DBus requests for the local application.

When using Bluetooth this function should be called on a regular basis. Bluez uses DBus to handle read/write requests to characteristics and descriptors, as wells advertisement. Failure to call this method frequently enough could result in requests from GATT clients to timeout. Some other functions are guaranteed to call this function at least once while waiting for a responses from the Bluez controller. This property is noted in these functions' descriptions.

pub fn clear_devices(&mut self)[src]

pub fn discover_devices(&mut self) -> Result<HashSet<MAC>, Error>[src]

Used to get devices devices known to Bluez. This function does not trigger scan/discovery on the Bluez controller. Use set_scan() to initiate actual device discovery.

Calls process_requests()

pub fn discover_device(&mut self, mac: &MAC) -> Result<(), Error>[src]

Get a device from the Bluez controller.

Calls process_requests()

Trait Implementations

impl<'a, 'b: 'a, 'c: 'a> Device<'a> for Bluetooth[src]

type ServiceBase = LocalServiceBase

type ServiceType = LocalService<'a>

Auto Trait Implementations

impl !RefUnwindSafe for Bluetooth

impl !Send for Bluetooth

impl !Sync for Bluetooth

impl Unpin for Bluetooth

impl !UnwindSafe for Bluetooth

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.