Из описания стандарта GSM 07.05:
AT+CMGS Send SMS message
Test command
AT+CMGS=?
Response
OK
Execute command
1) If text mode
(+CMGF=1):
+CMGS=<da>
[,<toda>]<CR>
text is entered
<ctrl-Z/ESC>
Response
TA transmits SMS message from TE to network (SMS-SUBMIT). Message
reference value <mr> is returned to TE on successful message delivery.
Value can be used to identify message upon unsolicited delivery status re-
port result code.
Execute command
2) If PDU mode
(+CMGF=0):
+CMGS=<length>
<CR>
PDU is given <ctrl-
Z/ESC>
ESC aborts message
Response
1) If text mode (+CMGF=1) and sending successful:
+CMGS: <mr>[,scts>] OK
2) If PDU mode (+CMGF=0) and sending successful:
+CMGS: <mr>[,ackpdu>] OK
3) If error is related to ME functionality:
+CMS ERROR: <err>
Parameter
<da> GSM 03.40 TP-Destination-Address Address-Value field in string
format; BCD numbers (or GSM default alphabet characters) are
converted into characters; type of address given by <toda>
<toda> GSM 04.11 TP-Destination-Address Type-of-Address octet in in-
teger format (when first character of <da> is + (IRA 43) default is
145, otherwise default is 129)
<length> integer type value indicating in text mode (+CMGF=1) the length of
the message body <data> (or <cdata>) in characters; or in PDU
mode (+CMGF=0), the length of the actual TP data unit in octets
(i.e. the RP layer SMSC address octets are not counted in the
length)
In text mode, the maximum length of an SMS depends on the
used coding scheme: It is 160 characters if the 7 bit GSM coding
scheme is used, and 140 characters according to the 8 bit GSM
coding scheme.
<mr> GSM 03.40 TP-Message-Reference in integer format
<scts> GSM 03.40 TP-Service-Centre-Time-Stamp in time-string format
(refer <dt>)
<dt> GSM 03.40 TP-Discharge-Time in time-string format: "yy/MM/
dd,hh:mm:ss±zz", where characters indicate year (two last digits),
month, day, hour, minutes, seconds and time zone. For example,
6th of May 1994, 22:10:00 GMT+2 hours equals
"94/05/06,22:10:00+08”"
<ackpdu>GSM 03.40 RP-User-Data element of RP-ACK PDU; format is
same as for <pdu> in case of SMS, but without GSM 04.11 SC
address field and parameter shall be enclosed in double quote
characters like a normal string type parameter
<pdu> For SMS: GSM 04.11 SC address followed by GSM 03.40 TPDU
in hexadecimal format: ME/TA converts each octet of TP data unit
into hexadecimal numbers containing two IRA characters (e.g.
octet with integer value 42 is presented to TE as two characters
2A (IRA 50 and 65)). In the case of CBS: GSM 03.41 TPDU in
hexadecimal format.
Note
• Use CTRL-Z at the end of input to send the message and return OK.
• Use ESC at the end of message input to abort message send operation.
NO message is sent although display returns OK!
• Sending e-mails via SMS: Note that some providers do not recognise @
symbol. Possible alternative "!" for "@"
• After invoking of the command CMGW, CMGS, CMGC it is necessary to
wait for the ">" symbol and only afterwards the text can be sent to the
module
• At baudrates lower than 19200 it is recommended to use the line termi-
nation character only (refer to +ATS3, default <CR>, pg. 24) before en-
tering the text/pdu. Use of the line termination character followed by the
response formating character (see +ATS4, default <LF>, pg. 24) can
cause problems.
• All characters entered behind the ">" symbol will be recognized as GSM
characters. For example, "Backspace" (ASCII character 8 ) does not de-
lete a character, but will be inserted into the SMS as an additional physi-
cal character. As a result, the character you wanted to delete still ap-
pears in the text, plus the GSM code equivalent of the Backspace key.
See also Chapter 9.5 which provides the supported alphabet tables.
исходя из чего:
- Код: Выделить всё
dim comm as new mscomm ' в референсах подключить mscomm32.ocx
comm.commport = <порт> ' номер порта к которому подключен GSM-модем
comm.portopen = true
comm.output = "AT+CMGF=1" & vbCrLf
comm.output = "AT+CSCA=" & Chr(34) & <номер> & Chr(34) & vbCrLf ' номер СМС-центра (если забит в тело модема - то не нужно)
comm.output = "AT+CMGS=" & Chr(34) & <номер> & Chr(34) & vbCrLf ' номер телефона (кому)
comm.output = <текст> & Chr(26) & vbCrLf ' текст сообщения
comm.portopen = false
между AT командами нужно делать паузы - дать модему время обработать команды. (ждать ответа готовности или ошибки не стоит, поскольку ЕМНИП, модем уйдя в процесс может не дать таковых)
и ещё: некоторые 3G модемы не могут отправлять СМС из 3G режима, их нужно перевести в 1х (см. мануал оного)