예제 #1
0
파일: modemSMS.cs 프로젝트: GLeroy/Synox
        public string encodeMsgPDU(string message, string no)
        {
            SMS sms = new SMS();

            //Setting direction of sms
            sms.Direction = SMSDirection.Submited;

            //Set the recipient number
            sms.PhoneNumber = no;

            sms.Message = message;

            sms.StatusReportIndication = true;

            //periode de validite de deux jours
            sms.ValidityPeriod = new TimeSpan(3,1,0,0,0);

            return sms.Compose(SMS.SMSEncoding._7bit);
        }
예제 #2
0
파일: SMS.cs 프로젝트: GLeroy/Synox
        public static void Fetch(SMS sms, ref string source)
        {
            SMSBase.Fetch(sms, ref source);

            if (sms._direction == SMSDirection.Submited)
                sms._messageReference = PopByte(ref source);

            sms._phoneNumber = PopPhoneNumber(ref source);
            sms._protocolIdentifier = PopByte(ref source);
            sms._dataCodingScheme = PopByte(ref source);

            if (sms._direction == SMSDirection.Submited)
            {
                if (sms._validityPeriod != 0x00)
                    sms._validityPeriod = PopByte(ref source);
            }

            if (sms._direction == SMSDirection.Received)
                sms._serviceCenterTimeStamp = PopDate(ref source);

            sms._userData = source;

            if (source == string.Empty)
                return;

            int userDataLength = PopByte(ref source);

            if (userDataLength == 0)
                return;

            if (sms._userDataStartsWithHeader) {
                byte userDataHeaderLength = PopByte(ref source);

                sms._userDataHeader = PopBytes(ref source, userDataHeaderLength);

                userDataLength -= userDataHeaderLength + 1;
            }

            if (userDataLength == 0)
                return;

            switch ((SMSEncoding) sms._dataCodingScheme & SMSEncoding.ReservedMask) {
                case SMSEncoding._7bit:
                    sms._message = Decode7bit(source, userDataLength);
                    break;
                case SMSEncoding._8bit:
                    sms._message = Decode8bit(source, userDataLength);
                    break;
                case SMSEncoding.UCS2:
                    sms._message = DecodeUCS2(source, userDataLength);
                    break;
            }
        }