S
sinboy
Unregistered / Unconfirmed
GUEST, unregistred user!
发送内容为“你好,测试”,经过PDU编码之后为“0891683108501705F011000D91683136143636F10008000A4F60597DFF0C6D4B8BD5”
初始化at+cmgf=0,at+cnmi=2,2,0,0,1,at+csmp=17,167,0,8
在超级终端上的输入结果为:
at+cmgs=25
> 0891683108501705F011000D91683136143636F10008000A4F60597DFF0C6D4B8BD5
+CMGS: 60
OK
手机成功接收
在JAVA程序里实现在主要代码是:
if (isPduMode) {
Config conf = new Config();
PduSendPack pack = new PduSendPack();
pack.setDestAddr(dest);
pack.setUserData(content);
pack.setSmsc(conf.smsc());
pack.setDataCodedCharset(8);
String coded = pack.getCodedStr();
if (coded != null)
cmd1 = "AT+CMGS="+ (coded.length() - 18)/ 2
+ "/r"
+ coded
+ (char) Integer.parseInt("1a", 16) + "z";
} else
{
Config conf = new Config();
codeType = conf.codeType();
if (codeType != null&&
codeType.equals("1")
content = Common.gb2unicode(content);
cmd1 = "AT+CMGS=/"+86"+ dest+ "/""+(char)13+ content+ (char)26;
}
if (cmd1 != null) {
System.err.println(cmd1);
sendMsg(cmd1, sPort);
isSendOK = false;
}
//把短消息通过数据猫发送出去
private void sendMsg(String msg, SerialPort sPort) {
DataOutputStream pw;//开始用的是PrintWriter,直接把数据按行输出
if (msg != null &&
sPort != null)
try {
pw = new DataOutputStream(sPort.getOutputStream());
pw.write(msg.getBytes() );
pw.write(13);
pw.flush();
pw.close();
System.out.println("/nmsg has been send from Modemn:/n"
+ msg+ "/n"
} catch (IOException e) {
e.printStackTrace();
}
}
输出的结果如下:
msg has been send from Modemn:
AT+CMGS=25
0891683108501705F011000D91683136143636F10008000A4F60597DFF0C6D4B8BD5z
>>>AT+CMGS=25
>>>//(MODEM收到的输入数据少了前面几位)
>>>> F011000D91683136143636F10008000A4F60597DFF0C6D4B8BD5z>>>
>>>ERROR
这是为何?大家救救我吧,搞了一天还是这人问题,一直搞不定
初始化at+cmgf=0,at+cnmi=2,2,0,0,1,at+csmp=17,167,0,8
在超级终端上的输入结果为:
at+cmgs=25
> 0891683108501705F011000D91683136143636F10008000A4F60597DFF0C6D4B8BD5
+CMGS: 60
OK
手机成功接收
在JAVA程序里实现在主要代码是:
if (isPduMode) {
Config conf = new Config();
PduSendPack pack = new PduSendPack();
pack.setDestAddr(dest);
pack.setUserData(content);
pack.setSmsc(conf.smsc());
pack.setDataCodedCharset(8);
String coded = pack.getCodedStr();
if (coded != null)
cmd1 = "AT+CMGS="+ (coded.length() - 18)/ 2
+ "/r"
+ coded
+ (char) Integer.parseInt("1a", 16) + "z";
} else
{
Config conf = new Config();
codeType = conf.codeType();
if (codeType != null&&
codeType.equals("1")
content = Common.gb2unicode(content);
cmd1 = "AT+CMGS=/"+86"+ dest+ "/""+(char)13+ content+ (char)26;
}
if (cmd1 != null) {
System.err.println(cmd1);
sendMsg(cmd1, sPort);
isSendOK = false;
}
//把短消息通过数据猫发送出去
private void sendMsg(String msg, SerialPort sPort) {
DataOutputStream pw;//开始用的是PrintWriter,直接把数据按行输出
if (msg != null &&
sPort != null)
try {
pw = new DataOutputStream(sPort.getOutputStream());
pw.write(msg.getBytes() );
pw.write(13);
pw.flush();
pw.close();
System.out.println("/nmsg has been send from Modemn:/n"
+ msg+ "/n"
} catch (IOException e) {
e.printStackTrace();
}
}
输出的结果如下:
msg has been send from Modemn:
AT+CMGS=25
0891683108501705F011000D91683136143636F10008000A4F60597DFF0C6D4B8BD5z
>>>AT+CMGS=25
>>>//(MODEM收到的输入数据少了前面几位)
>>>> F011000D91683136143636F10008000A4F60597DFF0C6D4B8BD5z>>>
>>>ERROR
这是为何?大家救救我吧,搞了一天还是这人问题,一直搞不定