Sending of AT CMGF=1 command finished (successfully or not) In fact stop reading this answer here now, download that document, read all of chapter 5 before returning to read the rest.įor sending commands where you do not particularly care about the response 1, the only reliably approach is to do something similar to serialport.Open() Just to emphasis how important that document is: Even after working with implementing AT command in mobile phones in Ericsson for over a decade I and my colleagues still consulted that standard regularly. Like for instance that using WriteLine and/or Environment.NewLine is wrong AT command lines should be terminated with \r alone and nothing else. This standard is the bible for AT command handling and will teach you an enormous amount regarding AT command handling. My suggestion is that you start by fetching a copy of the V.250 standard and read at least all of chapter 5. You must read and parse everything the modem sends back to you. Just as you would not write a http client that completely ignores all responses from the http server, you should not send AT commands to a modem and completely ignore the responses it sends back. You should never, never, ever use sleep as a substitute for waiting for the Final result code from the modem. If anyone can pin point the mistake in the above code, I will be very grateful. When I use the software that comes with gsm modem, I am able to send sms. I was able to send the sms using this very code yesterday, but i do not know why it doesn't work any more. MessageBox.Show("Couldn't send the SMS.", "CONNECTION ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error) Serialport.WriteLine(SMSTxt.Text (char)26) Serialport.WriteLine("AT CMGS=" (char)34 NumTxt.Text Serialport.WriteLine("AT CMGF=1" Environment.NewLine) Use.", "CONNECTION ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error) Serialport.NewLine = Environment.NewLine Įnvironment.NewLine "Phone not detected or The requested resource is in Serialport.Handshake = Handshake.XOnXOff Private void button1_Click(object sender, EventArgs e) Port name entered in texbox ComPort Here's the event handler of the button click event. A button, when clicked, sends an sms to the number entered in NumTxt textbox, and sends the text entered in SMSTxt textbox.
0 Comments
Leave a Reply. |