com.alarexgroup.m2mplf.adapters.csdDataCall
Class CSDDataCallAdapter

java.lang.Object
  extended by com.alarexgroup.m2mplf.adapters.csdDataCall.CSDDataCallAdapter
public final class CSDDataCallAdapter
extends java.lang.Object

This adapter can create data connection with other members of GSM network

Example:

import com.alarexgroup.m2mplf.M2Mlet;
import com.alarexgroup.m2mplf.adapters.csdDataCall.CSDDataCallAdapter;
import com.alarexgroup.m2mplf.adapters.csdDataCall.CSDDataCallAdapterListener;
import com.alarexgroup.m2mplf.adapters.incomingCallAdapter.IncomingCallAdapter;
import com.alarexgroup.m2mplf.adapters.incomingCallAdapter.IncomingCallAdapterListener;
import java.io.IOException;
import java.io.InputStream;

public class CSDExample extends M2Mlet implements CSDDataCallAdapterListener, IncomingCallAdapterListener {
    CSDDataCallAdapter csd;
    
    
    public CSDExample() {
    }

    public void onIncomingCSDData(InputStream is) {
        try {
            //method is called when there are incomming data from other side
            //incomming data are put into byte array
            byte [] b = new byte[is.available()];
            is.read(b);
        catch (IOException ex) {
            //error while reading data
        }
    }

    public void appStop(boolean unconditional) {
    }

    public void onDisconnectCSD() {
        //method is called in case the connection was interrupted
    }

    public void appStart() {
        //initialization;
        IncomingCallAdapter.getIncomingCallAdapter(this);
        csd = CSDDataCallAdapter.getCSDDataCallAdapter(this);
        
        // a variant with dialing the other side's number
        csd.dial("+420721888888");
        if (csd.isConnected()) {
            //connection established
            csd.sendData("Helooo, TC65 here, over!!!".getBytes());
        }
    }

    public void appPause() {
    }

    public void onIncomingCall(String number, int status, int type, int count) {
        if (status==IncomingCallAdapter.CALL_STATUS_INCOMING && type==IncomingCallAdapter.CALL_TYPE_DATA) {
            //incomming call is a data call
            //we answer (accept) it
            csd.answer();
            if (csd.isConnected()){
                //the connection is succesfully established
                csd.sendData("Helooo, TC65 here, over!!!".getBytes());
            }
            
        }
}

Field Summary
static int longSleep
           
static int shortSleep
           
static int timeForSleep
           
 
Method Summary
 java.lang.String answer()
          Answer to incomming data call
 void ATEvent(java.lang.String Event)
          Internal method
 void close()
          Releases this adapter's resources and terminates it's activity
 void CONNChanged(boolean SignalState)
          Internal method
 void DCDChanged(boolean SignalState)
          Internal method
 java.lang.String dial(java.lang.String dialnumber)
          Allows you to try for data connection with given number in GSM network
 void DSRChanged(boolean SignalState)
          Internal method
static CSDDataCallAdapter getCSDDataCallAdapter(CSDDataCallAdapterListener listener)
          Returns an active instance of CSD adapter
 java.io.OutputStream getOutputStream()
          Acquires active outputstream for data sending
 boolean isConnected()
          Method returns whether the CSD connection is active or not
 void RINGChanged(boolean SignalState)
          Internal method
 void sendData(byte[] data)
          Method for sending data
 void setPriority(int priority)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

shortSleep

public static int shortSleep

longSleep

public static int longSleep

timeForSleep

public static int timeForSleep
Method Detail

close

public void close()
Releases this adapter's resources and terminates it's activity

getCSDDataCallAdapter

public static CSDDataCallAdapter getCSDDataCallAdapter(CSDDataCallAdapterListener listener)
Returns an active instance of CSD adapter

Parameters:
listener - listener
Returns:
instance of active adapter

setPriority

public void setPriority(int priority)

isConnected

public boolean isConnected()
Method returns whether the CSD connection is active or not

Returns:
TRUE - only and if only the data connection is active

answer

public java.lang.String answer()
Answer to incomming data call

Returns:
a string with outcome of connection process or NULL
in case there were any problems

dial

public java.lang.String dial(java.lang.String dialnumber)
Allows you to try for data connection with given number in GSM network

Parameters:
dialnumber - number of other peer for connection in +420123456789 format
Returns:
a string with the outcome of connection attempt

sendData

public void sendData(byte[] data)
Method for sending data

Parameters:
data - byte array to be sent

getOutputStream

public java.io.OutputStream getOutputStream()
Acquires active outputstream for data sending

Returns:
OutputStream active outputstream

ATEvent

public final void ATEvent(java.lang.String Event)
Internal method

RINGChanged

public final void RINGChanged(boolean SignalState)
Internal method

DSRChanged

public final void DSRChanged(boolean SignalState)
Internal method

DCDChanged

public final void DCDChanged(boolean SignalState)
Internal method

CONNChanged

public final void CONNChanged(boolean SignalState)
Internal method