开发者

need help in sms project using vb .net

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.

Any开发者_如何学Goone 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?


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.

First SMS:  05 00 03 A6 02 01 .. bytes that make up the first part text..
Second SMS: 05 00 03 A6 02 02 .. bytes that make up the second part text..

Bytes  Description
05     (UDHL) Length of the UDH. So the following five bytes are UDH
00     (IEI) This identifier says this is a concatenated message
03     (IEDL) It says that next 3 bytes are the data for this IE.
A6     Reference number of this concatenated message. 
02     There are two parts to this concatenated message.
01or02 This indicates whether the SMS is the first or second part.

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