3. Support for ACL links

The integration with the JavaBluetooth protocol stack allows JSR82ext to provide support for JSR82-based ACL management. Unfortunately, since JavaBluetooth has been developed as a 100% pure Java system, it cannot iterface with native device drivers and its code actually does only support serial Bluetooth adapters by means of the javax.comm API.

To overcome these limitations, we have developed BluezTransport, a low-level interface between the JavaBluetooth Java protocol stack with the native, Linux-based Bluez protocol stack via the Java Native Interface (JNI).

BluezTransport is a JavaBluetooth driver (an implementation of the HCITransport interface) composed by two modules. The upper layer is the BluezTransport Java class which provides upper-layer classes with the ability to add HCI packets to the internal queue of packets that are going to be set over a Bluez interface, and to register an object implementing the HCITransportListener interface that will receive all the incoming data arriving to the Bluez interface (each Bluez interface represents a Bluetooth device - at the moment JSR82ext supports only the hci0 interface). The lower layer is the libBluezTransport Linux-native C library that uses low-level HCI Raw Socket to send packets from the internal outgoing packet queue to the correspoding Bluez interfaces (each Bluez interface represents a Bluetooth device - at the moment JSR82ext supports only the hci0 interface) and listens for incoming packets arrived to the Bluez interface.

The sendPacket method of the BluezTransport class inserts the given HCI packets in an internal packet queue.

As soon as the registerHCITransportListener method of the BluezTransport class is called, it creates a new thread that executes the native startBluez method. This method opens an HCI raw socket to the Bluez interface and starts a select(2) loop that checks if there are packets in the internal packet queue (in this case the code send(2)s packets over the Bluez socket) or incoming data from the Bluez socket (in this case the code forwards the data to the registered HCITransportListener instance).


          A picture representing the architecture of L2CAP stack in JSR82ext

The architecture of L2CAP stack in JSR82ext

The use of a Bluez HCI Raw Socket as a low-level interface effectively eliminates the current limitations of JavaBluetooth to serial adapters and allows JSR82ext-based applications to work with all the Bluetooth devices supported by the Bluez protocol stack.