繁体   English   中英

使用Java和AT命令发送短信

[英]Sending SMS using Java and AT Commands

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

有人可以帮我吗? 我将如何用Java编写:

号码= + xxxxxxxxxx

AT + CMGS =数字/输入

(消息)/输入

我要将这个程序上传到我的GSM调制解调器,以便它在开机时发送SMS。

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();    
    }
}

谢谢。

尝试这样的事情:

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;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM