com.intel.bluetooth
Class BlueCoveImpl

java.lang.Object
  extended by com.intel.bluetooth.BlueCoveImpl

public class BlueCoveImpl
extends Object

Singleton class used as holder for BluetoothStack. Under security manager all you need to do is initialize BlueCoveImpl inside Privileged context.

If automatic Bluetooth Stack detection is not enough Java System property "bluecove.stack" can be used to force desired Stack Initialization. Values "widcomm", "bluesoleil" or "winsock". By default winsock is selected if available.

Another property "bluecove.stack.first" is used optimize stack detection. If -Dbluecove.stack.first=widcomm then widcomm (bluecove.dll) stack is loaded first and if not available then BlueCove will switch to winsock. By default intelbth.dll is loaded first.

If multiple stacks are detected they are selected in following order: "winsock", "widcomm", "bluesoleil". Since BlueCove v2.0.1 "bluecove.stack.first" will alter the order of stack selection.

To use jsr-82 emulator set "bluecove.stack" value to "emulator".

If System property is not an option (e.g. when running in Webstart) create text file "bluecove.stack" or "bluecove.stack.first" containing stack name and add this file to BlueCove or Application jar. (Since v2.0.1)

Use `LocalDevice.getProperty("bluecove.stack")` to find out which stack is used.


Field Summary
static int BLUECOVE_STACK_DETECT_ANDROID_1_X
           
static int BLUECOVE_STACK_DETECT_ANDROID_2_X
           
static int BLUECOVE_STACK_DETECT_BLUEZ
           
static int BLUECOVE_STACK_DETECT_BLUEZ_DBUS
           
static int BLUECOVE_STACK_DETECT_EMULATOR
           
static String BLUETOOTH_API_VERSION
           
static String NATIVE_LIB_BLUESOLEIL
          To work on BlueSoleil version 2.3 we need to compile C++ code /MT the same as winsock.
static String NATIVE_LIB_BLUEZ
           
static String NATIVE_LIB_MS
           
static String NATIVE_LIB_OSX
           
static String NATIVE_LIB_TOSHIBA
           
static String NATIVE_LIB_WIDCOMM
           
static int nativeLibraryVersionExpected
           
static String OBEX_API_VERSION
           
static String STACK_ANDROID_2_X
           
static String STACK_BLUESOLEIL
           
static String STACK_BLUEZ
           
static String STACK_BLUEZ_DBUS
           
static String STACK_EMULATOR
           
static String STACK_OSX
           
static String STACK_TOSHIBA
           
static String STACK_WIDCOMM
           
static String STACK_WINSOCK
           
static String version
           
static int versionBuild
           
static int versionMajor1
           
static int versionMajor2
           
static int versionMinor
           
static String versionSufix
           
 
Method Summary
 void enableNativeDebug(boolean on)
           
 BluetoothStack getBluetoothStack()
          Applications should not used this function.
static Object getConfigObject(String key)
           
static String getConfigProperty(String key)
           
static boolean getConfigProperty(String key, boolean defaultValue)
           
static Object getCurrentThreadBluetoothStackID()
          Returns the ID to be used in other threads accessing the same stack.
 String getLocalDeviceFeature(int featureID)
           
static Vector getLocalDevicesID()
          List the local adapters that can be initialized using configuration property "bluecove.deviceID".
static Object getThreadBluetoothStackID()
          Initialize BluetoothStack if not already done and returns the ID to be used in other threads accessing the same stack.
static BlueCoveImpl instance()
          Applications should not used this function.
static void releaseThreadBluetoothStack()
          Detach BluetoothStack from ThreadLocal.
 String setBluetoothStack(String stack)
          Deprecated. use setConfigProperty("bluecove.stack", ...);
static void setConfigObject(String name, Object value)
          API that can be used to configure BlueCove properties that aren't just strings Initialization properties should be changed before stack initialized.
static void setConfigProperty(String name, String value)
          API that can be used to configure BlueCove properties instead of System properties.
static void setDefaultThreadBluetoothStackID(Object stackID)
          Set default Thread BluetoothStack for Threads that do not call setThreadBluetoothStackID(stackID).
static void setThreadBluetoothStackID(Object stackID)
          Updates the current Thread BluetoothStack.
static void shutdown()
          Shutdown all BluetoothStacks interfaces initialized by BlueCove
static void shutdownThreadBluetoothStack()
          Shutdown BluetoothStack assigned for current Thread and clear configuration properties for this thread
static void useThreadLocalBluetoothStack()
          API that enables the use of Multiple Adapters and Bluetooth Stacks in parallel in the same JVM.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BLUETOOTH_API_VERSION

public static final String BLUETOOTH_API_VERSION
See Also:
Constant Field Values

OBEX_API_VERSION

public static final String OBEX_API_VERSION
See Also:
Constant Field Values

versionMajor1

public static final int versionMajor1
See Also:
Constant Field Values

versionMajor2

