0% found this document useful (0 votes)
201 views

Decode Sms Pdu To Ascii

The document contains code for converting text to SMS format and vice versa. The TextToSMS function takes text and packs it into 7-bit segments to create the SMS PDU message. The SMSToText function takes an SMS PDU message and extracts and reconstructs the original text.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
201 views

Decode Sms Pdu To Ascii

The document contains code for converting text to SMS format and vice versa. The TextToSMS function takes text and packs it into 7-bit segments to create the SMS PDU message. The SMSToText function takes an SMS PDU message and extracts and reconstructs the original text.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

this is my code for pdu ,it works.(tested on nok.

3310)
void TextToSMS(void)
{
U8 shift = 0,c,w,n;
TSMS_PDULen = 0;
for (n=0; n<TSMS_TextLen; ++n)
{
c = TSMS_TextMsg[n] & 0x7f;
c >>= shift;
w = TSMS_TextMsg[n+1] & 0x7f;
w <<= (7-shift);
shift += 1;
c = c | w;
if (shift == 7)
{
shift = 0x00;
n++;
}
TSMS_PDUMsg[TSMS_PDULen] = c;
TSMS_PDULen++;
}
}
/*
**--------------------------------------------------------------------------**
** Abstract: Convert SMS to text
**
**
** Parameters:
**
**
** Returns:
**
**
**--------------------------------------------------------------------------*/
void SMSToText(void)
{
U8 r;
RSMS_TextLen = 0;
for (r=0; r<RSMS_PDULen; r++)
{
if (r%7 == 0)
{
RSMS_TextMsg[RSMS_TextLen++] = ( RSMS_PDUMsg[r] << 0 ) & 0x7F;
}
else if (r%7 == 6)
{
RSMS_TextMsg[RSMS_TextLen++]=((RSMS_PDUMsg[r]<<6)|(RSMS_PDUMsg[r-1]>>2))&0x7F;
RSMS_TextMsg[RSMS_TextLen++]=(RSMS_PDUMsg[r]>>1)&0x7F;
}
else
{

RSMS_TextMsg[RSMS_TextLen++]=((RSMS_PDUMsg[r]<<(r%7))|(RSMS_PDUMsg[r-1]>>(7+1-(r
%7))))&0x7F;
}
}
}

You might also like