tags:

views:

291

answers:

1

In order to send SMS (7-bit) longer than 160 chars, you have to break the message up into 153 character messsage data parts and prefix each of these with a 5 octect UDH (user data header), explaining that these are parts of a multipart SMS and should be 're-assembled' by the receiving device.

As the UDH is sent as part of the message data, whatever service I'm sending it through should, hopefully, ignore it and send it on to the recipient phone which will decode it and concatenate the parts of the long SMS.

I am using the following test code, but I get two separate messages. Any suggestions as to what I am doing wrong?

private void sendButton_Click(object sender, EventArgs e)
{
    if ((cellNumberText.Text.Trim().Length == 10) && (messageText.Text.Trim().Length > 0))
    {
        SendSms(cellNumberText.Text.Trim(), BuildUdh(255, 2, 1) + "Hello first time.  ");
        SendSms(cellNumberText.Text.Trim(), BuildUdh(255, 2, 2) + "Hello second time.  ");
    }
}

private string BuildUdh(byte messageId, byte partCount, byte partId)
{
    var udg = new byte[5];
    udg[0] = 0x00;
    udg[1] = 0x03;
    udg[2] = messageId;
    udg[3] = partCount;
    udg[4] = partId;

    return BitConverter.ToString(udg);
+1  A: 

It depends on the service which are you using to send the SMS with. In most Content Interfaces (for example SMPP or EMI/UCP) to SMSC's you could use the technique described above, but you have to specify that the SMS you are sending contains a User Data Header.

Besides your BuildUdh Function build the Concat Info-element correctly, but is missing the overall length of the UDH in the First Byte.

private string BuildUdh(byte messageId, byte partCount, byte partId)
{
    var udg = new byte[6];
    udg[0] = 0x05;      // Overall length of UDH
    udg[1] = 0x00;      // IE Concat 
    udg[2] = 0x03;      // IE parameter Length
    udg[3] = messageId;
    udg[4] = partCount;
    udg[5] = partId;
[..]

If you use a mobile phone and the AT+C interface of it to send the SMS you have to do the bit stuffing on your own, and submit a PDU with UDHI set and 140 bytes of data.

hth, cheerio Steve

Lairsdragon
@Steve, thanks. Other texts on the UDH omitted the UDH length. How should I encode the byte array as a string before prepending it? What encoding must I use?
ProfK
This depends on the Protocol, for EMI/UCP and SMPP you use a byte-stream, for some Webinterfaces like the one my company is offering the UDH will be coded as hexstrings.
Lairsdragon