nl.tbdev.IR
Class LmpConnection

java.lang.Object
  |
  +--nl.tbdev.IR.LmpConnection
All Implemented Interfaces:
IrConnection, LmpCallbackInterface

class LmpConnection
extends java.lang.Object
implements LmpCallbackInterface, IrConnection

This class implements an IR connection.


Field Summary
static int ACTIVE
          Active connection.
private  ConnectionCallbackInterface client
           
static int CSETUP
          Outgoing call being setup
static int INCOMING
          Incoming call received
private  byte localLsap
           
static int NOT_READY
          Connection not ready.
static int READY
          Ready for incomming/outgoing connection
private  byte remoteLsap
           
private  int state
           
private  LmpStation station
           
 
Constructor Summary
LmpConnection(ConnectionCallbackInterface client)
          Deprecated. Use LmpConnection(LmpStation,ConnectionCallbackInterface)
LmpConnection(LmpStation station, ConnectionCallbackInterface client)
          Constructor for the connection
 
Method Summary
private  void activeData(LmpFrame frame)
          Handle incomming data while connected.
 void connectConfirm(byte[] data)
          Confirm the requested connection.
 void connectionRequest(byte rLsap)
          Request a connection to the remote lsap.
 void connectionRequest(byte rLsap, byte[] data)
          Request a connection to the remote lsap.
private  void csetupData(LmpFrame frame)
          Handle incomming data during connection setup.
 boolean dataRequest(byte[] data)
          Queue data for tranmission to remote station.
 void dataRequest(byte lLsap, byte rLsap, byte[] data)
          Deprecated. This method has been replaced by dataRequest(byte[])
 boolean discoveryRequest(DiscoveryCallbackInterface dCb)
          start discovery of devices.
 byte getLocalLsap()
          Get the local lsap for this connection.
 int getMaxDataSize()
          get max size of payload
 int getPacketSize()
          get size of packet remote allows us to send
 byte getRemoteLsap()
          Get the remote lsap for this connection.
 int getState()
          Method to get the current state of the connection
 void linkConnectRequest(int address)
          create a LAP session to the given address.
 void linkDisconnectRequest()
          Request a Link disconnection (disconnects all IR connections)
 void lmpCallbackConnectConfirm()
          Called when an LAP connect is confirmed.
 void lmpCallbackConnectIndication()
          Called when an LAP connect occurs.
 void lmpCallbackData(LmpStation station, LmpFrame frame)
          Whenever data is received by the IrDA stack and the LMP session target matches the local lsap this method is called.
 void lmpCallbackDisconnect()
          This method is called whenever a disconnect occurs.
 void lmpSetLocalLsap(byte lsap)
          Set local lsap for this connection.
private  void readyData(LmpFrame frame)
          Handle data while waiting for a connection
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

NOT_READY

public static final int NOT_READY
Connection not ready.

READY

public static final int READY
Ready for incomming/outgoing connection

CSETUP

public static final int CSETUP
Outgoing call being setup

INCOMING

public static final int INCOMING
Incoming call received

ACTIVE

public static final int ACTIVE
Active connection.

state

private int state

client

private ConnectionCallbackInterface client

station

private LmpStation station

localLsap

private byte localLsap

remoteLsap

private byte remoteLsap
Constructor Detail

LmpConnection

public LmpConnection(ConnectionCallbackInterface client)
Deprecated. Use LmpConnection(LmpStation,ConnectionCallbackInterface)

Constructor for the connection
Parameters:
client - Instance of a class implementing the ConnectionCallbackInterface

LmpConnection

public LmpConnection(LmpStation station,
                     ConnectionCallbackInterface client)
Constructor for the connection
Parameters:
client - Instance of a class implementing the ConnectionCallbackInterface
station - Instance of LmpStation, the link to lower levels of IR
Method Detail

lmpCallbackConnectIndication

public void lmpCallbackConnectIndication()
Called when an LAP connect occurs. Used to initialize the stack. Used by lower levels of the IR stack.
Specified by:
lmpCallbackConnectIndication in interface LmpCallbackInterface

