com.siemens.mp.io
Class Connection

java.lang.Object
  extended bycom.siemens.mp.misc.NativeMem
      extended bycom.siemens.mp.io.Connection

public class Connection
extends com.siemens.mp.misc.NativeMem

The Connection class supports data transfer through SMS, IrDA and internal SMS loopback interfaces. It provides functionality for opening a bidirectional connection, sending data on it, and associating with it an incoming data listener. The listener object is an implementation of ConnectionListener interface. When associated to a specific connection, this objects' receiveData method will be called each time when incoming data is received.

See Also:
ConnectionListener

Example


Constructor Summary
Connection(String connectTo)
          Opens a new connection and creates a Connection object for it.
 
Method Summary
 ConnectionListener getListener()
           
 void send(byte[] data)
          Sends data via the created connection.
 void setListener(ConnectionListener listener)
          Registers a listener to receive data.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Connection

public Connection(String connectTo)
Opens a new connection and creates a Connection object for it. Now this connection may be used for data transfer.

Parameters:
connectTo - the connection type and destination address. The following strings may be used to create specific connections:
"SMS://number:appid". This will open an SMS data channel to the given phone number for the specified application id. This App-ID is in decimal format.
If the first part of the string is "IRDA:", infrared interface will be used. (This currently only works on SL45i / 6688i!)
If the first part of the string is "INTERNAL:", internal SMS loopback interface will be used.
Throws:
IllegalArgumentException - if SMS connection is used, and the number is not a correct phone-number

Example

Method Detail

send

public void send(byte[] data)
          throws NotAllowedException
Sends data via the created connection.

Parameters:
data - a bytearray containing data to send
Throws:
NotAllowedException - if SMS connection is used and the call is not acknowledged
See Also:
Connection constructor

Example


setListener

public void setListener(ConnectionListener listener)
Registers a listener to receive data. The listener object is an implementation of ConnectionListener interface. When associated to a specific connection, this objects' receiveData method will be called each time when incoming data is received.

Parameters:
listener - the ConnectionListener object

Example


getListener

public ConnectionListener getListener()
Returns:
registered ConnectionListener or null, if no listener is registered


Generated on 2003-10-17For further information and updates, please visit Siemens mobile Developer Portal