如何从模块GSM解析消息? [英] How to parse message from module GSM ?

查看:81
本文介绍了如何从模块GSM解析消息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

+CMGL: 0,"REC READ","+84963225103",,"16/01/25,15:05:19+28"
003A00290020006D1EDB0069002000681ED300690020007300E1006E0067002001110061006E00670020007400ED006E00680020006800F90020007400721EC50020006D1EA500790020006E006700E000790020003A002900290020006D00E0002000731EE300200061006E00680020006C006F0020003A00330020006E00EA006E00200074





如何解析



How to parse

003A00290020006D1EDB0069002000681ED300690020007300E1006E0067002001110061006E00670020007400ED006E00680020006800F90020007400721EC50020006D1EA500790020006E006700E000790020003A002900290020006D00E0002000731EE300200061006E00680020006C006F0020003A00330020006E00EA006E00200074

发短信?



我尝试过:



如何从模块GSM解析消息?

to text ?

What I have tried:

How to parse Message from module GSM ?

推荐答案

在网上搜索AT + CMGL。您将找到列出SMS消息命令的说明。



这些还应该提到消息输出格式有两种模式:文本模式和PDU模式可以是选择 AT + CMGF



因此您可以切换到文本模式以获得可读输出。



否则你必须转换十六进制数据字符串。如何执行此操作取决于调制解调器使用的PDU格式(请查看文档)以及要使用的编程语言。



您的数据显然是16位十六进制值。因此,获取4个字符的子字符串,将它们转换为二进制(例如,使用C / C ++使用 strtol())并将这些值写入缓冲区。如果解码是UCS2,转换很简单,因为它是UTF-16 BE,但转换字符串将交换字节,因此结果是Windows内部使用的UTF-16 LE,也受Linux支持。如果是其他东西则可能需要获得解码器(例如使用支持所使用编码的GSM库)。



相关链接:

短消息点对点 - 维基百科 [ ^ ]

SMS字母表·bitcoder / ruby​​_ucp Wiki·GitHub [ ^ ]
Search the net for "AT+CMGL". You will find descriptions for the list SMS messages command.

Those should also mention that there are two modes for the message output format: Text mode and PDU mode which can be selected with AT+CMGF.

So you might switch to text mode to get readable output.

Otheriwse you have to convert the hex data string. How to do this depends on the PDU format used by your modem (check the documentation) and which programming language you want to use.

Your data are obviously 16-bit hex values. So get sub strings of 4 characters, convert them to binary (e.g. using strtol() with C/C++) and write those values to a buffer. If the decoding is UCS2, conversion is simple because that is UTF-16 BE but converting the string will swap the bytes so that the result is UTF-16 LE as used by Windows internally and also supported by Linux. If it is something else it might be necessary to get a decoder (e.g. using a GSM library that supports the used encoding).

Related links:
Short Message Peer-to-Peer - Wikipedia[^]
SMS Alphabets · bitcoder/ruby_ucp Wiki · GitHub[^]


这篇关于如何从模块GSM解析消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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