lmpCallbackConnectConfirm

public void lmpCallbackConnectConfirm()
Called when an LAP connect is confirmed. Used to initialize the stack and notify the user. Used by lower levels of the IR stack.
Specified by:
lmpCallbackConnectConfirm in interface LmpCallbackInterface

lmpCallbackData

public void lmpCallbackData(LmpStation station,
                            LmpFrame frame)
Whenever data is received by the IrDA stack and the LMP session target matches the local lsap this method is called. Used by lower levels of the IR stack.
Specified by:
lmpCallbackData in interface LmpCallbackInterface
Parameters:
station - reference to the lower level
frame - LmpFrame received.

lmpCallbackDisconnect

public void lmpCallbackDisconnect()
This method is called whenever a disconnect occurs. This might even occur when no connection is currenly active. Used by lower levels of the IR stack
Specified by:
lmpCallbackDisconnect in interface LmpCallbackInterface

readyData

private void readyData(LmpFrame frame)
Handle data while waiting for a connection

csetupData

private void csetupData(LmpFrame frame)
Handle incomming data during connection setup.

activeData

private void activeData(LmpFrame frame)
Handle incomming data while connected.

dataRequest

public boolean dataRequest(byte[] data)
Queue data for tranmission to remote station. Data length should not exceed 48 bytes (not checked at this moment)
Specified by:
dataRequest in interface IrConnection
Parameters:
data - Byte array of data to be tranmitted
Returns:
boolean value indicating successfull queuing of the data. TRUE does not garantee succesfull transmission!

dataRequest

public void dataRequest(byte lLsap,
                        byte rLsap,
                        byte[] data)
Deprecated. This method has been replaced by dataRequest(byte[])


getState

public int getState()
Method to get the current state of the connection
Returns:
state of the connection.

getLocalLsap

public byte getLocalLsap()
Get the local lsap for this connection.
Returns:
byte lsap.

lmpSetLocalLsap

public void lmpSetLocalLsap(byte lsap)
Set local lsap for this connection. This is done at MUX registration time.
Specified by:
lmpSetLocalLsap in interface LmpCallbackInterface
Parameters:
lLsap - byte local lsap

getRemoteLsap

public byte getRemoteLsap()
Get the remote lsap for this connection. The value is only valid is the connection state is ACTIVE.
Returns:
byte lsap.

discoveryRequest

public boolean discoveryRequest(DiscoveryCallbackInterface dCb)
start discovery of devices.
Specified by:
discoveryRequest in interface IrConnection
Parameters:
dCb - DiscoveryCallbackInterface instance to report back to.

linkConnectRequest

public void linkConnectRequest(int address)
create a LAP session to the given address. Needed before LMP connections can be initiated
Specified by:
linkConnectRequest in interface IrConnection
Parameters:
address - The address of the remote device

linkDisconnectRequest

public void linkDisconnectRequest()
Request a Link disconnection (disconnects all IR connections)
Specified by:
linkDisconnectRequest in interface IrConnection

connectionRequest

public void connectionRequest(byte rLsap)
Request a connection to the remote lsap.
Specified by:
connectionRequest in interface IrConnection
Parameters:
lsap - Remote lsap to connect to.
Returns:
boolean value indication successfull queuing of the request

connectionRequest

public void connectionRequest(byte rLsap,
                              byte[] data)
Request a connection to the remote lsap.
Specified by:
connectionRequest in interface IrConnection
Parameters:
lsap - Remote lsap to connect to.
data - Data to be send to remote in this request
Returns:
boolean value indication successfull queuing of the request

connectConfirm

public void connectConfirm(byte[] data)
Confirm the requested connection.
Specified by:
connectConfirm in interface IrConnection
Parameters:
data - Data to be transferred in confirmation message, null in case no additional data is needed

getPacketSize

public int getPacketSize()
get size of packet remote allows us to send
Specified by:
getPacketSize in interface IrConnection
Returns:
size in bytes

getMaxDataSize

public int getMaxDataSize()
get max size of payload
Specified by:
getMaxDataSize in interface IrConnection
Returns:
size in bytes