Iqbal
Iqbal

Reputation: 17

Does AT command depend on device or its an independent API command?

I found some code on net that allow me to read/send SMS from a Mobile via bluetooth connection. But using USB EDGE modem I can't either send or read SMS. I just can connect to that modem's port.

My Code is:

string mobileNumber = txt_number.Text;
string smMessage = txt_message.Text;
AutoResetEvent receiveNow;
String command="";
SerialPort port = new SerialPort();
port.PortName = cmb_port.Text;
port.Open();
command = "AT+CMGF=1";
port.WriteLine(command);
command = "AT+CMGS=\"" + mobileNumber + "\"";
port.WriteLine(command);
command = smMessage + char.ConvertFromUtf32(26) + "\r";
port.WriteLine(command);
MessageBox.Show("Send Success");

It works on some device.

Upvotes: 1

Views: 372

Answers (1)

hlovdal
hlovdal

Reputation: 28258

It works on some device.

You are lucky if that code ever works. After you have sent an AT command to the modem, you MUST wait for and parse responses from the modem until you get a Final result code. There is absolutely no other way to handle this (but unfortunately there is a lot of dysfunctional code around the net that does not get this). For how to handle this, see this answer.

Upvotes: 1

Related Questions