1

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.

hlovdal
  • 26,565
  • 10
  • 94
  • 165
Iqbal
  • 17
  • 4
  • share your code , issue is in usb or bluetooth – ashish Mar 11 '14 at 10:43
  • Code is not my concern. I may find different code for different device. I need to know is that common command for all device. Thanks Ashish for quick reply. – Iqbal Mar 11 '14 at 10:46

1 Answers1

1

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.

Community
  • 1
  • 1
hlovdal
  • 26,565
  • 10
  • 94
  • 165
  • Thank u for your reply. The code I used from here: http://www.codeproject.com/Articles/38705/Send-and-Read-SMS-through-a-GSM-Modem-using-AT-Com. That is bit complex to show in here. But My above code woks for some device. – Iqbal Mar 12 '14 at 09:33