在使用 vb .net 的短信项目中需要帮助
我正在做一个短信项目,使用 VB .net 通过串行端口连接到我的 gsm 调制解调器。所有连接和一切都运行良好,我可以发送和接收短信。 那么问题来了,我需要发送超过160个字符的长短信。我阅读并做了一些研究,我知道我需要使用 pdu 和 udh。我设法稍微理解了 pdu 数据包,但在那部分仍然很混乱。
任何人都可以简要解释一下串联短信(长短信)的确切方法吗?
另一个问题是如何使用vb将数据编码为pdu gsm 7bit数据?是否有任何内置函数或者我需要自己编写它们?
I am doing a sms project using VB .net to connect to my gsm modem via serialport. All the connection and everything was working great and I can send and receive sms.
Then here come a problem, I need to send long sms more than 160 chars. I read and did some research and I know that I need to use the pdu and udh. I managed to understand slightly of the pdu packet but is still quite confuse on that part.
Anyone can briefly explain the exact way to do the concatented sms (long sms)?
Another problem is how can I use vb to encode the data into pdu gsm 7bit data? Is there any built in functions or do I need to write them myself?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这可能有助于连接 SMS 和 GSM 编码,但我从未使用过 GSM 调制解调器,因此希望其他人可以填补空白。
要将 .NET 字符串转换为 GSM 编码字符串,我编写了一个可用的开源库 在 Github 上可能会对您有所帮助。然而,它不执行您可能需要的 7 位打包。
对于长消息支持,您需要在每条消息的开头添加用户数据标头。
首先将消息分成多个部分,每个部分长 153 GSM(7 位)。不要忘记诸如 { 之类的扩展字符占用两个字节,请参阅 GSM 字符集 以获得完整列表。
然后将 UDH 字节添加到允许串联的开头。我在下面举了一个由两部分组成的消息的示例。
UHDL = 用户数据头长度
IEI = 信息元素标识符(00 是级联消息)
IEDL = 信息元素数据长度(级联消息头长度始终为 3)
对于参考号,最简单的方法就是在范围0-255,消息的每个部分必须具有相同的参考号。
This may help out with the concatenated SMS and GSM encoding, but I've never used a GSM modem so hopefully somebody else can fill in the gaps.
To convert your .NET string to a GSM encoded string, I've written an open-source library available on Github that might help you. However it doesn't do the 7 bit packing you might need.
For the long message support you need to add a User Data Header at the start of each message.
First split the message in to multiple parts each 153 GSM (7bit) bytes long. Don't forget that extended characters such as { take two bytes, see the GSM character set for a full list.
Then add the UDH bytes to the beginning that allow concatenation. I've put an example below for a two part message.
UHDL = User Data Header Length
IEI = Information Element Identifier (00 is a concatenated message)
IEDL = Information Element Data Length (A concatenated message header length is always 3)
For the reference number, the easiest way is just to assign an random number in the range 0-255, each part of the message must have the same reference number.