Nokia Extensions for JSR-257

com.nokia.nfc.llcp
Interface LLCPConnection

All Superinterfaces:
javax.microedition.io.Connection

public interface LLCPConnection
extends javax.microedition.io.Connection

The LLCPConnection provides an interface for communicating with an application on a remote LLCP device using a logical channel - a LLCP connection. The connection can use either Type 1 or Type 2 transport. Both ends of the connection use the same protocol identifier.


Field Summary
static int MAX_DATA_LEN
          Maximum amount of bytes that can be sent or received in one call.
static byte MAX_PID
          Maximum valid protocol identifier value.
static byte MIN_PID
          Minimum valid protocol identifier value.
static byte TYPE_1
          Type identifier for Type 1 transport.
static byte TYPE_2
          Type identifier for Type 2 transport.
 
Method Summary
 byte getProtocolId()
          Returns the protocol identifier of the connection.
 byte getTransportType()
          Returns the transport type of the connection.
 java.lang.String getUID()
          Returns the remote device identifier.
 byte[] receive()
          Receives data from the remote device.
 void send(byte[] data)
          Sends data to the remote device.
 void send(byte[] data, int offset, int len)
          Sends data to the remote device.
 

Field Detail

MIN_PID

public static final byte MIN_PID
Minimum valid protocol identifier value.

See Also:
Constant Field Values

MAX_PID

public static final byte MAX_PID
Maximum valid protocol identifier value.

See Also:
Constant Field Values

MAX_DATA_LEN

public static final int MAX_DATA_LEN
Maximum amount of bytes that can be sent or received in one call. The value is implementation specific.

See Also:
Constant Field Values

TYPE_1

public static final byte TYPE_1
Type identifier for Type 1 transport. Type 1 is a connection-less transport that is a unreliable, session-less data transport.

See Also:
Constant Field Values

TYPE_2

public static final byte TYPE_2
Type identifier for Type 2 transport. Type 2 is a connection-oriented transport that is a reliable, session-based data transport.

See Also:
Constant Field Values
Method Detail

getTransportType

public byte getTransportType()
Returns the transport type of the connection. Possible values are TYPE_1 and TYPE_2.

Returns:
the transport type.

getUID

public java.lang.String getUID()
Returns the remote device identifier.

Returns:
the remote device identifier as a hexadecimal string.

getProtocolId

public byte getProtocolId()
Returns the protocol identifier of the connection. Possible values range from 0 to 62.

Returns:
the protocol identifier.

send

public void send(byte[] data,
                 int offset,
                 int len)
          throws java.io.IOException

Sends data to the remote device. Bytes from offset to offset + len - 1 will be sent.

The maximum len value is defined by MAX_DATA_LEN.

Parameters:
data - the array containing the data to send.
offset - index of the first byte to send.
len - number of bytes to read from the byte array.
Throws:
java.lang.NullPointerException - if data is null.
java.lang.IllegalArgumentException - if the parameters offset and len define an invalid range of bytes.
java.io.IOException - if the connection has been closed or a communication error occurs.

send

public void send(byte[] data)
          throws java.io.IOException

Sends data to the remote device. All bytes from the specified byte array will be sent. This method blocks until the data has been received by the remote device.

The maximum array length is defined by MAX_DATA_LEN.

Parameters:
data - the array containing the data to send.
Throws:
java.lang.NullPointerException - if data is null.
java.io.IOException - if the connection has been closed or a communication error occurs.

receive

public byte[] receive()
               throws java.io.IOException

Receives data from the remote device. If no data is available this method will block until the remote device sends data. Data will be buffered in case the application isn't calling this method to receive data.

The maximum amount of data that can be received in one call is defined by MAX_DATA_LEN.

Returns:
the received data.
Throws:
java.io.IOException - if the connection has been closed or a communication error occurs.

Nokia Extensions for JSR-257

Copyright © 2006 Nokia Corporation. All Rights Reserved.
Java is a trademark of Sun Microsystems, Inc.