Introduction to AT Commands.doc

Embed Size (px)

Citation preview

  • 8/12/2019 Introduction to AT Commands.doc

    1/17

    Introduction to AT Commands

    AT commands are instructions used to control a modem. AT is the

    abbreviation of ATtention. Every command line starts with "AT"

    or "at". That's why modem commands are called AT commands.Many of the commands that are used to control wired dial-up

    modems, such as ATD (ial!, ATA(Answer), ATH(oo#

    control! and ATO ($eturn to online data state!, are also supported

    by %&M%$& modems and mobile phones. )esides this common

    AT command set, GSM/GPRSmodems and mobile phones

    support an AT command set that is specific to the GSM

    technolo*y, which includes SMS-related commands li#e

    AT+M%& (&end SMS messa*e!, AT+CMSS(&end SMS

    messa*e from stora*e!, AT+CMGL(ist SMSmessa*es! andAT+CMGR($ead SMSmessa*es!.

    ote that the startin* "AT"is the prefi/ that informs the modem

    about the start of a command line. 0t is not part ofth AT

    command nam! or #am$%, D is th actua%ATcommand

    name in ATD and +CMGSis the actual AT command name in

    AT+M%&. owever, some boo#s and &' sits us thm

    intrchan(a'% as th nam o* anAT command

    ith th AT commands, ou can do thin(s %i1

    $eadin*, writin* and deletin* SMSmessa*es.

    &endin* SMSmessa*es.

    Monitorin* the si*nal stren*th.

    Monitorin* the char*in* status and char*e level of the battery.

    $eadin*, writin* and searchin* phone boo# entries.

    -asic Commands and .#tndd Commands

    There are two types of AT commands1 basic commands and

    e/tended commands.

    )asic commands are ATcommands that do not start with "+". 2or

    e/ample, (ial!, A (Answer!, (oo# control! and 3 ($eturn to

    online data state! are basic commands.

    E/tended commands are ATcommands that start with "+". All

    %&M AT commands are e/tended commands. 2or e/ample,

  • 8/12/2019 Introduction to AT Commands.doc

    2/17

    +CMGS(&end &M& messa*e!, +CMSS(&end &M& messa*e from

    stora*e), +CMGL(List SMSmessa*es! and +CMGR($ead SMS

    messa*es! are e/tended commands

    Hr ar som o* th tass that can ' don usin( AT commands

    &ith a GSM/GPRS modm or mo'i% $hon

    %et basic information about the mobile phone or GSM/GPRS

    modem. 2or e/ample, name of manufacturer AT+CGMI),model

    number (AT+CGMM), IM.Inumber (0nternational Mobile

    E4uipment 0dentity! (AT+CGS0! and software version

    (AT+CGMR)! %et basic information about the subscriber. 2or e/ample, MSISD0

    AT+C01M! and IMSInumber (0nternational Mobile &ubscriber

    0dentity! AT+CIMI!.

    %et the current status of the mobile phone or GSM/GPRSmodem.

    2or e/ample, mobile phone activity status AT+CPAS!, mobile

    networ# re*istration status AT+CR.G!, radio si*nal stren*th

    (AT+CS2!, battery char*e level and battery char*in* status

    (AT+C-C)!

    Establish a data connection or voice connection to a remote modem

    (ATD, ATA, tc)!

    &end and receive fa/ (ATD, ATA, AT+3)!

    &end AT+CMGS, AT+CMSS!, read (AT+CM%$, AT+CMGL!,

    write (AT+CMG! or delete (AT+CMGD! SMSmessa*es and

    obtain notifications of newly received SMSmessa*es AT+C0MI)!

    $ead AT+CP-R),write AT+CP-! or search (AT+CP-)

    phoneboo# entries.

    erform security-related tas#s, such as openin* or closin* facility

    loc#s (AT+CLC4!, chec#in* whether a facility is loc#ed

    (AT+CLC4! and chan*in* passwords (AT+CPD!.

    (2acility loc# e/amples1 SIMloc# 5a password must be *iven to the

    SIMcard every time the mobile phone is switched on6 and -SIM

    loc# 5a certain SIMcard is associated with the mobile phone. To useother SIMcards with the mobile phone, a password must be entered.6!

  • 8/12/2019 Introduction to AT Commands.doc

    3/17

    ontrol the presentation of result codes error messa*es of AT

    commands. 2or e/ample, you can control whether to enable certain

    error messa*es (AT+CM..! and whether error messa*es should be

    displayed in numeric format or verbose format (AT+CM..56 or

    AT+CM..57!.

    %et or chan*e the confi*urations of the mobile phone or GSM/GPRS

    modem. 2or e/ample, chan*e the GSMnetwor# AT+COPS!, bearer

    service type (AT+C-ST!, radio lin# protocol parameters

    (AT+CRLP!, SMScenter address AT+CSCA! and stora*e of &M&

    messa*es (AT+CPMS!.

    &ave and restore confi*urations of the mobile phone or GSM/GPRS

    modem. 2or e/ample, save (AT+CSAS! and restore (AT+CR.S!

    settin*s related to SMSmessa*in* such as the SMS center address

    AT Command O$rations8

    Thr ar *our t$s o* AT command o$rations1

    Tst o$ration. A test operation is used to chec# whether a certainATcommand is supported by the GSM/GPRSmodem or mobile

    phone.

    St o$ration. A set operation is used to chan*e the settin*s used

    by the GSM/GPRSmodem or mobile phone for certain tas#s.

    Rad o$ration. A read operation is used to retrieve the current

    settin*s used by the GSM/GPRSmodem or mobile phone for

    certain tas#s.

    .#cution o$ration. An e/ecution operation is used to perform

    an action or retrieve informationstatus about the GSM/GPRS

    modem or mobile phone.

    Tst Command

    A test operation is used to chec# whether a certain AT command is

    supported by the GSM/GPRSmodem or mobile phone. All

    e/tended AT commands support the test operation. The synta/ is1

  • 8/12/2019 Introduction to AT Commands.doc

    4/17

    command59

    where commandis an AT command. 7hen an ATcommand is

    used in the above synta/ to perform a test operation, it is called a

    test command.

    Hr is an #am$%8

    AT+CGMI59

    0f the GSM/GPRSmodem or mobile phone supports the AT

    command +CGMI, the result code "O4" will be returned, li#e

    this1

    AT+CGMI59

    O4

    0f the GSM/GPRSmodem or mobile phone does not support the

    AT command +CGMI, the result code ".RROR" will be

    returned, li#e this1

    AT+CGMI59

    .RROR

    Chcin( i* th GSM/GPRS Modm or Mo'i% Phon Su$$orts th

    1s o* AT Commands to Snd, Rci: and Rad SMS Mssa(s

    Sndin( SMS Mssa(s

  • 8/12/2019 Introduction to AT Commands.doc

    5/17

    To find out whether a GSM/GPRSmodem or mobile phone supports the

    sendin* of &M& messa*es throu*h AT commands, you have to1

    8. 9se the AT command +CSMS(command name in te/t1 &elect

    Messa*e &ervice! to chec# whether mobile-ori*inated SMSmessa*es are supported.

    :. erform test operations to chec# whether +CMGS(command

    name in te/t1 &end Messa*e! andor +CMSS(command name in

    te/t1 &end Messa*e from &tora*e! are supported.

    (;ou may want to chec# the AT commands +CMG5command

    name in te/t1 7rite Messa*e to Memory6 and +CMGD5command

    name in te/t1 elete Messa*e6 in addition as they are sometimes

    used to*ether with +CMSS.

    Rci:in( SMS Mssa(s and Radin( SMS Mssa(s *rom

    Mssa( Stora(8

    To find out whether a GSM/GPRSmodem or mobile phone supports the

    receivin* and readin* of &M& messa*es throu*h AT commands, you

    have to1

    8. 9se the ATcommand +CSMS(command name in te/t1 &elect

    Messa*e &ervice! to chec# whether mobile-terminated &M&

    messa*es are supported.

    :. erform test operations to chec# whether +C0MI(command name

    in te/t1 ew Messa*e 0ndications to TE!, +CMGL(command

    name in te/t1 ist Messa*es! andor +CMGR(command name in

    te/t1 $ead Messa*e! are supported.

    0f the GSM/GPRSmodem or mobile phone supports the +M0 AT

    command, it can send a notification or directly forward the messa*e tothe whenever a new &M& messa*e arrives.

    0f the GSM/GPRSmodem or mobile phone does not support +M0 but

    supports +CMGLandor +CMGR, the has to poll the %&M%$&

    modem or mobile phone repeatedly in order to #now if any new SMS

    messa*es have arrived.

  • 8/12/2019 Introduction to AT Commands.doc

    6/17

    AT Commands8

    Th +C-C command

    The +C-Ccommand is used to retrieve the connection status and char*e

    level of the battery of the mobile device

    +CBC: connection_status, charge_level

    2or e/ample, if the battery is placed in the mobile device with no char*er

    connected and the char*e level is , the result of the e/ecution of the+C-C ATcommand will be1

    AT+C-C

    +C-C8 ;,

  • 8/12/2019 Introduction to AT Commands.doc

    7/17

  • 8/12/2019 Introduction to AT Commands.doc

    8/17

    to send an &M& te/t messa*e. The lines in bold type are the

    command lines that should be entered in H$rTrmina%. The

    other lines are responses returned from the GSM / GPRSmodem

    or mobile phone.

    AT

    O4

    AT+CMG56

    O4

    AT+CMG5"+7?67@>B"

    H.LLO .0G !AL..D .LSAO1RE!

    +CMG8 6

    O4

    AT+CMSS56

    +CMSS8 7;

    O4

    Hr is a dscri$tion o* &hat is don in th a'o: #am$%1

    ine 81 "AT" is sent to the GSM / GPRSmodem to test the

    connection. The GSM / GPRSmodem sends bac# the result code

    "3B" (line :!, which means the connection between the

    yperTerminal pro*ram and the GSM / GPRSmodem wor#s fine.

    ine C1 The ATcommand +CMGis used to instruct the %&M

    %$& modem to operate in &M& te/t mode. The result code "3B"

    is returned (line D!, which indicates the command line

    "AT+CMG56" has been e/ecuted successfully. 0f the result code

    ".RROR" is returned, it is li#ely that the GSM / GPRSmodem

    does not support the SMSte/t mode. To confirm, type

    "AT+CMG59"in the yperTerminal pro*ram. 0f the response is"+CMG1 (=,8!" (=?9 mode and 8?te/t mode!, then &M& te/t

    mode is supported. 0f the response is "+CMG8 ;!", then &M&

    te/t mode is not supported.

    ine and 1 The ATcommand +CMGis used to write an &M&

    te/t messa*e to the messa*e stora*e of the GSM /GPRS modm!

    "+7?67@>B" is the recipient mobile phone number. Aftertypin* the recipient mobile phone number, you should press the

  • 8/12/2019 Introduction to AT Commands.doc

    9/17

  • 8/12/2019 Introduction to AT Commands.doc

    10/17

    )elow shows a simple e/ample that demonstrates how to use AT

    commands and the H$rTrmina% $ro(ramof Microsoft

    7indows to read &M& te/t messa*es received by a GSM / GPRS

    modem or mobile phone. The lines in bold type are the command

    lines that should be entered in yperTerminal. The other lines are

    responses returned from the GSM / GPRSmodem or mobile

    phone.

    AT

    O4

    AT+CMG56O4

    AT+CMGL5"ALL"

    +CMGL8 6,"R.C R.AD","+7?67@>B",,";B/66/66,;;8@;87?+@7"

    H%%o, &%com to our $roct!

    +CMGL8 7,"R.C R.AD","+7?67@>B",,";B/66/66,;;8@787;+@7"

    H.LLO .0G AL..D .LSAO1RE!

    O4

    Hr is a dscri$tion o* &hat is don in th a'o: #am$%1

    ine 81 "AT"is sent to the GSM / GPRSmodem to test the

    connection. The GSM / GPRSmodem sends bac# the result code

    "O4" (line :!, which means the connection between the

    yperTerminal pro*ram and the GSM / GPRSmodem wor#s fine.

    ine C1 The ATcommand +CMGis used to instruct the GSM /

    GPRSmodem to operate in SMSte/t mode. The result code "O4"is returned (line D!, which indicates the command line

    "AT+CMG56" has been e/ecuted successfully. 0f the result code

    ".RROR" is returned, it is li#ely that theGSM / GPRSmodem

    does not support the SMS te/t mode. To confirm, type

    "AT+CMG59"in the H$rTrmina% $ro(ram. 0f the response

    is "+CMG1 (=,8!" (=?PD1mode and 8?te/t mode!, then &M&

    te/t mode is supported. 0f the response is "+CMG8 ;!", then

    SMSte/t mode is not supported.

  • 8/12/2019 Introduction to AT Commands.doc

    11/17

    ine -H1 The ATcommand +CMGLis used to list all &M& te/t

    messa*es in the messa*e stora*e of the GSM /GPRSmodem.

    There are two &M& te/t messa*es in the messa*e stora*e1 "H%%o,

    &%com to our $roct." and ". H.LLO .0G AL..D

    .LSAO1RE ". "+7?67@>B" is the sender mobile phonenumber. ";B/66/66,;;8@;87?+@7" and ";B/66/66,;;8@787;+@7"

    tell us when the SMSte/t messa*es were received by the &M&.

    "+C:" is the time Ione. ote that the unit is a 4uarter of an hour.

    &o, +@7means GMT+

  • 8/12/2019 Introduction to AT Commands.doc

    12/17

    Th +CMGL AT command is usd to rad SMS mssa(s that

    ha: a crtain status *rom th mssa( stora( ara

    or #am$%8

    AT+CMGL5"R.C 10R.AD"

    The GSM/GPRS modem or mobile phone should return somethin* li#e

    this1

    +CMGL8 6,"R.C

    10R.AD","+7?67@>B",,";/;7/686;+@7"

    Radin( t#t mssa(s is as!+CMGL8 7,"R.C

    10R.AD","+7?67@>B",,";/;7/6B",,";/;7/686;+@7"

    Radin( t#t mssa(s is as!

    +CMGL8 7,"R.C R.AD","+7?67@>B",,";/;7/6B",,";/;7/6+@7"

    H%%o, &%com to our $roct!

    O4

    ritin( SMS Mssa(s to Mmor / Mssa( Stora( Command J

    Th +CMG AT Command

    the synta/ of the +M%7 AT command is1

  • 8/12/2019 Introduction to AT Commands.doc

    13/17

    +CMG[=address[,address_type[,message_status]]]sms_messag

    e_ody

    or #am$%

    AT+CMG5"+7?67@>B",6>,"STO 10S.0T"This is an

    #am$% *or i%%ustratin( th snta# o* th +CMG AT command in

    SMS t#t mod!

    Th addrss Paramtr8

    Th *irst $aramtr o* th +CMGATcommand, address, s$ci*is

    th dstination addrss to snd th &M&mssa( to! 1sua%% it is a

    mo'i% num'r *ormattd usin( th t$ica% ISD0 / t%$hon

    num'rin( $%an (0T9 E.8DE.8C)! or #am$%, "+

  • 8/12/2019 Introduction to AT Commands.doc

    14/17

    6>. Meanin*1 The value of addressis formatted usin* the typical

    0& telephony numberin* plan (0T9 E.8DE.8C! and it is an

    international number. E/ample address1 "+

  • 8/12/2019 Introduction to AT Commands.doc

    15/17

    formed by these four characters1 the carria*e return character, the linefeed

    character, the "F" character and the space character. 0f you don't

    understand what this means, don't worry. This should be clear to you

    when you see the e/ample in the section "E/ample emonstratin* ow

    to 9se the +M%7 AT ommand to 7rite &M& Te/t Messa*es toMessa*e &tora*e in &M& Te/t Mode".

    Th smsmssa('od Paramtr

    The fourth parameter of the +CMGATcommand,

    sms_message_body, specifies the &M& messa*e body to be written to the

    memorymessa*e stora*e area. Enterin* the

  • 8/12/2019 Introduction to AT Commands.doc

    16/17

    messa*es accordin* to their messa*e status. The SMSspecification has

    defined these flagvalues1 =, 8, :, C and D.

    ;. Meanin*1 elete only the SMSmessa*e stored at the location

    indexfrom the messa*e stora*e area. This is the default value. 6. Meanin*1 0*nore the value of indexand delete all SMS messa*es

    whose status is "received read" from the messa*e stora*e area.

    7. Meanin*1 0*nore the value of indexand delete all &M& messa*es

    whose status is "received read" or "stored sent" from the messa*e

    stora*e area.

    @. Meanin*1 0*nore the value of indexand delete all SMS messa*es

    whose status is "received read", "stored unsent" or "stored sent"

    from the messa*e stora*e area.

    ! Manin(8 I(nor th :a%u o* inde#and d%t a%%SMS

    messa*es from the messa*e stora*e area.

    indin( th Su$$ortd Ind#s and %a( a%us8 erformin* a test operation with the +CMGD ATcommand allows

    you to find all inde/es that are supported by the indexparameter.

    The test operation may also return all supported values of the flag

    parameter. ere is the format of the information response returned

    after the e/ecution of the test command "+CMGD59"8(3ptional

    fields are enclosed in s4uare brac#ets.!

    +CMGD8 list_o$_inde#es)K,list_o$_$lag_values)

    The values inside the first parentheses are the values that are

    supported by the indexparameter of the +CMGD ATcommand.

    The values inside the second parentheses are the values that are

    supported by the flagparameter of the +CMGDAT command.0ot1 A GSM/GPRSmodem or mobile phone mi*ht not provide

    these values since the SMS specification defines them as optional.

  • 8/12/2019 Introduction to AT Commands.doc

    17/17

    As an e/ample, here is the response returned from my o#ia =:8

    mobile phone to 7indows'H$rTrmina% $ro(ram after the

    e/ecution of the test command "+CMGD59"8

    AT+CMGD59+CMGD8 6=6;),;=)

    O4