|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectde.avetana.bluetooth.connection.BTConnection
de.avetana.bluetooth.l2cap.L2CAPConnectionImpl
The implementation of the javax.bluetooth.L2CAPConnection 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:
This class is an implementation of the javax.bluetooth.L2CAPConnection class and
opens a new L2CAP connection with a remote BT device
L2CAPConnection| Field Summary | |
protected int |
m_receiveMTU
|
protected int |
m_transmitMTU
|
| Fields inherited from class de.avetana.bluetooth.connection.BTConnection |
closed, dataBuffer, fid, m_remote |
| Fields inherited from interface javax.bluetooth.L2CAPConnection |
DEFAULT_MTU, MINIMUM_MTU |
| Constructor Summary | |
|
L2CAPConnectionImpl(int fid)
Creates a new instance of L2CAPConnectionImpl and set the connection ID |
|
L2CAPConnectionImpl(int fid,
java.lang.String addr)
Creates a new instance of L2CAPConnectionImpl. |
protected |
L2CAPConnectionImpl(int fid,
java.lang.String addr,
int transmit,
int receive)
Creates a new instance of L2CAPConnectionImpl. |
| Method Summary | |
static L2CAPConnection |
createL2CAPConnection(JSR82URL url)
Creates a new L2CAP connection with a remote BT device. |
int |
getReceiveMTU()
Returns the ReceiveMTU that the connection supports. |
int |
getTransmitMTU()
Returns the MTU that the remote device supports. |
boolean |
ready()
Determines if there is a packet that can be read via a call to receive(). |
int |
receive(byte[] inBuf)
Reads a packet of data. |
void |
send(byte[] data)
Requests that data be sent to the remote device. |
void |
setConnectionURL(JSR82URL a_url)
Sets the connection URL. |
| Methods inherited from class de.avetana.bluetooth.connection.BTConnection |
available, close, getConnectionID, getRemoteDevice, isClosed, newData, read, setRemoteDevice |
| 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 |
| Field Detail |
protected int m_transmitMTU
protected int m_receiveMTU
| Constructor Detail |
public L2CAPConnectionImpl(int fid)
fid - the connection ID
public L2CAPConnectionImpl(int fid,
java.lang.String addr)
fid - The connection IDaddr - The address of the remote device
protected L2CAPConnectionImpl(int fid,
java.lang.String addr,
int transmit,
int receive)
fid - The connection IDaddr - The address of the remote devicetransmit - The desired value of transmitMTUreceive - The desire value of receiveMTU| Method Detail |
public void setConnectionURL(JSR82URL a_url)
a_url - The new connection URL
public static L2CAPConnection createL2CAPConnection(JSR82URL url)
throws java.lang.Exception
url - The connection URL
java.lang.Exception
public int getTransmitMTU()
throws java.io.IOException
Connector.open()
string then this value should be equal to that. If the application did
not specify any TransmitMTU, then this value should be less than or
equal to the ReceiveMTU the remote device advertised during channel configuration.
getTransmitMTU in interface L2CAPConnectionsend() without losing any data
java.io.IOException - if the connection is closed
public int getReceiveMTU()
throws java.io.IOException
DEFAULT_MTU. Also, if the connection
string did specify an MTU, this value will be less than or equal to the value specified in the connection string.
getReceiveMTU in interface L2CAPConnectionreceive()
java.io.IOException - if the connection is closed
public int receive(byte[] inBuf)
throws java.io.IOException,
java.lang.NullPointerException
inBuf is greater than or equal to ReceiveMTU, then
no data will be lost. Unlike read() on an
java.io.InputStream, if the size of inBuf is
smaller than ReceiveMTU, then the portion of the L2CAP payload that will
fit into inBuf will be placed in inBuf, the
rest will be discarded. If the application is aware of the number of
bytes (less than ReceiveMTU) it will receive in any transaction, then
the size of inBuf can be less than ReceiveMTU and no data
will be lost. If inBuf is of length 0, all data sent in
one packet is lost unless the length of the packet is 0.
receive in interface L2CAPConnectioninBuf - byte array to store the received data
inBuf length is zero
java.io.IOException - if an I/O error occurs or the connection has been closed
java.io.InterruptedIOException - if the request timed out
java.lang.NullPointerException - if inBuf is null
public boolean ready()
throws java.io.IOException
receive(). If true, a call to
receive() will not block the application.
ready in interface L2CAPConnectiontrue if there is data to read; false if there is no data to read
java.io.IOException - if the connection is closedreceive(byte[])
public void send(byte[] data)
throws java.io.IOException
data is
greater than the TransmitMTU, then only the first TransmitMTU bytes
of the packet are sent, and the rest will be discarded. If
data is of length 0, an empty L2CAP packet will be sent.
send in interface L2CAPConnectiondata - data to be sent
java.io.IOException - if data cannot be sent successfully or if the connection is closed
java.lang.NullPointerException - if the data is null
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||