You are here

Auto answering voice calls(java WA) for EHsx modules and Terminals

Tutorial, January 9, 2017 - 2:44pm, 1107 views

Hi,

Autoanswering voice calls is a feature not implemented in Java modules and Terminals.

Even if we are not using java, that's only AT commands, this small midlet can be used.

* Table 1: A typical sequence of MIDlet execution

* (A) Application Management Software (B) MIDlet

                1.            A) The application management software creates a new instance of a MIDlet.

                               B) The default (no argument) constructor for the MIDlet is called; it is in the Paused state.

                2.            A) The application management software has decided that it is anappropriate time for the MIDlet to run,

                so it calls the MIDlet.startApp() method for it to enter the Active state.

                               B) The MIDlet acquires any resources it needs and begins to perform its service.

                3.            A) The application management software no longer needs the application be active,

                so it signals it to stop performing its service by calling the MIDlet.pauseApp() method.

                               B) The MIDlet stops performing its service and might choose to release some resources it currently holds.

                4.            A) The application management software has determined that the MIDlet is no longer needed,

                or perhaps needs to make room for a higher priority application in memory,

                so it signals the MIDlet that it is a candidate to be destroyed by calling the MIDlet.destroyApp() method.

                               B) If it has been designed to do so, the MIDlet saves state or user preferences and performs clean up.

*

*/

 

package principal;

 

import java.io.IOException;

 

import javax.microedition.midlet.*;

 

import com.cinterion.io.*;

 

/**

* MIDlet demonstrating the usage of the ATCommand class

*/

 

public class AtCmd extends MIDlet {

 

    private ATCommand m_Cmd;

    private Listener m_Listener = new Listener();

 

 

    /**

    * Implementation of ATCommandListener to receive asynchronous events

    *

    * @link file:///C:/Program%20Files%20(x86)/Cinterion/CMTK/EHS5/WTK/doc/html_impng/index.html

    */

    private class Listener implements ATCommandListener {

                public void ATEvent(String Event) {

                               //System.out.println("ATEvent " + Event);

                }             

                public void DCDChanged(boolean SignalState) {

                               //System.out.println("DCDChanged " + SignalState);

                }

                public void DSRChanged(boolean SignalState) {

                               //System.out.println("DSRChanged " + SignalState);

                }

                public void CONNChanged(boolean SignalState) {

                               //System.out.println("CONNChanged " + SignalState);

                }

               

                public void RINGChanged(boolean SignalState) {

                               System.out.println("RINGChanged " + SignalState);

                               try {

                                               if (SignalState)

                                               {

                                                               String res = m_Cmd.send("ata\r");         // hang up the voice call

                                                               System.out.println("Anwer Hang up:"+res);

                                               }

                               } catch (Exception e) {

                                               System.out.println(e);

                               }    

                }

 

    }

 

                /**

                 * Default constructor

                 */

                public AtCmd() {

                               System.out.println("Constructor");

                               try {

                                               m_Cmd = new ATCommand(false);

                                               m_Cmd.addListener(m_Listener);

                               } catch (Exception e) {

                                               System.out.println(e);

                               }

                }

 

                /**

                 * Implementation of ATCommandResponseListener to receive asynchronous responses

                 */

                /*private class RspListener implements ATCommandResponseListener {

                               public void ATResponse(String Response) {

                                               System.out.println("Received asynchronous response:");

                                               System.out.println(Response);

                               }

                }*/

 

                /**

                 * This is the main application entry point. Here we simply give some

                 * text output and close the application immediately again.

                 */

                public void startApp() throws MIDletStateChangeException {

                              System.out.println("startApp");

 

                               try {

                                               // disabling echo

                                               m_Cmd.send("ate0\r");

                                               // Ask the FW version

                                               System.out.println("Sending synchronous AT...");

                                               String Response = m_Cmd.send("ati\r");

                                               System.out.println("Received synchronous response:");

                                               System.out.println(Response);

 

                                               /*

                                               System.out.println("Sending asynchronous AT...");

                                               m_Cmd.send("ati\r", new RspListener());

 

                                               Thread.sleep(1000);*/

                               } catch (Exception e) {

                                               System.out.println(e);

                               }

 

                               //destroyApp(true);

                }

 

                /**

                 * Called when the application has to be temporary paused.

                 */

                public void pauseApp() {

                               System.out.println("pauseApp()");

                }

 

                /**

                 * Called when the application is destroyed. Here we must clean

                 * up everything not handled by the garbage collector.

                 * In this case there is nothing to clean.

                 */

                public void destroyApp(boolean cond) {

                               System.out.println("destroyApp(" + cond + ")");

 

                               try {

                                               m_Cmd.release();          // Release the modem

                               } catch (IOException e) {

                                               System.out.println(e);

                               }

 

                               notifyDestroyed();

                }

}

Regards

ALopez

Alopez

Contributors

Profile Picture
mullengers
Profile Picture
esander