开发者

Generate an concatenated SMS UDH and prepend it to message text

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开发者_Python百科, 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);


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

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