Unosquare
    Show / Hide Table of Contents

    Class Bluetooth

    Represents the Bluetooth information.

    Inheritance
    Object
    Bluetooth
    Namespace: Unosquare.RaspberryIO.Computer
    Syntax
    public class Bluetooth : SingletonBase<Bluetooth>

    Methods

    Connect(String, String, CancellationToken)

    Performs a connection of a given controller with a given device.

    Declaration
    public Task<bool> Connect(string controllerAddress, string deviceAddress, CancellationToken cancellationToken = default(CancellationToken))
    Parameters
    Type Name Description
    String controllerAddress

    The mac address of the controller that will be used to make the connection.

    String deviceAddress

    The mac address of the device that will be connected.

    CancellationToken cancellationToken

    The cancellation token.

    Returns
    Type Description
    Task<Boolean>

    Returns true or false if the connection was successfully.

    Exceptions
    Type Condition
    BluetoothErrorException

    Failed to connect:.

    DeviceInfo(String, CancellationToken)

    Displays information about a particular device.

    Declaration
    public Task<string> DeviceInfo(string deviceAddress, CancellationToken cancellationToken = default(CancellationToken))
    Parameters
    Type Name Description
    String deviceAddress

    The mac address of the device which info will be retrieved.

    CancellationToken cancellationToken

    The cancellation token.

    Returns
    Type Description
    Task<String>

    Returns the device info.

    Exceptions
    Type Condition
    BluetoothErrorException

    Failed to retrieve info for {deviceAddress}.

    ListControllers(CancellationToken)

    Gets the list of bluetooth controllers.

    Declaration
    public Task<IEnumerable<string>> ListControllers(CancellationToken cancellationToken = default(CancellationToken))
    Parameters
    Type Name Description
    CancellationToken cancellationToken

    The cancellation token.

    Returns
    Type Description
    Task<IEnumerable<String>>

    Returns the list of bluetooth controllers.

    Exceptions
    Type Condition
    BluetoothErrorException

    Failed to retrieve controllers:.

    ListDevices(CancellationToken)

    Gets the list of detected devices.

    Declaration
    public Task<IEnumerable<string>> ListDevices(CancellationToken cancellationToken = default(CancellationToken))
    Parameters
    Type Name Description
    CancellationToken cancellationToken

    The cancellation token.

    Returns
    Type Description
    Task<IEnumerable<String>>

    Returns the list of detected devices.

    Exceptions
    Type Condition
    BluetoothErrorException

    Failed to retrieve devices:.

    Pair(String, String, CancellationToken)

    Pairs a specific device with a specific controller.

    Declaration
    public Task<bool> Pair(string controllerAddress, string deviceAddress, CancellationToken cancellationToken = default(CancellationToken))
    Parameters
    Type Name Description
    String controllerAddress

    The mac address of the controller that will be used to pair.

    String deviceAddress

    The mac address of the device that will be paired.

    CancellationToken cancellationToken

    The cancellation token.

    Returns
    Type Description
    Task<Boolean>

    Returns true or false if the pair was successfully.

    Exceptions
    Type Condition
    BluetoothErrorException

    Failed to Pair:.

    PowerOff(CancellationToken)

    Turns off the bluetooth adapter.

    Declaration
    public Task<bool> PowerOff(CancellationToken cancellationToken = default(CancellationToken))
    Parameters
    Type Name Description
    CancellationToken cancellationToken

    The cancellation token.

    Returns
    Type Description
    Task<Boolean>

    Returns true or false depending if the controller was turned off.

    Exceptions
    Type Condition
    BluetoothErrorException

    Failed to power off:.

    PowerOn(CancellationToken)

    Turns on the Bluetooth adapter.

    Declaration
    public Task<bool> PowerOn(CancellationToken cancellationToken = default(CancellationToken))
    Parameters
    Type Name Description
    CancellationToken cancellationToken

    The cancellation token.

    Returns
    Type Description
    Task<Boolean>

    Returns true or false depending if the controller was turned on.

    Exceptions
    Type Condition
    BluetoothErrorException

    Failed to power on:.

    Trust(String, String, CancellationToken)

    Sets the device to re-pair automatically when it is turned on, which eliminates the need to pair all over again.

    Declaration
    public Task<bool> Trust(string controllerAddress, string deviceAddress, CancellationToken cancellationToken = default(CancellationToken))
    Parameters
    Type Name Description
    String controllerAddress

    The mac address of the controller will be used.

    String deviceAddress

    The mac address of the device will be added to the trust list devices.

    CancellationToken cancellationToken

    The cancellation token.

    Returns
    Type Description
    Task<Boolean>

    Returns true or false if the operation was successful.

    Exceptions
    Type Condition
    BluetoothErrorException

    Failed to add to trust devices list:.

    Comments

    Back to top Copyright © 2017-2019 Unosquare