I want to make a call from a GSM modem using C#. I have written the following code. but I am unable to make the call. Please tell what the mistake is. Also let me know how to handle the response in the code from the modem so that I can display a message like "call connecting" or "cannot connect".
private void button1_Click(object sender, EventArgs e)
{
SerialPort po = new SerialPort();
po.PortName = "COM3";
po.BaudRate = int.Parse( "9600");
po.DataBits = Convert.ToInt32("8");
po.Parity = Parity.None;
po.StopBits = StopBits.One;
po.ReadTimeout = int.Parse("300");
po.WriteTimeout = int.Parse("300");
po.Encoding = Encoding.GetEncoding("iso-8859-1");
po.Open();
po.DtrEnable = true;
po.RtsEnable = true;
po.DataReceived += new SerialDataReceivedEventHandler(port_DataReceived);
po.Write("ATD9030665834;");
}
public void port_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
if (e.EventType == SerialData.Chars)
{
//what to write here to display the response??
}
}
Use port.WriteLine("ATD"+phno+";");
This will definitely solve your problem..
And to handle the response use port.ReadExisting() and compare with your requirement. As easy as that :)
Good luck..