public static final int versionMajor2
See Also:
Constant Field Values

versionMinor

public static final int versionMinor
See Also:
Constant Field Values

versionBuild

public static final int versionBuild
See Also:
Constant Field Values

versionSufix

public static final String versionSufix
See Also:
Constant Field Values

version

public static final String version

nativeLibraryVersionExpected

public static final int nativeLibraryVersionExpected
See Also:
Constant Field Values

STACK_WINSOCK

public static final String STACK_WINSOCK
See Also:
Constant Field Values

STACK_WIDCOMM

public static final String STACK_WIDCOMM
See Also:
Constant Field Values

STACK_BLUESOLEIL

public static final String STACK_BLUESOLEIL
See Also:
Constant Field Values

STACK_TOSHIBA

public static final String STACK_TOSHIBA
See Also:
Constant Field Values

STACK_BLUEZ

public static final String STACK_BLUEZ
See Also:
Constant Field Values

STACK_BLUEZ_DBUS

public static final String STACK_BLUEZ_DBUS
See Also:
Constant Field Values

STACK_OSX

public static final String STACK_OSX
See Also:
Constant Field Values

STACK_EMULATOR

public static final String STACK_EMULATOR
See Also:
Constant Field Values

STACK_ANDROID_2_X

public static final String STACK_ANDROID_2_X
See Also:
Constant Field Values

NATIVE_LIB_MS

public static final String NATIVE_LIB_MS
See Also:
Constant Field Values

NATIVE_LIB_WIDCOMM

public static final String NATIVE_LIB_WIDCOMM
See Also:
Constant Field Values

NATIVE_LIB_TOSHIBA

public static final String NATIVE_LIB_TOSHIBA
See Also:
Constant Field Values

NATIVE_LIB_BLUEZ

public static final String NATIVE_LIB_BLUEZ
See Also:
Constant Field Values

NATIVE_LIB_OSX

public static final String NATIVE_LIB_OSX
See Also:
Constant Field Values

NATIVE_LIB_BLUESOLEIL

public static final String NATIVE_LIB_BLUESOLEIL
To work on BlueSoleil version 2.3 we need to compile C++ code /MT the same as winsock.

See Also:
Constant Field Values

BLUECOVE_STACK_DETECT_BLUEZ

public static final int BLUECOVE_STACK_DETECT_BLUEZ
See Also:
Constant Field Values

BLUECOVE_STACK_DETECT_EMULATOR

public static final int BLUECOVE_STACK_DETECT_EMULATOR
See Also:
Constant Field Values

BLUECOVE_STACK_DETECT_BLUEZ_DBUS

public static final int BLUECOVE_STACK_DETECT_BLUEZ_DBUS
See Also:
Constant Field Values

BLUECOVE_STACK_DETECT_ANDROID_1_X

public static final int BLUECOVE_STACK_DETECT_ANDROID_1_X
See Also:
Constant Field Values

BLUECOVE_STACK_DETECT_ANDROID_2_X

public static final int BLUECOVE_STACK_DETECT_ANDROID_2_X
See Also:
Constant Field Values
Method Detail

instance

public static BlueCoveImpl instance()
Applications should not used this function. Allow default initialization. In Secure environment instance() should be called initially from secure context.

Returns:
Instance of the class, getBluetoothStack() can be called.

getLocalDevicesID

public static Vector getLocalDevicesID()
                                throws BluetoothStateException
List the local adapters that can be initialized using configuration property "bluecove.deviceID". (Linux BlueZ and Emulator) The first stack/adapter would be initialized if not initialized already, you can exclude it from the list. The function return empty list on non BlueZ environment.

Returns:
List of Strings
Throws:
BluetoothStateException - if stack interface can't be initialized
See Also:
BlueCoveConfigProperties.PROPERTY_LOCAL_DEVICE_ID, BlueCoveLocalDeviceProperties.LOCAL_DEVICE_PROPERTY_DEVICE_ID

useThreadLocalBluetoothStack

public static void useThreadLocalBluetoothStack()
API that enables the use of Multiple Adapters and Bluetooth Stacks in parallel in the same JVM. Each thread should call setThreadBluetoothStackID() before using JSR-82 API. Affects the following JSR-82 API methods:
  LocalDevice.getLocalDevice();
  LocalDevice.getProperty(String);
  Connector.open(...);
  methods of RemoteDevice instance created by user.
 
