在AT命令上写入波浪号(〜)字符 [英] writing tilde (~) character on an AT commands

查看:99
本文介绍了在AT命令上写入波浪号(〜)字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我有一个项目需要使用连接到USB线的itegno 3800 GSM调制解调器向任何手机号码发送短信(SMS) 。

我可以发送短信只用于普通信息,如字母和数字。



我的问题是当我以前发送包含的信息时( 〜)字符它不会出现在接收手机/设备上。



这里是我的发送代码:



Hi,

I have a project where I need to send an Text Message (SMS) to any mobile number using itegno 3800 GSM modem attached to a USB cable.
I can send SMS for only ordinary message like alphabet and numbers.

my problem is when i used to send a message containing (~) character it doesn't appear on the receiving mobile/device.

here is my code on sending:

port.PortName = p_strPortName;                 //COM1
              port.BaudRate = p_uBaudRate;                   //9600
              port.DataBits = p_uDataBits;                   //8
              port.StopBits = StopBits.One;                  //1
              port.Parity = Parity.None;                     //None
              port.ReadTimeout = p_uReadTimeout;             //300
              port.WriteTimeout = p_uWriteTimeout;           //300
              port.Encoding = Encoding.GetEncoding("iso-8859-1");
              port.Handshake = Handshake.None;
              port.DataReceived += new SerialDataReceivedEventHandler(port_DataReceived);

              System.Threading.Thread.Sleep(50);

              port.Open();
              port.DtrEnable = true;
              port.RtsEnable = true;







string recievedData = ExecCommand(port, "AT", 300, "No phone connected");
                   recievedData = ExecCommand(port, "AT+CMGF=1", 300, "Failed to set message format.");
                   String command = "AT+CMGS=\"" + PhoneNo + "\"";
                   recievedData = ExecCommand(port, command, 300, "Failed to accept phoneNo");
                   command = Message + char.ConvertFromUtf32(26) + "\r";

                   recievedData = ExecCommand(port, command, 3000, "Failed to send message"); //3 seconds

                   if (recievedData.EndsWith("\r\nOK\r\n"))
                   {
                       isSend = true;
                   }
                   else if (recievedData.Contains("ERROR"))
                   {
                       isSend = false;
                   }










port.DiscardOutBuffer();
               port.DiscardInBuffer();
               receiveNow.Reset();
               port.Write(command + "\r");

               string input = ReadResponse(port, responseTimeout);
               if ((input.Length == 0) || ((!input.EndsWith("\r\n> ")) && (!input.EndsWith("\r\nOK\r\n"))))
               {
                   return input;
               }
               else
               {
                   return input;
               }







请不要介意一些丢失的脚本,因为我只包括一些专业代码。



我的意图是完全发送短信,即使它有一个像(〜)这样的特殊字符。



您的意见和建议非常感谢。



谢谢。



Michael John Bernarte




please don't mind some missing scripts as I only included some major codes.

my intent is to send SMS completely even it has a special character like (~).

Your feedback and comments are highly appreciated.

Thank you.

Michael John Bernarte

推荐答案

SMS使用特定字符集,其中必须始终支持的基本7位集与ASCII不同。请参阅维基百科 [ ^ ]。



因此,您必须根据使用的GSM编码方案对消息字符串进行编码。





您可以查看CP文章用于解码/编码SMS PDU的库 [ ^ ]。
SMS use specific character sets where the basic 7-bit set which must be always supported is not identical to ASCII. See the Wikipedia[^].

So you must encode your message string according to the used GSM encoding scheme.


You might have a look at the CP article Library for Decode/Encode SMS PDU[^].


这篇关于在AT命令上写入波浪号(〜)字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