Preview only show first 10 pages with watermark. For full document please download

Sim2000_sms_v1.01

   EMBED


Share

Transcript

SMS Application notes AN_SMS_V1.01 Smart Machine Smart Decision Document Title: SMS Application notes Version: 1.01 Date: 2014-05-14 Status: Release Document Control ID: AN_SMS_V1.01 General Notes Simcom offers this information as a service to its customers, to support application and engineering efforts that use the products designed by Simcom. The information provided is based upon requirements specifically provided to Simcom by the customers. Simcom has not undertaken any independent search for additional relevant information, including any information that may be in the customer’s possession. Furthermore, system validation of this product designed by Simcom within a larger electronic system remains the responsibility of the customer or the customer’s system integrator. All specifications supplied herein are subject to change. Copyright This document contains proprietary technical information which is the property of SIMCOM Limited., copying of this document and giving it to others and the using or communication of the contents thereof, are forbidden without express authority. Offenders are liable to the payment of damages. All rights reserved in the event of grant of a patent or the registration of a utility model or design. All specification supplied herein are subject to change without notice at any time. Copyright © Shanghai SIMCom Wireless Solutions Ltd. 2014 AN_SMS_V1.01 2 2014.05.14 Smart Machine Smart Decision SCOPE This document describes how to use SMS functions of SIM2000 through AT commands. Examples are also given for reference. This document can be used for SIM2000 series modules, but this function needs special module and FW to be supported. For the detail, please help to contact with SIMCom. This document is subject to change without notice at any time. AN_SMS_V1.01 3 2014.05.14 Smart Machine Smart Decision Contents 1 Introduction....................................................................................................................................5  1.1 References ............................................................................................................................5  1.2 Related command.................................................................................................................5  2 Application example ......................................................................................................................6  2.1 Send Chinese and English short messages in PDU mode ....................................................6  2.2 Send Chinese short message in TEXT mode .......................................................................9  2.3 Send English short message in TEXT mode ......................................................................10  2.4 SMS Status Report (in PDU mode)....................................................................................10  2.5 SMS Status Report (in TEXT mode) .................................................................................11  2.6 Receive a new short message (in PDU mode)....................................................................11  2.7 Receive a new long short message (in PDU mode) ...........................................................12  3 Appendix A: Convert between in GB code and UCS2 code ........................................................14  3.1 Introduction:.......................................................................................................................14  3.2 Convert rules: .....................................................................................................................14  4 Appendix B: Source code.............................................................................................................16  4.1 GB code to Unicode code: .................................................................................................16  4.2 Unicode code to GB code: .................................................................................................16  AN_SMS_V1.01 4 2014.05.14 Smart Machine Smart Decision 1 Introduction This document describes how to send the Chinese and English short message through Hyper Terminal by AT command of SIMCOM module providing. 1.1 References [1] SIMCOM_ATC [2] SIMCOM_UGD [3] 3GPP2 C.S0015-0 1.2 Related command AT+CMGF SELECT SMS MESSAGE FORMAT AT+CSCS SELECT TE CHARACTER SET AT+CMGS SEND SMS MESSAGE AT+CSMP SET SMS TEXT MODE PARAMETERS AT+CNMI NEW SMS MESSAGE INDICATIONS AT+CMGD DELETE SMS MESSAGE AT+CMGL LIST SMS MESSAGES FROM PREFERRED STORE AT+CMGR READ SMS MESSAGE AT+CMGDA DELETE ALL SMS AT+CMSS SEND SMS MESSAGE FROM STORAGE AT+CPMS PREFERRED SMS MESSAGE STORAGE 1. The EVB of the module should be connected to PC by serial port cable. 2. On PC, start the Hyper Terminal procedure and set the serial port rate to 115200 3. Confirm the SIMCOM module and the SIM card are located on EVB, and then supply power. AN_SMS_V1.01 5 2014.05.14 Smart Machine Smart Decision 2 Application example 2.1 Send Chinese and English short messages in PDU mode Define the [PDU]data unit mode: 1 octet SMS MSG TYPE 1 octet 1 octet Record(1) _id Record(1) _len 1 octet … Record (n)_id Record(1)_len 1 octet Record(1) Data 1 octet Record (n)_len Record(2) _id 1 octet Record(2) _len record(2)_len Record(2) Data … Record (n)_len Record (n) Data Record list: Record id: AN_SMS_V1.01 6 2014.05.14 Smart Machine Smart Decision For example: send “你好” to 13912345678 The sending data: 你好 The Unicode coding: 4F60597D Set the short message mode to PDU mode: AT+CMGF=0 Send AT+CMGS=41 //The decimal length of PDU >0000021002040702C4E448D159E008190003200030010620127B02CBE80801000901000 A01000D0101 [ctrl-Z] 00 //sms Point-to-Point 00 //teleservice identifier 02 //length 1002 //demical:4098,CMT_95 SHORT MSG 04 //Destination Address TAG 07 //length 02C4E448D159E0 //Destination Address number 08 //bear data TAG 19 //length: 25 00 //MSG ID 03 //len 200030 //the first 4 bits:0010 indicates the message type is submit sms ,0003 is MSG ID 01 //user data ID 06 //len 20127B02CBE8 //data content 080100 //08: priority indicator id, 01:LEN, 00: normal 090100 //09: privacy indicator id, 01:LEN, 00: no restrict 0A0100 //0A: reply option id 0D0101 //0D: language indicator id NOTE 1: The address parameters have the following variable-length format: AN_SMS_V1.01 7 2014.05.14 Smart Machine Smart Decision The binary of “02C4E448D159E0” is: 0000 0010 1100 0100 1110 0100 0100 1000 1101 0001 0101 1001 1110 0000 The DIGIT_MODE bit is 0, the field indicates the address digits are 4-bit DTMF codes. The NUMBER_MODE bit is 0, the field indicates the address using the definitions in ANSI T1.607. The DIGIT_MODE is 0, so the NUMBER_TYPE and NUMBER_PLAN bits are omitted. The NUM_FIELDS is 00 0010 11, indicates the number of address is 11 in decimal. The following 44 bits are the Destination Address Number: 00 0100 1110 0100 0100 1000 1101 0001 0101 1001 1110 00 ->13912345678 The last two bits are reserved. If the number is ‘1010’, it is ‘0’in decimal. NOTE 2: The User Data subparameter has the following variable-length format: AN_SMS_V1.01 8 2014.05.14 Smart Machine Smart Decision The binary of “20127B02CBE8” is: 0010 0000 0001 0010 0111 1011 0000 0010 1100 1011 1110 1000 The MSG_ENCODING is 0x100, indicates the data format is UNICODE, if it is 0x10, the data format is ASCII. The MSG_ENCODING is not 0x1, The MESSAGE_TYPE is omitted. The NUM_FIELDS is 0x00000010, so the following 32 bits are the user data content: 010 0111 1011 0000 0010 1100 1011 1110 1, the HEX is 4F60597D, “你好”. If you want to send English chars “abcd” instead of “你好” , just do like this: 00010 //add MSG_ENCODING 00010 00000100 //add NUM_FIELDS 00010 00000100 1100001 1100010 1100011 1100100 //add 0x61,0x62,0x63,0x64 ,omit the highest bit. 0001 0000 0010 0110 0001 1100 0101 1000 1111 0010 0000 0000 //add RESERVED The HEX string is: 10261c58F200, so the new pdu is: 0000021002040702C4E448D159E008190003200030010610261C58F2000801000901000A0100 0D0101 2.2 Send Chinese short message in TEXT mode For example: send “你好” to 13912345678 AN_SMS_V1.01 9 2014.05.14 Smart Machine Smart Decision Set the short message mode as TEXT mode: AT+CMGF=1 Set the character mode as UCS2 mode: AT+CSCS=“UCS2” Send AT+CMGS=” 00310033003900310032003300340035003600370038” // Enter the coding of the mobile phone number directly ¾ 4F60597D[ctrl-Z] NOTE 1: User can send the Chinese short message of TEXT mode following the above mentioned example, and change the coding of mobile phone number and the Unicode coding of message content. 2.3 Send English short message in TEXT mode For example, send “Hello” to 13912345678 Set the short message mode as TEXT mode: AT+CMGF=1 Set the character mode as GSM mode: AT+CSCS=“GSM” Send AT+CMGS=”13912345678” // Enter the mobile phone number directly ¾ Hello[ctrl-Z] NOTE 1: User can send the English short message of TEXT mode following the above mentioned example, and change the mobile phone number and the message content. 2.4 SMS Status Report (in PDU mode) For example: Send “你好” To 13912345678 Set the short message mode as PDU mode: AT+CMGF=0 Set SMS-STATUS-REPORTs: AT+CNMI=2,1,0,1,0 SMS-STATUS-REPORTs are routed to the TE using unsolicited result code: +CDS: (PDU mode enabled) Send AT+CMGS=019 >0000021002040702C4E448D159E008190003200030010610261C58F2000801000901000A014 00D0101 [CTRL+Z] AN_SMS_V1.01 10 2014.05.14 Smart Machine Smart Decision Return result code: +CMGS: 121 OK +CDS: "",47 0000021002020702C4CDEA94A4540601FC081C0003400BA0010A20229E8C800B108294F8 0306140421124413140102 2.5 SMS Status Report (in TEXT mode) For example: Send “Hello” To 13912345678 Set the short message mode as TEXT mode: AT+CMGF=1 Set the character mode as GSM: AT+CSCS=”GSM” Set SMS-STATUS-REPORTs: AT+CNMI=2,1,0,1,0 Send AT+CMGS=“13912345678” >Hello[CTRL+Z] Return result code: +CMGS: 139 OK +CDS: "13912345678","14/04/16,17:40:19+00",8 53D190016210529F 2.6 Receive a new short message (in PDU mode) +CMTI: "ME",6 AT+CMGR=6 +CMGR: 0,"",52 0000021002020702C56484A8D5D00601FC08210003100B30010620127B02CBE803061404171 538340A01400E07058AC90951ABA0 OK 00 //sms Point-to-Point 00 //teleservice identifier 02 //length 1002 //demical:4098,CMT_95 SHORT MSG 02 //originating Address TAG 07 //length AN_SMS_V1.01 11 2014.05.14 Smart Machine Smart Decision 02C56484A8D5D0 //originating Address number 06 //Bear reply option 01//length FC 08 // Bearer data TAG 21 //length 00 //MSG ID 03 //LEN 100B30 //1:deliver message 00B3:MSG ID 01 //user data 06 //length 20127B02CBE8 // “你好” 03 //Message Center Time Stamp 06 //length 140417153834 //year:2014 month:04 data:17 hour:15 minute:38 sencond:34 0A //reply option 01 //length 40 0E //Call-Back Number 07 //length 058AC90951ABA0 //the first bit is 0, indicates the call-back number using the binary representation of DTMF digits, 00001011 is the call back number length, 000 1010 1100 1001 0000 1001 0101 0001 1010 1011 1010 0000 is the number ‘15921203574’. 2.7 Receive a new long short message (in PDU mode) +CMTI: "ME",7 +CMTI: "ME",8 AT+CMGR=7 +CMGR: 0,"",188 0000021002020702C56484A8D5D00601FC08A90003110B18018E223028001C68100A7B02CB EA7B02CBEA7B02CBEA7B02CBEA7B02CBEA7B02CBEA7B02CBEA7B02CBEA7B02CBE A7B02CBEA7B02CBEA7B02CBEA7B02CBEA7B02CBEA7B02CBEA7B02CBEA7B02CBEA 7B02CBEA7B02CBEA7B02CBEA7B02CBEA7B02CBEA7B02CBEA7B02CBEA7B02CBEA7 B02CBEA7B02CBEA7B02CBEA7B02CBEA7B02CBEA7B02CBEA7B02CBEA7B02CBEA7B 0003061404171649420A01400E07058AC90951ABA0 OK AT+CMGR=8 +CMGR: 0,"",64 0000021002020702C56484A8D5D00601FC082D0003103B480112204028001C681012CBEA7B AN_SMS_V1.01 12 2014.05.14 Smart Machine Smart Decision 02CBEA7B02CBE803061404171649450A01400E07058AC90951ABA0 OK 00 //sms Point-to-Point 00021002 //teleservice identifier 020702C56484A8D5D0 //originating Address 0601FC //Bear reply option 08 //Bearer data TAG A9 //length 00 //MSG ID 03 //length 110B18 //1:deliver message 10B1:MSG ID 8:the highest bit is 1,the short message is a long message 01 //user data 8E //length 142 223028001C68100A7B02CBEA7B02CBEA7B02CBEA7B02CBEA7B02CBEA7B02CBEA7B0 2CBEA7B02CBEA7B02CBEA7B02CBEA7B02CBEA7B02CBEA7B02CBEA7B02CBEA7B02 CBEA7B02CBEA7B02CBEA7B02CBEA7B02CBEA7B02CBEA7B02CBEA7B02CBEA7B02C BEA7B02CBEA7B02CBEA7B02CBEA7B02CBEA7B02CBEA7B02CBEA7B02CBEA7B02CB EA7B02CBEA7B02CBEA7B00 //note1 0306140417164942 //Message Center Time Stamp 0A0140 //reply option 0E07058AC90951ABA0 //Call-Back Number NOTE1: 223028001C68100A7B02CBEA7B02CBEA7B02CBEA7B02CBEA7B02CBEA7B02CBEA7B0 2CBEA7B02CBEA7B02CBEA7B02CBEA7B02CBEA7B02CBEA7B02CBEA7B02CBEA7B02 CBEA7B02CBEA7B02CBEA7B02CBEA7B02CBEA7B02CBEA7B02CBEA7B02CBEA7B02C BEA7B02CBEA7B02CBEA7B02CBEA7B02CBEA7B02CBEA7B02CBEA7B02CBEA7B02CB EA7B02CBEA7B02CBEA7B00 0010 00100011 0000 0010 1000 0000 0000 0001 1100 0110 1000 0001 0000 0000 1010 0111 1011 0000 0010 1100 1011 1110 1010 0111 1011 0000 0010 1100 The first five bits are the user data encoding type, the code is 00100, indicates “Unicode”. The following 8 bits is the number of Unicode chars, the code is 01000110, 0x46, indicates the short message has 70 unicode chars, but if the encoding is not IS91EP, the num is not right usually. The following bytes: 0500038D02014F60597D4F60597D… 0500038D0201 is SMS user data header: 8D:msg pref,02:total msg number 01:current number 4F60597D4F60597D.. is the content: “你好你好…” If we decode the second message in the same way, we can find its SMS user data header is: 05 00 03 8D0202 00 //sms Point-to-Point 00021002 //teleservice identifier 020702C56484A8D5D0 //originating Address AN_SMS_V1.01 13 2014.05.14 Smart Machine Smart Decision 0601FC //Bear reply option 082D0003103B48 01 //user data 12 //length 204028001C681012CBEA7B02CBEA7B02CBE8 //05 00 03 8D0202 597D4F60 597D4F60 597D 0306140417164945 //Message Center Time Stamp 0A0140 //reply option 0E07058AC90951ABA0 //Call-Back Number 3 Appendix A: Convert between in GB code and UCS2 code 3.1 Introduction: This file descripts that how to convert characters between window and UCS2, including transformation rules between GB code and Unicode. 3.2 Convert rules: 3.2.1 Convert characters from PC to module 1. Character less than 128 (character as same as 16bit Unicode code, do not need to convert), example: 0x12 to Unicode: 0x0012. 2. Character more than 127, 1) Can convert 8bit character string in windows to 16bit GB code, Example: 0x87, 0x10 to GB code: 0x8710; 2) Convert 16bit GB code to 16bit Unicode code: refer to list 3. at last, convert Unicode to UCS2 format, and split to IRA code (means one Unicode code be split to four 8bit character), Example: Trans 0x248E to IRA character as (character “2” (0x31), “4” (0x34), “8” (0x38), “E” (0x45)); then can send UCS2 format data (finial data be send to serial port)。 3.2.2 Convert characters from module to PC. 1. Convert UCS2 format (four 8bit one group) to 16bit Unicode code. Example: UCS2 format character string (“2”,”4”,”7”,”E”) to 16bit Unicode: 0x247E; 2. Convert 16bit Unicode to 16bit GB code: refer to list; 3. Finally, convert 16bit GB code to 8bit windows character; If 16bit GB code less than 128, then convert to 8bit windows character directly, Example: 0x0054 (GB code) to 0x54 (window character); 0x0012 (GB code) to 0x12 (window character); AN_SMS_V1.01 14 2014.05.14 Smart Machine Smart Decision If 16bit GB code more than 127, than split to two 8bit characters first, Example: 0x8710 (GB code) to 0x87, 0x10 (window character). AN_SMS_V1.01 15 2014.05.14 Smart Machine Smart Decision 4 Appendix B: Source code 4.1 GB code to Unicode code: 1.Convert Program: /************************************************************************* Function:convert GB code to Unicode code Parameter:GBCode(16bit standard GB code) Return: Notes: 16bit standard Unicode code this function only be converted when GB Code is more than 127, when GB Code is less than 128, can be convert to Unicode code directly. **************************************************************************/ Int16 GB2Unicode(Int16 GBCode) { WORD unicode; BYTE high, low; high = (GBCode & 0xff00)>>8; low = GBCode & 0x00ff; unicode = GB_TO_UNICODE_TABLE[(high - 0xa0) * 100 + (low - 0xa0) - 101]; return(unicode); } 2. Example(Only for GB code more than 127): 0x0D2BB (GB code) to 0x4E00(Unicode code) ; 0x0B6A1 (GB code) to 0x4E01(Unicode code) ; 0x0C6DF (GB code) to 0x4E03(Unicode code) . 4.2 Unicode code to GB code: 1. Convert program /************************************************************************** * Function: Convert Unicode code to GB code * Parameter:Unicode code(16bit standard Unicode code) *return: 16bit standard GB code **************************************************************************/ Int16 Unicode2GB(WORD Unicode) { AN_SMS_V1.01 16 2014.05.14 Smart Machine Smart Decision WORD QWCode, GBCode; BYTE hi, low; if(Unicode >= 0x4e00) { if(Unicode ==65306) // GB code for modify “:” { GBCode = 41914; } else if(Unicode == 65307) // GB code for modify”;” { GBCode = 41915; } else if(Unicode == 65281) // GB code for modify”!” { GBCode = 41889; } else if((Unicode<=0xFF5E)&&(Unicode>=0xFF01)) { //equal to ASCII code range 0x21~0x7E GBCode = Unicode - 0xFEE0; } else { Unicode = Unicode - 0x4e00; QWCode = UNICODE_To_GB_Table[Unicode]; hi = QWCode / 100 + 0xa0; low = QWCode % 100 + 0xa0; GBCode = (hi << 8) + low; } return(GBCode); } else { /* verify character code*/ if(Unicode == 12290) // return to full stop { return(41379); } else if(Unicode == 12288) // modify display of 0xA1 character, return to blank { AN_SMS_V1.01 17 2014.05.14 Smart Machine Smart Decision return(32); } else if(Unicode == 0x300e) // modify display of 『character { return(41402); } else if(Unicode == 0x300F) // modify display of 』character { return(41403); } else { return Unicode; } } } 2. Convert example: 0x4E00(Unicode code) to 0x0D2BB(GB code); 0x4E01(Unicode code) to 0x0B6A1(GB code); 0x4E03 (Unicode code ) to 0x0C6DF(GB code). AN_SMS_V1.01 18 2014.05.14 Contact us: Shanghai SIMCom Wireless Solutions Ltd. Add: SIM Technology Building, No. 700, Yishan Road, Shanghai,P. R. China 200233 Tel: +86 21 5427 8900 Fax: +86 21 5427 6035 URL: www.sim.com/wm