当前位置: 首页 > 知识库问答 >
问题:

如何在GSMComm库中接收长短信?

冯流觞
2023-03-14

这是我的代码:

根据这个页面,CreateCattextMessage方法返回一个类型为SmsSubmitPdu[]的数组,但是当我试图用SendMessages发送它时,我得到一个MessageServiceError 500。我错过了什么?

       SmsSubmitPdu[] pdu2;

        try{
            pdu2 = SmartMessageFactory.CreateConcatTextMessage("My name is Barry Allen. And I am the fastest man alive. When I was a child I saw my mother killed by something impossible. My father went to prison for her murder.", "+639234597676");
            comm.SendMessages(pdu2);
        }

        catch (MessageServiceErrorException e500){
            MessageBox.Show(e500.ToString(), "Information", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
        }
        catch (CommException e501){
            MessageBox.Show(e501.ToString(), "Information", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
        }

共有2个答案

邹宏峻
2023-03-14

输入不带县代码的号码。

using GsmComm.GsmCommunication;
using GsmComm.PduConverter;
using GsmComm.PduConverter.SmartMessaging; 
using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                GsmCommMain comm = new GsmCommMain("COM7", 19200, 500);
                comm.Open();
                string txtMessage = "Input here very long message please ";
                string txtDestinationNumbers = "+79235280406";
                bool unicode = true;  
                SmsSubmitPdu[] pdu = SmartMessageFactory.CreateConcatTextMessage(txtMessage, unicode, txtDestinationNumbers);
                comm.SendMessages(pdu);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
    }
}

https://github.com/welly87/GSMComm

拓拔德馨
2023-03-14

您的代码应该如下所示:

GsmCommMain comm=new GsmCommMain(/*Set your option here*/);

string txtMessage="your long message...";
string txtDestinationNumbers="your destination number";

//select unicode option by a checkBox or any other control
bool unicode = chkUnicode.Checked;

SmsSubmitPdu[] pdu = SmartMessageFactory.CreateConcatTextMessage(txtMessage, unicode, txtDestinationNumbers);
сomm.SendMessages(pdu);
 类似资料:
  • 我希望我的Java应用程序在不使用任何额外硬件设备的情况下发送和接收短信,而且它必须是免费的。 我进行了搜索,但我只找到了标题,我找到了一些类似SMSLib的东西,但另一方面,我没有找到学习这些的教程或书籍。 我还发现了SMSLib代码,但不明白: 发送消息/短信代码 阅读信息/短信代码

  • 问题内容: 我尝试在我的应用中收到短信,并且确定问题出在我的AndroidManifest.xml文件中 我的SmsReceive.java就是这样 我确定我的问题出在manifest.xml中,因为 什么都不显示 我该怎么办 ? 编辑:正如我们的朋友所说的,我曾经用过 在我的函数中,但LogCat中什么也不会显示,所以我断然确定我的问题出在我的AndroidManifest.xml注意:我在HT

  • 清单中是否需要receiver/intent-filter块,如果需要,如何在第一行中命名侦听器? 在onReceive()中无法收到传入消息副本的可能原因是什么?我应该做些什么来更正它? 我是否需要发送消息并在onReceive()中“捕获它”以便可靠地获得设备的电话号码,或者我是否可以从用户那里请求读取SMS的权限,然后只需读取第一条消息即可获得传入的电话号码? 请注意,我已经通读了所有类似的

  • 我正在尝试设置一个类来接收短信和发送状态。以下是我的清单如何查找此任务: 我收到了收到的消息,但没有收到发送的消息,我的清单声明有问题吗?

  • 本文向大家介绍HTTP长连接、短连接?相关面试题,主要包含被问及HTTP长连接、短连接?时的应答技巧和注意事项,需要的朋友参考一下 在HTTP/1.0中默认使用短连接。也就是说,客户端和服务器每进行一次HTTP操作,就建立一次连接,任务结束就中断连接。当客户端浏览器访问的某个HTML或其他类型的Web页中包含有其他的Web资源(如JavaScript文件、图像文件、CSS文件等),每遇到这样一个W

  • 我试图使用我的手机作为GSM调制解调器。我使用SMSLib发送和接收短信用这个调制解调器。问题是,当我的手机(GSM调制解调器)收到短信时,我没有用SMSL通知ib.but代码整体是好的,例如当GSM调制解调器收到呼叫时通知我。我的代码没有任何错误,因为我只使用SMSLib示例代码接收消息。SMSLib示例代码是: 程序输出例如: modem.com4的网关状态更改,旧:停止- 调制解调器信息:制