de.avetana.bluetooth.stack
Class BluetoothStack

java.lang.Object
  extended byde.avetana.bluetooth.stack.BluetoothStack
Direct Known Subclasses:
AvetanaBTStack

public abstract class BluetoothStack
extends java.lang.Object

COPYRIGHT:
(c) Copyright 2004 Avetana GmbH ALL RIGHTS RESERVED.

This file is part of the Avetana bluetooth API for Linux.

The Avetana bluetooth API for Linux is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

The Avetana bluetooth API is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

The development of the Avetana bluetooth API is based on the work of Christian Lorenz (see the Javabluetooth Stack at http://www.javabluetooth.org) for some classes, on the work of the jbluez team (see http://jbluez.sourceforge.net/) and on the work of the bluez team (see the BlueZ linux Stack at http://www.bluez.org) for the C code. Classes, part of classes, C functions or part of C functions programmed by these teams and/or persons are explicitly mentioned.



Description:

This abstract class defines the methods used by the implementation of javax.bluetooth.* to access the native and system dependant methods. The class BluezStack provides an example of how to implement this class. This strategy may look strange but the aim is to define a general framework independant of the stack implementation.
That way, you can define your own stack implementation, which will extend (for example) the functionnalities of the class BluezStack.

See Also:
de.avetana.bluetooth.stack.BluezStack, BlueZ

Field Summary
static int ACCEPT_POS
          This constant defines the array-position of the property Accept.
static int CON_AUTH_POS
          This constant defines the array-position of the property Authenticate.
static int CON_ENCRYPT_POS
          This constant defines the array-position of the property Encrypt.
static int CON_MASTER_POS
          This constant defines the array-position of the property Master.
static int CON_TRUSTED_POS
          This constant defines the array-position of the property Trusted.
 
Constructor Summary
BluetoothStack()
           
 
Method Summary
abstract  int authenticate(RemoteDevice dev)
          Asks the remote device to perform an authentication.
abstract  boolean cancelServiceSearch(int transID)
          Stops a service search.
abstract  int encrypt(Connection conn, RemoteDevice dev, boolean encrypt)
          Turns on/off the encryption of an ACL link
static BluetoothStack getBluetoothStack()
          Returns the instance of BluetoothStack currently used.
abstract  int getClassOfDevice()
          Returns the class of the local device.
abstract  boolean getConnectionFlag(RemoteDevice dev, int pos)
          Gets the property for a connection.
abstract  int getDiscoverableMode()
          Returns the discoverable mode of the local device.
abstract  java.lang.String getLocalDeviceAddress()
          Returns the local device address.
abstract  java.lang.String getLocalDeviceName()
          Returns the name of the local device.
abstract  java.lang.String getRemoteName(java.lang.String bd_addr)
          Returns the name of the remote device.
static void init(BluetoothStack stack)
          Deprecated.  
abstract  BTConnection isConnected(RemoteDevice dev)
          Returns true if the remote device is currently connected with the local device (whatever the type of connection: server an client connections are here concerned)
abstract  Connection openL2CAPConnection(JSR82URL url)
          Opens a new L2CAP client connection.
abstract  Connection openRFCommConnection(JSR82URL url)
          Opens a new RFCOMM client connnection.
abstract  int searchServices(int[] attrSet, UUID[] uuidSet, RemoteDevice btDev, DiscoveryListener myListener)
          Searches for desired services.
abstract  int setDiscoverableMode(int mode)
          Sets the new discoverable mode for this local device.
abstract  int updateService(ServiceRecord rec, long recordHandle)
          Updates a Service record stored in the local BCC.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ACCEPT_POS

public static final int ACCEPT_POS
This constant defines the array-position of the property Accept. Indeed, the method getConnectionOptions() returns an array of boolean describing the properties set for a specified connection and its related remote device.

See Also:
Constant Field Values

CON_MASTER_POS

public static final int CON_MASTER_POS
This constant defines the array-position of the property Master. Indeed, the method getConnectionOptions() returns an array of boolean describing the properties set for a specified connection and its related remote device.

See Also:
Constant Field Values

CON_AUTH_POS

public static final int CON_AUTH_POS
This constant defines the array-position of the property Authenticate. Indeed, the method getConnectionOptions() returns an array of boolean describing the properties set for a specified connection and its related remote device.

See Also:
Constant Field Values

CON_ENCRYPT_POS

public static final int CON_ENCRYPT_POS
This constant defines the array-position of the property Encrypt. Indeed, the method getConnectionOptions() returns an array of boolean describing the properties set for a specified connection and its related remote device.

See Also:
Constant Field Values

CON_TRUSTED_POS

public static final int CON_TRUSTED_POS
This constant defines the array-position of the property Trusted. Indeed, the method getConnectionOptions() returns an array of boolean describing the properties set for a specified connection and its related remote device.

See Also:
Constant Field Values
Constructor Detail

BluetoothStack

public BluetoothStack()
Method Detail

getBluetoothStack

public static BluetoothStack getBluetoothStack()
                                        throws java.lang.Exception
Returns the instance of BluetoothStack currently used. The BluetoothStack object must be intiliazed with the help of the method init().

Returns:
The current BluetoothStack
Throws:
java.lang.Exception - If the BluetoothStack was not initialized

getLocalDeviceName

public abstract java.lang.String getLocalDeviceName()
                                             throws java.lang.Exception
Returns the name of the local device.

Returns:
The name of the local device
Throws:
java.lang.Exception
See Also:
LocalDevice

getClassOfDevice

public abstract int getClassOfDevice()
                              throws java.lang.Exception
Returns the class of the local device.

Returns:
The class of the local device
Throws:
java.lang.Exception
See Also:
LocalDevice

getLocalDeviceAddress

public abstract java.lang.String getLocalDeviceAddress()
                                                throws java.lang.Exception
Returns the local device address.

Returns:
The local device address
Throws:
java.lang.Exception
See Also:
LocalDevice

getRemoteName

public abstract java.lang.String getRemoteName(java.lang.String bd_addr)
                                        throws java.lang.Exception
Returns the name of the remote device.

Parameters:
bd_addr - The BT address of the remote device
Returns:
The name of the remote device if available
Throws:
java.lang.Exception

openRFCommConnection

public abstract Connection openRFCommConnection(JSR82URL url)
                                         throws java.lang.Exception
Opens a new RFCOMM client connnection.

Parameters:
url - The connection URL
Returns:
A StreamConnection object.
Throws:
java.lang.Exception

openL2CAPConnection

public abstract Connection openL2CAPConnection(JSR82URL url)
                                        throws java.lang.Exception
Opens a new L2CAP client connection.

Parameters:
url - The connection URL
Returns:
A L2CAPConnection object
Throws:
java.lang.Exception

searchServices

public abstract int searchServices(int[] attrSet,
                                   UUID[] uuidSet,
                                   RemoteDevice btDev,
                                   DiscoveryListener myListener)
Searches for desired services.

Parameters:
attrSet - The list of attributes to be considered for each found service.
uuidSet - The list of UUIDs a service MUST contain.
btDev - The remote device
myListener - The discovery listener for callback methods.

cancelServiceSearch

public abstract boolean cancelServiceSearch(int transID)
Stops a service search.

Parameters:
transID - The SDP transaction ID.

updateService

public abstract int updateService(ServiceRecord rec,
                                  long recordHandle)
                           throws java.lang.Exception
Updates a Service record stored in the local BCC.

Parameters:
recordHandle - The record handle of the old service
Returns:
a positive integer if the update succeeds
Throws:
java.lang.Exception
See Also:
LocalDevice

getDiscoverableMode

public abstract int getDiscoverableMode()
                                 throws java.lang.Exception
Returns the discoverable mode of the local device.

Returns:
The discoverable mode of the local device
Throws:
java.lang.Exception
See Also:
LocalDevice

setDiscoverableMode

public abstract int setDiscoverableMode(int mode)
                                 throws java.lang.Exception
Sets the new discoverable mode for this local device.

Parameters:
mode - a value in the range 0x9E8B00 to 0x9E8B3F
Returns:
a positive integer if the operation succeeds.
Throws:
java.lang.Exception
See Also:
LocalDevice

isConnected

public abstract BTConnection isConnected(RemoteDevice dev)
Returns true if the remote device is currently connected with the local device (whatever the type of connection: server an client connections are here concerned)

Parameters:
dev - The remote device
Returns:
The active Connection object

authenticate

public abstract int authenticate(RemoteDevice dev)
                          throws java.lang.Exception
Asks the remote device to perform an authentication. The remote device MUST be connected with the local device

Parameters:
dev - The remote device
Returns:
1 If the authentication did succeed.
A negative integer otherwise.
Throws:
java.lang.Exception
See Also:
RemoteDevice

encrypt

public abstract int encrypt(Connection conn,
                            RemoteDevice dev,
                            boolean encrypt)
                     throws java.lang.Exception
Turns on/off the encryption of an ACL link

Parameters:
conn - The connection object representing the connection beteen the local and remote device
dev - The remote device for this connection
encrypt - If true, turn on the encryption of the ACL link. Otherwise, turn it off
Returns:
1 If the operation did succeed.
A negative integer otherwise.
Throws:
java.lang.Exception
See Also:
RemoteDevice

getConnectionFlag

public abstract boolean getConnectionFlag(RemoteDevice dev,
                                          int pos)
                                   throws java.lang.Exception
Gets the property for a connection.

Parameters:
dev - The remote device
pos - The position of the desired flag in the array of properties
Returns:
true If the property is true.
false Otherwise.
Throws:
java.lang.Exception
See Also:
RemoteDevice, ACCEPT_POS, CON_AUTH_POS, CON_ENCRYPT_POS, CON_MASTER_POS, CON_TRUSTED_POS

init

public static void init(BluetoothStack stack)
                 throws java.lang.Exception
Deprecated.  

This method is deprecated

Parameters:
stack -
Throws:
java.lang.Exception