用pc发短息

以上文字转自:

http://www.developershome.com/sms/howToUseHyperTerminal.asp

Ingeneral, there are two ways to send SMS messages from a computer / PCto a mobile phone:

  1. Connecta mobile phone or GSM/GPRS modem to a computer / PC. Then use thecomputer / PC and AT commands to instruct the mobile phone orGSM/GPRS modem to send SMS messages.

  2. Connectthe computer / PC to the SMS center (SMSC) or SMS gateway of awireless carrier or SMS service provider. Then send SMS messagesusing a protocol / interface supported by the SMSC or SMS gateway.

Ifyou do not want to develop SMS software or applications but just wantto use your computer / PC to send text messages, you may want to readour
Quick Guide for Non-Developers.

10.1. The 1st Way:Sending SMS Messages from a Computer Using a Mobile Phone or GSM/GPRSModem

TheSMS specification has defined a way for a computer to send SMSmessages through a mobile phone or GSM/GPRS modem. A GSM/GPRS modemis a wireless modem that works with GSM/GPRS wireless networks. Awireless modem is similar to a dial-up
modem. The main difference isthat a wireless modem transmits data through a wireless networkwhereas a dial-up modem transmits data through a copper telephoneline. More information about GSM/GPRS modems will be provided in thesection “Introduction
to GSM /GPRS Wireless Modems
“. Most mobile phones can be used as awireless modem. However, some mobile phones have certain limitationscomparing to GSM/GPRS modems. This will be discussed in the section”Which
is Better: Mobile Phoneor GSM / GPRS Modem
” later.

Tosend SMS messages, first place a valid SIM card from a wirelesscarrier into a mobile phone or GSM/GPRS modem, which is thenconnected to a computer. There are several ways to connect a mobilephone or GSM/GPRS modem to a computer.
For example, they can beconnected through a serial cable, a USB cable, a Bluetooth link or aninfrared link. The actual way to use depends on the capability of themobile phone or GSM/GPRS modem. For example, if a mobile phone doesnot support Bluetooth, it cannot
connect to the computer through aBluetooth link.

Afterconnecting a mobile phone or GSM/GPRS modem to a computer, you cancontrol the mobile phone or GSM/GPRS modem by sending instructions toit. The instructions used for controlling the mobile phone orGSM/GPRS modem are called AT commands.
(AT commands are also used tocontrol dial-up modems for wired telephone system.) Dial-up modems,mobile phones and GSM/GPRS modems support a common set of standard ATcommands. In addition to this common set of standard AT commands,mobile phones and GSM/GPRS
modems support an extended set of ATcommands. One use of the extended AT commands is to control thesending and receiving of SMS messages.

Thefollowing table lists the AT commands that are related to the writingand sending of SMS messages:

ATcommand

Meaning

+CMGS

Sendmessage

+CMSS

Sendmessage from storage

+CMGW

Writemessage to memory

+CMGD

Deletemessage

+CMGC

Sendcommand

+CMMS

Moremessages to send

Oneway to send AT commands to a mobile phone or GSM/GPRS modem is to usea terminal program. A terminal program’s function is like this: Itsends the characters you typed to the mobile phone or GSM/GPRS modem.It then displays the response
it receives from the mobile phone orGSM/GPRS modem on the screen. The terminal program on MicrosoftWindows is called HyperTerminal. More details about the use ofMicrosoft HyperTerminal can be found in the “Howto
Use Microsoft HyperTerminal to Send AT Commands to a Mobile Phoneor GSM/GPRS Modem
” section of this SMS tutorial.

Belowshows a simple example that demonstrates how to use AT commands andthe HyperTerminal program of Microsoft Windows to send an SMS textmessage. The lines in bold type are the command lines that should beentered in HyperTerminal.
The other lines are responses returned fromthe GSM / GPRS modem or mobile phone.

AT
OK
AT+CMGF=1
OK
AT+CMGW=”+85291234567″
>A simple demo of SMS text messaging.
+CMGW:1

OK
AT+CMSS=1
+CMSS: 20

OK

