hoagha / sms-pdu

Automatically exported from code.google.com/p/sms-pdu
0 stars 0 forks source link

Minor error in last-part of multimessage #4

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Hi, great project :)

Reproduce is simple:

string s_pdu2 = 
"06915404939099640A9154050515800000113071903202401E0500039A0202EC6550980E32A7DDE
432A84E0685CD20B43D4C7601";
SMS sms = new SMS();
SMS.Fetch(sms, ref s_pdu2);

this will return rubbish-text.

The solution (please change project sourcecode):

1. Add function to SMSBase:
public static byte[] PeekBytes(string source, int byteIndex, int length)
{
    string bytes = source.Substring(byteIndex * 2, length * 2);

    return GetBytes(bytes);
}

2. Change function Fetch in SMS where 'if (sms._userDataStartsWithHeader)' to 
(remember to add byte sms._userDataHeaderLength):
if (sms._userDataStartsWithHeader)
{
     sms._userDataHeaderLength = PeekByte( source);

     sms._userDataHeader = PeekBytes(source, 1, sms._userDataHeaderLength);
}

3. Still in Fetch, find:
            switch ((SMSEncoding)sms._dataCodingScheme & SMSEncoding.ReservedMask)
            {
                case SMSEncoding._7bit:
                    sms._message = Decode7bit(source, userDataLength);
                    break;

and change it to:
            switch ((SMSEncoding)sms._dataCodingScheme & SMSEncoding.ReservedMask)
            {
                case SMSEncoding._7bit:
                    sms._message = Decode7bit(source, userDataLength);
                    if (sms._userDataStartsWithHeader && sms._userDataHeaderLength > 0)
                        sms._message = sms._message.Remove(0, ((sms._userDataHeaderLength + 1) * 8 + ((sms._userDataHeaderLength + 1) * 8) % 7) / 7);
                    break;

Don't know about _8bit or UCS2 part, but it will work for _7bit.

Regards, Ole

Original issue reported on code.google.com by ole.tetz...@gmail.com on 17 Mar 2011 at 9:42

GoogleCodeExporter commented 8 years ago
dear sir , 

Sorry I am new to the google code , But how can i download this library.
it is not available into the download section.

Thanks,

Waleed.makarem@gmail.com

Original comment by waleed.m...@gmail.com on 24 Mar 2012 at 12:38

GoogleCodeExporter commented 8 years ago
Hi Waleed

Look under the tab 'source'.

Regards, Ole

Original comment by ole.tetz...@gmail.com on 24 Mar 2012 at 9:05

GoogleCodeExporter commented 8 years ago
Ole, you are a champion!

Original comment by Ryzi...@gmail.com on 7 Jun 2013 at 3:39