本文介绍了使用pdu格式通过gsm调制解调器发送波斯短信的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请帮助我

if (!comPort.IsOpen)
               comPort.Open();
           comPort.DiscardInBuffer();
           comPort.DiscardOutBuffer();





atCommandStr = "AT";
           comPort.WriteLine(atCommandStr + (char)13);
           messageTXT.Text = comPort.ReadExisting();
            //baraye moshakas kardan halate PDU
           atCommandStr = "AT+CMGF=0";
           comPort.WriteLine(atCommandStr + (char)13);
           messageTXT.Text = comPort.ReadExisting();
           atCommandStr = "AT+CMGS=20";
           comPort.WriteLine(atCommandStr + (char)13);
           messageTXT.Text = comPort.ReadExisting();


string path;
           //path = "0681398647575611000B819083660786F00008FF06062A0633062A" + Char.ConvertFromUtf32(26);
           path = "0681398647575611000B819083660786F00008FF06062A0633062A" + Char.ConvertFromUtf32(26);
           comPort.WriteLine(path + (char)13);
           //read immediately response
           messageTXT.Text = comPort.ReadExisting();
           comPort.Close();


运行此代码,但不发送短信
问题出在哪里?


run this code but do not send sms
where is problem ?

推荐答案


path = "0681398647575611000B819083660786F00008FF06062A0633062A" + Char.ConvertFromUtf32(26);
comPort.WriteLine(path + (char)13);



做:



do:

path = "0681398647575611000B819083660786F00008FF06062A0633062A";
char eof = Convert.ToChar( 26 );
comPort.Write( path + eof );



最好的问候


编辑.
我刚刚检查了您的pdu长度.



best regards


edit.
i just checked your pdu length.

atCommandStr = "AT+CMGS=20";



应该是



should be

atCommandStr = "AT+CMGS=26";



一般而言:
AT + CMGS =(pduString.Length/2)-1



in general:
AT+CMGS = (pduString.Length / 2) - 1


Service center number:
Service center time stamp: 01/01/0001 12:00:00 ق.ظ
Message reference #: 0
Direction: Submited
Phone number: 935421542
Status report indication: False
Message:
دلتا سافت



此Pdu格式为真



This Pdu Format Is True


这篇关于使用pdu格式通过gsm调制解调器发送波斯短信的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 02:34