de.avetana.bluetooth.l2cap
Class L2CAPConnectionNotifierImpl

java.lang.Object
  extended byde.avetana.bluetooth.connection.ConnectionNotifier
      extended byde.avetana.bluetooth.l2cap.L2CAPConnectionNotifierImpl
All Implemented Interfaces:
Connection, L2CAPConnectionNotifier

public class L2CAPConnectionNotifierImpl
extends ConnectionNotifier
implements L2CAPConnectionNotifier

The implementation of the javax.bluetooth.L2CAPConnectionNotifier class.

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:
The L2CAPConnectionNotifierImpl class provides an implementation of the javax.bluetooth.L2CAPConnectionNotifier interface.

To create a server connection, the protocol must be btl2cap. The target contains "localhost:" and the UUID of the service. The parameters are ReceiveMTU and TransmitMTU, the same parameters used to define a client connection. Here is an example of a valid server connection string:
btl2cap://localhost:3B9FA89520078C303355AAA694238F07;ReceiveMTU=512;TransmitMTU=512

A call to Connector.open() with this string will return a javax.bluetooth.L2CAPConnectionNotifier instance. An L2CAPConnection object is obtained from the L2CAPConnectionNotifier by calling the method acceptAndOpen().


Field Summary
 
Fields inherited from class de.avetana.bluetooth.connection.ConnectionNotifier
failEx, isClosed, m_fid, m_remote, m_serverFid, m_serviceHandle, myConnection, myRecord, parsedURL
 
Constructor Summary
L2CAPConnectionNotifierImpl(JSR82URL url)
          Creates a new instance of L2CAPConnectionNotifierImpl.
 
Method Summary
 L2CAPConnection acceptAndOpen()
          Waits for a client to connect to this L2CAP service.
 void setMTUs(int transMTU, int recMTU)
          This is used from JBlueZ to set the mtu on incoming connections
 
Methods inherited from class de.avetana.bluetooth.connection.ConnectionNotifier
acceptAndOpenI, close, getConnectionURL, getRemoteDevice, getServiceHandle, getServiceRecord, isNotifierClosed, isServiceRegistered, removeNotifier, setConnectionID, setFailure, setRemoteDevice, setServerFID, setServiceRecord
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.microedition.io.Connection
close
 

Constructor Detail

L2CAPConnectionNotifierImpl

public L2CAPConnectionNotifierImpl(JSR82URL url)
                            throws BadURLFormat,
                                   java.lang.Exception
Creates a new instance of L2CAPConnectionNotifierImpl. The connection URL be of the form: btl2cap://localhost:UUID

Parameters:
url - The connection URL
Throws:
BadURLFormat - If the connection URL does not describe a well-formed and correct L2CAP server URL.
java.lang.Exception
Method Detail

acceptAndOpen

public L2CAPConnection acceptAndOpen()
                              throws java.io.IOException,
                                     ServiceRegistrationException
Waits for a client to connect to this L2CAP service. Upon connection returns an L2CAPConnection that can be used to communicate with this client.

A service record associated with this connection will be added to the SDDB associated with this L2CAPConnectionNotifier object if one does not exist in the SDDB. This method will put the local device in connectable mode so that it may respond to connection attempts by clients.

The following checks are done to verify that any modifications made by the application to the service record after it was created by Connector.open() have not created an invalid service record. If any of these checks fail, then a ServiceRegistrationException is thrown.

This method will not ensure that the service record created is a completely valid service record. It is the responsibility of the application to ensure that the service record follows all of the applicable syntactic and semantic rules for service record correctness.

Specified by:
acceptAndOpen in interface L2CAPConnectionNotifier
Returns:
a connection to communicate with the client
Throws:
java.io.IOException - if the notifier is closed before acceptAndOpen() is called
ServiceRegistrationException - if the structure of the associated service record is invalid or if the service record could not be added successfully to the local SDDB. The structure of service record is invalid if the service record is missing any mandatory service attributes, or has changed any of the values described above which are fixed and cannot be changed. Failures to add the record to the SDDB could be due to insufficient disk space, database locks, etc.
BluetoothStateException - if the server device could not be placed in connectable mode because the device user has configured the device to be non-connectable.

setMTUs

public void setMTUs(int transMTU,
                    int recMTU)
This is used from JBlueZ to set the mtu on incoming connections