Exemple #1
0
        /// <summary>
        /// Decodes an incoming SMS PDU stream.
        /// </summary>
        /// <param name="pdu">The PDU string to decode.</param>
        /// <param name="includesSmscData">Specify true if the PDU data contains an SMSC header, otherwise false.</param>
        /// <param name="actualLength">The size of the PDU data in bytes, not counting the SMSC header. Set to -1 if unknown.</param>
        /// <returns>An <see cref="T:GSMCommunication.PDUDecoder.IncomingSmsPdu" /> object representing the decoded message.</returns>
        public static IncomingSmsPdu Decode(string pdu, bool includesSmscData, int actualLength)
        {
            if (pdu != string.Empty)
            {
                int num = 0;
                if (includesSmscData)
                {
                    int num1 = num;
                    num = num1 + 1;
                    byte num2 = BcdWorker.GetByte(pdu, num1);
                    if (num2 > 0)
                    {
                        num = num + num2;
                    }
                }
                int num3 = num;
                IncomingMessageType messageType         = IncomingSmsPdu.GetMessageType(BcdWorker.GetByte(pdu, num3));
                IncomingMessageType incomingMessageType = messageType;
                switch (incomingMessageType)
                {
                case IncomingMessageType.SmsDeliver:
                {
                    return(new SmsDeliverPdu(pdu, includesSmscData, actualLength));
                }

                case IncomingMessageType.SmsStatusReport:
                {
                    return(new SmsStatusReportPdu(pdu, includesSmscData, actualLength));
                }
                }
                throw new NotSupportedException(string.Concat("Message type ", messageType.ToString(), " recognized, but not supported by the SMS decoder."));
            }
            else
            {
                throw new ArgumentException("pdu must not be an empty string.");
            }
        }
Exemple #2
0
 /// <summary>
 /// Decodes an incoming SMS PDU stream.
 /// </summary>
 /// <param name="pdu">The PDU string to decode.</param>
 /// <param name="includesSmscData">Specify true if the PDU data contains an SMSC header, otherwise false.</param>
 /// <returns>An <see cref="T:GSMCommunication.PDUDecoder.IncomingSmsPdu" /> object representing the decoded message.</returns>
 /// <remarks>Use this overload only if you do not know the size of the PDU data.</remarks>
 public static IncomingSmsPdu Decode(string pdu, bool includesSmscData)
 {
     return(IncomingSmsPdu.Decode(pdu, includesSmscData, -1));
 }