如何使用短信猫发送中文短信

使用短信猫收发短信,原理是通过串口通信发送AT指令.当你发送中文短信时,你会又喜悦又困惑,短信确实收到了,但是是乱码的.本文介绍如何正确发送中文短信.


请注意短信猫支持SMSText模式,才能通过串口通信发送AT指令的方式收发短信.如果不支持SMSText,可以使用GSMCommunication串口通信,使用pdu编码短信内容.Some advanced GSM modems like WaveCom and Multitech, support the SMStext mode. This mode allows you to send SMS messages using AT commands, withoutthe need to encode the binairy PDU field of the SMS first. This is done by theGSM modem.

发送中文短信的原理是设置16进制模式,同时指定DCS为unicode编码方式.接收中文短信也同样如此.

AT

AT\r\r\nOK\r\n

 

设置modemSMS text mode

AT+CMGF=1

AT+CMGF=1\r\r\r\nOK\r\n

 

查询当前参数

AT+CSMP?

AT+CSMP?\r\r\r\n+CSMP:1,167,0,0\r\n\r\nOK\r\n

 

displays the codepages supported by the modem

AT+CSCS=?

AT+CSCS=?\r\r\n+CSCS:(\"GSM\",\"PCCP437\",\"CUSTOM\",\"HEX\")\r\n\r\nOK\r\n

 

设置modemhex mode

AT+CSCS="HEX"

AT+CSCS=\"HEX\"\r\r\r\nOK\r\n

 

specify the correct DCS (Data Coding Scheme) forUnicode messages, which is 0x08

AT+CSMP=1,167,0,8

AT+CSMP=1,167,0,8\r\r\r\nOK\r\n

 

设置sms发送的手机号码

AT+CMGS="+31638740161"

"AT+CMGS=\"+31638740161\"\r\r\r\n>"

 

unicode编码发送SMS

6d4b8bd5

"\r\n>"

测试

 

C# unicode编码方法

      public staticstring ConvertToUTF(string input_text)

        {

            string _out = String.Empty;

            char[] _chars =input_text.ToCharArray();

            foreach (char c in _chars)

            {

                _out +=((Int16)c).ToString("X4");

            }

            return _out;

        }

 

参考

Howto Send, Receive and Delete SMS with IOT Devices (Arduino and GSM Shield)

Send SMS using ATcommands

Persiantext box to hex to byte




你可能感兴趣的:(sms,C#)