I'm trying to make an SMS Application using AT Command. What I want to know is that how can I get the port of GSM Modem instead of hard coding it?
Below is my sample of my code.
private void SendSMSTo(string cnum)
{
SerialPort _serialPort;
_serialPort = new SerialPort("COM9", 115200);
//instead of hard coding the port COM9 I want to get the port from GSM Modem
Thread.Sleep(1000);
_serialPort.Open();
Thread.Sleep(1000);
_serialPort.Write("AT+CMGF=1\r");
Thread.Sleep(1000);
_serialPort.Write("AT+CMGS=\"" + cnum + "\"\r\n");
Thread.Sleep(1000);
_serialPort.Write(computation() + "\x1A");
Thread.Sleep(1000);
_serialPort.Close();
}