Esempio n. 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);
        }
Esempio n. 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);
        }
        private void Process(string pdu)
        {
            if (_DataHeaderIndication == DataHeaderIndication.Yes)
            {
                _DataHeader = new DataHeader(pdu);
                pdu         = pdu.Substring(2 * (_DataHeader.Length + 1));

                if ((pdu.Length % 2) != 0)
                {
                    throw new ArgumentException();
                }

                byte[] data = new byte[(pdu.Length / 2)];
                for (int i = 0; i < data.Length; i++)
                {
                    data[i] = byte.Parse(pdu.Substring((2 * i), 2), System.Globalization.NumberStyles.HexNumber);
                }

                if (data.Length > 0)
                {
                    if (IsConcatenatedMessage)
                    {
                        _Data = new byte[data.Length];
                        for (int i = 0; i < _Data.Length; i++)
                        {
                            _Data[i] = data[i];
                        }
                    }
                    else
                    {
                        if (_DataCodingScheme.MessageCoding == GsmDataCoding.Ascii)
                        {
                            _Data = new byte[data.Length];
                            for (int i = 0; i < _Data.Length; i++)
                            {
                                _Data[i] = data[i];
                            }
                            return;
                        }

                        if (_DataCodingScheme.MessageCoding == GsmDataCoding.GsmDefault)
                        {
                            _Data = DC.BinaryOp.Decode(data, DC.DataCoding.Coding7Bit);
                        }
                    }
                }
                else
                {
                    _Data = new byte[0];
                }
            }
            else
            {
                _DataHeader = new DataHeader();

                if ((pdu.Length % 2) != 0)
                {
                    throw new ArgumentException();
                }

                byte[] data = new byte[(pdu.Length / 2)];
                for (int i = 0; i < data.Length; i++)
                {
                    data[i] = byte.Parse(pdu.Substring((2 * i), 2), System.Globalization.NumberStyles.HexNumber);
                }

                if (data.Length > 0)
                {
                    if (_DataCodingScheme.MessageCoding == GsmDataCoding.Ascii)
                    {
                        _Data = new byte[data.Length];
                        for (int i = 0; i < _Data.Length; i++)
                        {
                            _Data[i] = data[i];
                        }
                        return;
                    }

                    if (_DataCodingScheme.MessageCoding == GsmDataCoding.GsmDefault)
                    {
                        _Data = DC.BinaryOp.Decode(data, DC.DataCoding.Coding7Bit);
                    }
                }
                else
                {
                    _Data = new byte[0];
                }
            }
        }