user2160158
user2160158

Reputation: 29

Creating UDH for 7-bit concatenated SMS

I need to send concatenated SMS for which i split the message(which is more than 160 bytes) in small parts now i want to put one header in each part.header have 6 octets as follows

Field 1 (1 octet): Length of User Data Header, in this case 05. Field 2 (1 octet): Information Element Identifier, equal to 00 (Concatenated short messages, 8-bit reference number) Field 3 (1 octet): Length of the header, excluding the first two fields; equal to 03 Field 4 (1 octet): 00-FF, CSMS reference number, must be same for all the SMS parts in the CSMS Field 5 (1 octet): 00-FF, total number of parts. Field 6 (1 octet): 00-FF, this part's number in the sequence.

Example: 05 00 03 CC 02 01 [ message ] 05 00 03 CC 02 02 [ message ]

Now the problem is i want to put these 6 octets in 7 septets and which need to decrements the size of an SMS message from 160 to 153 characters.How to convert these 6 octets in 7 septets.is there any coding avilable

Upvotes: 2

Views: 2797

Answers (1)

shawty
shawty

Reputation: 5829

It's really not that difficult.

The difference between a 7 bit number and an 8 bit number as that the 7 bit number has it's upper bit missing.

Given that your dealing directly with bytes I'm going to assume your doing this directly in PDU mode, esp since you do seem to know what your byte layout is.

to convert your 8 bit bytes into 7 bits you just need to get rid of the upper bit EG:

if you have

05 00 03 CC

then in 8 bit you have

00000101 00000000 00000011 11001100

technically to truncate these to 7 bit it's just a matter of stripping off the top bit as follows

0000101 0000000 0000011 1001100

However, you WILL have a problem with your values above, and that's with your

CC

Value. If you strip the top bit from that, you'll effectively change it to a value of

4C

which may cause your SMS system to interprete the details incorrectly

It's for this reason that in pretty much all cases when dealing directly with the binary that you use an 8 bit send, so that you preserve the values.

However, going ahead with the example should you wish to try it, the next step is to then concatenate the 7 bit values together as follows

0000101000000000000111001100

You then need to divide this by 8 (The transmission medium is still 8 bit, even if the coding is not)

00001010 00000000 00011100 1100

Then pad the final byte out to 8 bits so that the transmission is an even number

00001010 00000000 00011100 1100xxxx

The xxxx will be either all 1's or all 0's depending on what your using to send the bytes, if it's an AT command, then likley it'll be all 0's so your 7 bit encoding will end up being

0A 00 1C C0

Which as you can see hasn't saved you any bytes.

A 7 bit encoding only reliably works if your using the GSM alphabet (you get that by setting the correct DCS values) how you set this again depends on what your using to send the SMS in the first place.

Most HTTP providers for example provide some sort of switch/flag to do this.

Upvotes: 1

Related Questions