通过 GSM 调制解调器接收和发送短信

发布于 2025-01-07 14:10:43 字数 117 浏览 2 评论 0原文

我如何通过 GSM 调制解调器接收短信,以便我可以使用该短信进行进一步处理并发回回复短信。 我对如何实现这一目标没有特别的想法...... 我更喜欢在这个项目中使用 java 语言,并且我使用的是 Linux 操作系统。

How can I receive SMS through a GSM modem so that I can use this SMS for further processing and send back a reply SMS.
I do not have particular idea on how to achieve this.......
I prefer using java language for this project and I am using Linux OS.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

﹎☆浅夏丿初晴 2025-01-14 14:10:43

您可能想看看 SMSLib

SMSLib是一个用于发送和接收短信的程序员库
通过 GSM 调制解调器或移动电话发送消息。 SMSLib 还支持一些
批量短信运营商。

You might want to give a look at SMSLib:

SMSLib is a programmer's library for sending and receiving SMS
messages via a GSM modem or mobile phone. SMSLib also supports a few
bulk SMS operators.

jJeQQOZ5 2025-01-14 14:10:43

要使用 3G 调制解调器发送短信,您需要使用适当的 AT 命令。首先,您需要将调制解调器设置为文本模式:

AT+CMGF=1

然后发送消息:

AT+CMGS=<number><CR>
<message><CTRL-Z>

其中 是回车符 (ASCII 13),是您要发送的消息, 是 ASCII 26, 是您要将消息发送到的号码。

要读取收到的消息,请执行以下操作:

AT+CMGL=<stat><CR>

其中 是以下之一:"ALL""REC UNREAD"“REC READ”(带引号),分别表示所有消息、未读消息和已读消息。

要在 Java 中执行此操作,您需要使用 Java 通信 API。这是一个简短的例子:
http://java.sun.com/products/javacomm/reference/docs /API_users_guide_3.html

To send an SMS using a 3G modem, you need to use the appropriate AT commands. First you need to set the modem to text mode:

AT+CMGF=1

Then you send your message:

AT+CMGS=<number><CR>
<message><CTRL-Z>

Where <CR> is a carriage return (ASCII 13), and <message> is the message you want to send, <CTRL-Z> is ASCII 26, and <number> is the number you want to send your message to.

To read received messages, you do this:

AT+CMGL=<stat><CR>

Where <stat> is one of: "ALL", "REC UNREAD", "REC READ" (with the quotes), meaning all messages, unread messages, and read messages respectively.

To do this in Java you'll need to use the Java communications API. Here's a short example:
http://java.sun.com/products/javacomm/reference/docs/API_users_guide_3.html

那支青花 2025-01-14 14:10:43

嗨,我正在使用 RXTX 库,代码在这里!..它对我来说工作得很好,我搜索了很多东西来获得正确的方法,最终得到了短信的关键!..:D

                String mValue = "AT\r";// strating to communicate with port starts here!
    mOutputToPort.write(mValue.getBytes());
    mOutputToPort.flush();
    Thread.sleep(500);
    mInputFromPort.read(mBytesIn);
    value = new String(mBytesIn);
    System.out.println("Response from Serial Device: "+value);
                mValue = "AT+cmgf=1\r";
    mOutputToPort.write(mValue.getBytes());
                mOutputToPort.flush();
                mValue="at+cmgs=\" Mobile number\"\r";
                System.out.print(mValue);
                mOutputToPort.write(mValue.getBytes());
            mOutputToPort.flush();
            mValue="at+cmgs="\032";//calling ctrl+z
                System.out.print(mValue);
                mOutputToPort.write(mValue.getBytes());
            mOutputToPort.flush();
          mOutputToPort.close(); 
    mInputFromPort.close();

hi i'm using RXTX library the code goes here!.. and its works fine for me , i searched a lot of things to get correct method finaly got the key to sms!.. :D

                String mValue = "AT\r";// strating to communicate with port starts here!
    mOutputToPort.write(mValue.getBytes());
    mOutputToPort.flush();
    Thread.sleep(500);
    mInputFromPort.read(mBytesIn);
    value = new String(mBytesIn);
    System.out.println("Response from Serial Device: "+value);
                mValue = "AT+cmgf=1\r";
    mOutputToPort.write(mValue.getBytes());
                mOutputToPort.flush();
                mValue="at+cmgs=\" Mobile number\"\r";
                System.out.print(mValue);
                mOutputToPort.write(mValue.getBytes());
            mOutputToPort.flush();
            mValue="at+cmgs="\032";//calling ctrl+z
                System.out.print(mValue);
                mOutputToPort.write(mValue.getBytes());
            mOutputToPort.flush();
          mOutputToPort.close(); 
    mInputFromPort.close();
柏林苍穹下 2025-01-14 14:10:43

看看 SMSJ:一个功能齐全的库,允许使用 GSM 调制解调器或几种流行的网络发送和接收短信服务。

Take a look on SMSJ: a fully functional library that allows sending and receiving SMS using either GSM modem or several popular web services.

不语却知心 2025-01-14 14:10:43

查看 Java SMSLib API

来自该网站:“SMSLib 是一个程序员的库,用于通过 GSM 调制解调器或移动电话发送和接收 SMS 消息。SMSLib 还支持一些批量 SMS 运营商。”

Take a look at the Java SMSLib API.

From the web site : "SMSLib is a programmer's library for sending and receiving SMS messages via a GSM modem or mobile phone. SMSLib also supports a few bulk SMS operators."

尛丟丟 2025-01-14 14:10:43

您应该查看调制解调器手册。有些设备支持telnet连接,您可以通过命令行发送AT命令

如果这是您的情况,您必须了解(有时针对每种设备)并编写一个使用 telnet 与调制解调器通信的应用程序。
Apache Commons Net 项目 可能很有用。

一些 AT 命令指南:

或者,您可以尝试使用其他人建议的库之一。

You shoud take a look at your modem manual. Some devices support telnet connection and you can sent AT commands via command line.

If this is your case you have to learn about (sometimes specific for each device), and code an application that uses telnet to communicate with your modem.
Apache Commons Net project can be useful.

Some AT commands guides:

Alternatively you can try to use one of the libraries suggested by others.

难忘№最初的完美 2025-01-14 14:10:43

你可以使用很多方法...

  • SMS Enabler
  • SMS Lib for java
  • Ozeki sms gateway

用于接收短信的最佳和简单的解决方案将是
SMSenabler 它将立即将您的短信保存到文件或数据库中,您可以检索它
免费版本最多支持 12 个字符
如果您想发送短信,那么您可以使用[在此处输入链接描述][Ozeki] Ozeki 短信服务器网关

U can use many methods ...

  • SMS Enabler
  • SMS Lib for java
  • Ozeki sms gateway

For recieving SMS best and simple solution will be
SMSenabler it will save your SMS instantly to file or database and u can retrieve it
Free version supports upto 12 characters
and if you want to send sms then you can use [enter link description here][Ozeki] Ozeki sms server gateway

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文