de.avetana.bluetooth.stack
Class AvetanaBTStack

java.lang.Object
  extended byde.avetana.bluetooth.stack.BluetoothStack
      extended byde.avetana.bluetooth.stack.AvetanaBTStack

public class AvetanaBTStack
extends BluetoothStack

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 class implements the de.avetana.bluetooth.stack.BluetoothStack class.
Please refer to this abstract class for the documentation.

See Also:
BluetoothStack

Field Summary
 
Fields inherited from class de.avetana.bluetooth.stack.BluetoothStack
ACCEPT_POS, CON_AUTH_POS, CON_ENCRYPT_POS, CON_MASTER_POS, CON_TRUSTED_POS
 
Constructor Summary
AvetanaBTStack()
           
AvetanaBTStack(int devID)
           
 
Method Summary
 int authenticate(RemoteDevice dev)
          Asks the remote device to perform an authentication.
 boolean cancelServiceSearch(int transID)
          Stops a service search.
 void closeDevice()
           
 int encrypt(Connection conn, RemoteDevice dev, boolean encrypt)
          Turns on/off the encryption of an ACL link
 int getClassOfDevice()
          Returns the class of the local device.
 boolean getConnectionFlag(RemoteDevice dev, int pos)
          Gets the property for a connection.
 int getDiscoverableMode()
          Returns the discoverable mode of the local device.
 java.lang.String getLocalDeviceAddress()
          Returns the local device address.
 java.lang.String getLocalDeviceName()
          Returns the name of the local device.
 java.lang.String getRemoteName(java.lang.String bd_addr)
          Returns the name of the remote device.
 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)
 Connection openL2CAPConnection(JSR82URL url)
          Opens a new L2CAP client connection.
 Connection openRFCommConnection(JSR82URL url)
          Opens a new RFCOMM client connnection.
 int searchServices(int[] attrSet, UUID[] uuidSet, RemoteDevice btDev, DiscoveryListener myListener)
          Searches for desired services.
 void setDeviceID(int dev)
           
 int setDiscoverableMode(int mode)
          Sets the new discoverable mode for this local device.
 int updateService(ServiceRecord rec, long recordHandle)
          Updates a Service record stored in the local BCC.
 
Methods inherited from class de.avetana.bluetooth.stack.BluetoothStack
getBluetoothStack, init
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AvetanaBTStack

public AvetanaBTStack()
               throws java.lang.Exception

AvetanaBTStack

public AvetanaBTStack(int devID)
               throws java.lang.Exception
Method Detail

setDeviceID

public void setDeviceID(int dev)
                 throws java.lang.Exception
Throws:
java.lang.Exception

getRemoteName

public java.lang.String getRemoteName(java.lang.String bd_addr)
                               throws java.lang.Exception
Description copied from class: BluetoothStack
Returns the name of the remote device.

Specified by:
getRemoteName in class BluetoothStack
Parameters:
bd_addr - The BT address of the remote device
Returns:
The name of the remote device if available
Throws:
java.lang.Exception

authenticate

public int authenticate(RemoteDevice dev)
                 throws java.lang.Exception
Description copied from class: BluetoothStack
Asks the remote device to perform an authentication. The remote device MUST be connected with the local device

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

getConnectionFlag

public boolean getConnectionFlag(RemoteDevice dev,
                                 int pos)
                          throws java.lang.Exception
Description copied from class: BluetoothStack
Gets the property for a connection.

Specified by:
getConnectionFlag in class BluetoothStack
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, BluetoothStack.ACCEPT_POS, BluetoothStack.CON_AUTH_POS, BluetoothStack.CON_ENCRYPT_POS, BluetoothStack.CON_MASTER_POS, BluetoothStack.CON_TRUSTED_POS

encrypt

public int encrypt(Connection conn,
                   RemoteDevice dev,
                   boolean encrypt)
            throws java.lang.Exception
Description copied from class: BluetoothStack
Turns on/off the encryption of an ACL link

Specified by:
encrypt in class BluetoothStack
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

isConnected

public BTConnection isConnected(RemoteDevice dev)
Description copied from class: BluetoothStack
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)

Specified by:
isConnected in class BluetoothStack
Parameters:
dev - The remote device
Returns:
The active Connection object

getLocalDeviceAddress

public java.lang.String getLocalDeviceAddress()
                                       throws java.lang.Exception
Description copied from class: BluetoothStack
Returns the local device address.

Specified by:
getLocalDeviceAddress in class BluetoothStack
Returns:
The local device address
Throws:
java.lang.Exception
See Also:
LocalDevice

getLocalDeviceName

public java.lang.String getLocalDeviceName()
                                    throws java.lang.Exception
Description copied from class: BluetoothStack
Returns the name of the local device.

Specified by:
getLocalDeviceName in class BluetoothStack
Returns:
The name of the local device
Throws:
java.lang.Exception
See Also:
LocalDevice

searchServices

public int searchServices(int[] attrSet,
                          UUID[] uuidSet,
                          RemoteDevice btDev,
                          DiscoveryListener myListener)
Description copied from class: BluetoothStack
Searches for desired services.

Specified by:
searchServices in class BluetoothStack
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.

getClassOfDevice

public int getClassOfDevice()
                     throws java.lang.Exception
Description copied from class: BluetoothStack
Returns the class of the local device.

Specified by:
getClassOfDevice in class BluetoothStack
Returns:
The class of the local device
Throws:
java.lang.Exception
See Also:
LocalDevice

closeDevice

public void closeDevice()
                 throws java.lang.Exception
Throws:
java.lang.Exception

getDiscoverableMode

public int getDiscoverableMode()
                        throws java.lang.Exception
Description copied from class: BluetoothStack
Returns the discoverable mode of the local device.

Specified by:
getDiscoverableMode in class BluetoothStack
Returns:
The discoverable mode of the local device
Throws:
java.lang.Exception
See Also:
LocalDevice

setDiscoverableMode

public int setDiscoverableMode(int mode)
                        throws java.lang.Exception
Description copied from class: BluetoothStack
Sets the new discoverable mode for this local device.

Specified by:
setDiscoverableMode in class BluetoothStack
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

openRFCommConnection

public Connection openRFCommConnection(JSR82URL url)
                                throws java.lang.Exception
Description copied from class: BluetoothStack
Opens a new RFCOMM client connnection.

Specified by:
openRFCommConnection in class BluetoothStack
Parameters:
url - The connection URL
Returns:
A StreamConnection object.
Throws:
java.lang.Exception

openL2CAPConnection

public Connection openL2CAPConnection(JSR82URL url)
                               throws java.lang.Exception
Description copied from class: BluetoothStack
Opens a new L2CAP client connection.

Specified by:
openL2CAPConnection in class BluetoothStack
Parameters:
url - The connection URL
Returns:
A L2CAPConnection object
Throws:
java.lang.Exception

cancelServiceSearch

public boolean cancelServiceSearch(int transID)
Description copied from class: BluetoothStack
Stops a service search.

Specified by:
cancelServiceSearch in class BluetoothStack
Parameters:
transID - The SDP transaction ID.

updateService

public int updateService(ServiceRecord rec,
                         long recordHandle)
                  throws java.lang.Exception
Description copied from class: BluetoothStack
Updates a Service record stored in the local BCC.

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