25.10.3. Reading
the SMSC Number Saved with an SMS Message
Sometimes
you may want to find out the SMSC number saved with an SMS message.
It is not difficult to do so. The following sections discuss
how this can be done through the AT
command +CMGR (command
name in text: Read Message).
25.10.3.1. SMS
Text Mode
In
SMS text mode, first assign the value 1 to the AT command +CSDH
(command name in text: Show Text Mode Parameters) to tell the
GSM/GPRS modem or mobile phone that we want detailed header
information. Then use the AT
command +CMGR to read the
SMS message from the message storage area. The SMSC number can
be found in the ninth field of the +CMGR information response.
Here
is an example for illustration. Suppose there is an SMS text message
"It is easy to send text messages." located at index 5 of
the message storage area. To read the SMSC number saved with it,
enter the command line "AT+CSDH=1" and then "AT+CMGR=5".
The result shown in a terminal program such as HyperTerminal of
Microsoft Windows should be something like this:
AT+CSDH=1 OK AT+CMGR=5 +CMGR:
"STO
UNSENT","+85291234567",,145,17,0,0,167,"+85290000000",145,30 It
is easy to send text messages.
OK
The
value of the ninth field of the +CMGR information response, i.e.
+85290000000, is the SMSC number saved with the SMS text message.
25.10.3.2. SMS
PDU Mode
If
the GSM/GPRS modem or mobile phone is operating in SMS PDU mode,
first use the +CMGR
AT command to read the
SMS message from the message storage area. Then decode the
hexadecimal sequence of the fourth field of the +CMGR information
response.
Here
is an example for illustration. Suppose there is an SMS text message
"It is easy to send text messages." located at index 5 of
the message storage area. To read the SMSC number saved with it,
enter the command line "AT+CMGR=5". In SMS PDU mode, the
result shown in a terminal program such as HyperTerminal of Microsoft
Windows should be something like this:
AT+CMGR=5 +CMGR:
2,,42 07915892000000F001000B915892214365F7000021493A283D0795C3F33C88FE06CDCB6E32885EC6D341EDF27C1E3E97E72E
OK
The
hexadecimal sequence of the fourth field of the +CMGR information
response is:
07915892000000F001000B915892214365F7000021493A283D0795C3F33C88FE06CDCB6E32885EC6D341EDF27C1E3E97E72E
It
can be divided into two parts: the SMSC part and TPDU part. Here is
the SMSC part:
07915892000000F0
The
SMSC part can be further divided into three sub-fields, like this:
07
91 5892000000F0
The
value of the first sub-field 0x07 tells us that the second and third
sub-fields consist of 7 octets totally. The value of the second
sub-field 0x91 indicates the SMSC
number encoded in the third sub-field is in the typical international
numbering format. The value of the third sub-field 0x5892000000F0
tells us the SMSC number saved with the SMS text message. To decode
the hexadecimal value, group the digits into pairs, like this: 58 92
00 00 00 F0. Then swap the digits in each pair and you will get 85 29
00 00 00 0F. Remove the last "F", because it was placed
there to fill the empty bits of the last octet and it is not part of
the SMSC number. After that, combine the digits and you will
get the SMSC number +85290000000.
More
information about the sub-fields is available in the section "The
SMSC Part" of this SMS tutorial.
|
Feedback Form (ExpandCollapse)
|
|