i need a simple C/C++ program that sends SMSs via the attached GSM modem. I have some experience in C programming, but i haven't controlled the COM port.
Also, i need to give 2 variables , one for the recipient's number, and second for the actual message. So, when compiled, i should use (for example) : "C:\sms.exe" <number> <message>
I googled and found some similar apps ( including Microsoft SMS sender ) , but they all bring up the GUI, and i need to do it via command-line.
I doubt that it's complicated or hard, but i just don't have the knowledge to do it.
Thanks in advance, any help will be appreciated.

5 Years
Discussion Span
Last Post by sunnythesun

well u need to use At commands.
try to search about these commands and u sure will get what u want


Yes, i know the AT commands, googled it already. I'm sorry, i didn't specify the problem. I don't know how to communicate through the COM, how to open it, or initialize it, what is the syntax, etc.


U need to instal ur phones software
U need a cable or bluetooth to connect ur phone with pc
U need to check that phone is connected on which port
control panel -->phones and modems-->modems
connect ur phone
a new port will be made available
it is the one to be used in prj

There are 2 ways to send/rcv sms
1) using at commands
(used option)
2) using a sms gateway
(high in cost)

we use at commands
first set ur phone to data/fax mode
to check whether ur phone supports at commands perform following

open hyper terminal
create a new connecion
U get a notepad like window where u need to run AT commands

if the text u r typing is not visibile then
file->properties->settings->ascii setup->echo check(on)

to check 2 way comm link between mobile n comp

phone can work in 2 modes
text and pdu mode

set the phone to text mode so that i/o is in english text

to send sms

> this is a sample
> MESSAGE (press ctrl z)
+CMGS: 153


some phones require u to provide a ; after phone no
so the command becomes

> this is a sample
> MESSAGE (press ctrl z)
+CMGS: 153


to receive sms

+CMGL: 3830,"REC UNREAD","+919881111111"
Sir, please email full list of softwares to <<snip>>
Thank you.
+CMGL: 3828,"REC UNREAD","+919881111111"
Sir can we come today u r going to give appointment today at 4:00
Plz reply


Edited by Nick Evan: Removed mail


I have done that too, i have opened the hyperterminal, successfully communicated with the modem ( which is not a mobile phone, but a dedicated Siemens MC35i GSM modem ), and successfully sent a SMS to my number. The point is that i don't know the C/C++ syntax to send these AT commands. A friend told me it's like the printf() function, but you have to forward it not to screen, but the COM port. That's what i don't know how to accomplish. I already know how to make the program expect some variables ( the phone number and the message). As i said, i just don't know how to initialize the COM ( if it's needed) and how to make my C/C++ program send these AT commands.
Thank you very much for your previous comments!
P.S. I don't need to receive SMSs, i just need to send them.
P.S.2 Also, , what baud rate should i use, and how to define them. I have set the modem in Windows' Phone and Modem options, but i (think) am not communicating via this driver, i am connecting directly to the COM port, so the settings defined in Windows' modem options should not apply. Correct me if i'm wrong. Thanks again.

Edited by rattlesnake_bac: n/a


I think its better if u write this program in java and u will easily find that code
Also java provides many inbuilt libraries which c/c++ often don't provide.
using the port class u can set the baud rate and also write the required At commands
port.setSerialPortParams(9600, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);

This article has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.