it.gerdavax.android.bluetooth
Interface RemoteBluetoothDevice

All Superinterfaces:
BluetoothDevice

public interface RemoteBluetoothDevice
extends BluetoothDevice

Interface for managing a remote Bluetooth device and RFComm connections. RemoteBluetoothDevice instances are created and managed by the unique LocalBluetoothDevice instance.

Device name, address and class can be retrieved without connecting to the device. Before opening a BluetoothSocket for RFComm serial connection over Bluetooth, the RemoteBluetoothDevice has to be paired by invoking the pair() method. Pairing is an asynchronous process, therefore this method returns immediately. To get notifications on pairing process, a class implementing the RemoteBluetoothDeviceListener interface has to be registered as listener to this instance. Pairing may require to type a PIN number: if remote device asks for that, a message will appear on the notification area of the handset (the listener will receive an event on the method pinRequested() : once the user has typed the PIN, the listener will get a paired() event that notifies that device is connected and that BluetoothSocket instances can be created.

Author:
Stefano Sanna - gerdavax@gmail.com - http://www.gerdavax.it

Nested Class Summary
 
Nested classes/interfaces inherited from interface it.gerdavax.android.bluetooth.BluetoothDevice
BluetoothDevice.BluetoothClasses, BluetoothDevice.BluetoothProfiles, BluetoothDevice.BluetoothProtocols
 
Method Summary
 java.lang.String getAddress()
          Gets the BD Address of this device.
 int getDeviceClass()
          Gets the device class (see Bluetooth Protocol Specification)
 int getDeviceMajorClass()
          Gets the device major class (see Bluetooth Protocol Specification)
 int getDeviceMinorClass()
          Gets the device minor class (see Bluetooth Protocol Specification)
 void getRemoteServiceChannel(int uuid16)
           
 short getRSSI()
          Gets the signal strenght (Received Signal Strength Indicator) of this device
 int getServiceMajorClass()
          Gets the service major class of this device (see Bluetooth Protocol Specification)
 boolean isPaired()
          Gets the paired status of this device
 BluetoothSocket openSocket(int port)
          Opens a BluetoothSocket (RFComm) to this device on assigned port.
 void pair()
          Attempts to pair this remote device.
 void pair(java.lang.String pin)
          Attempts to pair this remote device with preassigned PIN.
 void setListener(RemoteBluetoothDeviceListener listener)
          Sets the listener for events coming from this RemoteBluetoothDevice
 void setPin(java.lang.String pin)
          Sets a default PIN for the pairing
 void unpair()
          Unpair this remote device
 
Methods inherited from interface it.gerdavax.android.bluetooth.BluetoothDevice
getName
 

Method Detail

getAddress

java.lang.String getAddress()
Gets the BD Address of this device.

Specified by:
getAddress in interface BluetoothDevice
Returns:
the BD Address

getRSSI

short getRSSI()
Gets the signal strenght (Received Signal Strength Indicator) of this device

Returns:

getDeviceClass

int getDeviceClass()
Gets the device class (see Bluetooth Protocol Specification)

Returns:
the device class, as bit-masked integer

getDeviceMajorClass

int getDeviceMajorClass()
Gets the device major class (see Bluetooth Protocol Specification)

Returns:
device major class
Since:
0.2

getDeviceMinorClass

int getDeviceMinorClass()
Gets the device minor class (see Bluetooth Protocol Specification)

Returns:
device minor class
Since:
0.2

getServiceMajorClass

int getServiceMajorClass()
Gets the service major class of this device (see Bluetooth Protocol Specification)

Returns:
service major class
Since:
0.2

setPin

void setPin(java.lang.String pin)
            throws BluetoothException
Sets a default PIN for the pairing

Parameters:
pin -
Throws:
BluetoothException

pair

void pair()
Attempts to pair this remote device.


pair

void pair(java.lang.String pin)
Attempts to pair this remote device with preassigned PIN.


unpair

void unpair()
Unpair this remote device

Since:
0.3

isPaired

boolean isPaired()
Gets the paired status of this device

Returns:
true if this device is paired

openSocket

BluetoothSocket openSocket(int port)
                           throws BluetoothException
Opens a BluetoothSocket (RFComm) to this device on assigned port. If the socket has been already opened, returns the existing instance.

Parameters:
port -
Returns:
BluetoothSocket instance associated to given port
Throws:
BluetoothException

setListener

void setListener(RemoteBluetoothDeviceListener listener)
Sets the listener for events coming from this RemoteBluetoothDevice

Parameters:
listener -
See Also:
RemoteBluetoothDeviceListener

getRemoteServiceChannel

void getRemoteServiceChannel(int uuid16)
                             throws java.lang.Exception
Parameters:
uuid16 -
Throws:
java.lang.Exception
Since:
0.2