Example

 BlueCoveImpl.useThreadLocalBluetoothStack();
 // On Windows
 BlueCoveImpl.setConfigProperty("bluecove.stack", "widcomm");
 // On Linux or in Emulator
 // BlueCoveImpl.setConfigProperty("bluecove.deviceID", "0");

 final Object id1 = BlueCoveImpl.getThreadBluetoothStackID();
 ... do some work with stack 1

 // Illustrates attaching thread to already initialized stack interface
 Thread t1 = new Thread() {
    public void run() {
        BlueCoveImpl.setThreadBluetoothStackID(id1);
        agent = LocalDevice.getLocalDevice().getDiscoveryAgent();
        agent.startInquiry(...);
        .....
    }
 };
 t1.start();

 // Illustrates initialization of new/different stack interface in new thread
 // Start another thread that is using different stack
 Thread t2 = new Thread() {
    public void run() {
        // On Windows
        BlueCoveImpl.setConfigProperty("bluecove.stack", "winsock");
        // On Linux or in Emulator
        // BlueCoveImpl.setConfigProperty("bluecove.deviceID", "1");
        agent = LocalDevice.getLocalDevice().getDiscoveryAgent();
        agent.startInquiry(...);
        .....
    }
 }
 t2.start();

 Thread t3 = new Thread() {
    public void run() {
        // Wrong, will produce error: Thread StackID not configured
        Connector.open("btspp://12345678:1");
        .....
    }
 };
 t3.start();

 

See Also:
setConfigProperty(java.lang.String, java.lang.String)

getThreadBluetoothStackID

public static Object getThreadBluetoothStackID()
                                        throws BluetoothStateException
Initialize BluetoothStack if not already done and returns the ID to be used in other threads accessing the same stack.

Returns:
an object that represents Adapter/BluetoothStack, stackID to be used in call to setThreadBluetoothStackID
Throws:
BluetoothStateException - if the Bluetooth system could not be initialized

getCurrentThreadBluetoothStackID

public static Object getCurrentThreadBluetoothStackID()
Returns the ID to be used in other threads accessing the same stack.

Returns:
an object that represents Adapter/BluetoothStack, stackID to be used in call to setThreadBluetoothStackID or null if ThreadLocalBluetoothStack not used.

setThreadBluetoothStackID

public static void setThreadBluetoothStackID(Object stackID)
Updates the current Thread BluetoothStack. Updating is possible only if stackID was obtained using the getThreadBluetoothStackID() method. Should be called before connection is made or LocalDevice received from LocalDevice.getLocalDevice().

Parameters:
stackID - stackID to use or null to detach the current Thread

releaseThreadBluetoothStack

public static void releaseThreadBluetoothStack()
Detach BluetoothStack from ThreadLocal. Used for removing itself from container threads. Also can be use to initialize different stack in the same thread.


setDefaultThreadBluetoothStackID

public static void setDefaultThreadBluetoothStackID(Object stackID)
Set default Thread BluetoothStack for Threads that do not call setThreadBluetoothStackID(stackID). Updating is possible only if stackID was obtained using the getThreadBluetoothStackID() method.

Parameters:
stackID - stackID to use or null to remove default

shutdownThreadBluetoothStack

public static void shutdownThreadBluetoothStack()
Shutdown BluetoothStack assigned for current Thread and clear configuration properties for this thread


shutdown

public static void shutdown()
Shutdown all BluetoothStacks interfaces initialized by BlueCove


setConfigProperty

public static void setConfigProperty(String name,
                                     String value)
API that can be used to configure BlueCove properties instead of System properties. Initialization properties should be changed before stack initialized. If null is passed as the value then the property will be removed.

Parameters:
name - property name
value - property value
Throws:
IllegalArgumentException - if the stack already initialized and property can't be changed.
See Also:
BlueCoveConfigProperties, setConfigObject(java.lang.String, java.lang.Object)

setConfigObject

public static void setConfigObject(String name,
                                   Object value)
API that can be used to configure BlueCove properties that aren't just strings Initialization properties should be changed before stack initialized. If null is passed as the value then the property will be removed.

Parameters:
name - property name
value - property value
Throws:
IllegalArgumentException - if the stack already initialized and property can't be changed.
See Also:
BlueCoveConfigProperties

getConfigObject

public static Object getConfigObject(String key)

getConfigProperty

public static String getConfigProperty(String key)

getConfigProperty

public static boolean getConfigProperty(String key,
                                        boolean defaultValue)

getLocalDeviceFeature

public String getLocalDeviceFeature(int featureID)
                             throws BluetoothStateException
Throws:
BluetoothStateException

setBluetoothStack

public String setBluetoothStack(String stack)
                         throws BluetoothStateException
Deprecated. use setConfigProperty("bluecove.stack", ...);

Parameters:
stack -
Returns:
stack ID
Throws:
BluetoothStateException

enableNativeDebug

public void enableNativeDebug(boolean on)

getBluetoothStack

public BluetoothStack getBluetoothStack()
                                 throws BluetoothStateException
Applications should not used this function.

Returns:
current BluetoothStack implementation
Throws:
BluetoothStateException - when BluetoothStack not detected. If one connected the hardware later, BlueCove would be able to recover and start correctly
Error - if called from outside of BlueCove internal code.


JSR-82 Javadocs Apache License, Version 2.0 Copyright © 2001-2008 Motorola, Inc. ALL RIGHTS RESERVED.
BlueCove Javadocs
Apache License, Version 2.0 Copyright © 2004-2008 BlueCove Team.