Пример #1
0
        public SubmitMessage(GsmDataCoding coding)
        {
            _Coding = coding;
            if (coding == GsmDataCoding.Ascii)
            {
                _DataHeader = new DataHeader();
                {
                    InfoElement.PortAddress elem = new InfoElement.PortAddress(InfoElement.AddressingScheme.TwoOctet)
                    {
                        SourcePort = 16001,
                        TargetPort = 16001
                    };
                    _DataHeader.Add(elem);
                }
                _DataHeaderIndication = DataHeaderIndication.Yes;
            }
            else
            {
                _DataHeaderIndication = DataHeaderIndication.No;
            }

            _ProtocolIdentifier = new ProtocolIdentifier();
            _DataCodingScheme   = new DataCodingScheme(coding);
            _ValidityPeriod     = new ValidityPeriod(ValidityPeriodDuration.OneDay);
        }
Пример #2
0
        /// <summary>
        ///
        /// </summary>
        public SubmitMessage(GsmDataCoding coding, int port)
        {
            _Coding = coding;
            _DataHeaderIndication = DataHeaderIndication.Yes;
            _DataHeader           = new DataHeader();
            {
                InfoElement.PortAddress elem = new InfoElement.PortAddress(InfoElement.AddressingScheme.TwoOctet)
                {
                    SourcePort = (ushort)port,
                    TargetPort = (ushort)port
                };
                _DataHeader.Add(elem);
            }

            _ProtocolIdentifier = new ProtocolIdentifier();
            _DataCodingScheme   = new DataCodingScheme(coding);
            _ValidityPeriod     = new ValidityPeriod(ValidityPeriodDuration.OneDay);
        }
        public DataHeader(string data)
        {
            _ElementCollection = new ArrayList();

            //
            // udhl (User Data Header Length)
            byte udhl = byte.Parse(data.Substring(0, 2), System.Globalization.NumberStyles.HexNumber);

            data = data.Substring(2, (2 * udhl));

            while (data.Length != 0)
            {
                byte iei = byte.Parse(data.Substring(0, 2), System.Globalization.NumberStyles.HexNumber);
                data = data.Substring(2);

                switch ((InfoElement.ElementIdentifier)iei)
                {
                case InfoElement.ElementIdentifier.ConcatenatedShortMessage:
                {
                    byte ieidl = byte.Parse(data.Substring(0, 2), System.Globalization.NumberStyles.HexNumber);
                    data = data.Substring(2);

                    if (data.Length < (2 * ieidl))
                    {
                        throw new ArgumentException();
                    }

                    InfoElement.ConcatenatedMessage cm = new InfoElement.ConcatenatedMessage(data.Substring(0, 6));
                    Add(cm);
                    data = data.Substring((2 * ieidl));

                    break;
                }

                case InfoElement.ElementIdentifier.PortAddressing16bitScheme:
                {
                    byte ieidl = byte.Parse(data.Substring(0, 2), System.Globalization.NumberStyles.HexNumber);
                    data = data.Substring(2);

                    if (data.Length < (2 * ieidl))
                    {
                        throw new ArgumentException();
                    }

                    InfoElement.PortAddress pa = new InfoElement.PortAddress(InfoElement.AddressingScheme.TwoOctet, data.Substring(0, 8));
                    Add(pa);
                    data = data.Substring((2 * ieidl));

                    break;
                }

                case InfoElement.ElementIdentifier.PortAddressing8bitScheme:
                {
                    byte ieidl = byte.Parse(data.Substring(0, 2), System.Globalization.NumberStyles.HexNumber);
                    data = data.Substring(2);

                    if (data.Length < (2 * ieidl))
                    {
                        throw new ArgumentException();
                    }

                    InfoElement.PortAddress pa = new InfoElement.PortAddress(InfoElement.AddressingScheme.OneOctet, data.Substring(0, 4));
                    Add(pa);
                    data = data.Substring((2 * ieidl));

                    break;
                }

                default:
                {
                    throw new NotSupportedException();
                }
                }
            }
        }