SmsSubmitPdu GSMComm command is not supported by the device Wavecom modem

心不动则不痛 提交于 2020-01-04 04:53:43

问题


i am using GSMComm library and Wavecom modem to create simple program SMS Sender, when i press the button Send in my winform a got a message debug in my VS2010.

The phone reports an unspecified error. This typically happens when a command is not supported by the device, a command is not valid for the current state or if a parameter is incorrect.

this my code

private void btnSend_Click(object sender, EventArgs e)
        {
            var port = "COM3"; // default port to connect modem wavecom
            var baudRate = 115200;
            var timeout = 300;
            var comm = new GsmCommMain(port, baudRate, timeout);

        try
        {
            var msg = txtIsiPesan.Text;
            var phoneNumber = txtNoTujuan.Text;
            comm.Open();
            SmsSubmitPdu pdu = new SmsSubmitPdu(msg, phoneNumber, "");
            comm.SendMessage(pdu); //debug found error here
            comm.Close();
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message, "error");
        }

    }

Is this indicate that my wavecom modem didn't support to SmsSubmitPdu ? Please suggest me thanks.


回答1:


I have finally found the solution.

SmsSubmitPdu pdu = new SmsSubmitPdu(msg, phoneNumber, "");

the third parameter should be service center number as i am using GrameenPhone it is +8801700000600

So i tried with

SmsSubmitPdu pdu = new SmsSubmitPdu(msg, phoneNumber, "+8801700000600");

and successfull send sms. By the way make sure your com port is correct as mine is COM5.

var port = "COM5"; // default port to connect modem wavecom
            var baudRate = 115200;
            var timeout = 300;
            var comm = new GsmCommMain(port, baudRate, timeout);

            try
            {
                var msg = "TESTING";
                var phoneNumber = "+8801719461643";
                comm.Open();
                SmsSubmitPdu pdu = new SmsSubmitPdu(msg, phoneNumber, "+8801700000600");
                comm.SendMessage(pdu); //debug found error here
                comm.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "error");
            }



回答2:


when comm is open you can do a long polling by while loop ,read sms and delete the index of the sms msg.Add the code after comm.Open();

while(true){
 DecodedShortMessage[] messages =
     gsmCommMain.ReadMessages(PhoneMessageStatus.All, PhoneStorageType.Sim);
    foreach (var decodedShortMessage in messages)
    {
           var msgData = decodedShortMessage.Data.UserDataText;
          int indexP = decodedShortMessage.Index;
          gsmCommMain.DeleteMessage(indexP, PhoneStorageType.Sim);
          //  gsmCommMain.DeleteMessages(DeleteScope.Read, PhoneStorageType.Sim); delete all msg


       } 
}

Hope this helps



来源:https://stackoverflow.com/questions/28910230/smssubmitpdu-gsmcomm-command-is-not-supported-by-the-device-wavecom-modem

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!