Dial a mobile phone through the C # program

I am trying to dial a mobile phone through a C # program. My program is shown below. In this case, when I press my dial button, dial the number (destination number) that I indicated in my program. But after one or two seconds, it disappears and does not connect to this destination number. Below is my C # code. Pls help me solve this problem. Thanks.......

using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.IO.Ports; namespace WindowsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { } private void button1_Click(object sender, EventArgs e) { SerialPort sp = new SerialPort(); sp.PortName = "COM10"; sp.BaudRate = 9600; sp.Parity = Parity.None; sp.DataBits = 8; sp.StopBits = StopBits.One; sp.Handshake = Handshake.XOnXOff; sp.DtrEnable = true; sp.RtsEnable = true; sp.Open(); if (!sp.IsOpen) { MessageBox.Show("Serial port is not opened"); return; } sp.WriteLine("AT" + Environment.NewLine); sp.WriteLine("ATD=\"" + "Destination Number" + "\"" + Environment.NewLine); } } } 

Finally, I found a solution. We must add a comma to the end of the destination number. then it worked.

 sp.WriteLine("ATD=\"" + "Destination Number;" + "\"" + Environment.NewLine); 
+8
c #
source share
3 answers

Maximize BaudRate and use the AT command:

 ATD = DestinationNumber; 

This will not work with ; , since the system will assume that you are accepting a data call, not a voice call.

+1
source share

Try moving the deviation 'sp' outside the method, for example:

 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.IO.Ports; namespace WindowsApplication1 { public partial class Form1 : Form { private SerialPort sp; public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { sp = new SerialPort(); } private void button1_Click(object sender, EventArgs e) { if (sp.IsOpen) { sp.Close(); } sp.PortName = "COM10"; sp.BaudRate = 9600; sp.Parity = Parity.None; sp.DataBits = 8; sp.StopBits = StopBits.One; sp.Handshake = Handshake.XOnXOff; sp.DtrEnable = true; sp.RtsEnable = true; sp.Open(); if (!sp.IsOpen) { MessageBox.Show("Serial port is not opened"); return; } sp.WriteLine("AT" + Environment.NewLine); sp.WriteLine("ATD=\"" + "Destination Number" + "\"" + Environment.NewLine); } } } 
0
source share

Here is my working set, which he calls on the phone. I don’t know how to get the input sound and exit the port. I am using huwavi E173 dongle. Here is my working C # cord

 SerialPort port = new SerialPort(); port.Open(); string t = port.ReadExisting(); Thread.Sleep(100); string cmd = "ATD"; Thread.Sleep(100); string phoneNumber = "071********"; Thread.Sleep(100); port.WriteLine(cmd + phoneNumber + ";\r"); port.Close(); 
0
source share

All Articles