/ * Since the work needs, use the WAVECOM module to program the programming of SMS, and search for a lot of library resources about the AT instruction set and SMS PDU encoding, but it seems that there is no text message to send text messages to SMS The number of PDU coding examples, so I changed the procedure of "Wu Zhiwen". After testing, I can successfully send it to SMS special service number (SP special service number), first publish the PDU encoder file, hope to be able Give everyone a little convenience. Oh, everyone pays attention to the last 2 fun. SMSDECodedsMSSP, SMSNumBersp * /////////////////////////////////> Summary: For Domestic SMS Coding (USC2) /// Composition Structure : contains four functions: /// smsDecodedCenterNumber (string srvCenterNumber) SMS center number coding /// smsPDUEncoded (string srvContent) message content encoding /// smsDecodedNumber (string srvNumber) mobile phone number to receive text messages encoded /// smsDecodedsms (string strCenterNumber, String strnumber, string strsmsMscontent) The code of the entire SMS /// //// String Nlength; // To send the length of the content, consisting of two parts, receive the mobile phone number plus the content to send ///// version This: 1.0.20031020 /// Usage: /// 1, copy file to your project, add reference using SMS; /// 2, define this class, for example: pdudecoding ss = new sms.pdudecoding () ; /// 3, now you can use this class, for example: /// textBox2.text = ss.smsdecodedsms (txtCenterNumber.Text, TXTNumber.Text, TextBox1.text); /// // This class library Everyone can freely copy, must retain the above copyright information. /// This class is for study purposes only, without obtaining the author I agree ///, please do not use any commercial interest usage. Author I retain /// all pursue rights. /// copyright to the author all using system; using system.text;
Namespace SMS {public class pdudecoding {public class pdudecoding {publicity; // To send content length, consist of two parts, receive mobile phone number plus content /// /// function function: SMS content encoding //// / Function Name: SMSPDUENCODED (STRING SRVCONTENT) / / / / NE: SRVContent To convert SMS content, string type /// Return value: SMS content after encoding, String Type / / Programmer: Sillnet@163.net /// Preparation: 2003-10-15 /// Function Description: /// 1 2. The converted SMS content is stored by the byte array /// 3, and it is removed in the Unicode format encoding, "-" in the two bytes, for example: 00-21, becomes 0021 //// 4, In addition to the length of the entire SMS content, the length of the SMS is retained 2 //// summary> public string smspduencoded (string srvcontent) {encoding encodingutf = system.text.encoding.bigenDianunicode; string s = null; Byte [ ] EncodedBytes = encodingutf.getbytes (srvcontent); for (int i = 0; i
/// /// function function: SMS center number code /// function name: SMSDECodedCenterNumber (String SRVCENTERNUMBER) / // parameter: SRVCENTERNUMBER To convert the SMS center number, string type /// return value: Post-encoded SMS, String Type /// Programmer: SILLNET@163.net /// Preparation Date: 2003-10-15 /// Function Description: /// 1, exchange odd digits and even digits. /// 2, after the SMS center number is exchanged, see if the length is an even number, if not, finally add f /// 3, plus the SMS center number type, 91 is international /// 4, calculate the encoding SMS center number length, concurrent into two hexadecimal /// summary> public string smsdecodedcenterNumber (string srvcenternumber) {string s = null; int NLENGTH = SRVCENTERNUMBER.LENGTH; for (int i = 1; I
/// /// function: Receive SMS mobile phone number encoding /// function name: SMSDECodedNumber /// parameter: SRVCENTERNUMBER To convert the SMS center number, string type /// return value : Post-encoded reception SMS mobile phone number, String Type /// Programmer: SILLNET@163.net /// Preparation date: 2003-10-15 /// Function Description: /// 1, check if the current receiving mobile phone number is Written in standard format, not, add "86" /// 1, exchange odd digits and even digits. /// 2, after the SMS center number is exchanged, see if the length is even, if not, finally add f /// summary> public string smsdecodednumber (string srvnumber) {string s = null; if (! Srvnumber.substring (0, 2) == "86")) {srvnumber = String.Format ("86 {0}", srvnumber); // Check if the current receiving mobile phone number is written in standard format, not, "86"} int NLENGTH = SRVNUMBER.LENGTH; For (int i = 1; i
/// /// function function: Code /// function name for the entire SMS: SMSDecodedsms (String strCenterNumber, string strnumber, string strsmscontent) /// parameter: StrCenterNumber To convert the SMS center number, String Type /// StrNumber receives the mobile phone number, string type /// strsmsContent SMS content /// return value: complete SMS code, can be executed in the AT instruction, String Type ///> Programmer: Sillnet@163.net ////// Code Date: 2003-10-15 /// Function Description: /// 11000d91 and 000800 In China, according to the principle of PDU coding, we write this here, please explain, please see my article /// summary> public String smsDecodedsms (string strCenterNumber, string strNumber, string strSMScontent) {string s = String.Format ( "{0} 11000D91 {1} 000800 {2}", smsDecodedCenterNumber (strCenterNumber), smsDecodedNumber (strNumber), smsPDUEncoded (strSMScontent)); nLength = String.format ("{0: D2}", (S.Length - smsdecodededcenternumber (strCenternumber) .length) / 2); // Get SMS content plus mobile phone number length Return S;}
// ------------------------------------------- Send号 号 Code ----------------------------------------------- ----- /// /// Function function: Receive SMS Speed Number Coding /// Function Name: SMSDecodedNumBersp (String Srvnumber) /// Parameter: SRVCenterNumber To convert the SMS center number, String Type /// Return Value: After the encoding, the SMS, String Type /// Programmer: Wu Zhiwen (Silkworm (Sworm Cocoon) Modification: Singphro ---Libingjin@vip.sina.com /// Preparation Date: 2004-10-19 /// Function Description: /// 1, sending SMS to the special service number does not need to add 86 before the speculation number. /// 1, exchange odd digits and even digits. /// 2, after the SMS center number is exchanged, see if the length is an even number, if not, finally add f /// summary> public string smsdecodedNumBersp (string srvnumber) {string s = null; / * f ( ! (SRVNUMBER.SUBSTRING (0, 2) == "86")) {srvnumber = String.Format ("86 {0}", srvnumber); // Check if the current receiving mobile phone number is written in standard format, not, Support "86"} * / int NLENGTH = SRVNUMBER.LENGTH; for (int i = 1; i
/// /// function function: The entire SMS encoding (send to the special service number) /// function name: SMSDECodedSMSSP (String strCenterNumber, string strunch, string strsmscontent, string strnumberngth) /// parameter: strCenterNumber To convert the SMS center number, String Type /// Strnumber receiving the special service number, string type /// strsmsMSContent SMS content /// StrNumberLength receives the special service number, String type (the same as Strnumber) /// Return Value: Complete SMS encoding, can be executed in the AT instruction, String Type /// Programmer: Wu Zhiwen (Silkworm (Silkworm) Modification: Sirfiro-Libingjin@vip.sina.com /// Preparation date: 2004-10-19 /// Function Description: /// 11000d91 and 000800 Send to mobile phone numbers in China, but when sending to the special service number, you need to re-encode // // / / will be 91 [ ] Modify to 81. /// summary> public string smsDecodedsmsSP (string strCenterNumber, string strNumber, string strSMScontent, string strNumberLength) {string s = String.Format ( "{0} 1100 {3} 81 {1} 000800 {2}", smsDecodedCenterNumber (strCenterNumber), smsDecodedNumberSP (strNumber), smsPDUEncoded (strSMScontent), smsNumberSP (strNumberLength)); nLength = String.Format ( "{0: D2}", (s.Length - smsDecodedCenterNumber (strCenterNumber) .Length) / 2); / / Get SMS content plus mobile phone number length Return S;} /// /// function function: Get Specific service number coding length (hexadecimal) /// function name: SMSNumBersp (String srvnumber) / // Parameter: Strnumber receives a special service number, string type /// return value: return Specific service number coding length String Type /// Programmer: Wu Zhiwen (silkworm 蛹) Modification: Sprodu --- LibingJin @ VIP .sina.com /// Preparation date: 2004-10-19 /// Function Description: /// The special service number limit is limited to 15 digits, that is, the maximum value is 0F /// summary> public string smsnumBersp (String Srvnumber) {string s = convert.toString (srvnumber.length, 16) .toupper (); Return "0" S;}
}