Hi all,
I am currently creating an app to send sms message to GSM Modem (mobile phone) using System.IO.Ports.SerialPort.
I beleive I have correctly configured the port as I am able to send AT commands to the modem and get replies form the modem which tells me I am connected.
But my problem is using the AT commands themselves, I dont know if they are being sent as expected.
All the commands I am using work with Hyperterminal on the same GSM Modem/Phone.
The problem may be the escape character for the end of the message, in Hyperterminal it is CTRL+Z, which I have read is chr(26).
Or it could be the other AT commands themselves.
Can anyone see my error in this code:
Code:
private void OpenPort()
{
port.PortName = "COM4";
port.ReceivedBytesThreshold = 1;
port.BaudRate = 115200;
port.DtrEnable = true;
port.DataReceived += new SerialDataReceivedEventHandler(OnCom4Receive);
port.Open();
}
private void SendMSG()
{
port.WriteLine("AT");
port.WriteLine("AT+CMGF=1");
port.WriteLine("AT+CMGS=\"0403075???\"");
//port.WriteLine("> TESTING 1,2,3,4" + char.ConvertFromUtf32(26));
port.WriteLine("TESTING 1,2,3,4" + Convert.ToChar(26));
}
static private void OnCom4Receive(object sender, SerialDataReceivedEventArgs e)
{
MessageBox.Show(port.ReadExisting());
}
There are not any errors returned at all.
Many thanks for your time in reading this.
======================================
They say, best men are molded out of faults,
And, for the most, become much more the better
For being a little bad.
======================================