1

Is it possible to send SMS messages using GSM Modem? As I try to do this, I can't seem to send SMS. It always run failed. I am using GSM Comm library.

Here is my Connect to Modem code

    if(ComPort.Text == "")
    {
        return;
    }
    comm = new GsmCommMain(ComPort.Text, 9600, 150);
    bool retry;
    do
    {
        retry = false;
        try
        {
            comm.Open();
            string message = "Success!";
            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            sb.Append("<script type = 'text/javascript'>");
            sb.Append("window.onload = function(){");
            sb.Append("alert('");
            sb.Append(message);
            sb.Append("')};");
            sb.Append("</script>");

            ClientScript.RegisterStartupScript(this.GetType(), "alert", sb.ToString());
            retry = true;
        }
        catch (Exception)
        {

            string message = "Gsm not available";
            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            sb.Append("<script type = 'text/javascript'>");
            sb.Append("window.onload = function(){");
            sb.Append("alert('");
            sb.Append(message);
            sb.Append("')};");
            sb.Append("</script>");

            ClientScript.RegisterStartupScript(this.GetType(), "alert", sb.ToString());
            return;
        }
    } while (retry);
}

And here is my Sending code

protected void Send_Click(object sender, EventArgs e)
{
    try
    {
        SmsSubmitPdu pdu;
        pdu = new SmsSubmitPdu(Message.Text, Number.Text);
        comm.SendMessage(pdu);

    }
    catch
    {
        string message = "Sending failed!";
        System.Text.StringBuilder sb = new System.Text.StringBuilder();
        sb.Append("<script type = 'text/javascript'>");
        sb.Append("window.onload = function(){");
        sb.Append("alert('");
        sb.Append(message);
        sb.Append("')};");
        sb.Append("</script>");

        ClientScript.RegisterStartupScript(this.GetType(), "alert", sb.ToString());
    }
}

I don't know what the problem is. It can't send messages.

Pang
  • 9,564
  • 146
  • 81
  • 122
  • Is there an exception? If so what and where is it. Run this with a monitoring tool like sysinternals portmon to view traffic between the app and the device to ensure there is some and to spot any error responses. Does SendMessage return a message ref? An infinite retry loop will cause problems. – Alex K. Dec 04 '15 at 11:31
  • @AlexK. But is it possible to do? – VincentOscar Maceda Dec 04 '15 at 12:30
  • With same sending code I am sending SMS –  Jan 24 '19 at 11:43

0 Answers0