Saturday, March 13, 2010

SEND SMS USING AT COMMANDS FROM MOBILE PHONE CONNECTED TO YOUR PC :ASP.NET C#


AT commands is used to communicate with gsm modem.There are many type of gsm modems,so that the AT commend also vary with the model we use.By AT commend mean Attention Terminal.we can communicate with a mobile phone connected to your PC using Hyper Terminals .First of all for starting a communication with gsm modem or mobile phone
we will send an "AT" command to the gsm modem,gsm modem respond it with an "OK" command. For sending an sms from nokia mobile we need to set the message format to text, for that we send the command "AT+CMGF=1",the phone also responses it with an "OK" command. then we will send the recipient mobile number to the gsm modem using "AT+CMGS="123456789"" after this command we will send the msg and for notifying the end of msg we click ctrl+z.



programming this using ASP.NET c# we have to declare a serial port

private SerialPort SMSPort;

send the commands through this serial port

char cr = (char)13;
char lf = (char)10;
SMSPort.WriteLine("AT");
Thread.Sleep(4);
SMSPort.Write("" + cr + lf);
Thread.Sleep(100);
Thread.Sleep(100);
Thread.Sleep(100);
SMSPort.Write("ATE0");
Thread.Sleep(25);
SMSPort.Write("" + cr + lf);
Thread.Sleep(25);
SMSPort.Write("AT+CMGF=1");
SMSPort.Write("" + cr + lf);
Thread.Sleep(25);
SMSPort.Write("AT+CMGS=");
SMSPort.Write("" + (char)34);
SMSPort.Write(SMSMessage);
SMSPort.Write("" + (char)34);
Thread.Sleep(100);
SMSPort.Write("" + cr + lf);
Thread.Sleep(200);
SMSPort.Write(msg);
Thread.Sleep(250);
SMSPort.Write("" + (char)26);


Here we use the ascii value of ctrl+z ,26 to notify the end of the msg.


6 comments:

  1. The blog posted is very interesting from all aspects and it will surely benefit the readers by all means.
    send sms from pc

    ReplyDelete
  2. That's an interesting blog post. For everyone, it is very important to promote the business and I am so glad that in the modern scenario you can effortlessly promote your brand by spending just a few bucks. Even I got the app for real estate text marketing. It is very affordable but super effective for my needs.

    ReplyDelete
  3. If you are looking for more information about flat rate locksmith Las Vegas check that right away. geolocatel

    ReplyDelete
  4. I have a hard time describing my thoughts on content, but I really felt I should here.Your article is really great.I like the way you wrote this information. amarmobile.com.bd

    ReplyDelete
  5. Your blog provided us with valuable information to work with. Each & every tips of your post are awesome. Thanks a lot for sharing. Keep blogging,
    Mobile Price in BD 2020

    ReplyDelete
  6. There is noticeably big money to comprehend this. I assume you have made specific nice points in features also. فضای مجازی

    ReplyDelete