|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.intel.bluetooth.BluetoothConnectionAccessAdapter
com.intel.bluetooth.btl2cap.Connection
public class Connection
This class is Proxy for btl2cap (L2CAP) Connection implementations for IBM J9 support
You need to configure -Dmicroedition.connection.pkgs=com.intel.bluetooth if not installing bluecove.jar to "%J9_HOME%\lib\jclMidp20\ext\
Your application should not use this class directly.
Field Summary |
---|
Fields inherited from interface javax.bluetooth.L2CAPConnection |
---|
DEFAULT_MTU, MINIMUM_MTU |
Constructor Summary | |
---|---|
Connection()
|
Method Summary | |
---|---|
L2CAPConnection |
acceptAndOpen()
Waits for a client to connect to this L2CAP service. |
void |
close()
|
protected BluetoothConnectionAccess |
getImpl()
|
int |
getReceiveMTU()
Returns the ReceiveMTU that the connection supports. |
ServiceRecord |
getServiceRecord()
|
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 |
setParameters(String spec,
int access,
boolean timeout)
Passes the parameters from the Connector.open() method to this object. |
Connection |
setParameters2(String spec,
int access,
boolean timeout)
Passes the parameters from the Connector.open() method to this object. |
void |
updateServiceRecord(boolean acceptAndOpen)
|
Methods inherited from class com.intel.bluetooth.BluetoothConnectionAccessAdapter |
---|
encrypt, getBluetoothStack, getRemoteAddress, getRemoteDevice, getSecurityOpt, isClosed, markAuthenticated, setRemoteDevice, shutdown |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Connection()
Method Detail |
---|
protected BluetoothConnectionAccess getImpl()
getImpl
in class BluetoothConnectionAccessAdapter
public void setParameters(String spec, int access, boolean timeout) throws IOException
CreateConnection
setParameters
in interface CreateConnection
spec
- String
The address passed to Connector.open()access
- int
The type of access this Connection is
granted (READ, WRITE, READ_WRITE)timeout
- boolean
A boolean indicating wether or not the
caller to Connector.open() wants timeout
exceptions or not
IOException
- If an error occured opening and configuring
serial port.Connector
public Connection setParameters2(String spec, int access, boolean timeout) throws IOException
CreateConnection
setParameters2
in interface CreateConnection
spec
- String
The address passed to Connector.open()access
- int
The type of access this Connection is
granted (READ, WRITE, READ_WRITE)timeout
- boolean
A boolean indicating wether or not the
caller to Connector.open() wants timeout
exceptions or not
IOException
- If an error occured opening and configuring
serial port.Connector
public void close() throws IOException
close
in interface Connection
IOException
public int getReceiveMTU() throws IOException
L2CAPConnection
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 L2CAPConnection
receive()
IOException
- if the connection is closedpublic int getTransmitMTU() throws IOException
L2CAPConnection
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 L2CAPConnection
send()
without losing any data
IOException
- if the connection is closedpublic boolean ready() throws IOException
L2CAPConnection
receive()
. If true
, a call to
receive()
will not block the application.
ready
in interface L2CAPConnection
true
if there is data to read;
false
if there is no data to read
IOException
- if the connection is closedL2CAPConnection.receive(byte[])
public int receive(byte[] inBuf) throws IOException
L2CAPConnection
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 L2CAPConnection
inBuf
- byte array to store the received data
inBuf
length is zero
IOException
- if an I/O error occurs or the connection has been
closedpublic void send(byte[] data) throws IOException
L2CAPConnection
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 L2CAPConnection
data
- data to be sent
IOException
- if data
cannot be sent successfully
or if the connection is closedpublic L2CAPConnection acceptAndOpen() throws IOException
L2CAPConnectionNotifier
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.
btl2cap
service record, must be present in
the service record.
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.
Note : once an application invokes close()
on any
L2CAPConnectionNotifier
, SessionNotifier
, or
StreamConnectionNotifer
instance, all pending
acceptAndOpen()
methods that have been invoked previously on
that instance MUST throw InterruptedIOException
. This
mechanism provides an application with the means to cancel any
outstanding acceptAndOpen()
method calls.
acceptAndOpen
in interface L2CAPConnectionNotifier
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.public ServiceRecord getServiceRecord()
getServiceRecord
in interface BluetoothConnectionNotifierServiceRecordAccess
public void updateServiceRecord(boolean acceptAndOpen) throws ServiceRegistrationException
updateServiceRecord
in interface BluetoothConnectionNotifierServiceRecordAccess
acceptAndOpen
- wrap validation in ServiceRegistrationException
ServiceRegistrationException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |