使用Java和AT命令发送短信

使用Java和AT命令发送短信

问题描述:

我有一个TC65调制解调器,我无法从任何地方获得帮助。我想问一下如何使用Java来执行AT命令。程序编写完成后,它将被上传到调制解调器,并可以独立运行。我想用Java编写一个使用AT命令发送SMS的代码。使用Java和AT命令发送短信

任何人都可以帮助我吗?我怎么会写这在Java中:

数= + XXXXXXXXXX

AT + CMGS =人数/输入

(消息)/输入

我要上传这个程序,我的GSM调制解调器,以便在上电时发送短信。

package example.helloworld; 

import javax.microedition.midlet.*; 

/** 
* MIDlet with some simple text output 
*/ 

public class HelloWorld extends MIDlet { 

    /** 
    * Default constructor 
    */ 
    public HelloWorld() { 
     System.out.println("Welcome"); 
    } 

    /** 
    * 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"); 
     System.out.println("\nHello World\n"); 

     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 + ")"); 

     notifyDestroyed();  
    } 
} 

谢谢。

+1

定义“使用Java语言编写本”,你的意思为'String'或流?还是其他什么东西?另外,告诉我们你已经尝试了什么。 – Jeffrey 2012-03-10 17:40:05

+0

已编辑的问题。 – 2012-03-11 15:03:10

+0

我在哪里添加它,以及如何告诉它执行AT命令?任何帮助,将不胜感激。 – 2012-03-11 15:06:44

尝试类似的东西:

public void startApp() throws MIDletStateChangeException { 
    System.out.println("startApp"); 

    String MyMessage = "Hello"; 

    ATCommand atc = new ATCommand(false); 
    atc.send("at+cmgf=1\r"); 
    atc.send("at+cmgs=1234567\r"); 
    atc.send(MyMessage + "\032\r"); // 32 = CTRL-Z 

    destroyApp(true); 
} 

注意,这是TC65的东西。不便携式。

所需进口:

import com.siemens.icm.io.ATCommand;