Как объединить длинные SMS в библиотеке GSMComm?

Вот мой код:

Согласно этой странице метод CreateConcatTextMessage возвращает массив с типом 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);
        }

person Dac    schedule 21.01.2016    source источник


Ответы (2)


Ваш код должен выглядеть так:

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);
person Morteza Zabihi    schedule 08.11.2016

Введите номер без кода округа.

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

person Mansoor    schedule 28.05.2016
comment
Приведенный выше код работает нормально. Однако я хотел знать, есть ли необходимость закрывать порт, который мы открыли? - person Muhammad Abbas; 06.12.2018