'SMS application using C# and GSM modem is giving error
I am trying to make a SMS application to send message to phone number from this C# application by using GSM modem. but it gives this eorror.
+CME Error:PACM(AP),UNREGISTED
OK
OK
+CME Error:PACM(AP),NOT_ALLOWED_SLO
OK
+CME Error:PACM(AP),NOT_ALLOWED_SLO
OK
+CME Error:PACM(AP),NOT_ALLOWED_SLO
OK HI
ERROR
here is my code
private void btnsend_Click(object sender, EventArgs e)
{
try
{
SerialPort sp = new SerialPort();
sp.PortName = txtport.Text;
sp.Open();
sp.WriteLine("AT" + Environment.NewLine);
Thread.Sleep(100);
sp.WriteLine("AT+CMGF=1" + Environment.NewLine);
Thread.Sleep(100);
sp.WriteLine("AT+CSCS=\"GSM\"" + Environment.NewLine);
Thread.Sleep(100);
sp.WriteLine("AT+CMGS=\"" + txtphone.Text + "\"" + Environment.NewLine);
Thread.Sleep(100);
sp.WriteLine(txtmessage.Text + Environment.NewLine);
Thread.Sleep(100);
sp.Write(new byte[] { 26 }, 0, 1);
Thread.Sleep(100);
var response = sp.ReadExisting();
if (response.Contains("ERROR"))
{
MessageBox.Show("Sending fialed", "Message", MessageBoxButtons.OK, MessageBoxIcon.Stop);
MessageBox.Show(response);
}
else
{
MessageBox.Show("Message sent", "Message", MessageBoxButtons.OK, MessageBoxIcon.None);
}
sp.Close();
}
catch (Exception ex)
{
}
}
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