Hereis a description of what is done in the above example:

  • Line1: “AT” is sent to theGSM / GPRS modem to test the connection. The GSM / GPRS modem sendsback the result code “OK” (line 2), which means theconnection between the HyperTerminal program and the GSM / GPRSmodem works fine.

  • Line3: The AT command +CMGF is used to instruct the GSM / GPRS modem tooperate in SMS text mode. The result code “OK” is returned(line 4), which indicates the command line “AT+CMGF=1” hasbeen executed successfully. If the result code
    “ERROR” isreturned, it is likely that the GSM / GPRS modem does not supportthe SMS text mode. To confirm, type “AT+CMGF=?” in theHyperTerminal program. If the response is “+CMGF: (0,1)”(0=PDU mode and 1=text mode), then SMS text mode is supported. Ifthe response
    is “+CMGF: (0)”, then SMS text mode is notsupported.

  • Line5 and 6: The AT command +CMGW is used to write an SMS text messageto the message storage of the GSM / GPRS modem. “+85291234567″is the recipient mobile phone number. After typing the recipientmobile phone number, you should press
    the Enter button of thekeyboard. The GSM / GPRS modem will then return a prompt “>” and you can start typing the SMS text message “A simpledemo of SMS text messaging.”. When finished, press Ctrl+z ofthe keyboard.

  • Line7: “+CMGW: 1” tells us that the index assigned to the SMStext message is 1. It indicates the location of the SMS text messagein the message storage.

  • Line9: The result code “OK” indicates the execution of the ATcommand +CMGW is successful.

  • Line10: The AT command +CMSS is used to send the SMS text message fromthe message storage of the GSM / GPRS modem. “1” is theindex of the SMS text message obtained from line 7.

  • Line11: “+CMSS: 20” tells us that the reference numberassigned to the SMS text message is 20.

  • Line13: The result code “OK” indicates the execution of the ATcommand +CMSS is successful.

Tosend SMS messages from an application, you have to write the sourcecode for connecting to and sending AT commands to the mobile phone orGSM/GPRS modem, just like what a terminal program does. You can writethe source code in C, C++,
Java, Visual Basic, Delphi or otherprogramming languages you like. However, writing your own code has afew disadvantages:

  • Youhave to learn how to use AT commands.

  • Youhave to learn how to compose the bits and bytes of an SMS message.For example, to specify the character encoding (e.g. 7-bit encodingand 16-bit Unicode encoding) of an SMS message, you need to knowwhich bits in the message header
    should be modified and what valueshould be assigned.

  • SendingSMS messages with a mobile phone or GSM/GPRS modem has a drawback –the SMS transmission speed is low. As your SMS messaging applicationbecomes more popular, it has to handle a larger amount of SMStraffic and finally the mobile
    phone or GSM/GPRS modem will not beable to take the load. To obtain a high SMS transmission speed, adirect connection to an SMSC or SMS gateway of a wireless carrier orSMS service provider is needed. However, AT commands are not usedfor communicating with
    an SMS center or SMS gateway. This means yourhave to make a big change to your SMS messaging application in orderto move from a wireless-modem-based solution to a SMSC-basedsolution.

Inmost cases, instead of writing your own code for interacting with themobile phone or GSM/GPRS modem via AT commands, a better solution isto use a high-level SMS messaging API (Application programminginterface) / SDK (Software development
kit) / library. The API / SDK/ library encapsulates the low-level details. So, an SMS applicationdeveloper does not need to know AT commands and the composition ofSMS messages in the bit-level. Some SMS messaging APIs / SDKs /libraries support SMSC protocols
in addition to AT commands. To movefrom a wireless-modem-based SMS solution to a SMSC-based SMSsolution, usually you just need to modify a configuration file /property file or make a few changes to your SMS messagingapplication’s source code.

Thelinks to some open source and free SMS messaging libraries can befound in the article “FreeLibraries/Tools for Sending/Receiving SMS with a Computer“.

Anotherway to hide the low-level AT command layer is to place an SMS gatewaybetween the SMS messaging application and the mobile phone orGSM/GPRS modem. (This has been described in the section “Whatis
an SMS Gateway?
” earlier.) Simple protocols such as HTTP/ HTTPS can then be used for sending SMS messages in the application.If an SMSC protocol (e.g. SMPP, CIMD, etc) is used for communicatingwith the SMS gateway instead of HTTP / HTTPS, an SMS messaging
API /SDK / library can be very helpful to you since it encapsulates theSMSC protocol’s details.

Usuallya list of supported / unsupported mobile phones or wireless modems isprovided on the web site of an SMS messaging API / SDK / library oran SMS gateway software package. Remember to check the list if youare going to use an SMS
messaging API / SDK / library or an SMSgateway software package.

10.1.1. MajorDrawback of Sending SMS Messages through a Mobile Phone or GSM/GPRSModem — Low SMS Sending Rate

Usinga mobile phone or GSM/GPRS modem to send SMS messages has a majordrawback, that is the SMS sending rate is too low. Only 6-10 SMSmessages can be sent per minute (when the “SMS over GSM”mode is used). The performance is not affected
by the connectionbetween the computer and the mobile phone or GSM/GPRS modem (i.e. theSMS sending rate is about the same no matter the mobile phone orGSM/GPRS modem is connected to the computer through a serial cable,USB cable, Bluetooth link or infrared link)
and does not depend onwhether a mobile phone or GSM/GPRS modem is used (i.e. the SMSsending rate is about the same no matter a mobile phone or a GSM/GPRSmodem is used). The determining factor for the SMS sending rate isthe wireless network.

Contents at a Glance

版权所有,禁止转载. 如需转载,请先征得博主的同意,并且表明文章出处,否则按侵权处理.

    分享到:

留言

你的邮箱是保密的 必填的信息用*表示