How-to use two bluetooth dongles inside the same java application
Da Wikipedia, l'enciclopedia libera.
See http://development.pracucci.com/jbluetooth
THIS HOW-TO HAS NOT BEEN COMPLETED YET
| Table of contents |
Introduction
The purpose of this little how-to is to explain how to use two Blueooth dongles inside a Java application that runs in a Windows XP environment, using Avetana Bluetooth library.
Background
JSR-82 specification (http://www.jcp.org/en/jsr/detail?id=82) standardizes a set of Java APIs to allow Java-enabled devices to integrate into a Bluetooth environment. A J2ME environment, that runs on a Bluetooth-enabled device, usually provides an implementation of these API. However, there is no (free) J2SE VM that provides an implementation of JSR-82 specification. Consequently, to develop a J2SE application that uses Bluetooth, it must be used an external library that implements Java APIs for Bluetooth.
Avetana Bluetooth (http://www.avetana-gmbh.de/avetana-gmbh/produkte/Readme.xml) is a good library that implements JSR-82: it's realible and quite cheap. This library supports Linux (with an opensource licence), Windows XP SP2, Windows Pocket PC, Mac OS (with a closed licence). Moreover, this library supports Microsoft stack and Widcomm stack on Windows, and this will be very useful for our purpose.
Limitations
JSR-82 specification assumes the environment contains one bluetooth radio at most. This is reasonable in a J2ME environment, but it's a strong limitation in a J2SE environment, because it means that you can only use one Bluetooth radio in a single Java application.
Microsoft Bluetooth Stack (included in Windows XP SP 2) is able to manage only one Bluetooth radio. It means that you can only configure one Bluetooth dongle in Windows XP Operating System.
The idea
To reduce the above limitations and achieve our goal (use two bluetooth dongles inside the same java application), my idea is to develop a custom class loader that load two times the same java library (avetana bluetooth java classes): the first time we load the library specifying to use Microsoft stack, while the second time it will use Widcomm stack.
However, avetana bluetooth library needs a little path in order to load this library two times inside the same application.
References
- http://www.avetana-gmbh.de/avetana-gmbh/produkte/Readme.xml Avetana Bluetooth
- http://www.jcp.org/en/jsr/detail?id=82 JSR-82 Specifications
