How To Send SMS

Embed Size (px)

Citation preview

  • 8/12/2019 How To Send SMS

    1/31

    Download application - 21.6 KB

    Introduction Lesson 1

    There are many different kinds of applications SMSapplications in the market today,

    and many others are ein! de"eloped. #pplications in which SMSmessa!in! can e

    utili$ed are "irtually unlimited. %ome common e&amples of these are !i"en elow'

    (erson-to-person te&t messa!in! is the most commonlyused SMSapplication, and it is what the SMStechnolo!y was ori!inally

    desi!ned for.

    )any content pro"iders make use of SMSte&t messa!es to send information

    such as news, weather report, and financial data to their suscriers.

    SMSmessa!es can carry inary data, and so SMScan e used as the

    transport medium of wireless downloads. *+ects such as rin!tones,

    wallpapers, pictures, and operator lo!os can e encoded in SMSmessa!es.

    SMSis a "ery suitale technolo!y for deli"erin! alerts and notifications of

    important e"ents.

    SMSmessa!in! can e used as a marketin! tool.

    In !eneral, there are two ways to send SMSmessa!es from a computer ( to a

    moile phone'

    1. onnect a moile phone or %)(/% modem to a computer (. Then use

    the computer ( and #T commands to instruct the moile phone or

    %)(/% modem to send SMSmessa!es.

    2. onnect the computer ( to the SMScenter 0SMS or SMS!ateway of a

    wireless carrier or SMSser"ice pro"ider. Then send SMSmessa!es usin! a

    protocol interface supported y the SMS or SMS!ateway.

    In this article, I will e&plain the first way to send, read, and delete SMSusin! #T

    commands. But efore startin!, I would like to e&plain a little it aout #T

    commands.

    AT Commands

    #T commands are instructions used to control a modem. #T is the are"iation of

    #Ttention. "ery command line starts with 3#T3 or 3at3. That4s why modem

    commands are called #T commands. There are two types of #T commands'

    1. Basic commands are #T commands that do not start with a 353. or e&ample,D 0Dial, # 0#nswer, 7 07ook control, and * 0/eturn to online data state

    are the asic commands.

    2. &tended commands are #T commands that start with a 353. #ll %) #T

    commands are e&tended commands. or e&ample, 5)%

    0%end SMSmessa!e, 5)8 08ist SMSmessa!es, and 5)/

    0/ead SMSmessa!es are e&tended commands.

    If you want to !et more information aout #T commands, then you can !et it on my

    other article on ode(ro+ect

    here' http'www.codepro+ect.comKBsystemIntroductionto#Tcommands.asp& .

    http://www.codeproject.com/KB/IP/Send_and_Read_SMS/SMSapplication.ziphttp://www.codeproject.com/KB/system/IntroductiontoATcommands.aspxhttp://www.codeproject.com/KB/IP/Send_and_Read_SMS/SMSapplication.ziphttp://www.codeproject.com/KB/system/IntroductiontoATcommands.aspx
  • 8/12/2019 How To Send SMS

    2/31

    Operating Modes

    The SMSspecification has defined two modes in which a %)(/% modem or

    moile phone can operate. They are called SMSte&t mode and SMS(D9 mode.

    0(D9 stands for (rotocol Data 9nit. The mode that a %)(/% modem or moile

    phone is operatin! in determines the synta& of some SMS#T commands and the

    format of the responses returned after e&ecution.

    I am usin! SMSte&t mode in this article.

    How to Test GSM Modem Connectivity Using Hyper Terminal

    irst, find the est %) modem that suits the needs. I tested this application

    with a :a"ecom #%T/#K )12;6.

    9nderstand the #T ommand set re)odem is connected?.

  • 8/12/2019 How To Send SMS

    3/31

    ollapse

    publicSerialPort OpenPort(stringp_strPortName, intp_uBaudRate, intp_uDataBits,

    intp_uReadTimeout, intp_uWriteTimeout){ receieNo! " ne!#utoReset$ent(%alse)& SerialPort port " ne!SerialPort()&

    tr' { portPortName " p_strPortName& //COM1 portBaudRate " p_uBaudRate& //9600 portDataBits " p_uDataBits& //8 portStopBits " StopBitsOne& //1 portParit' " Parit'None& //None portReadTimeout " p_uReadTimeout& //300 portWriteTimeout " p_uWriteTimeout& //300 port$ncoding " $ncodinget$ncoding(*iso+-.+/*)& portDataReceied 0" ne!SerialDataReceied$ent1andler (port_DataReceied)& portOpen()& portDtr$nable " true&

    portRts$nable " true& 2 catc3($4ception e4) { t3ro!e4& 2 returnport&2

    Send SMS

    In the second ta, you can send SMS'

  • 8/12/2019 How To Send SMS

    4/31

    ollapse

    publicboolsend5sg(SerialPort port, stringP3oneNo, string5essage){ boolisSend " %alse&

    tr' { stringrecieedData " $4ec6ommand(port,*#T*, 788, *No p3one connected*)&

    recieedData " $4ec6ommand(port,*#T0659"/*, 788, *9ailed to set message %ormat*)& Stringcommand " *#T065S":**0 P3oneNo 0 *:**& recieedData " $4ec6ommand(port,command, 788, *9ailed to accept p3oneNo*)& command " 5essage 0 c3ar6onert9rom;t%7

  • 8/12/2019 How To Send SMS

    5/31

    ollapse

    publicS3ort5essage6ollection ReadSMS(SerialPort port){ // Set up the phone and read the messages S3ort5essage6ollection messages " null& tr' { @region$4ecute 6ommand

    // Check connection $4ec6ommand(port,*#T*, 788, *No p3one connected*)& // Use message format !e"t mode $4ec6ommand(port,*#T0659"/*, 788, *9ailed to set message %ormat*)& // Use character set #CC#$3% $4ec6ommand(port,*#T06S6S":*P66PA7:**, 788, *9ailed to set c3aracter set*)& // Se&ect S'M storage $4ec6ommand(port,*#T06P5S":*S5:**, 788, *9ailed to select message storage*)& // (ead the messages stringinput " $4ec6ommand(port,*#T065C":*#CC:**, -888, *9ailed to read t3e messages*)& @endregion

    @regionParse messages messages " Parse5essages(input)& @endregion 2 catc3($4ception e4) { t3ro!ne!$4ception(e45essage)& 2

    i%(messages " null) returnmessages& else returnnull&2

  • 8/12/2019 How To Send SMS

    6/31

    elete SMS

    In the fourth and last ta, you can count the numer of SMSand delete SMSas

    well.

    ollapse

    publicboolDelete5sg(SerialPort port , stringp_str6ommand){ boolisDeleted " %alse& tr' { @region$4ecute 6ommand stringrecieedData " $4ec6ommand(port,*#T*, 788, *No p3one connected*)& recieedData " $4ec6ommand(port,*#T0659"/*, 788, *9ailed to set message %ormat*)& Stringcommand " p_str6ommand& recieedData " $4ec6ommand(port,command, 788, *9ailed to deletemessage*)& @endregion

    i%(recieedData$ndsWit3(*:r:nO?:r:n*))

    { isDeleted " true& 2 i%(recieedData6ontains(*$RROR*)) { isDeleted " %alse& 2 returnisDeleted& 2 catc3($4ception e4) { t3ro!ne!$4ception(e45essage)& 22

  • 8/12/2019 How To Send SMS

    7/31

    Lesson 2

    !ntroduction

    SMSclient and ser"er is an application software which is used for sendin! andrecei"in! messa!es0SMS. It listens for incomin! messa!es to arri"e, processes the

    messa!e if it4s in a "alid format. @ote the processin! of arri"ed messa!es depends on

    the application which will e discussed later. I am !oin! to e&plain the followin!

    thin!s'

    1. ommunication (ort %ettin!s

    2. /ecei"e Incomin! )essa!e

    A. %end )essa!es

    . /ead #ll )essa!es 0%ent y the users

    C. Delete )essa!es 0*ne or #ll

    I ha"e used the S56omm8irary for %endin! and /ecei"in! SMS. ou re

  • 8/12/2019 How To Send SMS

    8/31

    6ommSettingclass is used for storin! comm port settin!s'

    ollapse

    publicclass6ommSetting{ publicstaticint6omm_Port"8& publicstaticEnt=A6omm_BaudRate"8& publicstaticEnt=A6omm_TimeOut"8& publicstaticsm6omm5ain comm&

    public6ommSetting()

    { //

    // !O)O* +dd constructor &ogic here

    //

    22

    6ommis an o+ect of type sm6omm5ainwhich is re

  • 8/12/2019 How To Send SMS

    9/31

    6ursor6urrent " 6ursorsDe%ault& i%(5essageBo4S3o!(t3is, *No p3one connected*, *6onnection setup*, 5essageBo4ButtonsRetr'6ancel, 5essageBo4Econ$4clamation) "" DialogResult6ancel) { comm6lose()& return& 2 6ursor6urrent " 6ursorsWait6ursor& 2

    // C&ose Comm port connection ,Since it-s .ust for testing

    // connection

    comm6lose()&2catc3($4ception e4){ 5essageBo4S3o!(t3is, *6onnection errorF *0 e45essage, *6onnection setup*, 5essageBo4ButtonsO?, 5essageBo4EconWarning)& return&2

    // disp&a message if connection is a success

    5essageBo4S3o!(t3is, *Success%ull' connected to t3e p3one*,*6onnection setup*, 5essageBo4ButtonsO?, 5essageBo4EconEn%ormation)&

    $# Receive !ncoming Message

    :e are !oin! to re!ister the followin! e"ents for S56ommo+ect comm.

    1. P3one6onnected

    This e"ent is in"oked when you try to open the omm port. The e"ent handler

    for (hone connected iscomm_P3one6onnectedwhich will

    in"oke OnP3one6onnection63ange(boolconnected)with the help of

    Dele!ate 6onnected1andler.

    2.5essageReceiedThis e"ent is in"oked when a messa!e arri"es at the %) phone. :e will

    re!ister with5essageReceied$ent1andler. :hen the incomin! messa!e

    arri"es, the comm_5essageReceiedmethod will e in"oked which in turn

    calls the 5essageReceied()method in order to process the unread

    messa!e. S56ommo+ect commhas a method Read5essageswhich will e

    used for readin! messa!es. It accepts the followin! parameters phone status

    0#ll, ReceiedRead, Receied;nread, StoredSent, andStored;nsent

    and stora!e type' %I) memory or (hone memory.

    ollapse

  • 8/12/2019 How To Send SMS

    10/31

    priateoid5essageReceied(){ 6ursor6urrent " 6ursorsWait6ursor& stringstorage " et5essageStorage()& DecodedS3ort5essageGH messages " 6ommSettingcommRead5essages (P3one5essageStatusReceied;nread, storage)& %oreac3(DecodedS3ort5essage message inmessages) { Output(string9ormat(*5essage status " {82, Cocation " {/2>{

  • 8/12/2019 How To Send SMS

    11/31

    If you want to send a messa!e in your nati"e lan!ua!e 09nicode, you need to check

    in %end as 9nicode09%2.S56ommo+ect commhas a Send5essagemethod which

    will e used for sendin! SMSto any phone. reate a (D9 for sendin! messa!es. :e

    can create a (D9 in strai!ht forward "ersion as'

    ollapse

    SmsSubmitPdu pdu " ne!SmsSubmitPdu (t4t_messageTe4t,t4t_destination_numbersTe4t,**)&

    #n e&tended "ersion of (D9 is used when you are sendin! a messa!e in 9nicode.

    ollapse

    tr'{ // Send an SMSmessage

    SmsSubmitPdu pdu& boolalert " c3I#lert63ecIed& boolunicode " c3I;nicode63ecIed&

    i%(alert JJ unicode) { // !he straightfor2ard ersion

    pdu " ne!SmsSubmitPdu (t4t_messageTe4t, t4t_destination_numbersTe4t,**)& 2 else { // !he e"tended ersion 2ith dcs

    b'tedcs& i%(alert JJ unicode) dcs " Data6odingSc3emeNo6lass_/=Bit& else i%(alert JJ unicode) dcs " Data6odingSc3eme6lass8_Bit& else

    i%(alert JJ unicode) dcs " Data6odingSc3eme6lass8_/=Bit& else dcs " Data6odingSc3emeNo6lass_Bit&

    pdu " ne!SmsSubmitPdu (t4t_messageTe4t, t4t_destination_numbersTe4t, **, dcs)& 2

    // Send the same message mu&tip&e times if this is set

    inttimes " c3I5ultipleTimes63ecIed K intParse(t4tSendTimesTe4t) F /&

    // Send the message the specified num4er of times

    %or(inti"8&iLtimes&i00) { 6ommSettingcommSend5essage(pdu)& Output(*5essage {82 o% {/2 sent*, i0/, times)& Output(**)& 22catc3($4ception e4){ 5essageBo4S3o!(e45essage)&2

    6ursor6urrent " 6ursorsDe%ault&

  • 8/12/2019 How To Send SMS

    12/31

    Read All Messages

    ou can read all messa!es from the phone memory of %I) memory. Eust click on

    3/ead #ll )essa!es3 utton. The messa!e details such as sender, date-time, te&tmessa!e will e displayed on the Data rid. reate a new row for each read

    messa!e, add to Data tale and assi!n the Data tale to data!rid4s source

    ollapse

    priateoidBindrid(SmsPdu pdu){ DataRo! dr"dtNe!Ro!()& SmsDelierPdu data " (SmsDelierPdu)pdu&

    drG8H"dataOriginating#ddressToString()& drG/H"dataS6TimestampToString()& drG

  • 8/12/2019 How To Send SMS

    13/31

    ollapse

    )ecodedShortMessage5 messages 7 CommSettingcomm(eadMessages,#honeMessageStatus(eceiedUnread storage

    'or read all messages

    ollapse

    )ecodedShortMessage5 messages 7 CommSettingcomm(eadMessages,#honeMessageStatus+&& storage

    (# elete Messages )One or All#

    #ll messa!es which are sent y the users will e stored in %I) memory and we are

    !oin! to display them in the Data !rid. :e can delete a sin!le messa!e y specifyin!

    the messa!e inde& numer. :e can delete all messa!es from %I) memory y

    clickin! on 3Delete #ll3 utton. )essa!es are deleted ased on the inde&. "ery

    messa!e will e stored in memory with a uni

  • 8/12/2019 How To Send SMS

    14/31

    // )e&ete a&& messages from phone memor

    CommSettingcomm)e&eteMessages,)e&eteScope+&& storage

    The DeleteScopeis an $numwhich contains'

    1. #ll

    2. Read

    A. Read#ndSent

    . ReadSent#nd;nsent

    Applications

    7ere are some interestin! applications where you can use and modify this software.

    "# Pre paid *lectricity

    Scenario )Customer#

    The customer has a!reed for pre paid electricity rechar!es with the help of rechar!ecoupons. The coupon is made a"ailale at shops. The customer will first uy the

    coupons from shopsF e"ery coupon consists of oupon (I@ which will e masked, the

    customer needs to scratch to "iew the (I@ numer. The customer will send

    an SMSto the SMS%er"er with a specified messa!e format for rechar!in!.

    )essa!e ormat for /echar!in!'

    R$61#R$ L6oupon NoML6ustomer EDM

    Scenario )Server ata+ase#

    *n the %er"er, the Dataase consists of ustomer information alon! with histelephone numer, there will a field named #mountwhich will e used and updated

    when the customer rechar!ed with some amount. This application ecomes

    somewhat comple&, an automatic meter readin! software alon! with hardware needs

    to e inte!rated with this. #utomatic meter readin! systems will read all meter

    readin!s and calculate the amount to e deducted for the customer.

    $# Astrology

    ou can implement as astrolo!y software. The user will send an SMSwith his $odiac

    si!n. The SMSser"er will maintain an #strolo!y Dataase with $odiac si!n and a te&t

    description which contains a messa!e for the day. The Dataase is re

  • 8/12/2019 How To Send SMS

    15/31

    1. %hutdown

    2. /estart

    A. 8o! off system

    ou can send an SMS. The SMSser"er will listen and then process the messa!e.

    Based on the messa!e format sent y the user we can take action.

    &ample if messa!e format is'

    S1;TDOWN

    %end to SMSphone numer.

    Conclusion

    This pro+ect wouldn4t e completed unless I thank the S56omm8i de"eloper

    3%tefan )ayr3. I customi$ed my application usin! this 8irary. ou can download the

    sample pro+ect, lirary from the we link which I pro"ided under the /eference

    section.

    Re,erence

    http'www.scampers.or!ste"esmsinde&.htm

    -icense

    This article has no e&plicit license attached to it ut may contain usa!e terms in the

    article te&t or the download files themsel"es. If in dout please contact the author

    "ia the discussion oard elow.

    # list of licenses authors mi!ht use can e found here

    A+out the Author

    http://www.scampers.org/steve/sms/samples.htmhttp://www.scampers.org/steve/sms/samples.htmhttp://www.scampers.org/steve/sms/samples.htmhttp://www.scampers.org/steve/sms/samples.htmhttp://www.scampers.org/steve/sms/samples.htmhttp://www.codeproject.com/info/Licenses.aspxhttp://www.scampers.org/steve/sms/samples.htmhttp://www.codeproject.com/info/Licenses.aspx
  • 8/12/2019 How To Send SMS

    16/31

    !ntroduction to AT commands and its uses

    !ntroduction

    #T commands are instructions used to control a modem. #T is the are"iation of

    #Ttention. "ery command line starts with 3#T3 or 3at3. That4s why modem

    commands are called #T commands.

    @ote that the startin! 3#T3 is the prefi& that informs the modem aout the start of acommand line. It is not part of the #T command name. or e&ample, D is the actual

    #T command name in #TD, and 5)% is the actual #T command name in

    #T5)%.

    Tas.s Per,ormed +y AT Commands

    7ere are some of the tasks that can e done usin! #T commands with a %)(/%

    modem or moile phone'

    et asic information aout the moile phone or %)(/% modem. or

    e&ample, name of the manufacturer 0#T5)I, model numer 0#T5)),

    I)I numer 0International )oile

  • 8/12/2019 How To Send SMS

    17/31

    %a"e and restore confi!urations of the moile phone or %)(/% modem.

    or e&ample, sa"e 0#T5%#% and restore 0#T5/% settin!s related

    to SMSmessa!in! such as the SMScenter address.

    @ote that moile phone manufacturers usually do not implement all #T commands,

    command parameters, and parameter "alues in their moile phones. #lso, the

    eha"ior of the implemented #T commands may e different from that defined in the

    standard. In !eneral, %)(/% modems desi!ned for wireless applications ha"e

    etter support of #T commands than ordinary moile phones.

    Types o, AT Commands

    There are two types of #T commands'

    1. /asic commandsare #T commands that do not start with 353. or e&ample,

    D 0Dial, # 0#nswer, 7 07ook control, and * 0/eturn to online data state

    are asic commands.

    2. *0tended commandsare #T commands that start with 353. #ll %) #T

    commands are e&tended commands. or e&ample, 5)%

    0%end SMSmessa!e, 5)8 08ist SMSmessa!es, and 5)/0/ead SMSmessa!es are e&tended commands.

    General Synta0 o, AT Commands

    The !eneral synta& of e&tended #T commands is strai!htforward. The synta& rules

    are pro"ided elow'

    Synta0 rule ". #ll command lines must start with 3#T3 and end with a carria!e

    return character. In a terminal pro!ram like the 7yperTerminal of )icrosoft :indows,

    you can press the nter key on the keyoard to output a carria!e return character.

    &ample' To list all unread inound SMSmessa!es stored in the messa!e stora!e

    area, type 3#T3, then the e&tended #T command 35)83, and finally a carria!e

    return character, like this'

    ollapse

    #T065C:C(;

    Synta0 rule $. # command line can contain more than one #T command. *nly the

    first #T command should e prefi&ed with 3#T3. #T commands in the same

    command-line strin! should e separated with semicolons.

    &ample' To list all unread inound SMSmessa!es stored in the messa!e stora!e

    area and otain the manufacturer name of the moile de"ice, type 3#T3, then the

    e&tended #T command 35)83, followed y a semicolon and the ne&t e&tended #T

    command 35)I3'

    ollapse

    #T065C&065E:C(;

    #n error will occur if oth #T commands are prefi&ed with 3#T3, like this'

  • 8/12/2019 How To Send SMS

    18/31

    ollapse

    #T065CT065E:C(;

    Synta0 rule %. # strin! is enclosed etween doule

  • 8/12/2019 How To Send SMS

    19/31

    inal result codes

    9nsolicited result codes

    'inal Result Code o, AT Commands

    # final result code marks the end of an #T command response. It is an indication that

    the %)(/% modem or moile phone has finished the e&ecution of a command

    line. Two fre

  • 8/12/2019 How To Send SMS

    20/31

    How to Test GSM Modem Connectivity Using HyperTerminal

    irst, find the est %) modem that suits the needs.

    9nderstand the #T ommand set re

  • 8/12/2019 How To Send SMS

    21/31

    # software that pin!s many ser"ers inside a company and reports network health

    See Also

    )ore like this

    )ore y this author

    2A

    Article /rowse Code Revisions )4#

    .6N 012 "otes

    Sponsored -in.s

    Download source - A.1 KB

    !ntroduction

    This is old code that I de"eloped for my friend workin! in a network maintenance

    company many years a!o. 7e asked me to write a software to check the connecti"ity

    of all computers on networks that he should admin and if there was a prolem send

    him a SMS. :ith this stupid software, he successfully e&tended his +o into a lar!e

    usiness.

    How !t 5or.s

    #ll you need is a %) )odem usin! rs-2A2 or 9%B connection. Install it to a

    computer on a network that you want to admin and deu! this pro+ect and !i"e the

    software local machine names to monitor - the software fre

  • 8/12/2019 How To Send SMS

    22/31

    Pinger

    I +ust took the code of loadin! circle from an article named 8oadin! ircley )artin

    a!neand turned it to a pin!in! and status module that I used it a lot, thanks )artin

    P

    http://www.codeproject.com/KB/cs/mrg_loadingcircle.aspxhttp://www.codeproject.com/Members/Martin-Gagnehttp://www.codeproject.com/Members/Martin-Gagnehttp://www.codeproject.com/KB/cs/mrg_loadingcircle.aspxhttp://www.codeproject.com/Members/Martin-Gagnehttp://www.codeproject.com/Members/Martin-Gagne
  • 8/12/2019 How To Send SMS

    23/31

    Serer63ecIing()function is called e"ery time the loadingcircle control turns

    one cycle. This function sends a pin! packa!e to network 0for more information

    aout pin!, click here.

    ollapse

    stringbu% " *aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa*&publicirtualoidSerer63ecIing(){ i%( _serer63ecIing$nable "" %alse stringEsNullOr$mpt'( _sererName))return& string!3o " SererName&// args50 S'stemT3reading#utoReset$ent !aiter " ne!S'stemT3reading#utoReset$ent(%alse)& S'stemNetNet!orIEn%ormationPing pingSender "

    ne!S'stemNetNet!orIEn%ormationPing()& pingSenderPing6ompleted 0" ne!S'stemNetNet!orIEn%ormation

    Ping6ompleted$ent1andler(Ping6ompleted6allbacI)& stringdata " bu%& b'teGH bu%%er " $ncoding#S6EEetB'tes(data)& inttimeout " /888& S'stemNetNet!orIEn%ormationPingOptions options "

    ne!S'stemNetNet!orIEn%ormationPingOptions(=A, true)& pingSenderSend#s'nc(!3o, timeout, bu%%er, options, !aiter)&2

    #nd as pin! reply is recei"ed or there is a pin! error, you can specify the status

    on loadingcircle y chan!in! the color of it'

    ollapse

    http://www.codeproject.com/KB/dotnet/CSharpPing.aspx?msg=3040814#xx3040814xxhttp://www.codeproject.com/KB/dotnet/CSharpPing.aspx?msg=3040814#xx3040814xx
  • 8/12/2019 How To Send SMS

    24/31

    publicS'stemNetNet!orIEn%ormationPingRepl' repl'&

    publiceent$ent1andlerLconnectionstateeentargM 6onnectionState63anged&internal6onnectionState$ent#rg state " ne!6onnectionState$ent#rg()&

    protectedintsucc " 8&protectedint%ail " 8&oidPing6ompleted6allbacI(obectsender,

    S'stemNetNet!orIEn%ormationPing6ompleted$ent#rgs e){ i%(eRepl' " null) { repl' " eRepl'& state$4actReason " e& _serer6onnectionState " eRepl'StatusToString()& stateNe!Repl' " eRepl'Status& i%(repl'Status "" S'stemNetNet!orIEn%ormationEPStatusSuccess) { i%(succ M A) { t3is6olor " 6olorPalereen& t3isRotationSpeed " A88& stateNe!State " 6onnectionStatus6onnectedPer& 2 else {

    t3isRotationSpeed " 8& t3is6olor " 6olorBlue& stateNe!State " 6onnectionStatus6onnectedTem& 2 succ00& %ail " 8& Serer6onnected " true& 2 elsei%(repl'Status ""S'stemNetNet!orIEn%ormationEPStatusTimedOut) { i%(%ail M A) { t3isRotationSpeed " A88& t3is6olor " 6olorCig3tPinI&

    stateNe!State " 6onnectionStatusDisconnectedPer& 2 else { t3isRotationSpeed " 8& t3is6olor " 6olorOrange& stateNe!State " 6onnectionStatusDisconnectedTem& 2 Serer6onnected " %alse& %ail00& succ " 8& 2 else { t3isRotationSpeed " 8&

    t3is6olor " 6olorDarIRed& succ " 8& Serer6onnected " %alse& stateNe!State " 6onnectionStatusOt3er& %ail00& 2 %or(inti " 8& i L eRepl'Bu%%erCengt3& i00) { i%(eRepl'Bu%%erGiH " (b'te)bu%GiH) { t3is6olor " 6olorPurple& stateNe!State " 6onnectionStatusTransmit5ismac3& 2 2 2

  • 8/12/2019 How To Send SMS

    25/31

    else { t3isRotationSpeed " A88& t3is6olor " 6olorBlacI& succ " 8& Serer6onnected " %alse& stateNe!State " 6onnectionStatusOt3er& %ail00& 2 i%(t3is6onnectionState63anged " null) t3is6onnectionState63anged(t3is, state)&2

    GSM Handler

    (erhaps you need one of these for sendin! SMS'

  • 8/12/2019 How To Send SMS

    26/31

    %) )odems are workin! with #T ommand. 7ere is a component that I wrote for

    %) )odem %endin! and recei"in!SMS'

    ollapse

    publicclassS55anager F 6omponent{ publicCistLsmsmessageM Recied5essages " ne!CistLsmsmessageM()& publicCistLsmsmessageM Sending5essages " ne!CistLsmsmessageM()& Timer timer " ne!Timer()& publicS55anager() {

    timerEnteral " /888&2

    boolO " %alse& boolO? " %alse& bool$RROR " %alse& publicS'stemEOPortsSerialPort comPort " ne!S'stemEOPortsSerialPort()& //pu4&ic oid Send publicboolSMS$nable " true& publicoidSMS6on%ig() {

    i%(comPortEsOpen "" %alse) { comPortPortName "

    globalFFCoading6ircleTesterPropertiesSettingsDe%ault6O5PortName&

  • 8/12/2019 How To Send SMS

    27/31

    comPortBaudRate " //-

  • 8/12/2019 How To Send SMS

    28/31

    >>>

    O " %alse& $RROR " %alse& O? " %alse& %or(inti " 8& i L /88& i00) { i%(O? "" true) breaI& i%($RROR "" true) { //MessageBo"Sho2,?((O( returnnull& 2 S'stemT3readingT3readSleep(/-)& i%(i "" /88) $RROR " true& 2

    SMS5essage mess " ne!SMS5essage()& intI " 8& boolmess$rr " %alse& intl " 8& %or(int " 8& L 7& 00) { i%(I "" +/ l "" +/) { mess$rr " true& continue& 2 I " ReadedEnde4O%(*:**, l)& i%(I "" +/ l "" +/) { mess$rr " true& continue& 2 l " ReadedEnde4O%(*:**, I 0 /)& i%(I "" +/ l "" +/) { mess$rr " true& continue& 2

    stringinc " ReadedSubstring(I 0 /, l + I + /)& i%( "" /JJ mess$rr "" %alse) messP3oneNo " inc& i%( ""

  • 8/12/2019 How To Send SMS

    29/31

    // return nu&& 2 S'stemT3readingT3readSleep(/-)& i%(i "" /88) $RROR " true& 2 2 publicstringSendSMS(SMS5essage sms) { returnSendSMS(smsP3oneNo, sms5essage)& 2 publicstringcallserice& publicstringSendSMS(stringP3oneNo, string5essage ) { SMS_is_Disable()& strings " **&

    comPortWrite(*#T06S6#":**0callserice0*:**0 (c3ar)/7)&

    O " %alse& $RROR " %alse& O? " %alse& %or(inti " 8& i L /88& i00) { i%(O? "" true) breaI& i%($RROR "" true) { 5essageBo4S3o!(*$RROR*)& return*$RROR*&

    2 S'stemT3readingT3readSleep(/-)& i%(i "" /88) $RROR " true& 2

    >>> comPortWrite(*#T065S":**0 P3oneNo 0 *:**0 (c3ar)/7)& >>>

    O " %alse& $RROR " %alse& O? " %alse& %or(inti " 8& i L /88& i00) { i%(O? "" true) breaI& i%($RROR "" true) {

    5essageBo4S3o!(*$RROR*)& return*$RROR*& 2 S'stemT3readingT3readSleep(/-)& i%(i "" /88) $RROR " true& 2

    s 0" *:r*0 comPortRead$4isting()&

    >>> comPortWrite(5essage 0 (c3ar)>>

    O " %alse& $RROR " %alse& O? " %alse& %or(inti " 8& i L /88& i00) {

    i%(O? "" true) {breaI&

    2 i%($RROR "" true) { 5essageBo4S3o!(*$RROR*)& return*$RROR*& 2 S'stemT3readingT3readSleep(/-)& i%(i "" /88) $RROR " true& 2

    s 0" *:r*0 comPortRead$4isting()&

    comPort6lose()&

  • 8/12/2019 How To Send SMS

    30/31

    returns& 2

    publicCistLsmsmessageM ReadEncommingSMS(ReadEncommingSMST'pe t'pe) { DateTime t/ " DateTimeNo!& Readed " **& SMS_is_Disable()& i%(SMS$nable "" %alse) returnnull&

    s!itc3(t'pe) { caseReadEncommingSMST'peSTO_S$NTF comPortWrite(*#T065C":*STO S$NT:**0 (c3ar)/7)& breaI& caseReadEncommingSMST'peR$6_;NR$#DF comPortWrite(*#T065C":*R$6 ;NR$#D:**0 (c3ar)/7)& breaI& caseReadEncommingSMST'pe#CCF comPortWrite(*#T065C":*#CC:**0 (c3ar)/7)& breaI& caseReadEncommingSMST'peR$6_R$#DF comPortWrite(*#T065C":*R$6 R$#D:**0 (c3ar)/7)& breaI& caseReadEncommingSMST'peSTO_;NS$NTF comPortWrite(*#T065C":*STO ;NS$NT:**0 (c3ar)/7)&

    breaI& 2

    O " %alse& $RROR " %alse& O? " %alse& %or(inti " 8& i L /88& i00) { i%(O? "" true) breaI& i%($RROR "" true) { //MessageBo"Sho2,?((O( returnnull& 2 S'stemT3readingT3readSleep(/-)& i%(i "" /88)

    { $RROR " true& t3isSMS$nable " %alse& returnnull& 2

    2

    CistLsmsmessageM messCist " ne!CistLsmsmessageM()&

    stringGH re " ReadedSplit(ne!stringGH { *065CF*2,StringSplitOptionsRemoe$mpt'$ntries)&

    %or(inti " /& i L reCengt3& i00) { intI " 8& boolmess$rr " %alse& intl " 8& stringStr " reGiH& SMS5essage mess " ne!SMS5essage()& stringind " StrSubstring(8, StrEnde4O%(*,*))Trim()&

    messinde4 " intParse(ind)& %or(int " 8& L 7& 00) { i%(I "" +/ l "" +/) { mess$rr " true& continue& 2 I " StrEnde4O%(*:**, l)& i%(I "" +/ l "" +/) { mess$rr " true& continue& 2 l " StrEnde4O%(*:**, I 0 /)& i%(I "" +/ l "" +/) { mess$rr " true& continue& 2 stringinc " StrSubstring(I 0 /, l + I + /)& i%( "" /JJ mess$rr "" %alse) messP3oneNo " inc& i%( ""

  • 8/12/2019 How To Send SMS

    31/31

    2 i%(mess$rr "" %alse) { mess5essage " StrSubstring(l 0